Skip to content

Commit

Permalink
feat: update open resort date (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
Najeong-Kim authored Nov 18, 2024
1 parent b6f3d89 commit 0cebb7e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/entities/resort/model/model.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export type Resort = {
resortId: number,
name: string,
status: string,
openingDate: string,
closingDate: string,
openSlopes: number,
currentWeather: {
temperature: number,
Expand Down
6 changes: 5 additions & 1 deletion src/widgets/resort-detail/ui/resort-summary.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -12,6 +14,8 @@ import ResortSummaryAction from './resort-summary-action';
const ResortSummary = ({
resortId,
name,
status,
openingDate,
openSlopes,
currentWeather,
bus,
Expand All @@ -35,7 +39,7 @@ const ResortSummary = ({
</div>
<div className={cn('flex w-full items-center justify-between')}>
<p className={cn('body1-medium text-gray-60')}>
{openSlopes ? `운행중인 슬로프 ${openSlopes}개` : '개장일이 곧 공개될 예정이에요'}
{getResortStatusText(status, openingDate, openSlopes)}
</p>
<p className={cn('body1-semibold text-gray-60')}>{currentWeather.description}</p>
</div>
Expand Down
15 changes: 15 additions & 0 deletions src/widgets/resort/lib/getResortStatusText.ts
Original file line number Diff line number Diff line change
@@ -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 '개장일이 곧 공개될 예정이에요'
}
}
13 changes: 11 additions & 2 deletions src/widgets/resort/ui/resort-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -32,7 +41,7 @@ const ResortCard = ({ resortId, name, openSlopes, currentWeather, weeklyWeather
</div>
<div className={cn('flex w-full justify-between')}>
<p className={cn('body1-medium text-gray-60')}>
{openSlopes ? `운행중인 슬로프 ${openSlopes}개` : '개장일이 곧 공개될 예정이에요'}
{getResortStatusText(status, openingDate, openSlopes)}
</p>
<p className={cn('body1-semibold text-gray-60')}>{currentWeather.description}</p>
</div>
Expand Down

0 comments on commit 0cebb7e

Please sign in to comment.