diff --git a/src/components/Tables/OrdersPage/OrdersPage.js b/src/components/Tables/OrdersPage/OrdersPage.js index ec69b2e..25558dc 100644 --- a/src/components/Tables/OrdersPage/OrdersPage.js +++ b/src/components/Tables/OrdersPage/OrdersPage.js @@ -17,10 +17,12 @@ const { Option } = Select; export default function OrdersPage() { const dispatch = useDispatch(); const { data, pending } = useSelector(state => state.orderListPagination); + console.log(data); const [page, setPage] = useState(1); const [day, setDay] = useState('ALL'); const [isModalVisible, setIsModalVisible] = useState(false); const [id, setID] = useState(''); + const [orderPrice, setOrderPrice] = useState('xx'); const onPageChange = e => { // 페이지네이션 번호 바뀔때 뜸. @@ -60,11 +62,13 @@ export default function OrdersPage() { setIsModalVisible(false); handleSetFreeSelector(id); setID(''); + setOrderPrice('무료'); }; const handleCancel = () => { setIsModalVisible(false); setID(''); + setOrderPrice('유료'); }; useEffect(() => { @@ -113,6 +117,14 @@ export default function OrdersPage() { return moment(element).utc(false).format('MM월 DD일 HH:mm'); }} /> + { + return moment(element).utc(false).format('MM월 DD일 HH:mm'); + }} + /> { // navigate('/tickets/check', { @@ -52,14 +51,7 @@ export default function CheckEnterPage() { }; return ( -
+
diff --git a/src/components/Tickets/CheckPage/CheckPage.js b/src/components/Tickets/CheckPage/CheckPage.js index f0a0fd9..a85a5bb 100644 --- a/src/components/Tickets/CheckPage/CheckPage.js +++ b/src/components/Tickets/CheckPage/CheckPage.js @@ -2,18 +2,20 @@ import React, { useEffect, useState } from 'react'; import { useLocation } from 'react-router-dom'; import { useSelector, useDispatch } from 'react-redux'; import { QrReader } from 'react-qr-reader'; -import { checkPage } from '../../../state/actions-creators/CheckPage'; +import { + checkCount, + checkPage +} from '../../../state/actions-creators/CheckPage'; import './video.css'; import { ReactComponent as Scanner } from './scanner.svg'; import history from '../../../history'; +import { message } from 'antd'; function CheckPage() { const dispatch = useDispatch(); const location = useLocation(); - const [isOldOrYoung, setIsOldOrYoung] = useState(''); - const [isFrontOrRear, setIsFrontOrRear] = useState(''); - const { data, pending } = useSelector(state => state.checkPage); + const { data, pending, count } = useSelector(state => state.checkPage); useEffect(() => { if (!history.location.state) { @@ -21,18 +23,19 @@ function CheckPage() { } // console.log('history.location.state:', history.location.state); //result: '{date: 'OB', cam: 'environment'}' // console.log('location:', location); //result: '{pathname: '/tickets/check', search: '', hash: '', state: {…}, key: 'xf82gqmb'}' - setIsOldOrYoung(history.location.state.date); - setIsFrontOrRear(history.location.state.cam); //정상작동! }, [location]); const handleScan = (result, error) => { - if (!!result) { - console.log('result:', result); + dispatch( + checkPage( + { uuid: result ? result.text : null }, + { date: history.location.state.date }, + message + ) + ); - dispatch( - checkPage({ uuid: result.text }, { date: history.location.state.date }) - ); - } + dispatch(checkCount()); + // console.log('count:', count); }; // const handleClick = () => { @@ -43,9 +46,9 @@ function CheckPage() { <> {/* // history.location.state.cam 확인용 버튼 */} + ({ uuid }, { date }, message, callback) => async dispatch => { - try { - dispatch({ type: CHECKING_PENDING }); + const { checkPage } = store.getState(); + // console.log(); + if (uuid && checkPage.count > 4) { + try { + dispatch({ type: CHECKING_PENDING }); - const response = await axios.post( - `https://api.gosrock.band/v1/tickets/${uuid}/enter`, - { - date: `${date}` - } - ); - console.log('서버 응답?', response); - console.log('uuid, date: ', uuid, ',,,,', date); + const response = await axios.post( + `https://api.gosrock.band/v1/tickets/${uuid}/enter`, + { + date: `${date}` + } + ); + console.log('서버 응답?', response); + console.log('uuid, date: ', uuid, ',,,,', date); - dispatch({ type: CHECKING_SUCCESS, payload: '조회 성공' }); + message.success('조회에 성공했습니다. 입장이 가능합니다.'); + dispatch({ type: CHECKING_SUCCESS, payload: '조회 성공' }); - // 자동으로 피쳐로 넘어가게끔 - // callback(); - } catch (e) { - //400 ~ - dispatch({ type: CHECKING_ERROR, payload: '조회 실패' }); - console.log(e); + // 자동으로 피쳐로 넘어가게끔 + callback(); + } catch (e) { + //400 ~ 에러 타입에 따라서 경고메세지 다르게 표시 + // dispatch({ type: CHECKING_ERROR, payload: error }); + // console.log('ERROR: ', error.response.data.error.message); + const ERROR = e.response.data.error.message; + console.log('ERROR:', ERROR); + message.warn(`${ERROR}`); + dispatch({ type: CHECKING_ERROR, payload: e }); + } } }; + +export const checkCount = () => async dispatch => { + dispatch({ type: CHECKING_COUNT }); +}; diff --git a/src/state/reducers/CheckPage.js b/src/state/reducers/CheckPage.js index bcecb2d..d5c39b0 100644 --- a/src/state/reducers/CheckPage.js +++ b/src/state/reducers/CheckPage.js @@ -2,7 +2,8 @@ import { CHECKING_PENDING, CHECKING_SUCCESS, - CHECKING_ERROR + CHECKING_ERROR, + CHECKING_COUNT } from '../action-types/checkPage.js'; export default function ( @@ -11,7 +12,8 @@ export default function ( userUuid: '' }, error: null, - pending: false + pending: false, + count: 0 }, action ) { @@ -19,9 +21,23 @@ export default function ( case CHECKING_PENDING: return { ...state, data: action.payload, error: null, pending: true }; case CHECKING_SUCCESS: - return { ...state, data: action.payload, error: null, pending: false }; + return { + ...state, + data: action.payload, + error: null, + count: 0, + pending: false + }; case CHECKING_ERROR: - return { ...state, data: [], error: action.payload, pending: false }; + return { + ...state, + data: [], + error: action.payload, + count: 0, + pending: false + }; + case CHECKING_COUNT: + return { ...state, count: state.count + 1 }; default: return state; }