diff --git a/src/components/statistics/StatisticsSearch.js b/src/components/statistics/StatisticsSearch.js index 6d24c243..18612bb7 100644 --- a/src/components/statistics/StatisticsSearch.js +++ b/src/components/statistics/StatisticsSearch.js @@ -20,9 +20,11 @@ export default function StatisticsSearch({ dateLists, categoryTypeOptions, handlerBarTicks, - handlerTitleName, + handlerChartTitle, handleChangeSearchType, - formatSeconds + formatSeconds, + user, + entireGroupList }) { const [total, setTotal] = useState([]); const [top, setTop] = useState([]); @@ -271,6 +273,40 @@ export default function StatisticsSearch({
+ {user?.authId === 'SUPER' && ( +
+
+
그룹명
+
+
+ + + + handleChangeSearchType( + 'serviceType', + e.target.value + ) + } + > + {entireGroupList?.map(i => ( + + ))} + + + +
+
+
+
+ )}
검색조건
@@ -283,12 +319,13 @@ export default function StatisticsSearch({ type='select' id='' bsSize='sm' - onChange={e => + value={searchType.category} + onChange={e => { handleChangeSearchType( 'category', e.target.value - ) - } + ); + }} > {Object.entries(categoryTypeOptions).map( ([value, label]) => ( @@ -317,7 +354,7 @@ export default function StatisticsSearch({ - {handlerTitleName(searchType.category)} 통계 + {handlerChartTitle(searchType.category)} 통계
@@ -327,7 +364,7 @@ export default function StatisticsSearch({ type='select' id='' bsSize='sm' - value={searchType.type} + value={searchType.dateType} onChange={e => handleChangeSearchType('dateType', e.target.value) } @@ -427,7 +464,7 @@ export default function StatisticsSearch({ - {handlerTitleName(searchType.category)} TOP5 + {handlerChartTitle(searchType.category)} TOP5 diff --git a/src/components/statistics/StatisticsTotal.js b/src/components/statistics/StatisticsTotal.js index d7e26bb1..0a876134 100644 --- a/src/components/statistics/StatisticsTotal.js +++ b/src/components/statistics/StatisticsTotal.js @@ -1,5 +1,6 @@ import { Col, Row } from 'reactstrap'; import { FcAlarmClock, FcWorkflow, FcBarChart } from 'react-icons/fc'; +import { useEffect } from 'react'; export default function StatisticsTotal({ totalData, @@ -37,7 +38,7 @@ export default function StatisticsTotal({ {renderIcon(idx)} {totalTitle[idx]} - + 기체명 {i.name} diff --git a/src/containers/statistics/AbnormalSituationContainer.js b/src/containers/statistics/AbnormalSituationContainer.js index 2240d13d..ec649954 100644 --- a/src/containers/statistics/AbnormalSituationContainer.js +++ b/src/containers/statistics/AbnormalSituationContainer.js @@ -8,6 +8,7 @@ import StatisticsTotal from '../../components/statistics/StatisticsTotal'; export default function AbnormalSituationContainer() { const dispatch = useDispatch(); + const { abnormal, abnormalSearch } = useSelector( state => state.statisticsState ); @@ -17,7 +18,7 @@ export default function AbnormalSituationContainer() { const [searchType, setSearchType] = useState({ category: 'PLAN', dateType: 'year', - serviceType: '', + serviceType: 'KAC', year: new Date().getFullYear(), month: new Date().getMonth() + 1, day: new Date().getDate() @@ -35,30 +36,23 @@ export default function AbnormalSituationContainer() { CRASH: '충돌위험' }; + // 사용자가 SUPER 권한일 경우 전체 그룹 조회 useEffect(() => { - if (user) { - user.authId === 'SUPER' && - dispatch(GroupActions.ENTIRE_GROUP_LIST.request()); - } + user?.authId === 'SUPER' && + dispatch(GroupActions.ENTIRE_GROUP_LIST.request()); }, []); + // 사용자가 SUPER 권한일 경우 serviceType 파라미터 추가 - 상단 통계 데이터 useEffect(() => { - dispatch( - StcsActions.ABNORMAL_STCS.request({ serviceType: searchType.serviceType }) - ); - }, [searchType.serviceType]); - - useEffect(() => { - const { year, month } = searchType; - const lastDay = new Date(year, month, 0).getDate(); - const dayList = Array.from({ length: lastDay }, (_, index) => index + 1); + const params = + user?.authId === 'SUPER' ? { serviceType: searchType.serviceType } : {}; - setDateLists({ ...dateLists, day: dayList }); - }, [searchType.month]); + dispatch(StcsActions.ABNORMAL_STCS.request(params)); + }, [searchType.serviceType, user]); + // 사용자가 SUPER 권한일 경우 serviceType 파라미터 추가 - 하단 그래프 데이터 useEffect(() => { const { category, dateType, serviceType, year, month, day } = searchType; - const dateMapping = { month: year, day: `${year}-${month}`, @@ -66,15 +60,22 @@ export default function AbnormalSituationContainer() { }; const date = dateMapping[dateType] || ''; - dispatch( - StcsActions.ABNORMAL_STCS_SEARCH.request({ - cate: category, - date, - type: dateType, - serviceType - }) - ); - }, [searchType]); + const params = + user?.authId === 'SUPER' + ? { cate: category, date, type: dateType, serviceType } + : { cate: category, date, type: dateType }; + + dispatch(StcsActions.ABNORMAL_STCS_SEARCH.request(params)); + }, [searchType, user]); + + // 해당 월에 맞는 요일 표출 + useEffect(() => { + const { year, month } = searchType; + const lastDay = new Date(year, month, 0).getDate(); + const dayList = Array.from({ length: lastDay }, (_, index) => index + 1); + + setDateLists({ ...dateLists, day: dayList }); + }, [searchType.month]); // 검색조건 handler const handleChangeSearchType = useCallback( @@ -88,7 +89,7 @@ export default function AbnormalSituationContainer() { ); // 그래프 타이틀 handler - const handlerTitleName = category => { + const handlerChartTitle = category => { return categoryTypeOptions[category]; }; @@ -138,10 +139,12 @@ export default function AbnormalSituationContainer() {
diff --git a/src/containers/statistics/FlightContainer.js b/src/containers/statistics/FlightContainer.js index 2ae84d5d..faf5054f 100644 --- a/src/containers/statistics/FlightContainer.js +++ b/src/containers/statistics/FlightContainer.js @@ -8,6 +8,7 @@ import StatisticsSearch from '../../components/statistics/StatisticsSearch'; export default function FlightContainer() { const dispatch = useDispatch(); + const { flight, flightSearch } = useSelector(state => state.statisticsState); const { user } = useSelector(state => state.authState); const { entireGroupList } = useSelector(state => state.groupState); @@ -15,7 +16,7 @@ export default function FlightContainer() { const [searchType, setSearchType] = useState({ category: 'TIME', dateType: 'year', - serviceType: '', + serviceType: 'KAC', year: new Date().getFullYear(), month: new Date().getMonth() + 1, day: new Date().getDate() @@ -33,31 +34,23 @@ export default function FlightContainer() { FLT_COUNT: '비행 횟수' }; + // 사용자가 SUPER 권한일 경우 전체 그룹 조회 useEffect(() => { - if (user) { - user.authId === 'SUPER' && - dispatch(GroupActions.ENTIRE_GROUP_LIST.request()); - } - }, []); + user?.authId === 'SUPER' && + dispatch(GroupActions.ENTIRE_GROUP_LIST.request()); + }, [user]); + // 사용자가 SUPER 권한일 경우 serviceType 파라미터 추가 - 상단 통계 데이터 useEffect(() => { - dispatch( - StcsActions.FLIGHT_STCS.request({ serviceType: searchType.serviceType }) - ); - }, [searchType.serviceType]); + const params = + user?.authId === 'SUPER' ? { serviceType: searchType.serviceType } : {}; - // 해당 월에 맞는 요일 표출 - 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]); + dispatch(StcsActions.FLIGHT_STCS.request(params)); + }, [searchType.serviceType, user]); + // 사용자가 SUPER 권한일 경우 serviceType 파라미터 추가 - 하단 그래프 데이터 useEffect(() => { const { category, dateType, serviceType, year, month, day } = searchType; - const dateMapping = { month: year, day: `${year}-${month}`, @@ -65,15 +58,22 @@ export default function FlightContainer() { }; const date = dateMapping[dateType] || ''; - dispatch( - StcsActions.FLIGHT_STCS_SEARCH.request({ - cate: category, - date, - type: dateType, - serviceType - }) - ); - }, [searchType]); + const params = + user?.authId === 'SUPER' + ? { cate: category, date, type: dateType, serviceType } + : { cate: category, date, type: dateType }; + + dispatch(StcsActions.FLIGHT_STCS_SEARCH.request(params)); + }, [searchType, user]); + + // 해당 월에 맞는 요일 표출 + 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 const handleChangeSearchType = useCallback( @@ -87,7 +87,7 @@ export default function FlightContainer() { ); // 그래프 타이틀 handler - const handlerTitleName = category => { + const handlerChartTitle = category => { return categoryTypeOptions[category]; }; @@ -199,11 +199,13 @@ export default function FlightContainer() {
diff --git a/src/containers/statistics/FlightResultContainer.js b/src/containers/statistics/FlightResultContainer.js index 2480dcc6..7d395734 100644 --- a/src/containers/statistics/FlightResultContainer.js +++ b/src/containers/statistics/FlightResultContainer.js @@ -8,6 +8,7 @@ import StatisticsSearch from '../../components/statistics/StatisticsSearch'; export default function ResultContainer() { const dispatch = useDispatch(); + const { result, resultSearch } = useSelector(state => state.statisticsState); const { user } = useSelector(state => state.authState); const { entireGroupList } = useSelector(state => state.groupState); @@ -15,7 +16,7 @@ export default function ResultContainer() { const [searchType, setSearchType] = useState({ category: 'FLT_RESULT', dateType: 'year', - serviceType: '', + serviceType: 'KAC', year: new Date().getFullYear(), month: new Date().getMonth() + 1, day: new Date().getDate() @@ -33,31 +34,23 @@ export default function ResultContainer() { FLT_PLAN_APRVN: '비행 승인' }; + // 사용자가 SUPER 권한일 경우 전체 그룹 조회 useEffect(() => { - if (user) { - user.authId === 'SUPER' && - dispatch(GroupActions.ENTIRE_GROUP_LIST.request()); - } - }, []); + user?.authId === 'SUPER' && + dispatch(GroupActions.ENTIRE_GROUP_LIST.request()); + }, [user]); + // 사용자가 SUPER 권한일 경우 serviceType 파라미터 추가 - 상단 통계 데이터 useEffect(() => { - dispatch( - StcsActions.RESULT_STCS.request({ serviceType: searchType.serviceType }) - ); - }, [searchType.serviceType]); + const params = + user?.authId === 'SUPER' ? { serviceType: searchType.serviceType } : {}; - // 해당 월에 맞는 요일 표출 - 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]); + dispatch(StcsActions.RESULT_STCS.request(params)); + }, [searchType.serviceType, user]); + // 사용자가 SUPER 권한일 경우 serviceType 파라미터 추가 - 하단 그래프 데이터 useEffect(() => { const { category, dateType, serviceType, year, month, day } = searchType; - const dateMapping = { month: year, day: `${year}-${month}`, @@ -65,15 +58,22 @@ export default function ResultContainer() { }; const date = dateMapping[dateType] || ''; - dispatch( - StcsActions.RESULT_STCS_SEARCH.request({ - cate: category, - date, - type: dateType, - serviceType - }) - ); - }, [searchType]); + const params = + user?.authId === 'SUPER' + ? { cate: category, date, type: dateType, serviceType } + : { cate: category, date, type: dateType }; + + dispatch(StcsActions.RESULT_STCS_SEARCH.request(params)); + }, [searchType, user]); + + // 해당 월에 맞는 요일 표출 + 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 const handleChangeSearchType = useCallback( @@ -87,7 +87,7 @@ export default function ResultContainer() { ); // 그래프 타이틀 handler - const handlerTitleName = category => { + const handlerChartTitle = category => { return categoryTypeOptions[category]; }; @@ -137,10 +137,12 @@ export default function ResultContainer() {