feat: 오늘 탭 아이콘 줄에 날씨 게임(/game) 연결, 오늘 코디 빼기, 오늘 타로는 잠시 숨김
- feat/weather-game(구름 합치기) 브랜치를 합쳐 아이콘에서 바로 열림 - 오늘 코디 아이콘·창과 그걸 위해 넣은 GET /v1/card/latest 를 걷어냄 - 오늘 타로는 features.ts HIDDEN 으로 숨김 (아이콘 줄·각 모으는 법에서 빠짐, 안내 문구에서도 타로를 뺌)
This commit is contained in:
1 parent
4cfcbcf7ea
commit
e4834fd24e
15 files changed
+18
-183
No files matched your search
@@ -1,13 +1,9 @@
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import { type ReactNode } from 'react'
|
||||
import { Link } from 'react-router'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { getPostOptions, latestCardOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
|
||||
import { kst } from '@nalssigak/shared/lib'
|
||||
import { track } from '../lib/analytics'
|
||||
import { HIDDEN } from './features'
|
||||
import { useFoliage } from './foliage'
|
||||
import { useTarotBadge } from './fortune'
|
||||
import { PostCard, PostCardSkel } from './Post'
|
||||
import { useRegion } from './regionContext'
|
||||
import { sajuSeenToday } from './SajuPage'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { Ic, Rail } from './ui'
|
||||
@@ -15,34 +11,6 @@ import { Ic, Rail } from './ui'
|
||||
/** 오늘 탭 '내 각' 줄 자리 (아이콘에서 거기로 내려간다) */
|
||||
export const MY_GAK_ID = 'my-gak'
|
||||
|
||||
const OOTD_SEEN = 'nalssigak.b.ootdSeen'
|
||||
|
||||
function readSeen() {
|
||||
try {
|
||||
return Number(localStorage.getItem(OOTD_SEEN)) || null
|
||||
} catch {
|
||||
// 사파리 프라이빗 모드 등에서는 저장소를 못 쓴다 → 매번 새로 보는 것으로
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function markSeen(postId: number) {
|
||||
try {
|
||||
localStorage.setItem(OOTD_SEEN, String(postId))
|
||||
} catch (e) {
|
||||
console.warn('[ootd] 본 코디를 저장하지 못함', e)
|
||||
}
|
||||
}
|
||||
|
||||
function isToday(iso?: string | null) {
|
||||
if (!iso) return false
|
||||
const a = kst(iso)
|
||||
const b = kst(new Date())
|
||||
return a.y === b.y && a.mo === b.mo && a.d === b.d
|
||||
}
|
||||
|
||||
const useLatestOotd = () => useQuery({ ...latestCardOptions({ query: { template: 'ootd' } }), staleTime: 10 * 60_000 })
|
||||
|
||||
type Item = { key: string; label: string; icon: string; badge?: ReactNode; to?: string; onClick?: () => void }
|
||||
|
||||
const Dot = () => <span className="absolute -top-0.5 -right-0.5 size-[11px] rounded-full border-2 border-white bg-[#ff4d4f]" />
|
||||
@@ -51,10 +19,7 @@ const Dot = () => <span className="absolute -top-0.5 -right-0.5 size-[11px] roun
|
||||
export function TodayIcons() {
|
||||
const { open } = useSheet()
|
||||
const tarot = useTarotBadge()
|
||||
const ootd = useLatestOotd().data
|
||||
const [seen, setSeen] = useState(readSeen)
|
||||
const { inSeason } = useFoliage()
|
||||
const newOotd = !!ootd?.post_id && isToday(ootd.published_at) && seen !== ootd.post_id
|
||||
|
||||
const items: Item[] = [
|
||||
{
|
||||
@@ -69,24 +34,12 @@ export function TodayIcons() {
|
||||
onClick: () => open({ type: 'tarot' }),
|
||||
},
|
||||
{ key: 'saju', label: '날씨 사주', icon: 'yin_yang', badge: sajuSeenToday() ? null : <Dot />, to: '/saju' },
|
||||
{
|
||||
key: 'ootd',
|
||||
label: '오늘 코디',
|
||||
icon: 'tshirt',
|
||||
badge: newOotd ? <Dot /> : null,
|
||||
onClick: () => {
|
||||
if (ootd?.post_id) {
|
||||
markSeen(ootd.post_id)
|
||||
setSeen(ootd.post_id)
|
||||
}
|
||||
open({ type: 'ootd' })
|
||||
},
|
||||
},
|
||||
{ key: 'game', label: '날씨 게임', icon: 'game', to: '/game' },
|
||||
...(inSeason ? [{ key: 'foliage', label: '단풍 지도', icon: 'maple', to: '/foliage' }] : []),
|
||||
{ key: 'shorts', label: '쇼츠', icon: 'clapper', to: '/shorts' },
|
||||
{ key: 'myGak', label: '내 각', icon: 'rabbit', onClick: () => document.getElementById(MY_GAK_ID)?.scrollIntoView({ behavior: 'smooth', block: 'start' }) },
|
||||
{ key: 'talk', label: '동네 이야기', icon: 'speech', to: '/talk' },
|
||||
]
|
||||
].filter((it) => !HIDDEN.has(it.key))
|
||||
|
||||
const tile = (it: Item) => (
|
||||
<>
|
||||
@@ -124,15 +77,3 @@ export function TodayIcons() {
|
||||
)
|
||||
}
|
||||
|
||||
/** 오늘 코디 창: 오늘 피드에 올린 코디 카드 (오늘 것이 없으면 안내) */
|
||||
export function OotdSheet() {
|
||||
const { region } = useRegion()
|
||||
const latest = useLatestOotd()
|
||||
const postId = latest.data?.post_id
|
||||
const today = isToday(latest.data?.published_at)
|
||||
const post = useQuery({ ...getPostOptions({ path: { post_id: postId ?? 0 }, query: { region: region.code } }), enabled: !!postId && today })
|
||||
|
||||
if (latest.isPending || (postId && today && post.isPending)) return <PostCardSkel />
|
||||
if (!postId || !today || !post.data?.post) return <p className="m-0 px-4 py-10 text-center text-[14px] font-semibold text-(--ink2)">아직 오늘 코디가 없어요</p>
|
||||
return <PostCard post={post.data.post} />
|
||||
}
|
||||
Reference in new issue
Block a user