diff --git a/src/entities/resort/model/model.d.ts b/src/entities/resort/model/model.d.ts index dc9446e..40d22b5 100644 --- a/src/entities/resort/model/model.d.ts +++ b/src/entities/resort/model/model.d.ts @@ -53,6 +53,8 @@ export type Resort = { resortId: number, name: string, status: string, + openingDate: string, + closingDate: string, openSlopes: number, currentWeather: { temperature: number, diff --git a/src/widgets/resort-detail/ui/resort-summary.tsx b/src/widgets/resort-detail/ui/resort-summary.tsx index 474b283..f914978 100644 --- a/src/widgets/resort-detail/ui/resort-summary.tsx +++ b/src/widgets/resort-detail/ui/resort-summary.tsx @@ -1,4 +1,6 @@ import Link from 'next/link'; +// eslint-disable-next-line boundaries/element-types +import { getResortStatusText } from '@/widgets/resort/lib/getResortStatusText'; import WeatherIcon from '@/features/resort/ui/weather-icon'; import VoteDialog from '@/features/resort-detail/ui/vote-dialog'; import type { Resort, Url } from '@/entities/resort'; @@ -12,6 +14,8 @@ import ResortSummaryAction from './resort-summary-action'; const ResortSummary = ({ resortId, name, + status, + openingDate, openSlopes, currentWeather, bus, @@ -35,7 +39,7 @@ const ResortSummary = ({

- {openSlopes ? `운행중인 슬로프 ${openSlopes}개` : '개장일이 곧 공개될 예정이에요'} + {getResortStatusText(status, openingDate, openSlopes)}

{currentWeather.description}

diff --git a/src/widgets/resort/lib/getResortStatusText.ts b/src/widgets/resort/lib/getResortStatusText.ts new file mode 100644 index 0000000..fce2952 --- /dev/null +++ b/src/widgets/resort/lib/getResortStatusText.ts @@ -0,0 +1,15 @@ +export const getResortStatusText = (status: string, openingDate: string, openSlopes: number) => { + if (status === '운영중') { + return `운행중인 슬로프 ${openSlopes}개`; + } else if (status === '운영종료') { + return '다음 시즌에 또 만나요' + } + + if (openingDate) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const [_, month, day] = openingDate.split('-'); + return `${+month}월 ${+day}일에 개장 예정이에요` + } else { + return '개장일이 곧 공개될 예정이에요' + } +} \ No newline at end of file diff --git a/src/widgets/resort/ui/resort-card.tsx b/src/widgets/resort/ui/resort-card.tsx index 8a480fc..acb2c7b 100644 --- a/src/widgets/resort/ui/resort-card.tsx +++ b/src/widgets/resort/ui/resort-card.tsx @@ -4,9 +4,18 @@ import type { Resort } from '@/entities/resort'; import { cn } from '@/shared/lib'; import { getWeatherFromDescription } from '@/shared/lib/getWeatherFromDescription'; import Card from '@/shared/ui/card'; +import { getResortStatusText } from '../lib/getResortStatusText'; import WeeklyWeather from './weekly-weather'; -const ResortCard = ({ resortId, name, openSlopes, currentWeather, weeklyWeather }: Resort) => { +const ResortCard = ({ + resortId, + name, + status, + openingDate, + openSlopes, + currentWeather, + weeklyWeather, +}: Resort) => { const router = useRouter(); return ( @@ -32,7 +41,7 @@ const ResortCard = ({ resortId, name, openSlopes, currentWeather, weeklyWeather

- {openSlopes ? `운행중인 슬로프 ${openSlopes}개` : '개장일이 곧 공개될 예정이에요'} + {getResortStatusText(status, openingDate, openSlopes)}

{currentWeather.description}