import { useState } from 'react' import { useQuery } from '@tanstack/react-query' import { getSeasonWeekOptions, listArticlesOptions } from '../api/client/@tanstack/react-query.gen' import { ArticleCategory } from '../api/client/types.gen' import { cx } from '../lib/utils' import { ARTICLE_CAT, cardBg, dateRange, fall, loadOf, shortDay } from './lib' import { useSheet } from './sheetContext' import { Chips, Ic, Skel, StateBox, Thumb } from './ui' const CATS = [ ['all', '전체'], ['season', '계절 소식'], ['tip', '날씨 상식'], ['gak', '각 원리'], ] as const const CAT_PARAM = { season: ArticleCategory.SEASON, tip: ArticleCategory.TIP, gak: ArticleCategory.GAK } as const const HEAD_BOX = 'relative mx-3 mt-3 flex min-h-[250px] w-[calc(100%-24px)] flex-col overflow-hidden rounded-[28px] p-5 text-left' const ROW = 'grid w-full grid-cols-[1fr_84px] items-center gap-3 border-b-[1.5px] border-(--line) px-4 py-3.5 text-left' const ROW_SKELS = [0, 1, 2, 3] /** 특집 상자와 같은 틀: 머리말 · 제목 두 줄 · 시 한 줄 · 절기 막대 (최소 높이 250px 안) */ function HeadSkel() { return (
) } function RowSkel() { return ( ) } export function SeasonPage() { const { open } = useSheet() const [cat, setCat] = useState<(typeof CATS)[number][0]>('all') const week = useQuery(getSeasonWeekOptions()) const arts = useQuery(listArticlesOptions(cat === 'all' ? undefined : { query: { category: CAT_PARAM[cat] } })) const w = week.data const list = arts.data?.articles ?? [] const progress = Math.round((w?.progress ?? 0) * 100) const weekLoad = loadOf(week) const artLoad = loadOf(arts) return (