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,137 @@
|
||||
import { useState } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { getWeekOptions, listEventsOptions, listPlacesOptions } from '../api/client/@tanstack/react-query.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { cardBg, dateRange, sidoOf } from './lib'
|
||||
import { useRegion } from './regionContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { Ic, Rail, Sec, StateBox } from './ui'
|
||||
|
||||
const PLACE_BG: Record<string, string> = { picnic: 'mint', walk: 'mint', sunset: 'dusk', chimaek: 'peach', photo: 'butter', bulb: 'lilac' }
|
||||
|
||||
export function WeekPage() {
|
||||
const { region } = useRegion()
|
||||
const { open } = useSheet()
|
||||
const week = useQuery(getWeekOptions({ query: { region: region.code } }))
|
||||
const days = week.data?.days ?? []
|
||||
const [picked, setPicked] = useState<string | null>(null)
|
||||
// 지역을 바꾸면 동네 고르기는 전체로 돌아간다
|
||||
const [areaPick, setAreaPick] = useState({ region: region.code, area: '전체' })
|
||||
const area = areaPick.region === region.code ? areaPick.area : '전체'
|
||||
// 처음에는 이번 토요일을 고른다
|
||||
const sel = days.find((d) => d.day === picked) ?? days.find((d) => d.weekday === '토') ?? days[0]
|
||||
const places = useQuery({ ...listPlacesOptions({ query: { region: region.code, day: sel?.day, area: area === '전체' ? undefined : area } }), enabled: !!sel })
|
||||
const events = useQuery(listEventsOptions({ query: { region: region.code } }))
|
||||
const sido = sidoOf(region.name)
|
||||
const areas = places.data?.areas ?? []
|
||||
const rainy = places.data?.rainy ?? sel?.is_rainy
|
||||
const placeList = places.data?.places ?? []
|
||||
const eventList = events.data?.events ?? []
|
||||
|
||||
const sendPlan = () => {
|
||||
if (!sel) return
|
||||
open({ type: 'share', share: { title: `${sel.weekday}요일 일정`, icon: 'calendar', bg: 'mint', messages: [`${sel.weekday}요일 이렇게 놀자! ${sel.pick} 😆`, '이번 주말 같이 놀자 🙌'] } })
|
||||
}
|
||||
|
||||
return (
|
||||
<section aria-label="주말·행사">
|
||||
<Sec title="이번 주 날씨" sub="날짜를 누르면 그날 추천이 바뀌어요" />
|
||||
{days.length ? (
|
||||
<div className="grid grid-cols-7 gap-1 px-3 pt-3" role="group" aria-label="날짜 고르기">
|
||||
{days.map((d) => {
|
||||
const on = d.day === sel?.day
|
||||
const weekend = d.weekday === '토' || d.weekday === '일' || !!d.holiday
|
||||
return (
|
||||
<button
|
||||
key={d.day}
|
||||
type="button"
|
||||
aria-pressed={on}
|
||||
onClick={() => setPicked(d.day)}
|
||||
className={cx('flex cursor-pointer flex-col items-center gap-0.5 rounded-[18px] pt-[9px] pb-2 text-xs font-extrabold', on ? 'bg-(--ink) text-white' : cx('bg-white shadow-[inset_0_-4px_0_var(--shade)]', weekend ? 'text-[#d6457a]' : 'text-(--ink2)'))}
|
||||
>
|
||||
<span>{d.weekday}</span>
|
||||
<Ic name={d.icon} className="w-7" />
|
||||
<b className={cx('font-jua text-sm font-normal', on ? 'text-white' : 'text-(--ink)')}>{d.temp_max_c != null ? `${Math.round(d.temp_max_c)}°` : '-'}</b>
|
||||
<span className={cx('max-w-full truncate px-0.5 text-[9.5px]', on ? 'text-[#ffb3c4]' : 'text-[#d6457a]')}>{d.holiday ? d.holiday.replace(/\(.*\)/, '') : `${Number(d.day.slice(8))}일`}</span>
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<StateBox loading={week.isPending} error={week.error} onRetry={() => week.refetch()} empty="이번 주 날씨가 아직 없어요." />
|
||||
)}
|
||||
{sel && (
|
||||
<div className="mx-3 mt-3 flex items-center gap-3.5 rounded-3xl bg-[linear-gradient(180deg,#e9fbf2,#fff)] p-4 shadow-[inset_0_-5px_0_var(--shade)]" aria-live="polite">
|
||||
<Ic name={sel.icon} className="w-16" />
|
||||
<div>
|
||||
<b className="block font-jua text-[19px] font-normal">{sel.headline}</b>
|
||||
<p className="mt-0.5 text-[13.5px] font-semibold text-(--ink2)">{sel.summary}</p>
|
||||
<p className="mt-2 font-jua text-base text-(--ink)">추천: {sel.pick}</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{areas.length > 0 && (
|
||||
<div className="mx-3 mt-3.5 flex items-center justify-between">
|
||||
<label htmlFor="b-area" className="text-[13.5px] font-bold text-(--ink2)">
|
||||
{sido} · 데이트 명소
|
||||
</label>
|
||||
<select id="b-area" value={area} onChange={(e) => setAreaPick({ region: region.code, area: e.target.value })} className="rounded-full bg-white px-3 py-[7px] font-bold text-(--ink) shadow-[inset_0_-3px_0_var(--shade)]">
|
||||
{['전체', ...areas].map((a) => (
|
||||
<option key={a}>{a}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
<Sec title="날씨 맞춤 데이트 명소" sub={sel ? `${sel.weekday}요일은 ${rainy ? '비가 와서 실내 명소를 먼저' : '맑아서 야외 명소를 먼저'} 보여 줘요` : undefined} className="pt-3" />
|
||||
{placeList.length ? (
|
||||
<Rail>
|
||||
{placeList.map((p, i) => (
|
||||
<div key={p.place_id} className="w-[178px] overflow-hidden rounded-[22px] bg-white text-left shadow-[inset_0_-5px_0_var(--shade),0_8px_16px_rgb(40_48_74/0.06)]">
|
||||
<span className={cx('relative grid h-[104px] place-items-center', `b-bg-${PLACE_BG[p.icon] ?? (p.is_outdoor ? 'mint' : cardBg(p.icon, i))}`)}>
|
||||
{p.is_good && <span className={cx('absolute top-2.5 left-2.5 rounded-full px-2 py-[3px] text-[11.5px] font-extrabold text-white', p.is_outdoor ? 'bg-[#1f9d62]' : 'bg-(--rain)')}>{p.is_outdoor ? '오늘 딱' : '비 와도 OK'}</span>}
|
||||
<Ic name={p.icon} className="w-[62px]" />
|
||||
</span>
|
||||
<span className="block px-3 pt-2.5 pb-3">
|
||||
<span className="text-[11.5px] font-extrabold text-(--ink3)">
|
||||
{p.area} · {p.is_outdoor ? '야외' : '실내'}
|
||||
</span>
|
||||
<b className="block font-jua text-[16.5px] font-normal">{p.name}</b>
|
||||
<small className="block text-[12.5px] leading-snug font-semibold text-(--ink2)">
|
||||
{p.reason}
|
||||
<br />
|
||||
추천 {p.best_time}
|
||||
</small>
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</Rail>
|
||||
) : (
|
||||
<StateBox loading={places.isPending && !!sel} error={places.error} onRetry={() => places.refetch()} empty={`${sido} 데이트 명소는 아직 준비 중이에요.`} />
|
||||
)}
|
||||
<Sec title={`${sido} 축제·행사`} sub="앞으로 30일 · 그날 날씨까지 같이 봐요" className="pt-[18px]" />
|
||||
{eventList.length ? (
|
||||
eventList.map((e, i) => (
|
||||
<div key={e.event_id} className="mx-3 mt-2.5 grid grid-cols-[84px_1fr] items-center gap-3 rounded-[22px] bg-white p-3 shadow-[inset_0_-5px_0_var(--shade)]">
|
||||
<span className={cx('grid h-[84px] place-items-center rounded-2xl', `b-bg-${cardBg(e.icon, i)}`)}>
|
||||
<Ic name={e.icon} className="w-14" />
|
||||
</span>
|
||||
<span>
|
||||
<span className={cx('mr-1.5 inline-block rounded-full px-[7px] py-0.5 align-[2px] text-[11px] font-extrabold', e.status === 'live' ? 'bg-[#dff5ea] text-[#1f7a4f]' : 'bg-[#ffe8dc] text-[#c2471b]')}>{e.status_label}</span>
|
||||
<b className="inline font-jua text-[17px] leading-snug font-normal">{e.name}</b>
|
||||
<small className="block text-[12.5px] font-semibold text-(--ink2)">
|
||||
{dateRange(e.start_date, e.end_date)} · {e.place_name}
|
||||
{!e.is_confirmed && ' · 일정 확인 필요'}
|
||||
</small>
|
||||
{e.fit && <span className={cx('mt-[5px] inline-block text-xs font-extrabold', e.fit.includes('비') ? 'text-[#d6457a]' : 'text-[#1f9d62]')}>{e.fit}</span>}
|
||||
</span>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<StateBox loading={events.isPending} error={events.error} onRetry={() => events.refetch()} empty="이 지역 행사는 아직 없어요. 다른 지역을 골라 보세요." />
|
||||
)}
|
||||
<button type="button" onClick={sendPlan} disabled={!sel} className="mx-3 mt-4 block w-[calc(100%-24px)] cursor-pointer rounded-full bg-(--orange) p-[13px] font-jua text-[17px] text-white shadow-[inset_0_-5px_0_var(--orange-deep)] disabled:opacity-60">
|
||||
이번 주말 일정 보내기
|
||||
</button>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user