1
1
import { useRouter } from 'next/navigation' ;
2
2
import WeatherIcon from '@/features/discovery/ui/weather-icon' ;
3
- import type { Discovery } from '@/entities/discovery' ;
3
+ import type { Resort } from '@/entities/discovery' ;
4
4
import { cn } from '@/shared/lib' ;
5
+ import { getWeatherFromDescription } from '@/shared/lib/getWeatherFromDescription' ;
5
6
import Card from '@/shared/ui/card' ;
6
- import { getTargetDateWeekday } from '../lib/getTargetDateWeekday' ;
7
7
import WeeklyWeather from './weekly-weather' ;
8
8
9
- const DiscoveryCard = ( { id , name, slope , weather , weeklyWeather } : Discovery ) => {
9
+ const DiscoveryCard = ( { resortId , name, openSlopes , currentWeather , weeklyWeather } : Resort ) => {
10
10
const router = useRouter ( ) ;
11
11
12
12
return (
@@ -15,36 +15,32 @@ const DiscoveryCard = ({ id, name, slope, weather, weeklyWeather }: Discovery) =
15
15
'box-border flex cursor-pointer flex-col gap-[15px] pb-4 pt-[34px] md:pb-[26px] md:pt-10' ,
16
16
'transition-all hover:scale-[1.02] hover:border-2 hover:border-main-1/30 hover:pb-[15px] hover:pt-[33px] hover:md:pb-[25px] hover:md:pt-[39px]'
17
17
) }
18
- onClick = { ( ) => router . push ( `/${ id } ` ) }
18
+ onClick = { ( ) => router . push ( `/${ resortId } ` ) }
19
19
>
20
20
< div className = { cn ( 'mx-[30px] flex flex-col items-center gap-[5px] md:mx-[42px]' ) } >
21
21
< div className = { cn ( 'flex w-full items-center justify-between' ) } >
22
22
< h2 className = { cn ( 'title1 md:h2 text-gray-90' ) } > { name } </ h2 >
23
23
< div className = { cn ( 'flex items-center gap-2' ) } >
24
- < WeatherIcon className = { cn ( 'origin-right scale-[1.17]' ) } weather = { weather . weather } />
25
- < p className = { cn ( 'text-[30px] font-semibold leading-tight' ) } > { weather . temperature } °</ p >
24
+ < WeatherIcon
25
+ className = { cn ( 'origin-right scale-[1.17]' ) }
26
+ weather = { getWeatherFromDescription ( currentWeather . description ) }
27
+ />
28
+ < p className = { cn ( 'text-[30px] font-semibold leading-tight' ) } >
29
+ { currentWeather . temperature } °
30
+ </ p >
26
31
</ div >
27
32
</ div >
28
33
< div className = { cn ( 'flex w-full justify-between' ) } >
29
34
< p className = { cn ( 'body1-medium text-gray-60' ) } >
30
- { slope ? `운행중인 슬로프 ${ slope } 개` : '개장일이 곧 공개될 예정이에요' }
35
+ { openSlopes ? `운행중인 슬로프 ${ openSlopes } 개` : '개장일이 곧 공개될 예정이에요' }
31
36
</ p >
32
- < p className = { cn ( 'body1-semibold text-gray-60' ) } > { weather . description } </ p >
37
+ < p className = { cn ( 'body1-semibold text-gray-60' ) } > { currentWeather . description } </ p >
33
38
</ div >
34
39
</ div >
35
40
< hr className = { cn ( 'mx-[30px] border-gray-80 opacity-[0.04]' ) } />
36
- < ul
37
- className = { cn (
38
- 'flex w-full justify-between gap-[2px] overflow-x-scroll px-[30px] scrollbar-hide'
39
- ) }
40
- >
41
+ < ul className = { cn ( 'flex w-full gap-[2px] overflow-x-scroll px-[30px] scrollbar-hide' ) } >
41
42
{ weeklyWeather . map ( ( weather , index ) => (
42
- < WeeklyWeather
43
- key = { index }
44
- { ...weather }
45
- day = { getTargetDateWeekday ( index ) }
46
- isToday = { index === 0 }
47
- />
43
+ < WeeklyWeather key = { index } { ...weather } isToday = { index === 0 } />
48
44
) ) }
49
45
</ ul >
50
46
</ Card >
0 commit comments