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:
1 parent
e134295ce5
commit
f8b47f064a
147 files changed
+12350
No files matched your search
@@ -0,0 +1,95 @@
|
||||
import { useState } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { listArticlesOptions, listIndicesOptions } from '../api/client/@tanstack/react-query.gen'
|
||||
import { ArticleCategory, IndexCategory } from '../api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { MEDALS } from './lib'
|
||||
import { useRegion } from './regionContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { Chips, Ic, Sec, StateBox } from './ui'
|
||||
|
||||
type Cat = 'all' | 'out' | 'food' | 'home' | 'life' | 'core'
|
||||
|
||||
const CATS = [
|
||||
['all', '전체'],
|
||||
['out', '밖에서 놀기'],
|
||||
['food', '먹고 마시기'],
|
||||
['home', '집안일'],
|
||||
['life', '생활 고민'],
|
||||
['core', '가을 각'],
|
||||
] as const
|
||||
|
||||
const CAT_PARAM: Partial<Record<Cat, IndexCategory>> = { out: IndexCategory.OUTSIDE, food: IndexCategory.FOOD, home: IndexCategory.HOME, life: IndexCategory.LIFE }
|
||||
|
||||
export function GakPage() {
|
||||
const { region } = useRegion()
|
||||
const { open } = useSheet()
|
||||
const [cat, setCat] = useState<Cat>('all')
|
||||
const q = useQuery(listIndicesOptions({ query: { region: region.code, category: CAT_PARAM[cat], core: cat === 'core' ? true : undefined } }))
|
||||
const top = q.data?.top3 ?? []
|
||||
const items = q.data?.items ?? []
|
||||
const day = q.data?.day?.split('-').map(Number)
|
||||
const howto = useQuery(listArticlesOptions({ query: { category: ArticleCategory.GAK } })).data?.articles?.find((a) => a.code === 'howgak')
|
||||
|
||||
return (
|
||||
<section aria-label="각">
|
||||
<Sec title="오늘 1~3위" sub={`${day ? `${day[1]}월 ${day[2]}일 기준 · ` : ''}${region.name} · 칸 아래 막대는 오늘·내일·모레 점수`} />
|
||||
{top.length === 3 && (
|
||||
<div className="grid grid-cols-[1fr_1.15fr_1fr] items-end gap-1.5 px-3 pt-3">
|
||||
{[1, 0, 2].map((k) => {
|
||||
const g = top[k]
|
||||
return (
|
||||
<button
|
||||
key={g.index_id}
|
||||
type="button"
|
||||
onClick={() => open({ type: 'gak', indexId: g.index_id })}
|
||||
className={cx('flex cursor-pointer flex-col items-center rounded-3xl px-1.5 text-center shadow-[inset_0_-6px_0_var(--shade)]', k === 0 ? 'bg-[linear-gradient(180deg,#fff1c4,#fff)] py-4' : 'bg-white py-3')}
|
||||
>
|
||||
<span className="relative">
|
||||
<Ic name={g.icon} className={cx('drop-shadow-[0_10px_12px_rgb(40_48_74/0.15)]', k === 0 ? 'w-20' : 'w-[62px]')} />
|
||||
<Ic name={MEDALS[k]} className="absolute -top-1.5 -left-3 w-7" />
|
||||
</span>
|
||||
<b className="mt-1.5 font-jua text-base font-normal">
|
||||
{k + 1}위 {g.name}
|
||||
</b>
|
||||
<em className="font-bagel text-[30px] leading-[1.05] text-(--orange) not-italic">{g.score}</em>
|
||||
<small className="text-[11.5px] font-semibold text-(--ink2)">{g.summary}</small>
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
<Chips items={CATS} value={cat} onChange={setCat} label="분야" />
|
||||
<StateBox loading={q.isPending} error={q.error} onRetry={() => q.refetch()} empty={q.isSuccess && !items.length ? '이 분야는 오늘 계산된 각이 없어요.' : undefined} />
|
||||
<div className="grid grid-cols-3 gap-2 p-3">
|
||||
{items.map((g) => {
|
||||
const trend = g.trend ?? []
|
||||
const mx = Math.max(1, ...trend.map((t) => t.score))
|
||||
return (
|
||||
<button key={g.index_id} type="button" onClick={() => open({ type: 'gak', indexId: g.index_id })} aria-label={`${g.rank}위 ${g.name} ${g.score}점`} className="relative flex cursor-pointer flex-col items-center rounded-[22px] bg-white px-1.5 pt-3 pb-2.5 shadow-[inset_0_-5px_0_var(--shade)]">
|
||||
<span className="absolute top-[7px] left-[9px] font-jua text-[13px] text-(--ink3)">{g.rank}</span>
|
||||
{g.is_core && <span className="absolute top-2 right-2 text-[10.5px] font-extrabold text-[#1f9d62]">가을</span>}
|
||||
<Ic name={g.icon} className="w-[50px]" />
|
||||
<b className="mt-1 font-jua text-[15px] font-normal">{g.name}</b>
|
||||
<em className={cx('font-bagel text-[22px] leading-[1.1] not-italic', g.score < 50 ? 'text-(--ink3)' : 'text-(--orange)')}>{g.score}</em>
|
||||
<span className="mt-1 flex h-[18px] items-end gap-[3px]" aria-hidden="true">
|
||||
{trend.map((t, j) => (
|
||||
<i key={t.day} className={cx('w-[9px] rounded-[3px]', j ? 'bg-[#dbe4ef]' : 'bg-(--orange)')} style={{ height: Math.max(4, (t.score / mx) * 18) }} />
|
||||
))}
|
||||
</span>
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
{howto && (
|
||||
<button type="button" onClick={() => open({ type: 'article', articleId: howto.article_id })} className="mx-3 mt-1.5 flex w-[calc(100%-24px)] cursor-pointer items-center gap-3 rounded-[22px] bg-[#ece7ff] p-3.5 text-left">
|
||||
<Ic name="bulb" className="w-11" />
|
||||
<span>
|
||||
<b className="block font-jua text-[17px] font-normal">각 점수는 어떻게 매길까?</b>
|
||||
<small className="text-[12.5px] font-semibold text-(--ink2)">기온·비·바람·습도·공기·시간대 6가지로 계산해요</small>
|
||||
</span>
|
||||
</button>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user