feat: 토스판은 로그인 없이 — 로그인 버튼·글쓰기 칸·글 더보기(신고·차단) 숨김, 두 번째 내 각은 안내만

This commit is contained in:
minaChoi committed 2026-10-24 18:28:21 +09:00
1 parent 9b1e32d620
commit 0144a64b42
3 files changed
+24 -55

No files matched your search

+2 -1
View File
@@ -2,6 +2,7 @@ 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 { IS_TOSS } from '../lib/platform'
import { cx } from '../lib/utils'
import { kindOfHour, kst, seasonOf, type TimeKind } from './lib'
import './b.css'
@@ -61,7 +62,7 @@ function TopBar() {
<PinIcon className="size-3.5 shrink-0" />
{locateStatus === 'locating' ? <Skel className="w-[72px]" /> : <span className="truncate whitespace-nowrap"><span className="max-[399px]:hidden">{region.name}</span><span className="min-[400px]:hidden">{region.name.split(' ').at(-1)}</span></span>}
</button>
{mePending ? (
{IS_TOSS ? null : mePending ? (
<Skel shape className="size-9 shrink-0 rounded-full" />
) : me ? (
<button type="button" onClick={() => open({ type: 'me' })} aria-label={`내 정보, ${me.nickname}`} className="shrink-0 cursor-pointer rounded-full shadow-[0_6px_12px_rgb(40_48_74/0.12)]">
+9 -49
View File
@@ -15,13 +15,12 @@ import {
listCommentsInfiniteQueryKey,
listRegionsOptions,
meQueryKey,
tossMutation,
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'
import { track } from '../lib/analytics'
import { IS_TOSS, tossLogin, tossShare } from '../lib/platform'
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'
@@ -835,7 +834,7 @@ function LoginSheet({ onDone, onLoggedIn }: { onDone: () => void; onLoggedIn: ()
const fail = () => setError('서버에 닿지 못했어요. 잠시 뒤에 다시 해 주세요.')
if (me) return <MeSheet onDone={onDone} />
if (IS_TOSS) return <TossLoginSheet onDone={onDone} onLoggedIn={onLoggedIn} />
if (IS_TOSS) return <TossNoLoginSheet onDone={onDone} />
return (
<Body>
@@ -859,52 +858,13 @@ function LoginSheet({ onDone, onLoggedIn }: { onDone: () => void; onLoggedIn: ()
)
}
/** 앱인토스는 토스 로그인만 쓸 수 있다 */
function TossLoginSheet({ onDone, onLoggedIn }: { onDone: () => void; onLoggedIn: () => void }) {
const [error, setError] = useState('')
const [opening, setOpening] = useState(false)
const toss = useMutation(tossMutation())
const pending = opening || toss.isPending
const start = async () => {
setError('')
setOpening(true)
let code: Awaited<ReturnType<typeof tossLogin>>
try {
code = await tossLogin()
} catch (e) {
console.error('[login] toss', e)
setError('토스 로그인을 마치지 못했어요. 한 번 더 눌러 주세요.')
return
} finally {
setOpening(false)
}
toss.mutate(
{ body: { authorization_code: code.authorizationCode, referrer: code.referrer } },
{
onSuccess: (res) => {
if (!res.result?.success || !res.access_token) return setError('토스 로그인을 마치지 못했어요. 한 번 더 눌러 주세요.')
setTokens(res.access_token, res.refresh_token ?? null)
track('login', { method: 'toss' })
onLoggedIn()
},
onError: () => setError('서버에 닿지 못했어요. 잠시 뒤에 다시 해 주세요.'),
},
)
}
/** 토스판은 로그인이 없다. 로그인이 필요한 곳(두 번째 내 각)에서 안내만 한다 */
function TossNoLoginSheet({ onDone }: { onDone: () => void }) {
return (
<Body className="flex flex-col gap-2.5">
<h3 className="m-0 text-center font-jua text-xl font-normal">날씨각 로그인</h3>
<p className="m-0 text-center text-sm font-semibold text-(--ink2)">로그인하면 동네 이야기를 쓰고 내 각을 저장할 수 있어요</p>
<p className="min-h-5 text-center text-[13px] font-bold text-(--heart)" aria-live="polite">
{error}
</p>
<button type="button" onClick={start} disabled={pending} className="cursor-pointer rounded-[14px] bg-(--orange) p-[13px] font-jua text-[17px] text-white shadow-[inset_0_-5px_0_var(--orange-deep)] disabled:opacity-60">
<Swap labels={['토스로 로그인', '로그인 중…']} at={pending ? 1 : 0} />
</button>
<button type="button" onClick={onDone} className="cursor-pointer rounded-[14px] p-[13px] text-[15px] font-extrabold text-(--ink2)">
나중에 할게요
<p className="m-0 text-center text-sm font-semibold text-(--ink2)">토스에서는 내 각을 하나만 만들 수 있어요. 지금 각을 지우고 새로 만들어 주세요.</p>
<button type="button" onClick={onDone} className="cursor-pointer rounded-[14px] bg-(--orange) p-[13px] font-jua text-[17px] text-white shadow-[inset_0_-5px_0_var(--orange-deep)]">
알겠어요
</button>
</Body>
)
@@ -1113,12 +1073,12 @@ function RegionSheet({ onDone }: { onDone: () => void }) {
</li>
))}
</ul>
<p className="mt-4 flex items-center justify-center gap-2 text-[13px] font-bold text-(--ink2)">
{!IS_TOSS && <p className="mt-4 flex items-center justify-center gap-2 text-[13px] font-bold text-(--ink2)">
{me ? `${me.nickname}(으)로 로그인했어요` : '로그인하면 좋아요·댓글을 쓸 수 있어요'}
<button type="button" onClick={me ? logout : () => open({ type: 'login' })} className="cursor-pointer font-extrabold text-(--rain)">
{me ? '로그아웃' : '로그인'}
</button>
</p>
</p>}
</Body>
)
}
+13 -5
View File
@@ -12,6 +12,7 @@ import {
import { uploadTalkImage } from '../api/client/sdk.gen'
import { TalkReport, TalkTopic, type TalkData } from '../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'
@@ -251,10 +252,15 @@ function TalkRow({ t, onGone, compact }: { t: TalkData; onGone?: () => void; com
)}
{t.image && !compact && <img src={src} alt="" loading="lazy" className="mt-2 aspect-[4/5] w-full rounded-2xl bg-[#eef4fc] object-cover" />}
<small className={cx('block text-xs font-bold text-(--ink3)', compact ? 'mt-auto pt-1.5' : 'mt-0.5')}>
{ago(t.created_at)} · 좋아요 {count}개 ·{' '}
<button type="button" onClick={() => setMenu(menu === 'closed' ? 'open' : 'closed')} aria-expanded={menu !== 'closed'} className="cursor-pointer font-bold text-(--ink3)">
{t.mine ? '내 글' : '더보기'}
</button>
{ago(t.created_at)} · 좋아요 {count}개
{!IS_TOSS && (
<>
{' · '}
<button type="button" onClick={() => setMenu(menu === 'closed' ? 'open' : 'closed')} aria-expanded={menu !== 'closed'} className="cursor-pointer font-bold text-(--ink3)">
{t.mine ? '내 글' : '더보기'}
</button>
</>
)}
</small>
{menu !== 'closed' && (
<div className="mt-1.5 flex flex-wrap gap-1.5 text-[12.5px] font-extrabold" role="group" aria-label="글 메뉴">
@@ -298,6 +304,7 @@ function TalkRow({ t, onGone, compact }: { t: TalkData; onGone?: () => void; com
/** 이야기 탭: 쓰기 칸과 전국 최신 글 (아래로 더 받기) */
/** 피드 위 쓰는 칸. 늘 펼쳐 두고, 방금 올린 글은 바로 아래에 보인다 (피드 사이 글은 새로 받을 때 섞인다) */
export function FeedComposer({ onPosted }: { onPosted: (t: TalkData) => void }) {
if (IS_TOSS) return null
return (
<div className="mt-3.5">
<Composer onDone={onPosted} />
@@ -367,7 +374,8 @@ export function FirstTalkCard() {
/** '동네 사람들' 자리: 글이 GROUP_MIN 개 이상이면 묶음, 아니면 첫 글 쓰기 */
export function NearTalks({ talks, loaded }: { talks: TalkData[]; loaded: boolean }) {
if (!loaded) return null
return talks.length >= GROUP_MIN ? <TalkGroup title="동네 사람들" talks={talks} /> : <FirstTalkCard />
if (talks.length >= GROUP_MIN) return <TalkGroup title="동네 사람들" talks={talks} />
return IS_TOSS ? null : <FirstTalkCard />
}
/** 내 정보 창의 내가 쓴 글 */