Browse Source

공통모달 비행이력, 시뮬레이션 적용

master
junh_eee(이준희) 7 months ago
parent
commit
71edbf0eae
  1. 47
      src/_redux/features/analysis/history/historyThunk.ts
  2. 60
      src/_redux/features/analysis/simulation/simulationThunk.ts
  3. 69
      src/containers/analysis/history/AnalysisHistoryContainer.js

47
src/_redux/features/analysis/history/historyThunk.ts

@ -1,25 +1,17 @@
import axios from '../../../../modules/utils/customAxiosUtil'; import axios from '../../../../modules/utils/customAxiosUtil';
import qs from 'qs'; import qs from 'qs';
import { createAsyncThunk } from '@reduxjs/toolkit'; import { createAsyncThunk } from '@reduxjs/toolkit';
import { isError, isMessage } from '../../comn/message/messageSlice'; import { openModal } from '../../comn/message/messageSlice';
import { import { QS_OPTION } from '@src/configs/constants';
ERROR_MESSAGE,
DUPLATE_MESSAGE,
SAVE_MESSAGE,
DELETE_MESSAGE
} from '@src/configs/constants';
import { IHstryListRq } from './historyState'; import { IHstryListRq } from './historyState';
import { MODAL_DESC, MODAL_TITLE } from '@src/configs/msgConst';
// 비행이력 조회 // 비행이력 조회
export const getHstryList = createAsyncThunk( export const getHstryList = createAsyncThunk(
'analysis/getHstryList', 'analysis/getHstryList',
async (data: IHstryListRq, thunkAPI) => { async (data: IHstryListRq, thunkAPI) => {
const { rejectWithValue } = thunkAPI;
try { try {
const queryString = qs.stringify(data.searchParams, { const queryString = qs.stringify(data.searchParams, QS_OPTION);
addQueryPrefix: true,
arrayFormat: 'repeat'
});
const res: any = await axios.get( const res: any = await axios.get(
`/api/anls/hstry/list${queryString}&page=${data.page}` `/api/anls/hstry/list${queryString}&page=${data.page}`
); );
@ -27,14 +19,11 @@ export const getHstryList = createAsyncThunk(
return res.data; return res.data;
} catch (error) { } catch (error) {
thunkAPI.dispatch( thunkAPI.dispatch(
isError({ openModal({
errorCode: ERROR_MESSAGE.code, header: MODAL_TITLE.error,
errorMessage: ERROR_MESSAGE.message, body: MODAL_DESC.error
isHistoryBack: false,
isRefresh: false
}) })
); );
return rejectWithValue(error);
} }
} }
); );
@ -43,21 +32,16 @@ export const getHstryList = createAsyncThunk(
export const getHstryLog = createAsyncThunk( export const getHstryLog = createAsyncThunk(
'analysis/getHstryLog', 'analysis/getHstryLog',
async (id: string, thunkAPI) => { async (id: string, thunkAPI) => {
const { rejectWithValue } = thunkAPI;
try { try {
const res: any = await axios.get(`/api/anls/hstry/log/${id}`); const res: any = await axios.get(`/api/anls/hstry/log/${id}`);
return res.data; return res.data;
} catch (error) { } catch (error) {
thunkAPI.dispatch( thunkAPI.dispatch(
isError({ openModal({
errorCode: ERROR_MESSAGE.code, header: MODAL_TITLE.error,
errorMessage: ERROR_MESSAGE.message, body: MODAL_DESC.error
isHistoryBack: false,
isRefresh: false
}) })
); );
return rejectWithValue(error);
} }
} }
); );
@ -66,21 +50,16 @@ export const getHstryLog = createAsyncThunk(
export const getHstryDetail = createAsyncThunk( export const getHstryDetail = createAsyncThunk(
'analysis/getHstryDetail', 'analysis/getHstryDetail',
async (id: string, thunkAPI) => { async (id: string, thunkAPI) => {
const { rejectWithValue } = thunkAPI;
try { try {
const res: any = await axios.get(`/api/anls/hstry/detail/${id}`); const res: any = await axios.get(`/api/anls/hstry/detail/${id}`);
return res.data; return res.data;
} catch (error) { } catch (error) {
thunkAPI.dispatch( thunkAPI.dispatch(
isError({ openModal({
errorCode: ERROR_MESSAGE.code, header: MODAL_TITLE.error,
errorMessage: ERROR_MESSAGE.message, body: MODAL_DESC.error
isHistoryBack: false,
isRefresh: false
}) })
); );
return rejectWithValue(error);
} }
} }
); );

60
src/_redux/features/analysis/simulation/simulationThunk.ts

@ -1,42 +1,29 @@
import axios from '../../../../modules/utils/customAxiosUtil'; import axios from '../../../../modules/utils/customAxiosUtil';
import qs from 'qs'; import qs from 'qs';
import { createAsyncThunk } from '@reduxjs/toolkit'; import { createAsyncThunk } from '@reduxjs/toolkit';
import { isError, isMessage } from '../../comn/message/messageSlice'; import { openModal } from '../../comn/message/messageSlice';
import { import { QS_OPTION } from '@src/configs/constants';
ERROR_MESSAGE,
DUPLATE_MESSAGE,
SAVE_MESSAGE,
DELETE_MESSAGE
} from '@src/configs/constants';
import { IAnalysisSimulatorListRq } from './simulationState'; import { IAnalysisSimulatorListRq } from './simulationState';
import { MODAL_DESC, MODAL_TITLE } from '@src/configs/msgConst';
// 비행 현황 목록 // 비행 현황 목록
export const getSmltList = createAsyncThunk( export const getSmltList = createAsyncThunk(
'analysis/getSmltList', 'analysis/getSmltList',
async (data: IAnalysisSimulatorListRq, thunkAPI) => { async (data: IAnalysisSimulatorListRq, thunkAPI) => {
const { rejectWithValue } = thunkAPI;
try { try {
const queryString = qs.stringify(data.searchParams, { const queryString = qs.stringify(data.searchParams, QS_OPTION);
addQueryPrefix: true,
arrayFormat: 'repeat'
});
const res: any = await axios.get( const res: any = await axios.get(
`/api/anls/smlt/list${queryString}&page=${data.page}` `/api/anls/smlt/list${queryString}&page=${data.page}`
); );
console.log('>>', res.data);
return res.data; return res.data;
} catch (error) { } catch (error) {
thunkAPI.dispatch( thunkAPI.dispatch(
isError({ openModal({
errorCode: ERROR_MESSAGE.code, header: MODAL_TITLE.error,
errorMessage: ERROR_MESSAGE.message, body: MODAL_DESC.error
isHistoryBack: false,
isRefresh: false
}) })
); );
return rejectWithValue(error);
} }
} }
); );
@ -45,21 +32,16 @@ export const getSmltList = createAsyncThunk(
export const getSmltLog = createAsyncThunk( export const getSmltLog = createAsyncThunk(
'analysis/getSmltLog', 'analysis/getSmltLog',
async (id: string, thunkAPI) => { async (id: string, thunkAPI) => {
const { rejectWithValue } = thunkAPI;
try { try {
const res: any = await axios.get(`/api/anls/smlt/hist/${id}`); const res: any = await axios.get(`/api/anls/smlt/hist/${id}`);
return res.data; return res.data;
} catch (error) { } catch (error) {
thunkAPI.dispatch( thunkAPI.dispatch(
isError({ openModal({
errorCode: ERROR_MESSAGE.code, header: MODAL_TITLE.error,
errorMessage: ERROR_MESSAGE.message, body: MODAL_DESC.error
isHistoryBack: false,
isRefresh: false
}) })
); );
return rejectWithValue(error);
} }
} }
); );
@ -68,21 +50,16 @@ export const getSmltLog = createAsyncThunk(
export const getSmltDetail = createAsyncThunk( export const getSmltDetail = createAsyncThunk(
'analysis/getSmltDetail', 'analysis/getSmltDetail',
async (id: string, thunkAPI) => { async (id: string, thunkAPI) => {
const { rejectWithValue } = thunkAPI;
try { try {
const res: any = await axios.get(`/api/anls/smlt/detail/${id}`); const res: any = await axios.get(`/api/anls/smlt/detail/${id}`);
return res.data; return res.data;
} catch (error) { } catch (error) {
thunkAPI.dispatch( thunkAPI.dispatch(
isError({ openModal({
errorCode: ERROR_MESSAGE.code, header: MODAL_TITLE.error,
errorMessage: ERROR_MESSAGE.message, body: MODAL_DESC.error
isHistoryBack: false,
isRefresh: false
}) })
); );
return rejectWithValue(error);
} }
} }
); );
@ -91,21 +68,16 @@ export const getSmltDetail = createAsyncThunk(
export const getSmltStcs = createAsyncThunk( export const getSmltStcs = createAsyncThunk(
'analysis/getSmltStcs', 'analysis/getSmltStcs',
async (id: string, thunkAPI) => { async (id: string, thunkAPI) => {
const { rejectWithValue } = thunkAPI;
try { try {
const res: any = await axios.get(`/api/anls/smlt/stcs/${id}`); const res: any = await axios.get(`/api/anls/smlt/stcs/${id}`);
return res.data; return res.data;
} catch (error) { } catch (error) {
thunkAPI.dispatch( thunkAPI.dispatch(
isError({ openModal({
errorCode: ERROR_MESSAGE.code, header: MODAL_TITLE.error,
errorMessage: ERROR_MESSAGE.message, body: MODAL_DESC.error
isHistoryBack: false,
isRefresh: false
}) })
); );
return rejectWithValue(error);
} }
} }
); );

69
src/containers/analysis/history/AnalysisHistoryContainer.js

@ -9,21 +9,15 @@ import { CustomMainLayout } from '../../../components/layout/CustomMainLayout';
import { clientSelectHstryGroup } from '@src/_redux/features/analysis/history/historySlice'; import { clientSelectHstryGroup } from '@src/_redux/features/analysis/history/historySlice';
import { getHstryList } from '@src/_redux/features/analysis/history/historyThunk'; import { getHstryList } from '@src/_redux/features/analysis/history/historyThunk';
import FlightPlanGroupGrid from '../../../components/basis/flight/plan/FlightPlanGroupGrid'; import FlightPlanGroupGrid from '../../../components/basis/flight/plan/FlightPlanGroupGrid';
import { import { Col, Row } from '@component/ui';
Col,
Row,
Button,
Modal,
ModalHeader,
ModalBody,
ModalFooter
} from '@component/ui';
import { clientRoupSelect } from '@src/_redux/features/laanc/laancSlice'; import { clientRoupSelect } from '@src/_redux/features/laanc/laancSlice';
import { MessageErrorModal } from '../../../components/message/MessageErrorModal'; import { MessageErrorModal } from '../../../components/message/MessageErrorModal';
import { import {
getGroupList, getGroupList,
getJoinGroupList getJoinGroupList
} from '@src/_redux/features/basis/group/groupThunk'; } from '@src/_redux/features/basis/group/groupThunk';
import { openModal } from '@src/_redux/features/comn/message/messageSlice';
import { MODAL_DESC, MODAL_TITLE } from '@src/configs/msgConst';
export const AnalysisHistoryContainer = props => { export const AnalysisHistoryContainer = props => {
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -61,16 +55,6 @@ export const AnalysisHistoryContainer = props => {
// user: 로그인한 user 정보 // user: 로그인한 user 정보
const { user } = useSelector(state => state.authState, shallowEqual); const { user } = useSelector(state => state.authState, shallowEqual);
/**
* Modal 초기값 state
*/
const [modal, setModal] = useState({
isOpen: false,
title: '',
desc: '',
color: ''
});
/** /**
* 검색조건 초기값 * 검색조건 초기값
*/ */
@ -206,19 +190,19 @@ export const AnalysisHistoryContainer = props => {
// 검색 버튼 click handler // 검색 버튼 click handler
const handlerSearch = () => { const handlerSearch = () => {
if (!params.stDate || !params.endDate) { if (!params.stDate || !params.endDate) {
setModal({ dispatch(
isOpen: true, openModal({
title: '필수값 입력 오류', header: MODAL_TITLE.valid,
desc: '올바른 일자를 입력해 주세요.', body: '올바른 일자를' + MODAL_DESC.valid
color: 'modal-danger' })
}); );
} else if (!params.groupId) { } else if (!params.groupId) {
setModal({ dispatch(
isOpen: true, openModal({
title: '필수값 입력 오류', header: MODAL_TITLE.valid,
desc: '그룹 선택 해주세요.', body: '그룹 선택해주세요.'
color: 'modal-danger' })
}); );
} else { } else {
dispatch(clientRoupSelect({ ...params })); dispatch(clientRoupSelect({ ...params }));
dispatch(getHstryList({ searchParams: params, page: 1 })); dispatch(getHstryList({ searchParams: params, page: 1 }));
@ -326,29 +310,6 @@ export const AnalysisHistoryContainer = props => {
</Col> </Col>
</Row> </Row>
</div> </div>
<div className='vertically-centered-modal'>
<Modal
isOpen={modal.isOpen}
toggle={() => setModal({ ...modal, isOpen: !modal.isOpen })}
modalClassName={modal.color}
className='modal-dialog-centered'
>
<ModalHeader
toggle={() => setModal({ ...modal, isOpen: !modal.isOpen })}
>
{modal.title}
</ModalHeader>
<ModalBody>{modal.desc}</ModalBody>
<ModalFooter>
<Button
color='danger'
onClick={() => setModal({ ...modal, isOpen: !modal.isOpen })}
>
확인
</Button>{' '}
</ModalFooter>
</Modal>
</div>
<MessageErrorModal /> <MessageErrorModal />
</CustomMainLayout> </CustomMainLayout>
); );

Loading…
Cancel
Save