diff --git a/src/containers/statistics/AbnormalSituationContainer.js b/src/containers/statistics/AbnormalSituationContainer.js index f816150..a684a6a 100644 --- a/src/containers/statistics/AbnormalSituationContainer.js +++ b/src/containers/statistics/AbnormalSituationContainer.js @@ -14,6 +14,7 @@ export default function AbnormalSituationContainer() { const [searchType, setSearchType] = useState({ category: 'PLAN', dateType: 'year', + serviceType: '', year: new Date().getFullYear(), month: new Date().getMonth() + 1, day: new Date().getDate() @@ -32,8 +33,10 @@ export default function AbnormalSituationContainer() { }; useEffect(() => { - dispatch(StcsActions.ABNORMAL_STCS.request()); - }, []); + dispatch( + StcsActions.ABNORMAL_STCS.request({ serviceType: searchType.serviceType }) + ); + }, [searchType.serviceType]); useEffect(() => { const { year, month } = searchType; @@ -44,7 +47,7 @@ export default function AbnormalSituationContainer() { }, [searchType.month]); useEffect(() => { - const { category, dateType, year, month, day } = searchType; + const { category, dateType, serviceType, year, month, day } = searchType; const dateMapping = { month: year, @@ -57,7 +60,8 @@ export default function AbnormalSituationContainer() { StcsActions.ABNORMAL_STCS_SEARCH.request({ cate: category, date, - type: dateType + type: dateType, + serviceType }) ); }, [searchType]); diff --git a/src/containers/statistics/FlightContainer.js b/src/containers/statistics/FlightContainer.js index 01d8094..6e23119 100644 --- a/src/containers/statistics/FlightContainer.js +++ b/src/containers/statistics/FlightContainer.js @@ -12,6 +12,7 @@ export default function FlightContainer() { const [searchType, setSearchType] = useState({ category: 'TIME', dateType: 'year', + serviceType: '', year: new Date().getFullYear(), month: new Date().getMonth() + 1, day: new Date().getDate() @@ -30,8 +31,10 @@ export default function FlightContainer() { }; useEffect(() => { - dispatch(StcsActions.FLIGHT_STCS.request()); - }, []); + dispatch( + StcsActions.FLIGHT_STCS.request({ serviceType: searchType.serviceType }) + ); + }, [searchType.serviceType]); // 해당 월에 맞는 요일 표출 useEffect(() => { @@ -43,7 +46,7 @@ export default function FlightContainer() { }, [searchType.month]); useEffect(() => { - const { category, dateType, year, month, day } = searchType; + const { category, dateType, serviceType, year, month, day } = searchType; const dateMapping = { month: year, @@ -56,7 +59,8 @@ export default function FlightContainer() { StcsActions.FLIGHT_STCS_SEARCH.request({ cate: category, date, - type: dateType + type: dateType, + serviceType }) ); }, [searchType]); diff --git a/src/containers/statistics/FlightResultContainer.js b/src/containers/statistics/FlightResultContainer.js index 0956691..90242dd 100644 --- a/src/containers/statistics/FlightResultContainer.js +++ b/src/containers/statistics/FlightResultContainer.js @@ -12,6 +12,7 @@ export default function ResultContainer() { const [searchType, setSearchType] = useState({ category: 'FLT_RESULT', dateType: 'year', + serviceType: '', year: new Date().getFullYear(), month: new Date().getMonth() + 1, day: new Date().getDate() @@ -30,8 +31,10 @@ export default function ResultContainer() { }; useEffect(() => { - dispatch(StcsActions.RESULT_STCS.request()); - }, []); + dispatch( + StcsActions.RESULT_STCS.request({ serviceType: searchType.serviceType }) + ); + }, [searchType.serviceType]); // 해당 월에 맞는 요일 표출 useEffect(() => { @@ -43,7 +46,7 @@ export default function ResultContainer() { }, [searchType.month]); useEffect(() => { - const { category, dateType, year, month, day } = searchType; + const { category, dateType, serviceType, year, month, day } = searchType; const dateMapping = { month: year, @@ -56,7 +59,8 @@ export default function ResultContainer() { StcsActions.RESULT_STCS_SEARCH.request({ cate: category, date, - type: dateType + type: dateType, + serviceType }) ); }, [searchType]); diff --git a/src/modules/statistics/actions/index.ts b/src/modules/statistics/actions/index.ts index 470ea21..6fd975d 100644 --- a/src/modules/statistics/actions/index.ts +++ b/src/modules/statistics/actions/index.ts @@ -1,6 +1,6 @@ import { AxiosError } from 'axios'; import { createAsyncAction, ActionType } from 'typesafe-actions'; -import { IStcsRs, IStcsSearchRq, IStcsSearchRs } from '../models'; +import { IStcsRq, IStcsRs, IStcsSearchRq, IStcsSearchRs } from '../models'; // 비행 통계 (비행시간, 비행거리, 비행횟수) const FLIGHT_STCS_REQUEST = 'statistics/flight/FLIGHT_STCS_REQUEST'; @@ -43,7 +43,7 @@ export const FLIGHT_STCS = createAsyncAction( FLIGHT_STCS_REQUEST, FLIGHT_STCS_SUCCESS, FLIGHT_STCS_FAILURE -)(); +)(); export const FLIGHT_STCS_SEARCH = createAsyncAction( FLIGHT_STCS_SEARCH_REQUEST, @@ -55,7 +55,7 @@ export const ABNORMAL_STCS = createAsyncAction( ABNORMAL_STCS_REQUEST, ABNORMAL_STCS_SUCCESS, ABNORMAL_STCS_FAILURE -)(); +)(); export const ABNORMAL_STCS_SEARCH = createAsyncAction( ABNORMAL_STCS_SEARCH_REQUEST, @@ -67,7 +67,7 @@ export const RESULT_STCS = createAsyncAction( RESULT_STCS_REQUEST, RESULT_STCS_SUCCESS, RESULT_STCS_FAILURE -)(); +)(); export const RESULT_STCS_SEARCH = createAsyncAction( RESULT_STCS_SEARCH_REQUEST, diff --git a/src/modules/statistics/apis/index.ts b/src/modules/statistics/apis/index.ts index 5284ea6..46bb5da 100644 --- a/src/modules/statistics/apis/index.ts +++ b/src/modules/statistics/apis/index.ts @@ -1,10 +1,16 @@ import axios from '../../utils/customAxiosUtil'; import qs from 'qs'; -import { IStcsSearchRq } from '../models'; +import { IStcsRq, IStcsSearchRq } from '../models'; export const statisticsAPI = { - flight: async () => { - return await axios.get('/api/main/statistics/flight-static'); + flight: async (data: IStcsRq) => { + const { serviceType } = data; + + return await axios.get( + `/api/main/statistics/flight-static${ + serviceType ? '?serviceType=' + serviceType : '' + }` + ); }, flightSearch: async (data: IStcsSearchRq) => { const { type } = data; @@ -21,8 +27,14 @@ export const statisticsAPI = { return await axios.get(`api/main/statistics/flight/${type}${queryString}`); }, - abnormal: async () => { - return await axios.get('/api/main/statistics/warn-static'); + abnormal: async (data: IStcsRq) => { + const { serviceType } = data; + + return await axios.get( + `/api/main/statistics/warn-static${ + serviceType ? '?serviceType=' + serviceType : '' + }` + ); }, abnormalSearch: async (data: IStcsSearchRq) => { const { type } = data; @@ -39,8 +51,14 @@ export const statisticsAPI = { return await axios.get(`api/main/statistics/warn/${type}${queryString}`); }, - result: async () => { - return await axios.get('/api/main/statistics/flight/result-static'); + result: async (data: IStcsRq) => { + const { serviceType } = data; + + return await axios.get( + `/api/main/statistics/flight/result-static${ + serviceType ? '?serviceType=' + serviceType : '' + }` + ); }, resultSearch: async (data: IStcsSearchRq) => { const { type } = data; diff --git a/src/modules/statistics/models/index.ts b/src/modules/statistics/models/index.ts index 2b789a1..3988919 100644 --- a/src/modules/statistics/models/index.ts +++ b/src/modules/statistics/models/index.ts @@ -7,6 +7,10 @@ export interface IStatisticsState { resultSearch: IStcsSearchRs; } +export interface IStcsRq { + serviceType: string; +} + export interface IStcsRs { name: string; year: number | string; @@ -27,6 +31,7 @@ export interface IStcsSearchRq { cate: string; date: string; type: string; + serviceType: string; } export const initialState = { diff --git a/src/modules/statistics/sagas/index.ts b/src/modules/statistics/sagas/index.ts index ba42884..b007b46 100644 --- a/src/modules/statistics/sagas/index.ts +++ b/src/modules/statistics/sagas/index.ts @@ -9,7 +9,7 @@ function* flightStcsSaga( ) { try { const payload = action.payload; - const res = yield call(Apis.statisticsAPI.flight); + const res = yield call(Apis.statisticsAPI.flight, payload); const { data, errorCode } = res; if (errorCode) { @@ -63,7 +63,7 @@ function* abnormalStcsSaga( ) { try { const payload = action.payload; - const res = yield call(Apis.statisticsAPI.abnormal); + const res = yield call(Apis.statisticsAPI.abnormal, payload); const { data, errorCode } = res; if (errorCode) { @@ -117,7 +117,7 @@ function* resultStcsSaga( ) { try { const payload = action.payload; - const res = yield call(Apis.statisticsAPI.result); + const res = yield call(Apis.statisticsAPI.result, payload); const { data, errorCode } = res; if (errorCode) {