|
|
@ -8,6 +8,7 @@ import StatisticsSearch from '../../components/statistics/StatisticsSearch'; |
|
|
|
|
|
|
|
|
|
|
|
export default function FlightContainer() { |
|
|
|
export default function FlightContainer() { |
|
|
|
const dispatch = useDispatch(); |
|
|
|
const dispatch = useDispatch(); |
|
|
|
|
|
|
|
|
|
|
|
const { flight, flightSearch } = useSelector(state => state.statisticsState); |
|
|
|
const { flight, flightSearch } = useSelector(state => state.statisticsState); |
|
|
|
const { user } = useSelector(state => state.authState); |
|
|
|
const { user } = useSelector(state => state.authState); |
|
|
|
const { entireGroupList } = useSelector(state => state.groupState); |
|
|
|
const { entireGroupList } = useSelector(state => state.groupState); |
|
|
@ -15,7 +16,7 @@ export default function FlightContainer() { |
|
|
|
const [searchType, setSearchType] = useState({ |
|
|
|
const [searchType, setSearchType] = useState({ |
|
|
|
category: 'TIME', |
|
|
|
category: 'TIME', |
|
|
|
dateType: 'year', |
|
|
|
dateType: 'year', |
|
|
|
serviceType: '', |
|
|
|
serviceType: 'KAC', |
|
|
|
year: new Date().getFullYear(), |
|
|
|
year: new Date().getFullYear(), |
|
|
|
month: new Date().getMonth() + 1, |
|
|
|
month: new Date().getMonth() + 1, |
|
|
|
day: new Date().getDate() |
|
|
|
day: new Date().getDate() |
|
|
@ -33,31 +34,23 @@ export default function FlightContainer() { |
|
|
|
FLT_COUNT: '비행 횟수' |
|
|
|
FLT_COUNT: '비행 횟수' |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 사용자가 SUPER 권한일 경우 전체 그룹 조회
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if (user) { |
|
|
|
user?.authId === 'SUPER' && |
|
|
|
user.authId === 'SUPER' && |
|
|
|
dispatch(GroupActions.ENTIRE_GROUP_LIST.request()); |
|
|
|
dispatch(GroupActions.ENTIRE_GROUP_LIST.request()); |
|
|
|
}, [user]); |
|
|
|
} |
|
|
|
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 사용자가 SUPER 권한일 경우 serviceType 파라미터 추가 - 상단 통계 데이터
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
dispatch( |
|
|
|
const params = |
|
|
|
StcsActions.FLIGHT_STCS.request({ serviceType: searchType.serviceType }) |
|
|
|
user?.authId === 'SUPER' ? { serviceType: searchType.serviceType } : {}; |
|
|
|
); |
|
|
|
|
|
|
|
}, [searchType.serviceType]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 해당 월에 맞는 요일 표출
|
|
|
|
dispatch(StcsActions.FLIGHT_STCS.request(params)); |
|
|
|
useEffect(() => { |
|
|
|
}, [searchType.serviceType, user]); |
|
|
|
const { year, month } = searchType; |
|
|
|
|
|
|
|
const lastDay = new Date(year, Number(month), 0).getDate(); |
|
|
|
|
|
|
|
const dayList = Array.from({ length: lastDay }, (_, index) => index + 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setDateLists({ ...dateLists, day: dayList }); |
|
|
|
|
|
|
|
}, [searchType.month]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 사용자가 SUPER 권한일 경우 serviceType 파라미터 추가 - 하단 그래프 데이터
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
const { category, dateType, serviceType, year, month, day } = searchType; |
|
|
|
const { category, dateType, serviceType, year, month, day } = searchType; |
|
|
|
|
|
|
|
|
|
|
|
const dateMapping = { |
|
|
|
const dateMapping = { |
|
|
|
month: year, |
|
|
|
month: year, |
|
|
|
day: `${year}-${month}`, |
|
|
|
day: `${year}-${month}`, |
|
|
@ -65,15 +58,22 @@ export default function FlightContainer() { |
|
|
|
}; |
|
|
|
}; |
|
|
|
const date = dateMapping[dateType] || ''; |
|
|
|
const date = dateMapping[dateType] || ''; |
|
|
|
|
|
|
|
|
|
|
|
dispatch( |
|
|
|
const params = |
|
|
|
StcsActions.FLIGHT_STCS_SEARCH.request({ |
|
|
|
user?.authId === 'SUPER' |
|
|
|
cate: category, |
|
|
|
? { cate: category, date, type: dateType, serviceType } |
|
|
|
date, |
|
|
|
: { cate: category, date, type: dateType }; |
|
|
|
type: dateType, |
|
|
|
|
|
|
|
serviceType |
|
|
|
dispatch(StcsActions.FLIGHT_STCS_SEARCH.request(params)); |
|
|
|
}) |
|
|
|
}, [searchType, user]); |
|
|
|
); |
|
|
|
|
|
|
|
}, [searchType]); |
|
|
|
// 해당 월에 맞는 요일 표출
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
const { year, month } = searchType; |
|
|
|
|
|
|
|
const lastDay = new Date(year, Number(month), 0).getDate(); |
|
|
|
|
|
|
|
const dayList = Array.from({ length: lastDay }, (_, index) => index + 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setDateLists({ ...dateLists, day: dayList }); |
|
|
|
|
|
|
|
}, [searchType.month]); |
|
|
|
|
|
|
|
|
|
|
|
// 검색조건 handler
|
|
|
|
// 검색조건 handler
|
|
|
|
const handleChangeSearchType = useCallback( |
|
|
|
const handleChangeSearchType = useCallback( |
|
|
@ -87,7 +87,7 @@ export default function FlightContainer() { |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// 그래프 타이틀 handler
|
|
|
|
// 그래프 타이틀 handler
|
|
|
|
const handlerTitleName = category => { |
|
|
|
const handlerChartTitle = category => { |
|
|
|
return categoryTypeOptions[category]; |
|
|
|
return categoryTypeOptions[category]; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -199,11 +199,13 @@ export default function FlightContainer() { |
|
|
|
<StatisticsSearch |
|
|
|
<StatisticsSearch |
|
|
|
searchData={flightSearch} |
|
|
|
searchData={flightSearch} |
|
|
|
searchType={searchType} |
|
|
|
searchType={searchType} |
|
|
|
|
|
|
|
user={user} |
|
|
|
|
|
|
|
entireGroupList={entireGroupList} |
|
|
|
categoryTypeOptions={categoryTypeOptions} |
|
|
|
categoryTypeOptions={categoryTypeOptions} |
|
|
|
dateLists={dateLists} |
|
|
|
dateLists={dateLists} |
|
|
|
formatSeconds={formatSeconds} |
|
|
|
formatSeconds={formatSeconds} |
|
|
|
handlerBarTicks={handlerBarTicks} |
|
|
|
handlerBarTicks={handlerBarTicks} |
|
|
|
handlerTitleName={handlerTitleName} |
|
|
|
handlerChartTitle={handlerChartTitle} |
|
|
|
handleChangeSearchType={handleChangeSearchType} |
|
|
|
handleChangeSearchType={handleChangeSearchType} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|