import { useQuery } from '@tanstack/react-query' import type { ReactNode } from 'react' import { getSkyOptions, getSkyRankingOptions } from '../api/client/@tanstack/react-query.gen' import type { BestTime, SkyPlanData } from '../api/client/types.gen' import { cx } from '../lib/utils' import { clockShort, loadOf } from './lib' import { useRegion } from './regionContext' import { MapLink, Sec, Skel, StateBox } from './ui' function LiSkel({ ghost = false }: { ghost?: boolean }) { return ( ) } // 다른 탭 히어로보다 짧게. 배경은 하늘 상황별 색(b-sit-1~5), 아래에 동네 실루엣 const HERO = 'relative mx-3 mt-1 min-h-[230px] overflow-hidden rounded-[32px] px-5 pt-5 pb-14 text-white' const THREE = [0, 1, 2] const RANK_SKELS = Array.from({ length: 8 }, (_, i) => i) /** 히어로엔 해 지는 시각과 하늘 상황 한 줄만. 결론·이유는 아래 카드로 */ function HeroBody({ plan, sunset }: { plan?: SkyPlanData; sunset?: string }) { const v = (node: ReactNode, w: string) => (plan ? node : ) return (

{v(sunset && clockShort(sunset), 'w-[150px]')}

{v(plan?.situation_label ?? plan?.headline, 'w-[190px]')}

) } /** 결론과 이유, 예보 모델이 얼마나 같은 예보를 냈는지, 점수(작게) */ function Verdict({ plan }: { plan?: SkyPlanData }) { const v = (node: ReactNode, w: string) => (plan ? node : ) const agree = plan?.models_total ? `예보 모델 ${plan.models_total}개 중 ${plan.models_agree}개가 같은 예보` : '' return (

{v(plan?.headline, 'w-20')} {v(plan?.reason, 'w-[220px]')}

{v(plan && [agree, `노을 점수 ${plan.score}`].filter(Boolean).join(' · '), 'w-48')}
) } /** 골든아워 → 해 짐 → 블루아워 */ function Timeline({ rows }: { rows?: BestTime[] }) { return (
) } function SpotsSkel() { return ( <> ) } function RankSkel() { return ( ) } function Li({ no, title, sub, right, mine = false, place }: { no: number; title: string; sub?: string | null; right: string; mine?: boolean; place?: string }) { return (
  • {no} {place ? {title} : title} {mine && 내 지역} {sub || '\u00a0'} {right}
  • ) } export function SkyPage() { const { region } = useRegion() const sky = useQuery(getSkyOptions({ query: { region: region.code } })) const ranking = useQuery(getSkyRankingOptions()) const load = loadOf(sky) const rankLoad = loadOf(ranking) const plan = sky.data?.plan ?? undefined const spots = (sky.data?.spots ?? []).slice(0, 3) const items = (ranking.data?.items ?? []).slice(0, 8) const target = sky.data?.days?.find((d) => d.day === plan?.day) const sunset = plan?.timeline?.find((t) => t.kind === 'sun')?.at return (
    {/* 히어로 상자는 불러오는 중·실패·빈 값 모두 같은 크기 */}