Browse Source

serviceType rq 추가

pull/2/head
hhjk00 10 months ago
parent
commit
b930ca7079
  1. 12
      src/containers/statistics/AbnormalSituationContainer.js
  2. 12
      src/containers/statistics/FlightContainer.js
  3. 12
      src/containers/statistics/FlightResultContainer.js
  4. 8
      src/modules/statistics/actions/index.ts
  5. 32
      src/modules/statistics/apis/index.ts
  6. 5
      src/modules/statistics/models/index.ts
  7. 6
      src/modules/statistics/sagas/index.ts

12
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]);

12
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]);

12
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]);

8
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
)<null, IStcsRs[], AxiosError>();
)<IStcsRq, IStcsRs[], AxiosError>();
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
)<null, IStcsRs[], AxiosError>();
)<IStcsRq, IStcsRs[], AxiosError>();
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
)<null, IStcsRs[], AxiosError>();
)<IStcsRq, IStcsRs[], AxiosError>();
export const RESULT_STCS_SEARCH = createAsyncAction(
RESULT_STCS_SEARCH_REQUEST,

32
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;

5
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 = {

6
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) {

Loading…
Cancel
Save