diff --git a/components/statistics/new-equip-reservation.bar.jsx b/components/statistics/new-equip-reservation.bar.jsx new file mode 100644 index 0000000..9b89e95 --- /dev/null +++ b/components/statistics/new-equip-reservation.bar.jsx @@ -0,0 +1,40 @@ +import { useEffect, useState } from 'react'; +import { ResponsiveBar } from '@nivo/bar'; + +import { PoPoAxios } from '@/utils/axios.instance'; + +const NewEquipReservationBar = ({ year }) => { + const [barData, setBarData] = useState([]); + + useEffect(() => { + PoPoAxios.get( + `/statistics/reservation/equipment?start=${year}01&end=${year + 1}01`, + ).then((res) => { + // process data format + const barData = []; + for (const [key, value] of Object.entries(res.data.data)) { + barData.push({ + month: key, + 'new-reservation': value, + }); + } + setBarData(barData); + }); + }, [year]); + + return ( + <> + + + ); +}; + +export default NewEquipReservationBar; diff --git a/pages/reservation/index.jsx b/pages/reservation/index.jsx index 1962772..c5615c4 100644 --- a/pages/reservation/index.jsx +++ b/pages/reservation/index.jsx @@ -8,9 +8,12 @@ import PlaceReservationWaitTable from '@/components/place/place.reservation.wait import EquipmentReservationWaitTable from '@/components/equipment/equipment.reservation.wait.table'; const ReservationPage = ({ - totalReservationCnt, - todayReservationCnt, - thisWeekReservationCnt, + totalPlaceReservationCnt, + todayPlaceReservationCnt, + thisWeekPlaceReservationCnt, + totalEquipReservationCnt, + todayEquipReservationCnt, + thisWeekEquipReservationCnt, }) => { const [isLoading, setIsLoading] = useState(true); @@ -52,10 +55,17 @@ const ReservationPage = ({

예약 대기 목록

+

@@ -126,17 +136,20 @@ const ReservationPage = ({ export default ReservationPage; export async function getServerSideProps() { - const res1 = await PoPoAxios.get('statistics/reservation/count'); + const res1 = await PoPoAxios.get('statistics/reservation/place/count'); const placeReservationCntStats = res1.data; - const { totalReservationCnt, todayReservationCnt, thisWeekReservationCnt } = - placeReservationCntStats; + const res2 = await PoPoAxios.get('statistics/reservation/equipment/count'); + const equipReservationCntStats = res2.data; return { props: { - totalReservationCnt, - todayReservationCnt, - thisWeekReservationCnt, + totalPlaceReservationCnt: placeReservationCntStats.totalReservationCnt, + todayPlaceReservationCnt: placeReservationCntStats.todayReservationCnt, + thisWeekPlaceReservationCnt: placeReservationCntStats.thisWeekReservationCnt, + totalEquipReservationCnt: equipReservationCntStats.totalReservationCnt, + todayEquipReservationCnt: equipReservationCntStats.todayReservationCnt, + thisWeekEquipReservationCnt: equipReservationCntStats.thisWeekReservationCnt, }, }; } diff --git a/pages/statistics/index.jsx b/pages/statistics/index.jsx index 8f0ca43..3a54a73 100644 --- a/pages/statistics/index.jsx +++ b/pages/statistics/index.jsx @@ -15,7 +15,7 @@ const NewPlaceReservationBar = dynamic( { ssr: false }, ); const NewEquipmentReservationBar = dynamic( - () => import('../../components/statistics/new-place-reservation.bar'), + () => import('../../components/statistics/new-equip-reservation.bar'), { ssr: false }, );