-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignupModal.tsx
More file actions
39 lines (37 loc) · 1.19 KB
/
SignupModal.tsx
File metadata and controls
39 lines (37 loc) · 1.19 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
import { Modal, Button } from '@jdesignlab/react';
import { useMachine } from '@xstate/react';
import { UserProfileForm } from './action/UserProfileForm';
import { EmailPasswordForm } from './action/EmailPasswordForm';
import { signMachine } from '../machines/signMachine';
import { useSetUserAuthData } from '../hooks/useSetUserAuthData';
export const SignupModal = () => {
const [state, send, service] = useMachine(signMachine);
const { value: signState, history, context } = state;
const openFlag = signState !== 'done' && !!history;
const userInfo = context.user;
const { updateUserData } = useSetUserAuthData();
return (
<Modal
open={openFlag}
hasCloseIcon
onClose={() => {
if (userInfo) {
updateUserData(userInfo);
}
send('CLEAR');
}}
>
<Modal.Trigger>
<Button color="primary-500">회원가입</Button>
</Modal.Trigger>
<Modal.Header>회원가입</Modal.Header>
<Modal.Body>
{signState === 'registry' ? (
<UserProfileForm signupMachineRef={service} />
) : (
<EmailPasswordForm signMachine={service} signup />
)}
</Modal.Body>
</Modal>
);
};