diff --git a/src/entities/discovery/model/index.ts b/src/entities/discovery/model/index.ts index 0c1c15f..2466b9e 100644 --- a/src/entities/discovery/model/index.ts +++ b/src/entities/discovery/model/index.ts @@ -1,2 +1,2 @@ export { DiscoveryData } from './constants'; -export type { Weather, DuplicatedWeeklyWeather, Discovery, Vote, WeeklyWeather, WeatherResponse, Resort } from './model'; +export type { Weather, Discovery, Vote, WeeklyWeather, WeatherResponse, Resort, Url } from './model'; diff --git a/src/entities/discovery/model/model.d.ts b/src/entities/discovery/model/model.d.ts index 05e4c8d..44536f6 100644 --- a/src/entities/discovery/model/model.d.ts +++ b/src/entities/discovery/model/model.d.ts @@ -8,15 +8,17 @@ export type DuplicatedWeeklyWeather = { }; }; +export type Url = { + bus: string; + homepage: string; +}; + export type Discovery = { id: number; name: string; map: string; slope: number | null; - url: { - bus: string; - homepage: string; - }; + url: Url; weather: { weather: Weather; temperature: number; diff --git a/src/widgets/discovery/lib/getWeatherFromDescription.ts b/src/shared/lib/getWeatherFromDescription.ts similarity index 92% rename from src/widgets/discovery/lib/getWeatherFromDescription.ts rename to src/shared/lib/getWeatherFromDescription.ts index a9bb7a4..5006f66 100644 --- a/src/widgets/discovery/lib/getWeatherFromDescription.ts +++ b/src/shared/lib/getWeatherFromDescription.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line boundaries/element-types import type { Weather } from "@/entities/discovery"; const weatherDescription = { diff --git a/src/views/discovery-detail/ui/discovery-detail-page.tsx b/src/views/discovery-detail/ui/discovery-detail-page.tsx index 50d9cc2..122a92b 100644 --- a/src/views/discovery-detail/ui/discovery-detail-page.tsx +++ b/src/views/discovery-detail/ui/discovery-detail-page.tsx @@ -26,6 +26,8 @@ const DiscoveryDetailPage = ({ params }: { params: { resortId: string } }) => { const discovery = DiscoveryData.find( (discovery) => discovery.id === +params?.resortId ) as Discovery; + const { data: resortsData } = useQuery(discoveryApi.resortQueries.list()); + const resort = resortsData?.find((resort) => resort.resortId === +params?.resortId); const { data: voteData } = useQuery(discoveryApi.discoveryQueries.vote(+params?.resortId)); const data = RESORT_DOMAIN[discovery?.map as keyof typeof RESORT_DOMAIN]; const [selectedTab, setSelectedTab] = useState('webcam'); @@ -72,12 +74,12 @@ const DiscoveryDetailPage = ({ params }: { params: { resortId: string } }) => { } }, [isPositive, mutateAsync, params?.resortId]); - if (!discovery) return; + if (!discovery || !resort) return; return (
-
- +
+
    {DiscoveryContentTabList.map((tab) => (
  • { +const DiscoverySummary = ({ + resortId, + name, + openSlopes, + currentWeather, + bus, + homepage, +}: Resort & Url) => { return (
    -
    +

    {name}

    -
    - -

    {weather.temperature}°

    +
    + +

    + {currentWeather.temperature}° +

    -
    +

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

    -

    {weather.description}

    +

    {currentWeather.description}

    @@ -36,7 +46,7 @@ const DiscoverySummary = ({ id, name, slope, url, weather }: Discovery) => { return ( } /> } @@ -44,11 +54,7 @@ const DiscoverySummary = ({ id, name, slope, url, weather }: Discovery) => { ); } else { return ( - + : } diff --git a/src/widgets/discovery/ui/discovery-card.tsx b/src/widgets/discovery/ui/discovery-card.tsx index c3da83a..070bab3 100644 --- a/src/widgets/discovery/ui/discovery-card.tsx +++ b/src/widgets/discovery/ui/discovery-card.tsx @@ -2,8 +2,8 @@ import { useRouter } from 'next/navigation'; import WeatherIcon from '@/features/discovery/ui/weather-icon'; import type { Resort } from '@/entities/discovery'; import { cn } from '@/shared/lib'; +import { getWeatherFromDescription } from '@/shared/lib/getWeatherFromDescription'; import Card from '@/shared/ui/card'; -import { getWeatherFromDescription } from '../lib/getWeatherFromDescription'; import WeeklyWeather from './weekly-weather'; const DiscoveryCard = ({ resortId, name, openSlopes, currentWeather, weeklyWeather }: Resort) => { diff --git a/src/widgets/discovery/ui/weekly-weather.tsx b/src/widgets/discovery/ui/weekly-weather.tsx index 4baf494..8deca5c 100644 --- a/src/widgets/discovery/ui/weekly-weather.tsx +++ b/src/widgets/discovery/ui/weekly-weather.tsx @@ -1,7 +1,7 @@ import WeatherIcon from '@/features/discovery/ui/weather-icon'; import type { SummarizedWeeklyWeather as WeeklyWeatherType } from '@/entities/discovery/model/model'; import { cn } from '@/shared/lib'; -import { getWeatherFromDescription } from '../lib/getWeatherFromDescription'; +import { getWeatherFromDescription } from '@/shared/lib/getWeatherFromDescription'; interface WeeklyWeatherProps extends WeeklyWeatherType { isToday: boolean;