feat: 시안 B 화면을 기본 화면으로, Hey API로 백엔드 연결

- 예전 화면(/, /a)과 목업 데이터를 지우고 시안 B 를 / 로
- @hey-api/openapi-ts 로 타입·TanStack Query 함수 생성, 토큰·401 갱신 처리
- 공유는 기본 공유창, 없으면 링크 복사

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
minaChoiandClaude Opus 5.5 committed 2026-10-02 11:32:22 +09:00
1 parent e134295ce5
commit f8b47f064a
147 files changed
+12350

No files matched your search

+84
View File
@@ -0,0 +1,84 @@
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, fall, shortDay } from './lib'
import { useSheet } from './sheetContext'
import { Chips, Ic, StateBox } from './ui'
const CATS = [
['all', '전체'],
['season', '계절 소식'],
['tip', '날씨 상식'],
['gak', '각 원리'],
] as const
const CAT_PARAM = { season: ArticleCategory.SEASON, tip: ArticleCategory.TIP, gak: ArticleCategory.GAK } as const
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)
return (
<section aria-label="계절·상식">
{w?.headline ? (
<button type="button" onClick={() => open({ type: 'seasonWeek' })} className="relative mx-3 mt-3 flex min-h-[250px] w-[calc(100%-24px)] cursor-pointer flex-col overflow-hidden rounded-[28px] bg-[linear-gradient(180deg,#ffd2bb,#fff2ea)] p-5 text-left">
<p className="m-0 text-[13px] font-extrabold opacity-75">이번 주 특집 · {w.week}번째 주</p>
<p className="mt-1 max-w-[62%] font-jua text-[29px] leading-tight">{w.headline}</p>
<span className="b-fall pointer-events-none absolute top-[18%] right-3.5 w-[38%]" style={fall('.1s')}>
<Ic name="maple" className="w-full drop-shadow-[0_16px_18px_rgb(40_48_74/0.18)]" />
</span>
{(w.poem_lines ?? []).length > 0 && (
<p className="mt-auto max-w-[72%] pt-3 font-batang text-[22px] leading-[1.7]">
{w.poem_lines?.map((l, i) => (
<span key={l}>
{i > 0 && <br />}
{l}
</span>
))}
</p>
)}
{w.term_now && w.term_next && (
<div className={cx('max-w-[70%]', (w.poem_lines ?? []).length ? 'mt-2.5' : 'mt-auto')}>
<div className="flex justify-between text-xs font-extrabold text-(--ink2)">
<span>
{w.term_now.name} {shortDay(w.term_now.day)}
</span>
<span>
{w.term_next.name} {shortDay(w.term_next.day)}
</span>
</div>
<div className="mt-1 h-[7px] overflow-hidden rounded-full bg-[rgb(40_48_74/0.1)]" role="img" aria-label={`다음 절기까지 ${progress}% 지났어요`}>
<s className="block h-full bg-(--orange)" style={{ width: `${progress}%` }} />
</div>
</div>
)}
</button>
) : (
<StateBox loading={week.isPending} error={week.error} onRetry={() => week.refetch()} empty="이번 주 특집이 아직 없어요." />
)}
<Chips items={CATS} value={cat} onChange={setCat} label="분류" />
<div className="mt-1.5">
<StateBox loading={arts.isPending} error={arts.error} onRetry={() => arts.refetch()} empty={arts.isSuccess && !list.length ? '읽을거리가 아직 없어요.' : undefined} />
{list.map((a) => (
<button key={a.article_id} type="button" onClick={() => open({ type: 'article', articleId: a.article_id })} className="grid w-full cursor-pointer grid-cols-[1fr_84px] items-center gap-3 border-b-[1.5px] border-(--line) px-4 py-3.5 text-left">
<span>
<span className={cx('text-xs font-extrabold', ARTICLE_CAT[a.category]?.[1])}>{ARTICLE_CAT[a.category]?.[0]}</span>
<b className="mt-0.5 block font-jua text-[17.5px] leading-snug font-normal">{a.title}</b>
<small className="mt-1 block text-xs font-semibold text-(--ink3)">{a.read_minutes}분 읽기</small>
</span>
<span className={cx('grid h-[84px] place-items-center rounded-[18px]', `b-bg-${cardBg(a.icon, a.article_id)}`)}>
<Ic name={a.icon} className="w-[54px]" />
</span>
</button>
))}
</div>
</section>
)
}