import { useState, type ReactNode } from 'react' import { Link } from 'react-router' import { track } from '../lib/analytics' import { HIDDEN } from './features' import { firstSnowInSeason } from './firstSnow' import { useFoliage } from './foliage' import { useTarotBadge } from './fortune' import { sajuSeenToday } from './SajuPage' import { useSunrise } from './sunrise' import { useSheet } from './sheetContext' import { Ic, Rail } from './ui' import { showTypeDot } from './weatherType' /** 오늘 탭 '내 각' 줄 자리 (아이콘에서 거기로 내려간다) */ export const MY_GAK_ID = 'my-gak' type Item = { key: string; label: string; icon: string; badge?: ReactNode; to?: string; onClick?: () => void } const Dot = () => /** 오늘 탭 히어로 아래 아이콘 줄: 누르면 창이 뜨거나 그 페이지로 간다. 오늘 아직 안 본 것엔 빨간 점 */ export function TodayIcons() { const { open } = useSheet() const tarot = useTarotBadge() const { inSeason } = useFoliage() const [snowSeason] = useState(() => firstSnowInSeason()) const { inSeason: sunriseSeason } = useSunrise() const items: Item[] = [ { key: 'tarot', label: '오늘 타로', icon: 'crystal_ball', badge: tarot.drawn ? ( {tarot.streak}일째 ) : ( ), onClick: () => open({ type: 'tarot' }), }, { key: 'saju', label: '날씨 사주', icon: 'yin_yang', badge: sajuSeenToday() ? null : , to: '/saju' }, // 날씨 유형 테스트: 이 기기에서 아직 안 해 봤으면 빨간 점 { key: 'type', label: '날씨 유형', icon: 'rainbow', badge: showTypeDot() ? : null, to: '/type' }, { key: 'game', label: '날씨 게임', icon: 'game', to: '/game' }, // 계절 지도 칸: 단풍 지도 → 첫눈 지도 → 해돋이 지도 순으로 한 번에 하나만 나온다 ...(inSeason ? [{ key: 'foliage', label: '단풍 지도', icon: 'maple', to: '/foliage' }] : []), ...(snowSeason ? [{ key: 'firstSnow', label: '첫눈 지도', icon: 'snow', to: '/first-snow' }] : []), ...(sunriseSeason ? [{ key: 'sunrise', label: '해돋이 지도', icon: 'sunset', to: '/sunrise' }] : []), { 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) => ( <> {it.badge} {it.label} ) const cls = 'flex w-[60px] cursor-pointer flex-col items-center' return ( {items.map((it) => it.to ? ( track('today_icon', { icon: it.key })} className={cls}> {tile(it)} ) : ( ), )} ) }