-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSigninModal.tsx
More file actions
71 lines (69 loc) · 2.3 KB
/
SigninModal.tsx
File metadata and controls
71 lines (69 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { GitHubIcon, GoogleIcon, Loading } from '@shared/components/Icons';
import { Modal, Stack, Button } from '@jdesignlab/react';
import { useMachine } from '@xstate/react';
import { Mail } from '@jdesignlab/react-icons';
import { EmailPasswordForm } from './action/EmailPasswordForm';
import { useSigninWithProvider } from '../hooks/useSigninWithProvider';
import { signMachine } from '../machines/signMachine';
export const SigninModal = () => {
const [state, send, service] = useMachine(signMachine);
const { value: signState, history } = state;
const openState = signState !== 'done' && !!history;
const { isLoading: loadingGithub, mutate: signinGithub } = useSigninWithProvider('GITHUB', send);
const { isLoading: loadingGoogle, mutate: signinGoogle } = useSigninWithProvider('GOOGLE', send);
return (
<Modal
open={openState}
hasCloseIcon
onClose={() => {
send('CLEAR');
}}
>
<Modal.Trigger>
<Button variant="outline" color="primary-500">
로그인
</Button>
</Modal.Trigger>
<Modal.Header>로그인</Modal.Header>
<Modal.Body>
{signState === 'selection' && (
<Stack direction="vertical">
<Button
color="primary-500"
variant="outline"
icon={<Mail />}
onClick={() => {
send('EMAIL');
}}
>
Email로 로그인
</Button>
<Button
color="primary-500"
variant="outline"
onClick={() => {
signinGithub();
}}
disabled={loadingGithub}
icon={loadingGithub ? <Loading /> : <GitHubIcon />}
>
GitHub 계정으로 로그인
</Button>
<Button
color="primary-500"
variant="outline"
disabled={loadingGoogle}
icon={loadingGoogle ? <Loading /> : <GoogleIcon />}
onClick={() => {
signinGoogle();
}}
>
Google 계정으로 로그인
</Button>
</Stack>
)}
{signState === 'email' && <EmailPasswordForm signMachine={service} signup={false} />}
</Modal.Body>
</Modal>
);
};