Skip to content

Commit 20497e9

Browse files
fix(ui): Add phone_code verification step strategy (#3760)
1 parent 851a180 commit 20497e9

File tree

2 files changed

+90
-1
lines changed

2 files changed

+90
-1
lines changed

.changeset/pretty-bananas-end.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/ui/src/components/sign-in/sign-in.tsx

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { useDisplayConfig } from '~/hooks/use-display-config';
1818
import { useEnabledConnections } from '~/hooks/use-enabled-connections';
1919
import { useEnvironment } from '~/hooks/use-environment';
2020
import { useLocalizations } from '~/hooks/use-localizations';
21-
import { useSupportEmail } from '~/hooks/use-support-email';
2221
import { useResetPasswordFactor } from '~/hooks/use-reset-password-factor';
22+
import { useSupportEmail } from '~/hooks/use-support-email';
2323
import { Alert } from '~/primitives/alert';
2424
import { Button } from '~/primitives/button';
2525
import * as Card from '~/primitives/card';
@@ -451,6 +451,93 @@ export function SignInComponentLoaded() {
451451
</Card.Body>
452452
</SignIn.Strategy>
453453

454+
<SignIn.Strategy name='phone_code'>
455+
<Card.Header>
456+
{logoImageUrl ? (
457+
<Card.Logo
458+
href={homeUrl}
459+
src={logoImageUrl}
460+
alt={applicationName}
461+
/>
462+
) : null}
463+
<Card.Title>{t('signIn.phoneCode.title')}</Card.Title>
464+
<Card.Description>{t('signIn.phoneCode.subtitle', { applicationName })}</Card.Description>
465+
<Card.Description>
466+
<span className='flex items-center justify-center gap-2'>
467+
<SignIn.SafeIdentifier
468+
// TODO: uncomment once https://github.com/clerk/javascript/pull/3749 is merged
469+
// transform={formatSafeIdentifier}
470+
/>
471+
<SignIn.Action
472+
navigate='start'
473+
asChild
474+
>
475+
<button
476+
type='button'
477+
className='text-accent-9 focus-visible:ring-default size-4 rounded-sm outline-none focus-visible:ring-2'
478+
aria-label='Start again'
479+
>
480+
<Icon.PencilUnderlined />
481+
</button>
482+
</SignIn.Action>
483+
</span>
484+
</Card.Description>
485+
</Card.Header>
486+
487+
<Card.Body>
488+
<Common.GlobalError>
489+
{({ message }) => {
490+
return <Alert>{message}</Alert>;
491+
}}
492+
</Common.GlobalError>
493+
<OTPField
494+
disabled={isGlobalLoading}
495+
resend={
496+
<SignIn.Action
497+
asChild
498+
resend
499+
// eslint-disable-next-line react/no-unstable-nested-components
500+
fallback={({ resendableAfter }) => (
501+
<p className='text-gray-11 border border-transparent px-2.5 py-1.5 text-center text-base font-medium'>
502+
{t('signIn.phoneCode.resendButton')} (
503+
<span className='tabular-nums'>{resendableAfter}</span>)
504+
</p>
505+
)}
506+
>
507+
<LinkButton type='button'>{t('signIn.phoneCode.resendButton')}</LinkButton>
508+
</SignIn.Action>
509+
}
510+
/>
511+
<Common.Loading scope='step:verifications'>
512+
{isSubmitting => {
513+
return (
514+
<div className='flex flex-col gap-4'>
515+
<SignIn.Action
516+
submit
517+
asChild
518+
>
519+
<Button
520+
busy={isSubmitting}
521+
disabled={isGlobalLoading}
522+
icon={<Icon.CaretRight />}
523+
>
524+
{t('formButtonPrimary')}
525+
</Button>
526+
</SignIn.Action>
527+
528+
<SignIn.Action
529+
asChild
530+
navigate='choose-strategy'
531+
>
532+
<LinkButton type='button'>{t('footerActionLink__useAnotherMethod')}</LinkButton>
533+
</SignIn.Action>
534+
</div>
535+
);
536+
}}
537+
</Common.Loading>
538+
</Card.Body>
539+
</SignIn.Strategy>
540+
454541
<SignIn.Strategy name='email_link'>
455542
<Card.Header>
456543
{logoImageUrl ? (

0 commit comments

Comments
 (0)