import { useQuery } from '@tanstack/react-query' import { Link, useLocation } from 'react-router' import { getWeatherTodayOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen' import type { HeroTomorrow, HoursSlide, TomorrowEvent } from '@nalssigak/shared/api/client' import { type Load, MEDALS } from '@nalssigak/shared/lib' import { track } from '../lib/analytics' import { PostCardSkel, PostFrame, SlideView } from './Post' import { useRegion } from './regionContext' import { Ic } from './ui' const md = (d: string) => `${Number(d.slice(5, 7))}/${Number(d.slice(8, 10))}` const days = (e: TomorrowEvent) => (e.start_date === e.end_date ? md(e.start_date) : `${md(e.start_date)}~${md(e.end_date)}`) /** 내일 날씨 페이지(/tomorrow/...)의 히어로 아래. 오늘 피드 대신 내일 것만 둬서 오늘 페이지와 본문이 겹치지 않게 한다 */ export function TomorrowFeed({ tomorrow, load }: { tomorrow?: HeroTomorrow | null; load: Load }) { const { region } = useRegion() const { pathname } = useLocation() const [sido] = region.name.split(' ') const place = region.name.split(' ').at(-1)! const w = useQuery(getWeatherTodayOptions({ query: { region: region.code, day: 'tomorrow' } })).data const hours: HoursSlide | null = w?.slots?.length && w.headline ? { kind: 'hours', eyebrow: '내일 하루 · 3시간마다', line: w.headline, hours: w.slots.map((s) => ({ label: s.label, icon: s.icon, temp_c: s.temp_c, tone: s.tone })) } : null const ranked = tomorrow?.ranked ?? [] const events = tomorrow?.events ?? [] return (
내일의 각 · {place} 하루 기준
내일 열리는 행사 · {sido}