Merge branch 'react-native' into release/1026-merge

# Conflicts:
#	backend/common/enums.py
#	backend/router/v1/auth/account.py
#	frontend/.dockerignore
#	frontend/package-lock.json
#	frontend/package.json
#	frontend/public/terms.html
#	frontend/src/api/client/index.ts
#	frontend/src/b/BLayout.tsx
#	frontend/src/b/Sheets.tsx
#	shared/api/client/@tanstack/react-query.gen.ts
#	shared/api/client/sdk.gen.ts
#	shared/api/client/types.gen.ts
This commit is contained in:
minaChoi committed 2026-10-26 15:36:05 +09:00
commit 5d18fa51fa
148 files changed
+21940 -4532

No files matched your search

+2 -2
View File
@@ -1,10 +1,10 @@
import { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react'
import { NavLink, Outlet, useLocation, useNavigationType } from 'react-router'
import { useIsFetching, useQuery } from '@tanstack/react-query'
import { getSeasonWeekOptions } from '../api/client/@tanstack/react-query.gen'
import { getSeasonWeekOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { IS_TOSS } from '../lib/platform'
import { cx } from '../lib/utils'
import { kindOfHour, kst, seasonOf, type TimeKind } from './lib'
import { kindOfHour, kst, seasonOf, type TimeKind } from '@nalssigak/shared/lib'
import './b.css'
import { AuthProvider } from './auth'
import { RegionProvider } from './region'
+3 -3
View File
@@ -1,9 +1,9 @@
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 { listArticlesOptions, listIndicesOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { ArticleCategory, IndexCategory } from '@nalssigak/shared/api/client/types.gen'
import { cx } from '../lib/utils'
import { kst, loadOf, MEDALS, seasonOf } from './lib'
import { kst, loadOf, MEDALS, seasonOf } from '@nalssigak/shared/lib'
import { useRegion } from './regionContext'
import { useSheet } from './sheetContext'
import { Chips, Ic, Sec, Skel, StateBox } from './ui'
+6 -5
View File
@@ -1,13 +1,14 @@
import { useEffect, useRef, useState, type CSSProperties, type MouseEvent, type ReactNode, type RefObject } from 'react'
import { createPortal } from 'react-dom'
import { PostType, SlotTone, type GakSlide, type HoursSlide, type ImageSlide, type PlanSlide, type PostData, type PostReaction, type ResFeed, type RowsSlide, type SunsetSlide, type WeekSlide } from '../api/client/types.gen'
import { PostType, SlotTone, type GakSlide, type HoursSlide, type ImageSlide, type PlanSlide, type PostData, type PostReaction, type ResFeed, type RowsSlide, type SunsetSlide, type WeekSlide } from '@nalssigak/shared/api/client/types.gen'
import { API_BASE_URL } from '../api/setup'
import { cx } from '../lib/utils'
import { cardBg, clockShort, fall } from './lib'
import type { SlideBg } from './types'
import { deg } from './weatherText'
import { cardBg, clockShort } from '@nalssigak/shared/lib'
import { fall } from './lib'
import type { SlideBg } from '@nalssigak/shared/lib/types'
import { deg } from '@nalssigak/shared/lib/weatherText'
import { useMutation, useQueryClient, type QueryClient } from '@tanstack/react-query'
import { likePostMutation, unlikePostMutation } from '../api/client/@tanstack/react-query.gen'
import { likePostMutation, unlikePostMutation } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { usePinnedLike, type PinnedKey } from './pinnedLike'
import { useSheet } from './sheetContext'
import { CommentIcon, HeartIcon, SendIcon } from './svg'
+4 -3
View File
@@ -1,9 +1,10 @@
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 { getSeasonWeekOptions, listArticlesOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { ArticleCategory } from '@nalssigak/shared/api/client/types.gen'
import { cx } from '../lib/utils'
import { ARTICLE_CAT, cardBg, dateRange, fall, loadOf, shortDay } from './lib'
import { cardBg, dateRange, loadOf, shortDay } from '@nalssigak/shared/lib'
import { ARTICLE_CAT, fall } from './lib'
import { useSheet } from './sheetContext'
import { Chips, Ic, Skel, StateBox, Thumb } from './ui'
+250 -28
View File
@@ -1,10 +1,12 @@
import { useInfiniteQuery, useMutation, useQuery, useQueryClient, type InfiniteData } from '@tanstack/react-query'
import { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState, type FormEvent, type ReactNode } from 'react'
import regionPages from '../../seo/region.json'
import { setTokens, subscribeAuth } from '../api/auth'
import { clearTokens, setTokens, subscribeAuth } from '@nalssigak/shared/api/auth'
import { SITE_URL } from '../api/setup'
import {
addCommentMutation,
agreeTermsMutation,
blockAuthorMutation,
deleteCommentMutation,
getArticleOptions,
getFeedQueryKey,
@@ -12,24 +14,30 @@ import {
getSeasonWeekOptions,
likeCommentMutation,
listCommentsInfiniteOptions,
listBlockedOptions,
listBlockedQueryKey,
listCommentsInfiniteQueryKey,
listRegionsOptions,
meQueryKey,
reportCommentMutation,
unblockMutation,
unlikeCommentMutation,
updateMeMutation,
} from '../api/client/@tanstack/react-query.gen'
import { AuthProvider, type CommentData, type Factor, type ResAuth, type ResCommentList, type ResIndexDetail } from '../api/client/types.gen'
withdrawMutation,
} from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { AuthProvider, ReportReason, type CommentData, type Factor, type ResAuth, type ResCommentList, type ResIndexDetail } from '@nalssigak/shared/api/client/types.gen'
import { track } from '../lib/analytics'
import { IS_TOSS, tossShare } from '../lib/platform'
import { cx } from '../lib/utils'
import { useAuth } from './authContext'
import { ago, ARTICLE_CAT, articleMeta, AVATAR_COLORS, cardBg, CHARACTERS, dateRange, loadOf, MOODS, shortDay } from './lib'
import { ago, articleMeta, AVATAR_COLORS, cardBg, CHARACTERS, dateRange, loadOf, MOODS, shortDay } from '@nalssigak/shared/lib'
import { GoogleButton } from './googleLogin'
import { useInstall, useInstallable } from './install'
import { InstallSheet } from './installBanner'
import { WeatherWhySheet } from './weatherWhy'
import { ARTICLE_CAT } from './lib'
import { MixSheet } from './myGak'
import { ownPage, useRegion } from './regionContext'
import { WeatherWhySheet } from './weatherWhy'
import { useSky } from './skyContext'
import { SHARE_SIZES, shareImage, type ShareSize } from './storyImage'
import { SheetContext, useSheet, type SharePayload, type SheetState } from './sheetContext'
@@ -642,8 +650,88 @@ function ShareSheet({ share }: { share: SharePayload }) {
/* ---------- 댓글 ---------- */
const NOT_FOUND = 3001 // 서버 ErrorType.NOT_FOUND
const EMOJIS = ['☀️', '🌂', '🍻', '🌇', '😍', '👍']
const REPORT_REASONS = [
[ReportReason.ABUSE, '욕설·비하'],
[ReportReason.AD, '광고'],
[ReportReason.PRIVACY, '개인정보 노출'],
[ReportReason.OTHER, '기타'],
] as const
const isCommentList = (q: { queryKey: readonly unknown[] }) => (q.queryKey[0] as { _id?: string } | undefined)?._id === 'listComments'
function CommentRow({ c, postId }: { c: CommentData; postId: number }) {
/** 남의 댓글: ⋯ → 신고하기(이유 고르기) / 이 사람 차단하기(한 번 더 묻기). 끝나면 목록을 다시 받아 그 댓글이 빠진다 */
function CommentMenu({ c, postId, onNotice }: { c: CommentData; postId: number; onNotice: (text: string) => void }) {
const { loggedIn } = useAuth()
const { open } = useSheet()
const queryClient = useQueryClient()
const [step, setStep] = useState<'closed' | 'menu' | 'report' | 'block'>('closed')
const [failed, setFailed] = useState(false)
const report = useMutation(reportCommentMutation())
const block = useMutation(blockAuthorMutation())
const pending = report.isPending || block.isPending
const finish = (notice: string) => ({
onSuccess: (res: { result?: { success?: boolean } }) => {
if (!res.result?.success) return setFailed(true)
setStep('closed')
onNotice(notice)
queryClient.invalidateQueries({ predicate: isCommentList })
queryClient.invalidateQueries({ queryKey: listBlockedQueryKey() })
},
onError: () => setFailed(true),
})
const go = (next: typeof step) => {
setFailed(false)
if (next !== 'closed' && !loggedIn) return open({ type: 'login', then: { type: 'comments', postId } })
setStep(next)
}
const btn = 'cursor-pointer rounded-[12px] bg-[#f3f6fb] px-3 py-2 text-[13px] font-extrabold text-(--ink) disabled:opacity-50'
return (
<>
<button type="button" onClick={() => go(step === 'closed' ? 'menu' : 'closed')} aria-expanded={step !== 'closed'} aria-label="댓글 메뉴" className="ml-1.5 cursor-pointer px-1 font-extrabold text-(--ink3)">
⋯
</button>
{step !== 'closed' && (
<span className="mt-2 flex flex-wrap items-center gap-1.5" role="group" aria-label="댓글 메뉴">
{step === 'menu' && (
<>
<button type="button" className={btn} onClick={() => go('report')}>
신고하기
</button>
<button type="button" className={btn} onClick={() => go('block')}>
이 사람 차단하기
</button>
</>
)}
{step === 'report' &&
REPORT_REASONS.map(([reason, label]) => (
<button key={reason} type="button" disabled={pending} className={btn} onClick={() => report.mutate({ path: { comment_id: c.comment_id }, body: { reason } }, finish('신고했어요. 확인하고 조치할게요.'))}>
{label}
</button>
))}
{step === 'block' && (
<>
<span className="w-full text-[13px] font-bold text-(--ink)">{c.nickname}님 댓글을 더는 안 볼까요?</span>
<button type="button" disabled={pending} className={cx(btn, 'bg-(--heart) text-white')} onClick={() => block.mutate({ path: { comment_id: c.comment_id } }, finish('차단했어요. 내 정보에서 풀 수 있어요.'))}>
차단하기
</button>
<button type="button" disabled={pending} className={btn} onClick={() => go('closed')}>
취소
</button>
</>
)}
{failed && (
<span className="w-full text-[13px] font-bold text-(--heart)" role="alert">
잠시 뒤에 다시 해 주세요.
</span>
)}
</span>
)}
</>
)
}
function CommentRow({ c, postId, onNotice }: { c: CommentData; postId: number; onNotice: (text: string) => void }) {
const { region } = useRegion()
const queryClient = useQueryClient()
const [liked, setLiked] = useState(c.liked)
@@ -725,6 +813,7 @@ function CommentRow({ c, postId }: { c: CommentData; postId: number }) {
</button>
</>
)}
{!c.mine && <CommentMenu c={c} postId={postId} onNotice={onNotice} />}
</small>
</div>
<button type="button" onClick={toggle} aria-pressed={liked} aria-label="댓글 좋아요" className={cx('relative cursor-pointer pt-1', TAP44)}>
@@ -744,13 +833,21 @@ function CommentsSheet({ postId, draft }: { postId: number; draft?: string }) {
getNextPageParam: (last) => last.next_cursor ?? undefined,
})
const add = useMutation(addCommentMutation())
const agree = useMutation(agreeTermsMutation())
const [addFailed, setAddFailed] = useState(false)
const [askTerms, setAskTerms] = useState(false)
const [notice, setNotice] = useState('')
const [text, setText] = useState(draft ?? '')
const inputRef = useRef<HTMLInputElement>(null)
const comments = list.data?.pages.flatMap((p) => p.comments ?? []) ?? []
const submit = (e: FormEvent) => {
e.preventDefault()
useEffect(() => {
if (!notice) return
const t = setTimeout(() => setNotice(''), 3000)
return () => clearTimeout(t)
}, [notice])
const send = () => {
const body = text.trim()
if (!body || add.isPending) return
setAddFailed(false)
@@ -758,6 +855,7 @@ function CommentsSheet({ postId, draft }: { postId: number; draft?: string }) {
{ path: { post_id: postId }, body: { body, region: region.code } },
{
onSuccess: (res) => {
if (res.result?.desc === 'TERMS_REQUIRED') return setAskTerms(true)
setAddFailed(!res.result?.success)
if (!res.result?.success) return
setText('')
@@ -769,13 +867,35 @@ function CommentsSheet({ postId, draft }: { postId: number; draft?: string }) {
)
}
// 로그인했으면 약관에 동의해야 댓글을 쓸 수 있다. 동의하면 쓰던 댓글을 바로 올린다
const submit = (e: FormEvent) => {
e.preventDefault()
if (me && !me.terms_agreed) return setAskTerms(true)
send()
}
const agreeAndSend = () => {
setAddFailed(false)
agree.mutate(
{},
{
onSuccess: (res) => {
if (!res.result?.success) return setAddFailed(true)
queryClient.setQueryData(meQueryKey(), res)
setAskTerms(false)
send()
},
onError: () => setAddFailed(true),
},
)
}
return (
<>
<Body>
{comments.length ? (
<>
{/* 다시 받은 좋아요 상태(로그인 바뀜 등)가 행에 반영되도록 key 에 넣는다 */}
{comments.map((c) => <CommentRow key={`${c.comment_id}:${c.liked}:${c.like_count}`} c={c} postId={postId} />)}
{comments.map((c) => <CommentRow key={`${c.comment_id}:${c.liked}:${c.like_count}`} c={c} postId={postId} onNotice={setNotice} />)}
{list.hasNextPage && (
<button type="button" onClick={() => list.fetchNextPage()} disabled={list.isFetchingNextPage} className="my-2 w-full cursor-pointer text-center text-sm font-bold text-(--ink3) disabled:opacity-50">
{list.isFetchingNextPage ? '불러오는 중…' : '댓글 더 보기'}
@@ -788,24 +908,38 @@ function CommentsSheet({ postId, draft }: { postId: number; draft?: string }) {
<StateBox load={loadOf(list)} onRetry={() => list.refetch()} empty="아직 댓글이 없어요. 첫 댓글을 남겨 보세요." hold={<CommentsSkel />} className="inset-0" />
)}
</Body>
<div className="flex justify-around pt-1 text-[22px]" role="group" aria-label="빠른 이모지">
{EMOJIS.map((e) => (
<button
key={e}
type="button"
disabled={add.isPending}
className="cursor-pointer disabled:opacity-40"
onClick={() => {
setText((t) => (t + e).slice(0, 60))
inputRef.current?.focus()
}}
>
{e}
</button>
))}
</div>
<p className="h-4 px-4 text-center text-xs leading-4 font-bold text-(--heart)" role="alert">
{addFailed && '댓글을 올리지 못했어요. 다시 해 주세요.'}
{askTerms ? (
<div className="mx-3 flex flex-col gap-2 rounded-[16px] bg-[#f3f6fb] p-3" role="dialog" aria-label="이용약관 동의">
<p className="m-0 text-[13px] font-bold text-(--ink)">댓글을 쓰려면 이용약관에 동의해 주세요. 욕설·광고·개인정보 노출은 숨겨지고, 계속되면 이용이 제한돼요.</p>
<div className="flex gap-2">
<a href="/terms.html" target="_blank" rel="noopener" className="flex-1 rounded-[12px] bg-white p-2.5 text-center text-[13px] font-extrabold text-(--ink)">
이용약관 보기
</a>
<button type="button" onClick={agreeAndSend} disabled={agree.isPending || add.isPending} className="flex-1 cursor-pointer rounded-[12px] bg-(--orange) p-2.5 text-[13px] font-extrabold text-white disabled:opacity-60">
동의하고 쓰기
</button>
</div>
</div>
) : (
<div className="flex justify-around pt-1 text-[22px]" role="group" aria-label="빠른 이모지">
{EMOJIS.map((e) => (
<button
key={e}
type="button"
disabled={add.isPending}
className="cursor-pointer disabled:opacity-40"
onClick={() => {
setText((t) => (t + e).slice(0, 60))
inputRef.current?.focus()
}}
>
{e}
</button>
))}
</div>
)}
<p className={cx('h-4 px-4 text-center text-xs leading-4 font-bold', addFailed ? 'text-(--heart)' : 'text-(--ink2)')} role="alert">
{addFailed ? '댓글을 올리지 못했어요. 다시 해 주세요.' : notice}
</p>
<form onSubmit={submit} className="flex items-center gap-2.5 border-t border-(--line) px-3 pt-2.5 pb-2.5">
<input ref={inputRef} value={text} onChange={(e) => setText(e.target.value)} readOnly={add.isPending} maxLength={60} placeholder={me ? `${me.nickname}(으)로 댓글 달기…` : '댓글 달기…'} aria-label="댓글" className="min-w-0 flex-1 rounded-full border border-[#dfe5ee] bg-[#f7f9fc] px-3.5 py-2.5" />
@@ -870,7 +1004,93 @@ function TossNoLoginSheet({ onDone }: { onDone: () => void }) {
)
}
/* ---------- 내 정보: 캐릭터·닉네임·로그아웃 ---------- */
/* ---------- 내 정보: 캐릭터·닉네임·로그아웃·탈퇴 ---------- */
/** 탈퇴: 한 번 더 묻고 지운다. 계정이 없어지니 이 기기 토큰도 지운다 */
function Withdraw({ onDone }: { onDone: () => void }) {
const withdraw = useMutation(withdrawMutation())
const [asking, setAsking] = useState(false)
const [failed, setFailed] = useState(false)
if (!asking)
return (
<button type="button" onClick={() => setAsking(true)} className="cursor-pointer self-center p-1 text-[13px] font-semibold text-(--ink3)">
탈퇴하기
</button>
)
const run = () => {
setFailed(false)
withdraw.mutate(
{},
{
onSuccess: (res) => {
if (!res.result?.success) return setFailed(true)
clearTokens()
onDone()
},
onError: () => setFailed(true),
},
)
}
return (
<div className="flex flex-col gap-2.5 rounded-[18px] bg-[#fff1f3] p-3.5" role="alert">
<p className="m-0 text-center text-sm font-bold text-(--ink)">
탈퇴하면 계정과 남긴 댓글·좋아요가
<br />
모두 지워져요. 되돌릴 수 없어요.
</p>
<div className="flex gap-2">
<button type="button" onClick={() => setAsking(false)} disabled={withdraw.isPending} className="flex-1 cursor-pointer rounded-[14px] bg-white p-3 text-sm font-extrabold text-(--ink)">
그만둘게요
</button>
<button type="button" onClick={run} disabled={withdraw.isPending} className="flex-1 cursor-pointer rounded-[14px] bg-(--heart) p-3 text-sm font-extrabold text-white disabled:opacity-60">
탈퇴할게요
</button>
</div>
{failed && <p className="m-0 text-center text-[13px] font-bold text-(--heart)">탈퇴하지 못했어요. 잠시 뒤에 다시 해 주세요.</p>}
</div>
)
}
/** 차단한 사람: 있을 때만 보이고, 풀면 그 사람 댓글이 다시 보인다 */
function Blocked() {
const queryClient = useQueryClient()
const list = useQuery(listBlockedOptions())
const unblock = useMutation(unblockMutation())
const [failed, setFailed] = useState(false)
const users = list.data?.users ?? []
if (!users.length) return null
const release = (user_id: string) => {
setFailed(false)
unblock.mutate(
{ path: { user_id } },
{
onSuccess: (res) => {
if (!res.result?.success) return setFailed(true)
queryClient.invalidateQueries({ queryKey: listBlockedQueryKey() })
queryClient.invalidateQueries({ predicate: isCommentList })
},
onError: () => setFailed(true),
},
)
}
return (
<section aria-label="차단한 사람">
<h4 className="m-0 mb-2 text-sm font-extrabold">차단한 사람</h4>
<ul className="m-0 flex list-none flex-col gap-2 p-0">
{users.map((u) => (
<li key={u.user_id} className="flex items-center gap-2.5">
<Avatar character={u.character} color={u.color} />
<span className="flex-1 text-sm font-bold">{u.nickname}</span>
<button type="button" onClick={() => release(u.user_id)} disabled={unblock.isPending} className="cursor-pointer rounded-[12px] bg-[#f3f6fb] px-3 py-2 text-[13px] font-extrabold text-(--ink) disabled:opacity-50">
풀기
</button>
</li>
))}
</ul>
{failed && <p className="m-0 mt-1.5 text-[13px] font-bold text-(--heart)">잠시 뒤에 다시 해 주세요.</p>}
</section>
)
}
function MeSheet({ onDone }: { onDone: () => void }) {
const install = useInstall()
const installable = useInstallable()
@@ -997,6 +1217,8 @@ function MeSheet({ onDone }: { onDone: () => void }) {
>
로그아웃
</button>
<Blocked />
<Withdraw onDone={onDone} />
</Body>
)
}
+3 -3
View File
@@ -1,9 +1,9 @@
import { useQuery } from '@tanstack/react-query'
import { useState, type ReactNode } from 'react'
import { getSkyOptions, getSkyRankingOptions } from '../api/client/@tanstack/react-query.gen'
import type { BestTime, SkyPlanData } from '../api/client/types.gen'
import { getSkyOptions, getSkyRankingOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import type { BestTime, SkyPlanData } from '@nalssigak/shared/api/client/types.gen'
import { cx } from '../lib/utils'
import { clockShort, loadOf } from './lib'
import { clockShort, loadOf } from '@nalssigak/shared/lib'
import { useRegion } from './regionContext'
import { MapLink, Sec, Skel, StateBox } from './ui'
+1 -1
View File
@@ -1,5 +1,5 @@
import { useSearchParams } from 'react-router'
import type { TalkTopic } from '../api/client/types.gen'
import type { TalkTopic } from '@nalssigak/shared/api/client/types.gen'
import { cx } from '../lib/utils'
import { TalkCard } from './talk'
import { TOPICS, useTopicTalks } from './talkState'
+5 -4
View File
@@ -1,7 +1,7 @@
import { Fragment, useEffect, useRef, useState, type ReactNode } from 'react'
import { Link, useLocation } from 'react-router'
import { useQuery } from '@tanstack/react-query'
import { getFeedOptions, getWeatherTodayOptions } from '../api/client/@tanstack/react-query.gen'
import { getFeedOptions, getWeatherTodayOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import {
PostType,
RainType,
@@ -15,9 +15,10 @@ import {
type TalkData,
type TopIndex,
type WeatherSlot,
} from '../api/client/types.gen'
} from '@nalssigak/shared/api/client/types.gen'
import { cx } from '../lib/utils'
import { cardBg, fall, kindOfHour, kst, type Load, loadOf, MEDALS, type TimeKind, WEEKDAYS } from './lib'
import { cardBg, kindOfHour, kst, type Load, loadOf, MEDALS, type TimeKind, WEEKDAYS } from '@nalssigak/shared/lib'
import { fall } from './lib'
import { FoliageCard } from './foliageMap'
import { InstallBanner } from './installBanner'
import { MyGakRow } from './myGak'
@@ -33,7 +34,7 @@ import { useSky } from './skyContext'
import { DayShareCard, DayShareGrid, GakShareCard, type DayShare } from './shareCards'
import { CommentIcon, HeartIcon, SendIcon } from './svg'
import { Ic, Rail, Sec, Skel, StateBox, TAP44, Thumb } from './ui'
import { deg, slotAt } from './weatherText'
import { deg, slotAt } from '@nalssigak/shared/lib/weatherText'
type Mode = 'now' | TimeKind
+2 -2
View File
@@ -1,8 +1,8 @@
import { useRef, useState, type ReactNode } from 'react'
import { useQuery } from '@tanstack/react-query'
import { getWeekOptions, getWeekRankingOptions, listEventsOptions, listPlacesOptions } from '../api/client/@tanstack/react-query.gen'
import { getWeekOptions, getWeekRankingOptions, listEventsOptions, listPlacesOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { cx } from '../lib/utils'
import { cardBg, dateRange, loadOf, shortDay } from './lib'
import { cardBg, dateRange, loadOf, shortDay } from '@nalssigak/shared/lib'
import { useRegion } from './regionContext'
import { useSheet } from './sheetContext'
import { Arrows, Chips, Ic, MapLink, Rail, Sec, Skel, SkelRail, StateBox, Thumb } from './ui'
+13 -4
View File
@@ -1,8 +1,8 @@
import { useQuery, useQueryClient } from '@tanstack/react-query'
import { useEffect, useMemo, useSyncExternalStore, type ReactNode } from 'react'
import { clearTokens, getAccessToken, subscribeAuth } from '../api/auth'
import { meOptions } from '../api/client/@tanstack/react-query.gen'
import { logout as logoutOnServer } from '../api/client/sdk.gen'
import { clearTokens, getAccessToken, subscribeAuth } from '@nalssigak/shared/api/auth'
import { meOptions, meQueryKey } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { logout as logoutOnServer } from '@nalssigak/shared/api/client/sdk.gen'
import { AuthContext } from './authContext'
const subscribe = (cb: () => void) => subscribeAuth((reason) => reason === 'change' && cb())
@@ -18,7 +18,16 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const me = useQuery({ ...meOptions(), enabled: !!token })
// 로그인·로그아웃하면 좋아요 여부가 달라지니 받아 둔 데이터를 다시 받는다
useEffect(() => subscribeAuth((reason) => reason === 'change' && queryClient.invalidateQueries()), [queryClient])
// 로그아웃·탈퇴 땐 내 정보 캐시를 먼저 버린다. 남겨 두면 다시 받다가 401 이 나서 로그인 창이 뜬다
useEffect(
() =>
subscribeAuth((reason) => {
if (reason !== 'change') return
if (!getAccessToken()) queryClient.removeQueries({ queryKey: meQueryKey() })
void queryClient.invalidateQueries()
}),
[queryClient],
)
const mePending = !!token && me.isPending
const api = useMemo(() => ({ loggedIn: !!token, me: (token && me.data?.me) || null, mePending, logout }), [token, me.data, mePending])
+1 -1
View File
@@ -1,5 +1,5 @@
import { createContext, use } from 'react'
import type { Me } from '../api/client/types.gen'
import type { Me } from '@nalssigak/shared/api/client/types.gen'
/** mePending: 토큰은 있고 내 정보를 받는 중 (아바타 자리를 비워 두지 않으려고) */
export type AuthApi = { loggedIn: boolean; me: Me | null; mePending: boolean; logout: () => void }
+1 -1
View File
@@ -1,6 +1,6 @@
import { useLayoutEffect, useMemo, useState, type RefObject } from 'react'
import data from '../../seo/foliage_2026.json'
import { kst } from './lib'
import { kst } from '@nalssigak/shared/lib'
export type Kind = 'maple' | 'ginkgo'
export type Stage = 'before' | 'first' | 'peak' | 'gone'
+1 -1
View File
@@ -1,7 +1,7 @@
import { useLayoutEffect, useMemo, useRef, useState, type MouseEvent } from 'react'
import { useNavigate } from 'react-router'
import { cx } from '../lib/utils'
import type { PostReaction } from '../api/client/types.gen'
import type { PostReaction } from '@nalssigak/shared/api/client/types.gen'
import { useCarousel } from './carousel'
import { headline, ICON_R, LABEL, LABEL_INK, LEAF_SHADOW, MAP_IMG, MAP_SRC, md, placeLabels, PROVINCE, PROVINCES, labelBoxes, placeProvinces, rankNow, spread, useFoliage, useLabelSize } from './foliage'
import { PostFrame } from './Post'
+2 -2
View File
@@ -1,7 +1,7 @@
import { useMutation, useQuery } from '@tanstack/react-query'
import { useEffect, useRef, useState } from 'react'
import { authConfigOptions, googleLoginMutation } from '../api/client/@tanstack/react-query.gen'
import type { ResAuth } from '../api/client/types.gen'
import { authConfigOptions, googleLoginMutation } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import type { ResAuth } from '@nalssigak/shared/api/client/types.gen'
type GoogleId = {
initialize: (o: { client_id: string; callback: (r: { credential?: string }) => void; ux_mode?: 'popup' }) => void
+2 -131
View File
@@ -1,4 +1,5 @@
import type { CSSProperties } from 'react'
import { ARTICLE_LABEL } from '@nalssigak/shared/lib'
const SHARED = new Set(['bear', 'bike', 'bronze', 'camping', 'carwash', 'chimaek', 'cloud', 'coldwind', 'delivery', 'dog', 'garden', 'glasses', 'gold', 'hiking', 'iced_hot', 'jjamppong', 'laundry', 'letter', 'makeup', 'makgeolli', 'maple', 'moon', 'muggy', 'naengmyeon', 'photo', 'picnic', 'rabbit', 'rain', 'running', 'silver', 'snow', 'stars', 'sun_cloud', 'sun', 'sunset', 'taxi', 'umbrella', 'vent', 'walk', 'yajang', 'baseball', 'study', 'netflix', 'chestnut', 'peanut', 'tangerine', 'sweet_potato', 'fallen_leaf', 'kimchi', 'apple', 'mask', 'golf', 'jipkok', 'fishing', 'drive', 'kite', 'waterplay', 'riverwind', 'trot', 'pajeon', 'bingsu', 'blanket', 'indoordry', 'flower', 'bungeoppang', 'singing_rain', 'hangang', 'themepark', 'date', 'frizz', 'boiler', 'sunscreen', 'mosquito', 'tennis', 'hyodo', 'thanks', 'gift', 'party', 'game', 'selfie', 'sentimental', 'ginkgo'])
const OWN = new Set(['fireworks', 'bulb', 'calendar', 'thermo', 'sheaf', 'popup', 'exhibition', 'concert'])
@@ -10,136 +11,6 @@ export function iconSrc(name: string) {
return `/icons/${SHARED.has(name) ? name : 'sun_cloud'}.png`
}
export const MEDALS = ['gold', 'silver', 'bronze'] as const
/** 고를 수 있는 프로필 캐릭터 (백엔드 CHARACTERS 와 같아야 한다) */
export const CHARACTERS = [
['rabbit', '토끼'],
['bear', '곰'],
['dog', '강아지'],
['sun', '해님'],
['moon', '달님'],
['cloud', '구름'],
] as const
/** 프로필 배경색 (백엔드 COLORS 와 같아야 한다) */
export const AVATAR_COLORS: Record<string, string> = { orange: '#ff8e4e', blue: '#4f97e3', green: '#1f9d62', purple: '#7a5cd6', pink: '#d6457a', brown: '#a8643a' }
/** 오늘 기분 (백엔드 MOODS 와 같아야 한다) */
export const MOODS = [
['clear', '☀️', '맑음'],
['partly', '⛅', '구름 조금'],
['cloudy', '☁️', '흐림'],
['rain', '🌧️', '비'],
['thunder', '⚡', '번개'],
['snow', '❄️', '눈'],
['fog', '🌫️', '안개'],
['rainbow', '🌈', '무지개'],
] as const
export const moodEmoji = (mood?: string | null) => MOODS.find(([k]) => k === mood)?.[1]
export const fall = (d: string, f = '4.8s') => ({ '--d': d, '--f': f }) as CSSProperties
export const WEEKDAYS = ['일', '월', '화', '수', '목', '금', '토'] as const
// 달(1~12) → 계절 이름과 아이콘. 봄 3–5 · 여름 6–8 · 가을 9–11 · 겨울 12–2 (서버 각 제철 기준과 같다)
const SEASONS: [string, string][] = [['겨울', 'snow'], ['봄', 'garden'], ['여름', 'sun'], ['가을', 'maple']]
export const seasonOf = (month: number) => SEASONS[Math.floor((month % 12) / 3)]
const KST = new Intl.DateTimeFormat('en-US', { timeZone: 'Asia/Seoul', year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', hourCycle: 'h23', weekday: 'short' })
const WD_EN = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
/** 한국 시각으로 쪼개기 (브라우저 시간대와 상관없이) */
export function kst(input: string | Date) {
const parts = Object.fromEntries(KST.formatToParts(typeof input === 'string' ? new Date(input) : input).map((p) => [p.type, p.value]))
return { y: +parts.year, mo: +parts.month, d: +parts.day, h: +parts.hour, mi: +parts.minute, wd: WD_EN.indexOf(parts.weekday) }
}
const h12 = (h: number) => h % 12 || 12
/** 18:25 → "18:25" (포스트·플랜과 같은 24시간제) */
export function clockShort(iso: string) {
const t = kst(iso)
return `${t.h}:${String(t.mi).padStart(2, '0')}`
}
const COMPASS = ['북', '북북동', '북동', '동북동', '동', '동남동', '남동', '남남동', '남', '남남서', '남서', '서남서', '서', '서북서', '북서', '북북서']
/** 방위각 → 16방위 이름. 263 → "서" */
/** 네이버 지도에서 장소 이름(또는 주소)으로 찾기 */
export const naverMap = (query: string) => `https://map.naver.com/p/search/${encodeURIComponent(query)}`
export const compass = (deg: number) => COMPASS[Math.round(deg / 22.5) % 16]
/** 18:30 → "6시 반", 18:25 → "6시 25분" */
export function timeWords(iso: string) {
const t = kst(iso)
return `${h12(t.h)}시${t.mi === 0 ? '' : t.mi === 30 ? ' 반' : ` ${t.mi}분`}`
}
/** 발표 시각 → "방금" · "12분 전" · "3시간 전" */
export function ago(iso: string | null | undefined, now = Date.now()) {
if (!iso) return '오늘'
const min = Math.max(0, Math.round((now - new Date(iso).getTime()) / 60000))
if (min < 5) return '방금'
if (min < 60) return `${min}분 전`
return `${Math.floor(min / 60)}시간 전`
}
/** 날짜 칸 이름: 오늘 · 내일 · "토 10.4" */
export function dayLabel(date: string, index: number) {
if (index === 0) return '오늘'
if (index === 1) return '내일'
const [, m, d] = date.split('-').map(Number)
const wd = new Date(`${date}T12:00:00+09:00`).getUTCDay()
return `${WEEKDAYS[wd]} ${m}.${d}`
}
export type TimeKind = 'morning' | 'day' | 'sunset' | 'night'
// 서울 월별 대략 일몰 시각(시). 서버 값(/v1/feed hero.sky_mode)이 없을 때만 쓴다
const SUNSET_HOUR = [17.7, 18.2, 18.6, 19.1, 19.5, 19.9, 19.9, 19.5, 18.9, 18.2, 17.6, 17.3]
/** 피드와 같은 시간대: 아침 05–11 · 낮 11–일몰 2시간 전 · 저녁(sunset) 일몰 2시간 전–일몰 1시간 뒤 · 밤 일몰 1시간 뒤–05 */
export function kindOfHour(h: number, month = new Date().getMonth() + 1, minute = 0): TimeKind {
const at = h + minute / 60
const sunset = SUNSET_HOUR[month - 1]
if (at >= 5 && at < 11) return 'morning'
if (at >= 11 && at < sunset + 1) return at < sunset - 2 ? 'day' : 'sunset'
return 'night'
}
/** "서울 마포구" → "서울" */
export const sidoOf = (regionName: string) => regionName.split(' ')[0]
/** 2026-10-02 ~ 2026-10-11 → "10.2 ~ 10.11", 하루짜리는 "10.3" */
export function dateRange(start: string, end: string) {
return start === end ? shortDay(start) : `${shortDay(start)} ~ ${shortDay(end)}`
}
const CARD_BG = ['night', 'butter', 'lilac', 'mint', 'peach', 'sky'] as const
const ICON_BG: Record<string, (typeof CARD_BG)[number] | 'dusk'> = { picnic: 'mint', walk: 'mint', sunset: 'dusk', chimaek: 'peach', photo: 'butter', fireworks: 'night', popup: 'peach', exhibition: 'lilac', concert: 'night', sheaf: 'butter', rain: 'sky', calendar: 'sky', bulb: 'lilac', maple: 'peach', snow: 'sky', thermo: 'sky', umbrella: 'lilac' }
/** API에 배경색이 없어 아이콘·순서로 카드 배경을 고른다 */
export function cardBg(icon: string, index: number) {
return ICON_BG[icon] && icon !== 'calendar' ? ICON_BG[icon] : CARD_BG[index % CARD_BG.length]
}
/** "2026-09-23" → "9.23" */
export const shortDay = (day: string) => day.split('-').slice(1).map(Number).join('.')
export const ARTICLE_CAT: Record<number, [string, string]> = { 1: ['계절 소식', 'text-[#1f9d62]'], 2: ['날씨 상식', 'text-[#7a5cd6]'], 3: ['각 원리', 'text-(--orange)'] }
/** 읽을거리 한 줄 정보: "계절 소식 · 3분" */
export const articleMeta = (a: { category: number; read_minutes: number }) => `${ARTICLE_CAT[a.category]?.[0] ?? '읽을거리'} · ${a.read_minutes}분`
export type Load = 'loading' | 'error' | 'retrying' | 'ready'
type QueryLike = { data?: unknown; isPending: boolean; isError: boolean; isFetching: boolean; errorUpdateCount: number }
/** 데이터가 있으면 ready. 실패 뒤 다시 받는 중(retrying)은 처음 불러오기(loading)와 구분한다 */
export function loadOf(q: QueryLike): Load {
if (q.data !== undefined) return 'ready'
if (q.isError) return q.isFetching ? 'retrying' : 'error'
return q.isFetching && q.errorUpdateCount > 0 ? 'retrying' : 'loading'
}
export const ARTICLE_CAT: Record<number, [string, string]> = { 1: [ARTICLE_LABEL[1], 'text-[#1f9d62]'], 2: [ARTICLE_LABEL[2], 'text-[#7a5cd6]'], 3: [ARTICLE_LABEL[3], 'text-(--orange)'] }
+1 -1
View File
@@ -1,5 +1,5 @@
import { useState, type ReactNode } from 'react'
import type { MyGakPreset, MyGakRule, MyGakScore } from '../api/client/types.gen'
import type { MyGakPreset, MyGakRule, MyGakScore } from '@nalssigak/shared/api/client/types.gen'
import { cx } from '../lib/utils'
import { gakName, shareUrl, SLOTS, type MyGak, type Slot, useMyGak, useMyGakScores, usePresets } from './myGakState'
import { useRegion } from './regionContext'
+3 -3
View File
@@ -1,9 +1,9 @@
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { useEffect, useSyncExternalStore } from 'react'
import { SITE_URL } from '../api/setup'
import { addMyGakMutation, deleteMyGakMutation, listMyGakOptions, listMyGakQueryKey, listPresetsOptions } from '../api/client/@tanstack/react-query.gen'
import { scoreMyGak } from '../api/client/sdk.gen'
import type { MyGakRule, MyGakScore } from '../api/client/types.gen'
import { addMyGakMutation, deleteMyGakMutation, listMyGakOptions, listMyGakQueryKey, listPresetsOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { scoreMyGak } from '@nalssigak/shared/api/client/sdk.gen'
import type { MyGakRule, MyGakScore } from '@nalssigak/shared/api/client/types.gen'
import { useAuth } from './authContext'
import { useRegion } from './regionContext'
import { useSheet } from './sheetContext'
+2 -2
View File
@@ -1,7 +1,7 @@
import { useState } from 'react'
import { useMutation, useQueryClient } from '@tanstack/react-query'
import { likePostMutation, unlikePostMutation } from '../api/client/@tanstack/react-query.gen'
import type { PostReaction, ResFeed } from '../api/client/types.gen'
import { likePostMutation, unlikePostMutation } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import type { PostReaction, ResFeed } from '@nalssigak/shared/api/client/types.gen'
export type PinnedKey = 'hero_post' | 'gak_post' | 'foliage_post' | 'events_post' | 'season_post'
+2 -2
View File
@@ -1,8 +1,8 @@
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
import { useLocation, useNavigate } from 'react-router'
import regionPages from '../../seo/region.json'
import { nearestRegion } from '../api/client/sdk.gen'
import type { RegionData } from '../api/client/types.gen'
import { nearestRegion } from '@nalssigak/shared/api/client/sdk.gen'
import type { RegionData } from '@nalssigak/shared/api/client/types.gen'
import { track } from '../lib/analytics'
import { IS_TOSS, tossLocation } from '../lib/platform'
import { DEFAULT_REGION, ownPage, RegionContext, type LocateStatus } from './regionContext'
+2 -2
View File
@@ -1,12 +1,12 @@
import { createContext, use } from 'react'
import type { RegionData } from '@nalssigak/shared/api/client/types.gen'
import regionPages from '../../seo/region.json'
import type { RegionData } from '../api/client/types.gen'
export type LocateStatus = 'idle' | 'locating' | 'denied' | 'error'
export type RegionApi = { region: RegionData; setRegion: (r: RegionData) => void; locate: (onFound?: () => void) => void; locateStatus: LocateStatus }
export const DEFAULT_REGION: RegionData = { code: '1144000000', name: '서울 마포구', short_name: '마포구', lat: 37.56071, lon: 126.91053 }
export { DEFAULT_REGION } from '@nalssigak/shared/lib'
/** 구 하나만 보여 주는 지역 페이지: 일반 시군구, 또는 구로 나뉜 시의 구 페이지 */
export const ownPage = (code: string) => regionPages.find((p) => p.regions.length === 1 && p.regions[0].code === code)
+2 -2
View File
@@ -1,9 +1,9 @@
import type { Ref } from 'react'
import { createPortal } from 'react-dom'
import { cx } from '../lib/utils'
import type { TopIndex } from '../api/client/types.gen'
import type { TopIndex } from '@nalssigak/shared/api/client/types.gen'
import { LEAF_SHADOW, MAP_IMG, MAP_SRC, md, PROVINCE, PROVINCES, STAGE, type Spot } from './foliage'
import { MEDALS, type TimeKind } from './lib'
import { MEDALS, type TimeKind } from '@nalssigak/shared/lib'
import { Ic } from './ui'
/** 공유 이미지 전용 틀. 화면 밖에 그려 두고 보내기 때 이것만 찍는다 (화면의 버튼은 이미지에서 빠지므로 글자만으로 만든다) */
+1 -1
View File
@@ -1,5 +1,5 @@
import type { MyGak } from './myGakState'
import type { TalkData } from '../api/client/types.gen'
import type { TalkData } from '@nalssigak/shared/api/client/types.gen'
import type { WeatherWhyPayload } from './weatherWhy'
import { createContext, use } from 'react'
/** square: 1:1 비율일 때 slides 대신 찍을 틀 (없으면 slides) */
+1 -1
View File
@@ -1,5 +1,5 @@
import { createContext, use } from 'react'
import type { TimeKind } from './lib'
import type { TimeKind } from '@nalssigak/shared/lib'
/** 화면 전체 하늘 배경의 시간대. 히어로의 미리보기 버튼으로 고른 값은 탭을 옮겨도 유지된다 */
export type SkyApi = { kind: TimeKind; preview: TimeKind | null; setServerKind: (k: TimeKind | null) => void; setPreview: (k: TimeKind | null) => void }
+4 -4
View File
@@ -8,14 +8,14 @@ import {
likeTalkMutation,
reportTalkMutation,
unlikeTalkMutation,
} from '../api/client/@tanstack/react-query.gen'
import { uploadTalkImage } from '../api/client/sdk.gen'
import { TalkReport, TalkTopic, type TalkData } from '../api/client/types.gen'
} from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { uploadTalkImage } from '@nalssigak/shared/api/client/sdk.gen'
import { TalkReport, TalkTopic, type TalkData } from '@nalssigak/shared/api/client/types.gen'
import { API_BASE_URL } from '../api/setup'
import { IS_TOSS } from '../lib/platform'
import { cx } from '../lib/utils'
import { useAuth } from './authContext'
import { ago, kst } from './lib'
import { ago, kst } from '@nalssigak/shared/lib'
import { useRegion } from './regionContext'
import { topicName, TOPICS, useMyTalks } from './talkState'
import { useSheet } from './sheetContext'
+2 -2
View File
@@ -1,6 +1,6 @@
import { useInfiniteQuery, useQuery } from '@tanstack/react-query'
import { listMyTalksInfiniteOptions, listTalksInfiniteOptions, talkGroupsOptions } from '../api/client/@tanstack/react-query.gen'
import { TalkTopic, type TalkData } from '../api/client/types.gen'
import { listMyTalksInfiniteOptions, listTalksInfiniteOptions, talkGroupsOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { TalkTopic, type TalkData } from '@nalssigak/shared/api/client/types.gen'
import { useRegion } from './regionContext'
// 글 주제와 피드 묶음 이름
-1
View File
@@ -1 +0,0 @@
export type SlideBg = 'sky' | 'butter' | 'peach' | 'mint' | 'lilac' | 'dusk' | 'night'
+2 -1
View File
@@ -3,7 +3,8 @@ import { Link } from 'react-router'
import { IS_TOSS } from '../lib/platform'
import { cx } from '../lib/utils'
import { useCarousel, type Carousel } from './carousel'
import { AVATAR_COLORS, iconSrc, moodEmoji, naverMap, type Load } from './lib'
import { AVATAR_COLORS, moodEmoji, naverMap, type Load } from '@nalssigak/shared/lib'
import { iconSrc } from './lib'
type IcProps = { name: string; className?: string; alt?: string; style?: CSSProperties }
-19
View File
@@ -1,19 +0,0 @@
import { RainType, Sky, type WeatherSlot } from '../api/client/types.gen'
import { kst } from './lib'
const RAIN_TEXT: Partial<Record<RainType, string>> = { [RainType.RAIN]: '비', [RainType.SLEET]: '진눈깨비', [RainType.SNOW]: '눈', [RainType.SHOWER]: '소나기' }
const SKY_TEXT: Record<Sky, string> = { [Sky.CLEAR]: '맑음', [Sky.PARTLY]: '구름 많음', [Sky.CLOUDY]: '흐림' }
/** 칸 하나의 하늘 상태 한 마디: 비·눈이 오면 그걸, 아니면 하늘 */
export function skyText(slot: WeatherSlot) {
return (slot.rain_type != null && RAIN_TEXT[slot.rain_type]) || (slot.sky != null ? SKY_TEXT[slot.sky] : slot.note)
}
/** 주어진 시(0~23)를 넘지 않는 마지막 칸 */
export function slotAt(slots: WeatherSlot[], hour: number) {
let pick: WeatherSlot | undefined
for (const s of slots) if (kst(s.at).h <= hour) pick = s
return pick ?? slots[0]
}
export const deg = (v: number | null | undefined) => (v == null ? '?°' : `${Math.round(v)}°`)
+1 -1
View File
@@ -1,4 +1,4 @@
import type { WeatherWhy } from '../api/client/types.gen'
import type { WeatherWhy } from '@nalssigak/shared/api/client/types.gen'
import { cx } from '../lib/utils'
/** status: 히어로 상태 줄 그대로 (단계 이름, 실제 값) */