Skip to content

Commit

Permalink
fix: ์ˆ˜์ • (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansoojeongsj committed Jan 24, 2025
1 parent ccee4f9 commit 96c316d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 140 deletions.
12 changes: 8 additions & 4 deletions src/pages/class/components/ClassInfoWrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Flex from '@/components/Flex';
import Head from '@/components/Head';
import Tag from '@/components/Tag';
import Text from '@/components/Text';
import { calculateDday } from '@/utils/dateCalculate';
import { ROUTES_CONFIG } from '@/routes/routesConfig';
import { genreMapping } from '@/constants/index';
import { IcThunderMain0424 } from '@/assets/svg';
Expand All @@ -27,12 +26,17 @@ const ClassInfoWrapper = ({ lessonData }: { lessonData: LessonDetailApiResponse
price,
maxReservationCount,
reservationCount,
status,
remainingDays,
} = lessonData;
const translatedGenre = genreMapping[genre] || genre;

// ๊ฐ ํšŒ์ฐจ์— ๋Œ€ํ•ด D-Day ๊ณ„์‚ฐ
const dDay = status === 'EXPIRED' || status === 'OVER_BOOKED' ? '๋งˆ๊ฐ' : calculateDday(lessonRounds[0].startDateTime);
// D-DAY remaingDays๋กœ ํ†ต์ผ
const dDay =
remainingDays > 0
? `D-${remainingDays}`
: remainingDays === 0
? 'D-DAY'
: '๋งˆ๊ฐ';

// ๋‚จ์€ ์˜ˆ์•ฝ ๊ฐ€๋Šฅ ์ธ์› ๊ณ„์‚ฐ
const remainingSeats = maxReservationCount - reservationCount;
Expand Down

This file was deleted.

63 changes: 0 additions & 63 deletions src/pages/reservation/components/ReservationCompletion/index.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions src/routes/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import MyPageReservation from '@/pages/mypage/mypageReservation';
import MyPageReservationDetail from '@/pages/mypage/mypageReservationDetail';
import Onboarding from '@/pages/onboarding';
import Reservation from '@/pages/reservation';
import ReservationCompletion from '@/pages/reservation/components/ReservationCompletion';
import { CheckoutPage } from '@/pages/reservation/components/TossPayments/CheckOut/CheckOut';
import { FailPage } from '@/pages/reservation/components/TossPayments/Fail/Fail';
import { SuccessPage } from '@/pages/reservation/components/TossPayments/Success/Success';
Expand Down Expand Up @@ -54,10 +53,6 @@ export const router = createBrowserRouter([
path: ROUTES_CONFIG.reservation.path(':id'),
element: <Reservation />,
},
{
path: ROUTES_CONFIG.reservationCompletion.path,
element: <ReservationCompletion />,
},
{
path: ROUTES_CONFIG.mypageReservation.path,
element: <MyPageReservation />,
Expand Down
4 changes: 0 additions & 4 deletions src/routes/routesConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ export const ROUTES_CONFIG = {
title: 'Reservation',
path: (id: string) => `/reservation/${id}`,
},
reservationCompletion: {
title: 'reservationCompletion',
path: '/reservation/completion',
},
payments: {
title: 'payments',
path: '/reservation/payments',
Expand Down
33 changes: 0 additions & 33 deletions src/utils/dateCalculate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,3 @@ export const formatSimpleDate = (dateString: string) => {
const days = ['์ผ', '์›”', 'ํ™”', '์ˆ˜', '๋ชฉ', '๊ธˆ', 'ํ† '];
return `${date.getFullYear()}๋…„ ${date.getMonth() + 1}์›” ${date.getDate()}์ผ (${days[date.getDay()]})`;
};

// D-day ๊ณ„์‚ฐ
export const calculateDday = (startDateTime: string): string => {
const now = new Date();
const startDate = new Date(startDateTime);

// ํ˜„์žฌ ๋‚ ์งœ์™€ ์‹œ์ž‘ ๋‚ ์งœ์˜ ๋‚ ์งœ ๋ถ€๋ถ„๋งŒ ๋น„๊ต
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
const startOfDay = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());

// 1. ์‹œ์ž‘ ๋‚ ์งœ๊ฐ€ ์˜ค๋Š˜์ธ ๊ฒฝ์šฐ
if (today.getTime() === startOfDay.getTime()) {
const differenceInMs = startDate.getTime() - now.getTime();
if (differenceInMs > 0) {
return 'D-Day';
} else {
return '๋งˆ๊ฐ';
}
}

// 2. ์‹œ์ž‘ ๋‚ ์งœ๊ฐ€ ์˜ค๋Š˜์ด ์•„๋‹Œ ๊ฒฝ์šฐ (D-1, D-2 ๊ณ„์‚ฐ)
const differenceInMs = startOfDay.getTime() - today.getTime();
const oneDayInMs = 1000 * 60 * 60 * 24; // ํ•˜๋ฃจ๋ฅผ ๋ฐ€๋ฆฌ์ดˆ๋กœ ๊ณ„์‚ฐ

const remainingDays = Math.floor(differenceInMs / oneDayInMs); // ๋‚ด๋ฆผ ์ฒ˜๋ฆฌ๋กœ ์ •ํ™•ํ•œ ๋‚จ์€ ์ผ ๊ณ„์‚ฐ

if (remainingDays > 0) {
return `D-${remainingDays}`;
}

// 3. ์ด๋ฏธ ์ง€๋‚œ ๊ฒฝ์šฐ
return '๋งˆ๊ฐ';
};

0 comments on commit 96c316d

Please sign in to comment.