From aec14eaab1066844b784145ac112a91035dab3b2 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Tue, 14 Jun 2022 16:04:09 +0900 Subject: [PATCH] fix: source fix --- .env.production | 3 +- package.json | 3 +- src/index.js | 33 +++++++++++++++++-- src/store/index.js | 4 ++- src/store/slices/user.js | 10 ------ src/views/biz/admin/judge/JudgeDataReview.jsx | 13 ++++---- src/views/biz/pboard/PublicBoard.jsx | 28 +++++++++------- 7 files changed, 61 insertions(+), 33 deletions(-) diff --git a/.env.production b/.env.production index 94d0c98..b49e885 100644 --- a/.env.production +++ b/.env.production @@ -1,5 +1,6 @@ NODE_PATH=src REACT_APP_MODE=production REACT_APP_VERSION = v0.0.1 -REACT_APP_API_URL=http://211.119.124.9:8090 +#REACT_APP_API_URL=http://211.119.124.9:8090 +REACT_APP_API_URL=http://localhost:8090 REACT_APP_SERVER_TIMEOUT=6000 \ No newline at end of file diff --git a/package.json b/package.json index e763ab9..f97de0d 100755 --- a/package.json +++ b/package.json @@ -94,7 +94,8 @@ "build": "env-cmd -f .env.production react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", - "format": "prettier --write ." + "format": "prettier --write .", + "serve" : "serve -s build" }, "eslintConfig": { "extends": [ diff --git a/src/index.js b/src/index.js index e8a145c..32a646e 100755 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,10 @@ +import React from 'react'; import ReactDOM from 'react-dom'; // third party import { BrowserRouter } from 'react-router-dom'; import { Provider } from 'react-redux'; -import { QueryClient, QueryClientProvider } from 'react-query'; +import { MutationCache, QueryCache, QueryClient, QueryClientProvider } from 'react-query'; import { ReactQueryDevtools } from 'react-query/devtools'; import { PersistGate } from 'redux-persist/integration/react'; @@ -20,6 +21,7 @@ import { ConfigProvider } from 'contexts/ConfigContext'; // style + assets import 'assets/scss/style.scss'; +import axios from 'axios'; // ==============================|| REACT DOM RENDER ||============================== // @@ -35,23 +37,50 @@ const options = { } }; -const queryClient = new QueryClient(); +const queryClient = new QueryClient({ + mutationCache: new MutationCache({ + onError: (error) => { + if (axios.isAxiosError(error)) { + const errorCode = error.response?.data.code; + console.log(`###################@@@@@@@@@@@@@@${errorCode}`); // 에러 팝업 띄우기 + } else { + throw error; // error boundary로 전달 + } + } + }), + queryCache: new QueryCache({ + onError: (error) => { + if (axios.isAxiosError(error)) { + const errorCode = error.response?.data.code; + console.log(`###################@@@@@@@@@@@@@@${errorCode}`); // 에러 팝업 띄우기 + } else { + throw error; // error boundary로 전달 + } + } + }) +}); ReactDOM.render( + // + {/* */} + {/* */} + {/* //TODO : 개발완료시 교체 */} + {/* */} , + // , document.getElementById('root') ); diff --git a/src/store/index.js b/src/store/index.js index 3e4711d..b3dff10 100755 --- a/src/store/index.js +++ b/src/store/index.js @@ -13,7 +13,9 @@ import logger from 'redux-logger'; const store = configureStore({ reducer: rootReducer, middleware: (getDefaultMiddleware) => getDefaultMiddleware({ serializableCheck: false, immutableCheck: false }).concat(logger), - devTools: process.env.NODE_ENV !== 'production' + // TODO :: 개발 완료시 교체 + devTools: true + // devTools: process.env.NODE_ENV !== 'production' }); const persister = persistStore(store); diff --git a/src/store/slices/user.js b/src/store/slices/user.js index 21533de..99c9840 100755 --- a/src/store/slices/user.js +++ b/src/store/slices/user.js @@ -9,16 +9,6 @@ import { dispatch } from '../index'; const initialState = { error: null - // usersS1: [], - // usersS2: [], - // followers: [], - // friendRequests: [], - // friends: [], - // gallery: [], - // posts: [], - // detailCards: [], - // simpleCards: [], - // profileCards: [] }; const slice = createSlice({ diff --git a/src/views/biz/admin/judge/JudgeDataReview.jsx b/src/views/biz/admin/judge/JudgeDataReview.jsx index 1775bb3..a2566cb 100644 --- a/src/views/biz/admin/judge/JudgeDataReview.jsx +++ b/src/views/biz/admin/judge/JudgeDataReview.jsx @@ -16,6 +16,7 @@ import JudgeDataDetailForm from './JudgeDataDetailForm'; import { useAlert } from 'react-alert'; import { getComboCodeList } from 'apis/common'; import JudgeDataModifyForm from './JudgeDataModifyForm'; +import { useQuery } from 'react-query'; const JudgeDataReview = ({ scDatagb, menuName }) => { const showAlert = useAlert(); @@ -74,13 +75,13 @@ const JudgeDataReview = ({ scDatagb, menuName }) => { { headerName: '자료상태', headerAlign: 'center', field: 'scStateNm', align: 'center' } ]; - const search = useCallback(() => { - const params = { - scDatagb, // 거주자 - page: rowsState.page, - size: rowsState.pageSize - }; + const params = { + scDatagb, // 거주자 + page: rowsState.page, + size: rowsState.pageSize + }; + const search = useCallback(() => { findJudgeDatas(params).then((response) => { if (response && response.data) { setTotalCount(response.count); diff --git a/src/views/biz/pboard/PublicBoard.jsx b/src/views/biz/pboard/PublicBoard.jsx index f3ea7e3..cbc0938 100644 --- a/src/views/biz/pboard/PublicBoard.jsx +++ b/src/views/biz/pboard/PublicBoard.jsx @@ -99,12 +99,6 @@ const PublicBoard = () => { setTitle('공지사항 상세'); setSelectedRow(e?.row); setOwner(user.name === e?.row.inName); - // eslint-disable-next-line react-hooks/rules-of-hooks - // useMutation(modifyPublicBoardHitCount(e?.row?.inCode), { - // onSuccess: () => { - // queryClient.invalidateQueries('pboards'); - // } - // }); modifyPublicBoardHitCount(e?.row?.inCode); setOpen(true); } @@ -115,17 +109,27 @@ const PublicBoard = () => { case 'SAVE': setOpen(false); - saveAlert(() => - // eslint-disable-next-line react-hooks/rules-of-hooks - useMutation(savePublicBoard(payload)) - ); + saveAlert(() => { + savePublicBoard(payload).then((res) => { + if (res?.success) { + search(); + } else { + alert.show(`${res?.data.message}`); + } + }); + }); break; case 'DELETE': setOpen(false); removeAlert( - // eslint-disable-next-line react-hooks/rules-of-hooks - () => useMutation(removePublicBoard(payload)) + removePublicBoard(payload).then((res) => { + if (res?.success) { + search(); + } else { + alert.show(`${res?.data.message}`); + } + }) ); break; default: