@jsb188/auth-web 1.1.3 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,712 @@
1
+ import { APP_EMAILS } from '@jsb188/app/constants/app.ts';
2
+ import i18n from '@jsb188/app/i18n/index.ts';
3
+ import { useCheckUsernameOrEmail, useConfirmPhoneVerificationCode, useRequestTokenizedEmail, useSendPhoneVerificationCode, useSignUpWithEmail } from '@jsb188/graphql/hooks/use-auth-mtn';
4
+ import { SMSCodeInput } from '@jsb188/react-web/modules/Form';
5
+ import SchemaForm from '@jsb188/react-web/modules/SchemaForm';
6
+ import { FullWidthButton } from '@jsb188/react-web/ui/Button';
7
+ import { FormBreak } from '@jsb188/react-web/ui/Form';
8
+ import Markdown, { TextWithLinks } from '@jsb188/react-web/ui/Markdown';
9
+ import { ModalErrorMessage, ModalSimpleContent } from '@jsb188/react-web/ui/ModalUI';
10
+ import { useMemo, useState } from 'react';
11
+ import { Link, useNavigate } from 'react-router';
12
+ import type { AuthPageName } from './_helpers';
13
+ import { getAuthRoute, persistSignInSession } from './_helpers';
14
+ import { SsoSignIn } from './AuthForms-SSO';
15
+ import { ContinueWithGoogle, ContinueWithMicrosoft, ContinueWithPhone, ContinueWithSso } from './OtherAuthButtons';
16
+ import { makeRequestTokenizedEmailSchema, makeSendPhoneVerificationSchema, makeSignInSchema, makeSignUpSchema } from './schemas';
17
+
18
+ /**
19
+ * Page meta tags
20
+ */
21
+
22
+ export const meta = [{
23
+ title: i18n.t('app.route_', { text: i18n.t('app.route_auth') })
24
+ }];
25
+
26
+ /**
27
+ * Sign in form (main screen)
28
+ */
29
+
30
+ interface AuthFormProps {
31
+ appNamespace: string;
32
+ initialError?: any;
33
+ initialFormData?: any;
34
+ authRoutesMap?: Record<AuthPageName, string>;
35
+ setAuthIface: (iface: SignInIface | null) => void;
36
+
37
+ // Check if needed still
38
+ onError?: (error: any) => void;
39
+ }
40
+
41
+ function SignInMain(p: AuthFormProps) {
42
+ const { authRoutesMap, initialError, initialFormData, setAuthIface } = p;
43
+ const navigate = useNavigate();
44
+ const [waitingForPostRequest, setWaitingForPostRequest] = useState(false);
45
+ const signInSchema = useMemo(makeSignInSchema, []);
46
+ const { saving, checkUsernameOrEmail, dataForSchema, setDataForSchema, error, setError, resetErrors } = useCheckUsernameOrEmail({
47
+ initialError,
48
+ initialFormData
49
+ });
50
+
51
+ const hidePassword = dataForSchema.hidePassword;
52
+ const onFormValuesChange = (formValues: any, _currentValues: any, setFormValues: (val: any) => void) => {
53
+ const hasInput = !!formValues.identifier?.trim();
54
+ if (
55
+ !hidePassword &&
56
+ formValues.identifier !== dataForSchema.lastIdentifier
57
+ ) {
58
+ setDataForSchema({
59
+ ...dataForSchema,
60
+ hasInput,
61
+ lastIdentifier: '',
62
+ hidePassword: true,
63
+ });
64
+
65
+ setFormValues({
66
+ ...formValues,
67
+ password: '',
68
+ });
69
+ } else if (hasInput !== dataForSchema.hasInput) {
70
+ setDataForSchema({
71
+ ...dataForSchema,
72
+ hasInput,
73
+ });
74
+ }
75
+ };
76
+
77
+ async function onSubmit(formValues: any, _currentValues: any, setFormValues: any) {
78
+ const identifier = formValues.identifier?.trim();
79
+ if (hidePassword) {
80
+ const { checkUsernameOrEmail: result } = await checkUsernameOrEmail({
81
+ variables: {
82
+ usernameOrEmail: identifier,
83
+ authCheck: true,
84
+ },
85
+ });
86
+
87
+ switch (result?.type) {
88
+ case 'PHONE': {
89
+ if (!result.taken) {
90
+ setError({
91
+ message: i18n.t('auth.no_account_with_phone'),
92
+ });
93
+ return false;
94
+ } else if (result?.hasPassword === false) {
95
+ setAuthIface('VERIFY_PHONE');
96
+ return false;
97
+ }
98
+ // Do this if you want to redirect to sign up
99
+ // setScreen({
100
+ // name: 'sign_up',
101
+ // email: result.value,
102
+ // });
103
+ // return false;
104
+ } break;
105
+ case 'EMAIL': {
106
+ if (!result.taken) {
107
+ setError({
108
+ message: i18n.t('auth.no_account_with_email'),
109
+ });
110
+ // Do this if you want to redirect to sign up
111
+ // setScreen({
112
+ // name: 'sign_up',
113
+ // email: result.value,
114
+ // });
115
+ return false;
116
+ }
117
+ } break;
118
+ default:
119
+ // This auth type is not supported
120
+ console.dev('Unknown auth type:', result);
121
+
122
+ if (result?.type) {
123
+ setError({
124
+ message: i18n.t('auth.not_valid_email_or_phone'),
125
+ });
126
+ }
127
+ return false;
128
+ }
129
+
130
+ setDataForSchema({
131
+ ...dataForSchema,
132
+ lastIdentifier: identifier || '',
133
+ hidePassword: !result?.taken,
134
+ });
135
+
136
+ setFormValues({
137
+ ...formValues,
138
+ identifier: identifier || '',
139
+ });
140
+ } else if (formValues.password && identifier) {
141
+ setWaitingForPostRequest(true);
142
+ return true; // "Do" post form
143
+ }
144
+
145
+ return false; // Do not post form
146
+ }
147
+
148
+ const showSignUpLink = hidePassword && !error;
149
+
150
+ const onFinishSignIn = async (token: string, sessionBootstrapToken?: string | null, sessionPersisted?: boolean) => {
151
+ const persisted = sessionPersisted || await persistSignInSession(token, sessionBootstrapToken);
152
+ if (!persisted) {
153
+ setError({
154
+ message: i18n.t('error.network_error'),
155
+ });
156
+ return false;
157
+ }
158
+ navigate(getAuthRoute('signin_success', authRoutesMap));
159
+ return true;
160
+ };
161
+
162
+ return (
163
+ <>
164
+ <ContinueWithGoogle onFinishSignIn={onFinishSignIn} />
165
+ <ContinueWithMicrosoft onFinishSignIn={onFinishSignIn} />
166
+ <ContinueWithSso onClickButton={() => setAuthIface('SSO')} />
167
+ <ContinueWithPhone onClickButton={() => setAuthIface('VERIFY_PHONE')} />
168
+
169
+ <FormBreak className='mt_md' colorClassName='strong_bf'>
170
+ {i18n.t('form.or')}
171
+ </FormBreak>
172
+
173
+ <SchemaForm
174
+ doNotPostForm={fv => !fv.identifier || !fv.password}
175
+ httpMethod='post'
176
+ actionUrl={getAuthRoute('signin', authRoutesMap)}
177
+ className='py_df'
178
+ currentData={{ identifier: initialFormData?.identifier || '' }}
179
+ saving={saving || waitingForPostRequest}
180
+ schema={signInSchema}
181
+ dataForSchema={dataForSchema}
182
+ onSubmit={onSubmit}
183
+ onFormValuesChange={onFormValuesChange}
184
+ >
185
+ <input type='hidden' name='managedSessionVersion' value='1' />
186
+ {error && (
187
+ <ModalErrorMessage
188
+ error={error}
189
+ resetErrors={resetErrors}
190
+ // className='mt_sm'
191
+ />
192
+ )}
193
+ </SchemaForm>
194
+
195
+ <div className='a_c'>
196
+ {showSignUpLink
197
+ ? <Link
198
+ className='text ft_sm cl_md link'
199
+ to={getAuthRoute('signup', authRoutesMap)}
200
+ replace
201
+ >
202
+ {i18n.t('auth.signup_email')}
203
+ </Link>
204
+ : <button
205
+ className='text ft_sm cl_md link'
206
+ onClick={() => setAuthIface('REQUEST_PASSWORD_RESET')}
207
+ >
208
+ {i18n.t('auth.forgot_password_')}
209
+ </button>}
210
+ </div>
211
+ </>
212
+ );
213
+ }
214
+
215
+ /**
216
+ * Forgot password form
217
+ */
218
+
219
+ interface RequestTokenizedEmailProps extends AuthFormProps {
220
+ requestType: 'PASSWORD_RESET' | 'EMAIL_VERIFICATION';
221
+ }
222
+
223
+ function RequestTokenizedEmail(p: RequestTokenizedEmailProps) {
224
+ const { requestType, initialFormData, setAuthIface } = p;
225
+ const [error, setError] = useState<any>(null);
226
+ const initialEmailAddress = initialFormData?.identifier || '';
227
+ const onSuccess = (_emailAddress: string) => setAuthIface('EMAIL_SENT');
228
+
229
+ const tokenizedEmailSchema = useMemo(() => {
230
+ const schema = makeRequestTokenizedEmailSchema();
231
+ if (!initialEmailAddress) {
232
+ return schema;
233
+ }
234
+
235
+ return {
236
+ ...schema,
237
+ listData: schema.listData.map((obj) => {
238
+ if (obj.item.name === 'email') {
239
+ return {
240
+ ...obj,
241
+ item: {
242
+ ...obj.item,
243
+ placeholder: initialEmailAddress
244
+ }
245
+ };
246
+ }
247
+
248
+ return obj;
249
+ }),
250
+ };
251
+ }, []);
252
+
253
+ // Data hook
254
+
255
+ const { requestTokenizedEmail, saving } = useRequestTokenizedEmail({
256
+ onCompleted: (data: any, _: any, variables: any) => {
257
+ const success = data?.requestTokenizedEmail;
258
+ if (success) {
259
+ onSuccess(variables.email);
260
+ }
261
+ },
262
+ onError: (err: any) => {
263
+ setError(err);
264
+ }
265
+ });
266
+
267
+ const onSubmit = (fv: any) => {
268
+ requestTokenizedEmail({
269
+ variables: {
270
+ ...fv,
271
+ requestType
272
+ }
273
+ });
274
+ };
275
+
276
+ let instructionText;
277
+ switch (requestType) {
278
+ case 'PASSWORD_RESET':
279
+ instructionText = i18n.t('auth.request_reset_password_instr');
280
+ break;
281
+ case 'EMAIL_VERIFICATION':
282
+ instructionText = i18n.t('auth.resend_verification_instr');
283
+ break;
284
+ default:
285
+ }
286
+
287
+ return (
288
+ <SchemaForm
289
+ saving={saving}
290
+ schema={tokenizedEmailSchema}
291
+ currentData={{ email: initialEmailAddress || '' }}
292
+ onError={setError}
293
+ onSubmit={onSubmit}
294
+ buttonText={i18n.t('auth.resend_verification')}
295
+ >
296
+ {!error ? null : (
297
+ <ModalErrorMessage
298
+ error={error}
299
+ resetErrors={() => setError(null)}
300
+ />
301
+ )}
302
+
303
+ <Markdown as='p' className={error ? 'py_xs a_c' : '-mt_5 pb_xs a_c'}>
304
+ {instructionText}
305
+ </Markdown>
306
+ </SchemaForm>
307
+ );
308
+ }
309
+
310
+ /**
311
+ * Request for password reset is completed
312
+ */
313
+
314
+ function ResetPasswordCompleted(p: AuthFormProps) {
315
+ const { initialFormData } = p;
316
+ const emailAddress = initialFormData?.identifier;
317
+ const supportEmail = APP_EMAILS.support;
318
+
319
+ // Because this screen is opened by a client-side fetch, emailAddress will not always be present;
320
+ // Only way to have the used email address here is if we used POST form request.
321
+
322
+ return <ModalSimpleContent
323
+ title={i18n.t('auth.email_sent')}
324
+ iconName='circle-check'
325
+ >
326
+ <TextWithLinks as='p'>
327
+ {i18n.t(emailAddress
328
+ ? 'auth.reset_password_requested_msg'
329
+ : 'auth.reset_password_requested_msg_no_email'
330
+ , { emailAddress })}
331
+ </TextWithLinks>
332
+ <TextWithLinks as='p'>
333
+ {i18n.t('auth.if_need_more_help_email', { emailAddress: supportEmail })}
334
+ </TextWithLinks>
335
+ </ModalSimpleContent>;
336
+ }
337
+
338
+ /**
339
+ * Request phone verification
340
+ */
341
+
342
+ function SendPhoneVerification(p: AuthFormProps) {
343
+ const { setAuthIface } = p;
344
+ const sendPhoneVerificationSchema = useMemo(() => makeSendPhoneVerificationSchema(), []);
345
+
346
+ // Data hook
347
+
348
+ const { sendPhoneVerificationCode, saving, error, setError, resetErrors } = useSendPhoneVerificationCode({
349
+ onCompleted: (data: any, _: any, variables: any) => {
350
+ const success = data?.sendPhoneVerificationCode;
351
+ if (success) {
352
+ setAuthIface(['VERIFY_PHONE_SENT', variables.phone]);
353
+ }
354
+ },
355
+ onError: (err: any) => {
356
+ setError(err);
357
+ }
358
+ });
359
+
360
+ const onSubmit = (fv: any) => {
361
+ sendPhoneVerificationCode({
362
+ variables: {
363
+ phone: fv.phone,
364
+ }
365
+ });
366
+ };
367
+
368
+ return <>
369
+ <SchemaForm
370
+ className='mb_df'
371
+ saving={saving}
372
+ schema={sendPhoneVerificationSchema}
373
+ onError={setError}
374
+ onSubmit={onSubmit}
375
+ buttonText={i18n.t('auth.send_verification_code')}
376
+ >
377
+ {!error ? null : (
378
+ <ModalErrorMessage
379
+ error={error}
380
+ resetErrors={resetErrors}
381
+ />
382
+ )}
383
+
384
+ <p className={error ? 'py_xs a_c' : '-mt_5 pb_xs a_c'}>
385
+ {i18n.t('auth.send_verification_code_msg')}
386
+ </p>
387
+ </SchemaForm>
388
+
389
+ <div className='a_c h_center'>
390
+ <button
391
+ disabled={saving}
392
+ onClick={() => setAuthIface(null)}
393
+ className='text ft_sm cl_md link'
394
+ >
395
+ {i18n.t('auth.sign_in_other_methods')}
396
+ </button>
397
+ </div>
398
+ </>;
399
+ }
400
+
401
+ /**
402
+ * Confirm phone verification code (after it was sent)
403
+ */
404
+
405
+ interface ConfirmPhoneVerificationCodeProps extends AuthFormProps {
406
+ phoneNumber: string;
407
+ }
408
+
409
+ function ConfirmPhoneVerificationCode(p: ConfirmPhoneVerificationCodeProps) {
410
+ const { setAuthIface, phoneNumber, authRoutesMap } = p;
411
+ const [retryCount, setRetryCount] = useState(0);
412
+ const navigate = useNavigate();
413
+
414
+ // Data hook
415
+
416
+ const { confirmPhoneVerificationCode, saving, error, setError, resetErrors } = useConfirmPhoneVerificationCode({
417
+ onCompleted: async (data: any, _: any) => {
418
+ const { success, token } = data?.confirmPhoneVerificationCode || {};
419
+
420
+ if (success && token) {
421
+ const persisted = await persistSignInSession(token);
422
+ if (!persisted) {
423
+ setError({
424
+ message: i18n.t('error.network_error'),
425
+ });
426
+ return;
427
+ }
428
+ navigate(getAuthRoute('signin_success', authRoutesMap));
429
+ } else {
430
+ setRetryCount(retryCount + 1);
431
+ setError({
432
+ message: i18n.t('auth.verification_code_wrong')
433
+ })
434
+ }
435
+ }
436
+ });
437
+
438
+ const onSubmit = (code: string) => {
439
+ confirmPhoneVerificationCode({
440
+ variables: {
441
+ phone: phoneNumber,
442
+ code
443
+ }
444
+ });
445
+ }
446
+
447
+ return <>
448
+ {!error ? null : (
449
+ <ModalErrorMessage
450
+ error={error}
451
+ resetErrors={resetErrors}
452
+ />
453
+ )}
454
+ <SMSCodeInput
455
+ key={retryCount}
456
+ saving={saving}
457
+ error={error}
458
+ onSubmit={onSubmit}
459
+ />
460
+ <p className='a_c p_n mt_md mb_df rel'>
461
+ {i18n.t('auth.confirm_verification_code_instr')}
462
+ </p>
463
+ <div className='a_c h_center'>
464
+ <button
465
+ disabled={saving}
466
+ onClick={() => setAuthIface('VERIFY_PHONE')}
467
+ className='text ft_sm cl_md link'
468
+ >
469
+ {i18n.t('auth.resend_verification_code')}
470
+ </button>
471
+ </div>
472
+ </>;
473
+ }
474
+
475
+ /**
476
+ * Sign in form
477
+ */
478
+
479
+ type SignInIface = 'REQUEST_PASSWORD_RESET' | 'SSO' | 'VERIFY_PHONE' | 'VERIFY_EMAIL' | 'EMAIL_SENT' | 'VERIFY_PHONE_SENT' | ['VERIFY_PHONE_SENT', string];
480
+
481
+ export function SignInForm(p: Omit<AuthFormProps, 'setAuthIface'>) {
482
+ const { initialError } = p;
483
+ const errCode = initialError?.errorCode;
484
+ const initialIface = errCode === '20053' ? 'VERIFY_PHONE' : errCode === '20049' ? 'VERIFY_EMAIL' : null;
485
+ const [signInIface_, setAuthIface] = useState<SignInIface | null>(initialIface);
486
+ const ifaceIsArray = Array.isArray(signInIface_);
487
+
488
+ switch (ifaceIsArray ? signInIface_[0] : signInIface_) {
489
+ case 'SSO':
490
+ // Email-first SSO sign in (org home realm discovery)
491
+ return <SsoSignIn
492
+ {...p}
493
+ setAuthIface={setAuthIface}
494
+ />;
495
+ case 'VERIFY_PHONE':
496
+ // Attempted phone login but it was not verified
497
+ return <SendPhoneVerification
498
+ {...p}
499
+ setAuthIface={setAuthIface}
500
+ />;
501
+ case 'VERIFY_PHONE_SENT':
502
+ // User requested phone verification code, and it was sent
503
+ return <ConfirmPhoneVerificationCode
504
+ {...p}
505
+ phoneNumber={ifaceIsArray ? signInIface_[1] : ''}
506
+ setAuthIface={setAuthIface}
507
+ />;
508
+ case 'VERIFY_EMAIL':
509
+ // Attempted email login but it was not verified
510
+ return <RequestTokenizedEmail
511
+ {...p}
512
+ requestType='EMAIL_VERIFICATION'
513
+ setAuthIface={setAuthIface}
514
+ />;
515
+ case 'REQUEST_PASSWORD_RESET':
516
+ return <RequestTokenizedEmail
517
+ {...p}
518
+ requestType='PASSWORD_RESET'
519
+ setAuthIface={setAuthIface}
520
+ />;
521
+ case 'EMAIL_SENT':
522
+ return <ResetPasswordCompleted
523
+ {...p}
524
+ setAuthIface={setAuthIface}
525
+ />;
526
+ default:
527
+ }
528
+
529
+ return <SignInMain
530
+ {...p}
531
+ setAuthIface={setAuthIface}
532
+ />;
533
+ }
534
+
535
+ /**
536
+ * Sign up main form
537
+ */
538
+
539
+ interface SignUpMainProps extends Omit<AuthFormProps, 'setAuthIface'> {
540
+ setAuthIface: (iface: SignUpIface) => void;
541
+ setSignUpToken: (token: string | null) => void;
542
+ }
543
+
544
+ function SignUpMain(p: SignUpMainProps) {
545
+ const { authRoutesMap, initialError, setAuthIface, setSignUpToken } = p;
546
+ const navigate = useNavigate();
547
+ const signUpSchema = useMemo(makeSignUpSchema, []);
548
+
549
+ const { saving, signUpWithEmail, error, setError, resetErrors } = useSignUpWithEmail({
550
+ initialError,
551
+ onCompleted: (data: any, _: any) => {
552
+ const signUpToken = data?.signUpWithEmail;
553
+
554
+ if (signUpToken) {
555
+ setSignUpToken(signUpToken);
556
+ }
557
+ },
558
+ onError: (err: any) => {
559
+ if (err?.errorCode === '20054') {
560
+ setAuthIface('INVITATION_REQUIRED');
561
+ }
562
+ }
563
+ });
564
+
565
+ const onSubmit = async(formValues: any) => {
566
+ signUpWithEmail({
567
+ variables: {
568
+ emailAddress: formValues.email,
569
+ password: formValues.password,
570
+ }
571
+ });
572
+ };
573
+
574
+ // SSO providers auto-create accounts, so they work as sign up too
575
+ const onFinishSignIn = async (token: string, sessionBootstrapToken?: string | null, sessionPersisted?: boolean) => {
576
+ const persisted = sessionPersisted || await persistSignInSession(token, sessionBootstrapToken);
577
+ if (!persisted) {
578
+ setError({
579
+ message: i18n.t('error.network_error'),
580
+ });
581
+ return false;
582
+ }
583
+ navigate(getAuthRoute('signin_success', authRoutesMap));
584
+ return true;
585
+ };
586
+
587
+ return (
588
+ <>
589
+ <ContinueWithGoogle onFinishSignIn={onFinishSignIn} />
590
+ <ContinueWithMicrosoft onFinishSignIn={onFinishSignIn} />
591
+
592
+ <FormBreak className='mt_md' colorClassName='strong_bf'>
593
+ {i18n.t('form.or')}
594
+ </FormBreak>
595
+
596
+ <SchemaForm
597
+ className='py_df'
598
+ saving={saving}
599
+ schema={signUpSchema}
600
+ // currentData={{}}
601
+ onError={setError}
602
+ onSubmit={onSubmit}
603
+ buttonText={i18n.t('auth.agree_and_continue')}
604
+ FooterComponent={
605
+ <TextWithLinks
606
+ as='div'
607
+ className='ft_xs mt_sm cl_md'
608
+ linkClassName='u link cl_md'
609
+ >
610
+ {i18n.t('auth.sign_up_notice_msg')}
611
+ </TextWithLinks>
612
+ }
613
+ >
614
+ {!error ? null : (
615
+ <ModalErrorMessage
616
+ error={error}
617
+ resetErrors={resetErrors}
618
+ // className='mt_sm'
619
+ />
620
+ )}
621
+ </SchemaForm>
622
+
623
+ <div className='a_c h_center'>
624
+ <Link
625
+ to={getAuthRoute('signin', authRoutesMap)}
626
+ replace
627
+ className='text ft_sm cl_md link'
628
+ >
629
+ {i18n.t('auth.sign_in_w_existing')}
630
+ </Link>
631
+ </div>
632
+ </>
633
+ );
634
+ }
635
+
636
+ /**
637
+ * Sign up; invitation required
638
+ */
639
+
640
+ function SignUpInviteRequired(p: Omit<AuthFormProps, 'setAuthIface'>) {
641
+ const supportEmail = APP_EMAILS.support;
642
+
643
+ return <ModalSimpleContent
644
+ title={i18n.t('auth.invite_required')}
645
+ iconName='mailbox-filled'
646
+ >
647
+ <TextWithLinks as='p'>
648
+ {i18n.t('auth.invite_required_msg', { emailAddress: supportEmail })}
649
+ </TextWithLinks>
650
+ </ModalSimpleContent>;
651
+ }
652
+
653
+ /**
654
+ * Sign up; success
655
+ */
656
+
657
+ interface SignUpSuccessProps extends Omit<AuthFormProps, 'setAuthIface'> {
658
+ signUpToken: string;
659
+ }
660
+
661
+ function SignUpSuccess(p: SignUpSuccessProps) {
662
+ const { authRoutesMap } = p;
663
+
664
+ return <ModalSimpleContent
665
+ title={i18n.t('auth.account_created')}
666
+ iconName='circle-check'
667
+ className='px_df pt_md'
668
+ >
669
+ <TextWithLinks as='p'>
670
+ {i18n.t('auth.account_created_msg')}
671
+ </TextWithLinks>
672
+
673
+ <FullWidthButton
674
+ to={getAuthRoute('signin', authRoutesMap)}
675
+ preset='bg_primary'
676
+ className='mt_lg shadow'
677
+ replace
678
+ >
679
+ {i18n.t('auth.continue_to_login')}
680
+ </FullWidthButton>
681
+ </ModalSimpleContent>;
682
+ }
683
+
684
+ /**
685
+ * Sign up form
686
+ */
687
+
688
+ type SignUpIface = 'INVITATION_REQUIRED' | null;
689
+
690
+ export function SignUpForm(p: Omit<AuthFormProps, 'setAuthIface'>) {
691
+ const [signUpToken, setSignUpToken] = useState<string | null>(null);
692
+ const [signUpIface, setAuthIface] = useState<SignUpIface>(null);
693
+
694
+ if (signUpToken) {
695
+ return <SignUpSuccess
696
+ {...p}
697
+ signUpToken={signUpToken}
698
+ />;
699
+ }
700
+
701
+ switch (signUpIface) {
702
+ case 'INVITATION_REQUIRED':
703
+ return <SignUpInviteRequired {...p} />;
704
+ default:
705
+ }
706
+
707
+ return <SignUpMain
708
+ {...p}
709
+ setAuthIface={setAuthIface}
710
+ setSignUpToken={setSignUpToken}
711
+ />;
712
+ }