Skip to content

Commit 825f727

Browse files
committed
feat : 모바일 UI에 로그인 기능 추가
1 parent a5f0901 commit 825f727

File tree

1 file changed

+38
-9
lines changed
  • apps/pyconkr/src/components/layout/SignInButton

1 file changed

+38
-9
lines changed

apps/pyconkr/src/components/layout/SignInButton/index.tsx

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Shop from "@frontend/shop";
2-
import { Login } from "@mui/icons-material";
2+
import { Login, Logout } from "@mui/icons-material";
33
import { Button, Stack } from "@mui/material";
44
import { ErrorBoundary, Suspense } from "@suspensive/react";
55
import { useNavigate } from "react-router-dom";
@@ -12,15 +12,32 @@ type InnerSignInButtonImplPropType = {
1212
onSignOut?: () => void;
1313
isMobile?: boolean;
1414
isMainPath?: boolean;
15+
onClose?: () => void;
1516
};
1617

17-
const InnerSignInButtonImpl: React.FC<InnerSignInButtonImplPropType> = ({ loading, signedIn, onSignOut, isMobile = false, isMainPath = true }) => {
18+
const InnerSignInButtonImpl: React.FC<InnerSignInButtonImplPropType> = ({
19+
loading,
20+
signedIn,
21+
onSignOut,
22+
isMobile = false,
23+
isMainPath = true,
24+
onClose,
25+
}) => {
1826
const navigate = useNavigate();
1927
const { language } = useAppContext();
2028

2129
const signInBtnStr = language === "ko" ? "로그인" : "Sign In";
2230
const signOutBtnStr = language === "ko" ? "로그아웃" : "Sign Out";
2331

32+
const handleClick = () => {
33+
if (signedIn) {
34+
onSignOut?.();
35+
} else {
36+
onClose?.();
37+
navigate("/account/sign-in");
38+
}
39+
};
40+
2441
if (isMobile) {
2542
return (
2643
<Button
@@ -39,10 +56,10 @@ const InnerSignInButtonImpl: React.FC<InnerSignInButtonImplPropType> = ({ loadin
3956
},
4057
}}
4158
loading={loading}
42-
onClick={() => (signedIn ? onSignOut?.() : navigate("/account/sign-in"))}
59+
onClick={handleClick}
4360
>
44-
<Stack direction="row" alignItems="center" spacing={0.5}>
45-
<Login fontSize="small" />
61+
<Stack direction="row" alignItems="center" sx={{ gap: "3px" }}>
62+
{signedIn ? <Logout fontSize="small" /> : <Login fontSize="small" />}
4663
{signedIn ? signOutBtnStr : signInBtnStr}
4764
</Stack>
4865
</Button>
@@ -60,15 +77,27 @@ const InnerSignInButtonImpl: React.FC<InnerSignInButtonImplPropType> = ({ loadin
6077
);
6178
};
6279

63-
export const SignInButton: React.FC<{ isMobile?: boolean; isMainPath?: boolean }> = ({ isMobile = false, isMainPath = true }) => {
80+
export const SignInButton: React.FC<{ isMobile?: boolean; isMainPath?: boolean; onClose?: () => void }> = ({
81+
isMobile = false,
82+
isMainPath = true,
83+
onClose,
84+
}) => {
6485
const SignInWithErrorBoundary = ErrorBoundary.with(
65-
{ fallback: <InnerSignInButtonImpl isMobile={isMobile} isMainPath={isMainPath} /> },
66-
Suspense.with({ fallback: <InnerSignInButtonImpl loading isMobile={isMobile} isMainPath={isMainPath} /> }, () => {
86+
{ fallback: <InnerSignInButtonImpl isMobile={isMobile} isMainPath={isMainPath} onClose={onClose} /> },
87+
Suspense.with({ fallback: <InnerSignInButtonImpl loading isMobile={isMobile} isMainPath={isMainPath} onClose={onClose} /> }, () => {
6788
const shopAPIClient = Shop.Hooks.useShopClient();
6889
const signOutMutation = Shop.Hooks.useSignOutMutation(shopAPIClient);
6990
const { data } = Shop.Hooks.useUserStatus(shopAPIClient);
7091

71-
return <InnerSignInButtonImpl signedIn={data !== null} onSignOut={signOutMutation.mutate} isMobile={isMobile} isMainPath={isMainPath} />;
92+
return (
93+
<InnerSignInButtonImpl
94+
signedIn={data !== null}
95+
onSignOut={signOutMutation.mutate}
96+
isMobile={isMobile}
97+
isMainPath={isMainPath}
98+
onClose={onClose}
99+
/>
100+
);
72101
})
73102
);
74103

0 commit comments

Comments
 (0)