-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): Render email or phone number during verification step (#3694)
- Loading branch information
1 parent
1de2cfb
commit e2782ed
Showing
5 changed files
with
41 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useClerk } from '@clerk/clerk-react'; | ||
|
||
import { parsePhoneString } from '~/common/phone-number-field/utils'; | ||
import type { RequireExactlyOne } from '~/types/utils'; | ||
|
||
type Identifiers = { | ||
emailAddress: boolean; | ||
phoneNumber: boolean; | ||
}; | ||
|
||
type Identifier = RequireExactlyOne<Identifiers>; | ||
|
||
export function SignUpIdentifier({ emailAddress, phoneNumber }: Identifier) { | ||
const { client } = useClerk(); | ||
|
||
if (emailAddress) { | ||
return <span>{client.signUp.emailAddress}</span>; | ||
} | ||
|
||
if (phoneNumber) { | ||
const { formattedNumberWithCode } = parsePhoneString(client.signUp.phoneNumber || ''); | ||
return <span>{formattedNumberWithCode}</span>; | ||
} | ||
|
||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ import * as Icon from '~/primitives/icon'; | |
import { LinkButton } from '~/primitives/link-button'; | ||
import { Seperator } from '~/primitives/seperator'; | ||
|
||
import { SignUpIdentifier } from './indentifiers'; | ||
|
||
export function SignUpComponent() { | ||
return ( | ||
<SignUp.Root> | ||
|
@@ -115,6 +117,7 @@ function SignUpComponentLoaded() { | |
hintText={t('formFieldHintText__optional')} | ||
required={phoneNumberRequired} | ||
disabled={isGlobalLoading} | ||
initPhoneWithCode={clerk.client.signUp.phoneNumber || ''} | ||
locationBasedCountryIso={locationBasedCountryIso} | ||
/> | ||
) : null} | ||
|
@@ -171,11 +174,7 @@ function SignUpComponentLoaded() { | |
<Card.Description>{t('signUp.phoneCode.subtitle')}</Card.Description> | ||
<Card.Description> | ||
<span className='flex items-center justify-center gap-2'> | ||
{/* TODO: elements work | ||
1. https://linear.app/clerk/issue/SDK-1830/add-signup-elements-for-accessing-email-address-and-phone-number | ||
2. https://linear.app/clerk/issue/SDK-1831/pre-populate-emailphone-number-fields-when-navigating-back-to-the | ||
*/} | ||
+1 (424) 424-4242{' '} | ||
<SignUpIdentifier phoneNumber /> | ||
<SignUp.Action | ||
navigate='start' | ||
asChild | ||
|
@@ -244,11 +243,7 @@ function SignUpComponentLoaded() { | |
<Card.Description>{t('signUp.emailCode.subtitle')}</Card.Description> | ||
<Card.Description> | ||
<span className='flex items-center justify-center gap-2'> | ||
{/* TODO: elements work | ||
1. https://linear.app/clerk/issue/SDK-1830/add-signup-elements-for-accessing-email-address-and-phone-number | ||
2. https://linear.app/clerk/issue/SDK-1831/pre-populate-emailphone-number-fields-when-navigating-back-to-the | ||
*/} | ||
[email protected]{' '} | ||
<SignUpIdentifier emailAddress /> | ||
<SignUp.Action | ||
navigate='start' | ||
asChild | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// https://github.com/sindresorhus/type-fest/blob/main/source/require-exactly-one.d.ts | ||
export type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = { | ||
[Key in KeysType]: Required<Pick<ObjectType, Key>> & Partial<Record<Exclude<KeysType, Key>, never>>; | ||
}[KeysType] & | ||
Omit<ObjectType, KeysType>; |