- {gameId} / {activeDate}
+
+ setSelectedTabId(selectedId as MyReservationsStatus)}
+ />
);
};
diff --git a/src/constants/tapOptions.ts b/src/constants/tapOptions.ts
index 0c4cc65e..a1dfd0c0 100644
--- a/src/constants/tapOptions.ts
+++ b/src/constants/tapOptions.ts
@@ -1,5 +1,13 @@
+import { ScheduleTabOptions } from '@/types';
+
export const MYPAGE_TAB_OPTIONS = [
{ id: 'myPost', text: '등록한 게시글' },
{ id: 'myReservation', text: '신청한 예약' },
{ id: 'reservationsStatus', text: '예약 현황' },
];
+
+export const SCHEDULE_TAB_OPTIONS: ScheduleTabOptions[] = [
+ { id: 'pending', text: '신청' },
+ { id: 'confirmed', text: '승인' },
+ { id: 'declined', text: '거절' },
+];
diff --git a/src/types/schedule.ts b/src/types/schedule.ts
index b0fb91f9..713435b2 100644
--- a/src/types/schedule.ts
+++ b/src/types/schedule.ts
@@ -1,4 +1,4 @@
-import { ReservationResponse } from '@/types';
+import { MyReservationsStatus, MyReservationsStatusKR, ReservationResponse } from '@/types';
export type AvailableSchedule = {
date: string;
@@ -37,3 +37,8 @@ export type DetailSchedule = {
};
export type ReservationsByDate = Record
;
+
+export type ScheduleTabOptions = {
+ id: MyReservationsStatus;
+ text: MyReservationsStatusKR;
+};
From aa26529d14173c36de3cda3897d481008de94f42 Mon Sep 17 00:00:00 2001
From: CheeseB <2489ckckck@naver.com>
Date: Thu, 28 Mar 2024 11:19:58 +0900
Subject: [PATCH 03/18] =?UTF-8?q?refactor:=20=EC=98=88=EC=95=BD=20?=
=?UTF-8?q?=ED=98=84=ED=99=A9=20response=20=ED=83=80=EC=9E=85=EB=AA=85=20?=
=?UTF-8?q?=EB=8D=94=20=EB=AA=85=ED=99=95=ED=95=98=EA=B2=8C=20=EB=B3=80?=
=?UTF-8?q?=EA=B2=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/calendar/ListBody/index.tsx | 4 ++--
src/components/calendar/index.tsx | 6 +++---
src/types/schedule.ts | 6 +++---
src/utils/dataMap.ts | 4 ++--
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/components/calendar/ListBody/index.tsx b/src/components/calendar/ListBody/index.tsx
index daeeed2b..54bb8b0b 100644
--- a/src/components/calendar/ListBody/index.tsx
+++ b/src/components/calendar/ListBody/index.tsx
@@ -3,14 +3,14 @@ import classNames from 'classnames/bind';
import ListCard from '@/components/calendar/ListCard';
import EmptyCard from '@/components/layout/empty/EmptyCard';
-import { MonthlySchedule } from '@/types';
+import { MonthlyReservationResponse } from '@/types';
import styles from './ListBody.module.scss';
const cx = classNames.bind(styles);
type ListBodyProps = {
- schedules?: MonthlySchedule[];
+ schedules?: MonthlyReservationResponse[];
onClick: (date: string) => void;
};
diff --git a/src/components/calendar/index.tsx b/src/components/calendar/index.tsx
index 4d0caef7..8db9921a 100644
--- a/src/components/calendar/index.tsx
+++ b/src/components/calendar/index.tsx
@@ -16,7 +16,7 @@ import MockMonthlySchedule4 from '@/constants/mockData/myScheduleMockDataMonth4.
import { useDeviceType } from '@/hooks/useDeviceType';
import useMultiState from '@/hooks/useMultiState';
-import { MonthlySchedule } from '@/types';
+import { MonthlyReservationResponse } from '@/types';
import styles from './Calendar.module.scss';
@@ -29,7 +29,7 @@ const getMonthlyMockData = (year: number, month: number) => {
const yearText = year.toString();
const monthText = month.toString().padStart(2, '0');
- const MonthlyMockData: Record = {
+ const MonthlyMockData: Record = {
'2024/01': MockMonthlySchedule1,
'2024/02': MockMonthlySchedule2,
'2024/03': MockMonthlySchedule3,
@@ -49,7 +49,7 @@ const Calendar = ({ gameId }: CalendarProps) => {
const [isCalendar, setIsCalendar] = useState(true);
const [currentYear, setCurrentYear] = useState(today.year);
const [currentMonth, setCurrentMonth] = useState(today.month);
- const [monthlySchedule, setMonthlySchedule] = useState([]);
+ const [monthlySchedule, setMonthlySchedule] = useState([]);
const [activeDate, setActiveDate] = useState('');
const { multiState, toggleClick } = useMultiState(['scheduleModal, confirmModal']);
diff --git a/src/types/schedule.ts b/src/types/schedule.ts
index 713435b2..936d921d 100644
--- a/src/types/schedule.ts
+++ b/src/types/schedule.ts
@@ -18,19 +18,19 @@ export type DailyReservationCount = {
pending: number;
};
-export type MonthlySchedule = {
+export type MonthlyReservationResponse = {
date: string;
reservations: MonthlyReservationCount;
};
-export type DailySchedule = {
+export type DailyReservationResponse = {
scheduleId: number;
startTime: string;
endTime: string;
count: DailyReservationCount;
};
-export type DetailSchedule = {
+export type DetailReservationResponse = {
cursorId: 0;
totalCount: 0;
reservations: Omit[];
diff --git a/src/utils/dataMap.ts b/src/utils/dataMap.ts
index c12ae395..873f9191 100644
--- a/src/utils/dataMap.ts
+++ b/src/utils/dataMap.ts
@@ -1,6 +1,6 @@
import { PRICE_TO_POST_TYPES } from '@/constants';
-import { MonthlySchedule, ReservationsByDate } from '@/types';
+import { MonthlyReservationResponse, ReservationsByDate } from '@/types';
import { formatCategoryToGameNameKR } from './gameFormatter';
@@ -29,7 +29,7 @@ export const splitDescByDelimiter = (inputString: string) => {
};
};
-export const scheduleListToObjectByDate = (scheduleData: MonthlySchedule[] | undefined) => {
+export const scheduleListToObjectByDate = (scheduleData: MonthlyReservationResponse[] | undefined) => {
const result: ReservationsByDate = {};
scheduleData?.forEach((schedule) => (result[schedule.date] = schedule.reservations));
From ba6e9c745e18fd8b00590734f03122561e941755 Mon Sep 17 00:00:00 2001
From: CheeseB <2489ckckck@naver.com>
Date: Thu, 28 Mar 2024 12:13:04 +0900
Subject: [PATCH 04/18] =?UTF-8?q?feat:=20=EB=AA=A8=EB=8B=AC=EC=97=90=20?=
=?UTF-8?q?=EC=9D=BC=EB=B3=84=20=EC=8A=A4=EC=BC=80=EC=A4=84=20=EC=A0=95?=
=?UTF-8?q?=EB=B3=B4=20=ED=91=9C=EC=8B=9C=ED=95=98=EB=8A=94=20=EA=B8=B0?=
=?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84=20(mock=EB=8D=B0=EC=9D=B4?=
=?UTF-8?q?=ED=84=B0)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../calendar/ModalContents/index.tsx | 42 ++++++++++++++++---
src/components/calendar/index.tsx | 4 +-
src/constants/tapOptions.ts | 8 ----
src/types/schedule.ts | 3 +-
src/utils/dataMap.ts | 36 ++++++++++++++--
src/utils/getDate.ts | 2 +
6 files changed, 76 insertions(+), 19 deletions(-)
diff --git a/src/components/calendar/ModalContents/index.tsx b/src/components/calendar/ModalContents/index.tsx
index 0ed28750..fa0d8c4c 100644
--- a/src/components/calendar/ModalContents/index.tsx
+++ b/src/components/calendar/ModalContents/index.tsx
@@ -2,11 +2,13 @@ import { useState } from 'react';
import classNames from 'classnames/bind';
-import { SCHEDULE_TAB_OPTIONS } from '@/constants';
+import { getDateStringKR, getScheduleDropdownOption, getStatusCountByScheduleId } from '@/utils';
+import Dropdown from '@/components/commons/Dropdown';
import Tab from '@/components/commons/Tab';
+import DailyScheduleMockData from '@/constants/mockData/reservedScheduleMockData.json';
-import { MyReservationsStatus } from '@/types';
+import { DailyReservationResponse, MyReservationsStatus, StatusTabOptions } from '@/types';
import styles from './ModalContents.module.scss';
@@ -18,19 +20,49 @@ type ModalContentsProps = {
};
const ModalContents = ({ gameId, activeDate }: ModalContentsProps) => {
- const [selectedTabId, setSelectedTabId] = useState(SCHEDULE_TAB_OPTIONS[0].id);
+ const DailyMockData: Record = {
+ '2024-03-27': DailyScheduleMockData['2024-03-27'],
+ '2024-03-30': DailyScheduleMockData['2024-03-30'],
+ '2024-04-01': DailyScheduleMockData['2024-04-01'],
+ };
+
+ const dropdownOptions = getScheduleDropdownOption(DailyMockData[activeDate]);
+ const statusCountByScheduleId = getStatusCountByScheduleId(DailyMockData[activeDate]);
+
+ const [scheduleId, setScheduleId] = useState(dropdownOptions[0].value as number);
+
+ const statusCount = statusCountByScheduleId[scheduleId];
+
+ const statusTabOptions: StatusTabOptions[] = [
+ { id: 'pending', text: '신청', count: statusCount.pending },
+ { id: 'confirmed', text: '승인', count: statusCount.confirmed },
+ { id: 'declined', text: '거절', count: statusCount.declined },
+ ];
+
+ const [selectedTabId, setSelectedTabId] = useState(statusTabOptions[0].id);
console.log(gameId);
- console.log(activeDate);
return (
setSelectedTabId(selectedId as MyReservationsStatus)}
/>
+
+
예약 날짜
+ {getDateStringKR(activeDate)}
+ {
+ setScheduleId(value as number);
+ }}
+ color='yellow'
+ isSmall
+ />
+
);
};
diff --git a/src/components/calendar/index.tsx b/src/components/calendar/index.tsx
index 8db9921a..0bf4a498 100644
--- a/src/components/calendar/index.tsx
+++ b/src/components/calendar/index.tsx
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import classNames from 'classnames/bind';
-import { getCurrentDate, scheduleListToObjectByDate } from '@/utils';
+import { getCurrentDate, getScheduleByDate } from '@/utils';
import CalendarBody from '@/components/calendar/CalendarBody';
import CalendarHeader from '@/components/calendar/CalendarHeader';
@@ -103,7 +103,7 @@ const Calendar = ({ gameId }: CalendarProps) => {
today={today}
currentYear={currentYear}
currentMonth={currentMonth}
- schedules={scheduleListToObjectByDate(monthlySchedule)}
+ schedules={getScheduleByDate(monthlySchedule)}
onClick={handleScheduleClick}
/>
) : (
diff --git a/src/constants/tapOptions.ts b/src/constants/tapOptions.ts
index a1dfd0c0..0c4cc65e 100644
--- a/src/constants/tapOptions.ts
+++ b/src/constants/tapOptions.ts
@@ -1,13 +1,5 @@
-import { ScheduleTabOptions } from '@/types';
-
export const MYPAGE_TAB_OPTIONS = [
{ id: 'myPost', text: '등록한 게시글' },
{ id: 'myReservation', text: '신청한 예약' },
{ id: 'reservationsStatus', text: '예약 현황' },
];
-
-export const SCHEDULE_TAB_OPTIONS: ScheduleTabOptions[] = [
- { id: 'pending', text: '신청' },
- { id: 'confirmed', text: '승인' },
- { id: 'declined', text: '거절' },
-];
diff --git a/src/types/schedule.ts b/src/types/schedule.ts
index 936d921d..2e8fc0c3 100644
--- a/src/types/schedule.ts
+++ b/src/types/schedule.ts
@@ -38,7 +38,8 @@ export type DetailReservationResponse = {
export type ReservationsByDate = Record;
-export type ScheduleTabOptions = {
+export type StatusTabOptions = {
id: MyReservationsStatus;
text: MyReservationsStatusKR;
+ count: number;
};
diff --git a/src/utils/dataMap.ts b/src/utils/dataMap.ts
index 873f9191..e9921535 100644
--- a/src/utils/dataMap.ts
+++ b/src/utils/dataMap.ts
@@ -1,6 +1,11 @@
import { PRICE_TO_POST_TYPES } from '@/constants';
-import { MonthlyReservationResponse, ReservationsByDate } from '@/types';
+import {
+ DailyReservationCount,
+ DailyReservationResponse,
+ MonthlyReservationResponse,
+ ReservationsByDate,
+} from '@/types';
import { formatCategoryToGameNameKR } from './gameFormatter';
@@ -29,10 +34,35 @@ export const splitDescByDelimiter = (inputString: string) => {
};
};
-export const scheduleListToObjectByDate = (scheduleData: MonthlyReservationResponse[] | undefined) => {
+export const getScheduleByDate = (scheduleData: MonthlyReservationResponse[] | undefined) => {
const result: ReservationsByDate = {};
- scheduleData?.forEach((schedule) => (result[schedule.date] = schedule.reservations));
+ scheduleData?.forEach((schedule) => {
+ result[schedule.date] = schedule.reservations;
+ });
+
+ return result;
+};
+
+export const getStatusCountByScheduleId = (scheduleData: DailyReservationResponse[] | undefined) => {
+ const result: { [id: number]: DailyReservationCount } = {};
+
+ scheduleData?.forEach((schedule) => {
+ result[schedule.scheduleId] = schedule.count;
+ });
+
+ return result;
+};
+
+export const getScheduleDropdownOption = (scheduleData: DailyReservationResponse[] | undefined) => {
+ const result: { title: string; value: number | string }[] = [];
+
+ scheduleData?.forEach((schedule) => {
+ result.push({
+ title: `${schedule.startTime} - ${schedule.endTime}`,
+ value: schedule.scheduleId,
+ });
+ });
return result;
};
diff --git a/src/utils/getDate.ts b/src/utils/getDate.ts
index c3a0e41c..c4cdc5fa 100644
--- a/src/utils/getDate.ts
+++ b/src/utils/getDate.ts
@@ -126,3 +126,5 @@ export const getMonthString = (month: number) =>
dayjs()
.month(month - 1)
.format('MMMM');
+
+export const getDateStringKR = (date: string) => dayjs(date).format('YYYY년 M월 D일');
From 34b80b142bba7d9b7dfe4dbd73a6f6d5376c51ed Mon Sep 17 00:00:00 2001
From: CheeseB <2489ckckck@naver.com>
Date: Thu, 28 Mar 2024 12:58:37 +0900
Subject: [PATCH 05/18] =?UTF-8?q?feat:=20=EB=AA=A8=EB=8B=AC=EC=B0=BD=20?=
=?UTF-8?q?=EC=8A=A4=ED=83=80=EC=9D=BC=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ModalContents/ModalContents.module.scss | 30 +++++++++++++++++++
.../calendar/ModalContents/index.tsx | 20 +++++++++++--
src/components/calendar/index.tsx | 10 +++----
3 files changed, 51 insertions(+), 9 deletions(-)
diff --git a/src/components/calendar/ModalContents/ModalContents.module.scss b/src/components/calendar/ModalContents/ModalContents.module.scss
index e7e5a6c2..2626e144 100644
--- a/src/components/calendar/ModalContents/ModalContents.module.scss
+++ b/src/components/calendar/ModalContents/ModalContents.module.scss
@@ -2,4 +2,34 @@
&-container {
@include column-flexbox(start, stretch, 1.6rem);
}
+
+ &-date {
+ @include column-flexbox(start, stretch, 0.8rem);
+
+ &-title {
+ @include text-style(16, $white, bold);
+ }
+
+ &-korean {
+ @include text-style(14, $gray10);
+ }
+ }
+
+ &-reservation {
+ @include column-flexbox(start, stretch, 0.8rem);
+
+ &-title {
+ @include flexbox(start, center, 0.4rem);
+ @include text-style(16, $white, bold);
+ }
+
+ &-count {
+ @include text-style(14, $primary, bold);
+ }
+ }
+
+ &-close {
+ flex-grow: 0;
+ margin: 0 auto;
+ }
}
diff --git a/src/components/calendar/ModalContents/index.tsx b/src/components/calendar/ModalContents/index.tsx
index fa0d8c4c..2fae18f8 100644
--- a/src/components/calendar/ModalContents/index.tsx
+++ b/src/components/calendar/ModalContents/index.tsx
@@ -1,9 +1,10 @@
-import { useState } from 'react';
+import { MouseEventHandler, useState } from 'react';
import classNames from 'classnames/bind';
import { getDateStringKR, getScheduleDropdownOption, getStatusCountByScheduleId } from '@/utils';
+import { BaseButton } from '@/components/commons/buttons';
import Dropdown from '@/components/commons/Dropdown';
import Tab from '@/components/commons/Tab';
import DailyScheduleMockData from '@/constants/mockData/reservedScheduleMockData.json';
@@ -17,9 +18,10 @@ const cx = classNames.bind(styles);
type ModalContentsProps = {
gameId: number;
activeDate: string;
+ onClick: MouseEventHandler;
};
-const ModalContents = ({ gameId, activeDate }: ModalContentsProps) => {
+const ModalContents = ({ gameId, activeDate, onClick }: ModalContentsProps) => {
const DailyMockData: Record = {
'2024-03-27': DailyScheduleMockData['2024-03-27'],
'2024-03-30': DailyScheduleMockData['2024-03-30'],
@@ -40,6 +42,7 @@ const ModalContents = ({ gameId, activeDate }: ModalContentsProps) => {
];
const [selectedTabId, setSelectedTabId] = useState(statusTabOptions[0].id);
+ const totalCount = Object.values(statusCount).reduce((prev, cur) => prev + cur, 0);
console.log(gameId);
@@ -53,7 +56,7 @@ const ModalContents = ({ gameId, activeDate }: ModalContentsProps) => {
/>
예약 날짜
- {getDateStringKR(activeDate)}
+ {getDateStringKR(activeDate)}
{
@@ -63,6 +66,17 @@ const ModalContents = ({ gameId, activeDate }: ModalContentsProps) => {
isSmall
/>
+
+
+ 예약 내역
+ {totalCount}
+
+
+
+
+ 닫기
+
+
);
};
diff --git a/src/components/calendar/index.tsx b/src/components/calendar/index.tsx
index 0bf4a498..379f713c 100644
--- a/src/components/calendar/index.tsx
+++ b/src/components/calendar/index.tsx
@@ -69,10 +69,6 @@ const Calendar = ({ gameId }: CalendarProps) => {
setCurrentMonth(newMonth);
};
- const handleToggleModal = (modalKey: string) => {
- toggleClick(modalKey);
- };
-
const handleScheduleClick = (date: string) => {
setActiveDate(date);
toggleClick('scheduleModal');
@@ -112,9 +108,11 @@ const Calendar = ({ gameId }: CalendarProps) => {