From dd133c9d5284120f8bb2547cc88a95381ffb5e21 Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Tue, 27 Oct 2026 14:49:41 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=B0=BD?= =?UTF-8?q?=20=EA=B5=AC=EA=B8=80=20=EB=B2=84=ED=8A=BC=20=EC=9E=90=EB=A6=AC?= =?UTF-8?q?=EC=97=90=20=EC=8A=A4=EC=BC=88=EB=A0=88=ED=86=A4=20=E2=80=94=20?= =?UTF-8?q?=EB=B9=88=EC=B9=B8=EC=97=90=20=EB=B2=84=ED=8A=BC=EC=9D=B4=20?= =?UTF-8?q?=EB=8A=A6=EA=B2=8C=20=ED=88=AD=20=ED=8A=80=EC=96=B4=EB=82=98?= =?UTF-8?q?=EC=99=80=20=EB=B2=84=EB=B2=85=EC=9D=B4=EB=8A=94=20=EA=B2=83?= =?UTF-8?q?=EC=B2=98=EB=9F=BC=20=EB=B3=B4=EC=9D=B4=EB=8D=98=20=EA=B2=83,?= =?UTF-8?q?=20=EB=8B=A4=20=EA=B7=B8=EB=A0=A4=EC=A7=80=EB=A9=B4=20=EB=B6=80?= =?UTF-8?q?=EB=93=9C=EB=9F=BD=EA=B2=8C=20=EB=B0=94=EA=BF=94=20=EB=B3=B4?= =?UTF-8?q?=EC=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/b/googleLogin.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/src/b/googleLogin.tsx b/frontend/src/b/googleLogin.tsx index 6d8ba9d..c2b8886 100644 --- a/frontend/src/b/googleLogin.tsx +++ b/frontend/src/b/googleLogin.tsx @@ -2,15 +2,20 @@ import { useMutation, useQuery } from '@tanstack/react-query' import { useEffect, useRef, useState } from 'react' import { authConfigOptions, googleLoginMutation } from '@nalssigak/shared/api/client/@tanstack/react-query.gen' import type { ResAuth } from '@nalssigak/shared/api/client/types.gen' +import { cx } from '../lib/utils' import { loadGoogle } from './googleScript' import { SHEET_OPEN_MS } from './lib' +import { Skel } from './ui' /** 구글로 계속하기 버튼. 서버에 클라이언트 ID가 없으면 아무것도 그리지 않는다 */ export function GoogleButton({ onResult, onFail }: { onResult: (res: ResAuth) => void; onFail: () => void }) { - const clientId = useQuery({ ...authConfigOptions(), staleTime: Infinity }).data?.google_client_id + const config = useQuery({ ...authConfigOptions(), staleTime: Infinity }) + const clientId = config.data?.google_client_id const login = useMutation(googleLoginMutation()) const box = useRef(null) const [broken, setBroken] = useState(false) + // 구글 버튼(iframe)이 다 그려지기 전엔 같은 크기의 스켈레톤을 보여 준다. 빈칸에 버튼이 툭 튀어나오면 버벅이는 것처럼 보여서 + const [ready, setReady] = useState(false) const { mutate } = login // 로그인 창이 다시 그려질 때마다 버튼을 새로 만들지 않게 콜백은 ref 로 들고 있는다 const cb = useRef({ onResult, onFail }) @@ -35,6 +40,9 @@ export function GoogleButton({ onResult, onFail }: { onResult: (res: ResAuth) => }, }) g.renderButton(box.current, { theme: 'outline', size: 'large', shape: 'pill', text: 'continue_with', locale: 'ko', width: box.current.offsetWidth }) + const frame = box.current.querySelector('iframe') + if (frame) frame.addEventListener('load', () => alive && setReady(true), { once: true }) + else setReady(true) }, (e: unknown) => { console.error('[google] script', e) @@ -46,10 +54,14 @@ export function GoogleButton({ onResult, onFail }: { onResult: (res: ResAuth) => } }, [clientId, mutate]) + if (config.isPending) return if (!clientId) return null return (
-
+
+ {!ready && !broken && } +
+
{broken &&

구글 로그인을 불러오지 못했어요. 잠시 뒤에 다시 해 주세요.

}
)