-
Notifications
You must be signed in to change notification settings - Fork 444
Expand file tree
/
Copy pathSignInAlternativePhoneCodePhoneNumberCard.tsx
More file actions
113 lines (108 loc) · 3.91 KB
/
SignInAlternativePhoneCodePhoneNumberCard.tsx
File metadata and controls
113 lines (108 loc) · 3.91 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import type { PhoneCodeChannelData } from '@clerk/shared/types';
import type { CountryIso } from '@/ui/elements/PhoneInput/countryCodeData';
import { Card } from '@/ui/elements/Card';
import { useCardState } from '@/ui/elements/contexts';
import { Form } from '@/ui/elements/Form';
import { Header } from '@/ui/elements/Header';
import type { FormControlState } from '@/ui/utils/useFormControl';
import { ProviderIcon } from '../../common';
import { Button, Col, descriptors, Flex, localizationKeys } from '../../customizables';
import { CaptchaElement } from '../../elements/CaptchaElement';
import { useEnabledThirdPartyProviders } from '../../hooks';
type SignUpAlternativePhoneCodePhoneNumberCardProps = {
handleSubmit: React.FormEventHandler;
phoneNumberFormState: FormControlState<any>;
onUseAnotherMethod: () => void;
phoneCodeProvider: PhoneCodeChannelData;
defaultCountryIso?: CountryIso;
};
export const SignInAlternativePhoneCodePhoneNumberCard = (props: SignUpAlternativePhoneCodePhoneNumberCardProps) => {
const { handleSubmit, phoneNumberFormState, onUseAnotherMethod, phoneCodeProvider, defaultCountryIso } = props;
const { providerToDisplayData, strategyToDisplayData } = useEnabledThirdPartyProviders();
const provider = phoneCodeProvider.name;
const channel = phoneCodeProvider.channel;
const card = useCardState();
const strategyData = strategyToDisplayData[channel];
return (
<Card.Root>
<Card.Content>
<Header.Root
showLogo
showDivider
>
<Col center>
{providerToDisplayData[channel] && (
<ProviderIcon
id={channel}
iconUrl={providerToDisplayData[channel].iconUrl}
name={strategyData?.name || channel || provider}
alt={`${strategyData?.name || channel || provider} logo`}
size='$7'
sx={theme => ({
marginBottom: theme.sizes.$6,
})}
/>
)}
</Col>
<Header.Title
localizationKey={localizationKeys('signIn.start.alternativePhoneCodeProvider.title', {
provider,
})}
/>
<Header.Subtitle
localizationKey={localizationKeys('signIn.start.alternativePhoneCodeProvider.subtitle', {
provider,
})}
/>
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
<Flex
direction='col'
elementDescriptor={descriptors.main}
gap={6}
>
<Form.Root
onSubmit={handleSubmit}
gap={8}
>
<Col gap={6}>
<Form.ControlRow elementId='phoneNumber'>
<Form.PhoneInput
{...phoneNumberFormState.props}
defaultCountryIso={defaultCountryIso}
label={localizationKeys('signIn.start.alternativePhoneCodeProvider.label', { provider })}
isRequired
isOptional={false}
actionLabel={undefined}
onActionClicked={undefined}
/>
</Form.ControlRow>
</Col>
<Col center>
<CaptchaElement />
<Col
gap={6}
sx={{
width: '100%',
}}
>
<Form.SubmitButton
hasArrow
localizationKey={localizationKeys('formButtonPrimary')}
/>
</Col>
</Col>
<Col center>
<Button
variant='link'
colorScheme='neutral'
onClick={onUseAnotherMethod}
localizationKey={localizationKeys('signIn.start.alternativePhoneCodeProvider.actionLink')}
/>
</Col>
</Form.Root>
</Flex>
</Card.Content>
</Card.Root>
);
};