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 (
{ranked.length > 0 ? (

내일의 각 · {place} 하루 기준

    {ranked.map((g, i) => (
  1. {i < 3 ? : {i + 1}} {g.name} {g.summary && {g.summary}} {g.score}
  2. ))}
) : ( load === 'loading' && )} {hours && (
)} {events.length > 0 && ( 행사 더 보기 ›}>

내일 열리는 행사 · {sido}

    {events.map((e) => (
  • {e.name} {e.place} · {days(e)}
  • ))}
)} track('tomorrow_to_today', { region_name: region.name })} className="mx-3 mt-4 mb-2 block rounded-full bg-white py-3 text-center font-jua text-[16px] shadow-[inset_0_-4px_0_var(--shade)]" > 오늘 {place} 소식 보기 ›
) }