Skip to content

Commit 84128a9

Browse files
authored
chore: email is now required (#1803)
fixes PROD-344
1 parent 48e9c9a commit 84128a9

File tree

7 files changed

+40
-123
lines changed

7 files changed

+40
-123
lines changed

@3rdweb-sdk/react/hooks/useApi.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export type Account = {
2828
email?: string;
2929
currentBillingPeriodStartsAt: string;
3030
currentBillingPeriodEndsAt: string;
31-
onboardedAt?: string;
3231
emailConfirmedAt?: string;
3332
unconfirmedEmail?: string;
3433
stripePaymentActionUrl?: string;

components/onboarding/ConfirmEmail.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const OnboardingConfirmEmail: React.FC<OnboardingConfirmEmailProps> = ({
9595
return (
9696
<>
9797
<OnboardingTitle
98-
heading="Verify your email"
98+
heading="You're almost done! Verify your email."
9999
description={
100100
<>
101101
We&apos;ve sent a 6 letter confirmation code to{" "}
@@ -156,7 +156,7 @@ export const OnboardingConfirmEmail: React.FC<OnboardingConfirmEmailProps> = ({
156156
onClick={onBack}
157157
isDisabled={saving}
158158
>
159-
Change email
159+
Update email
160160
</Button>
161161
</Flex>
162162
</Flex>

components/onboarding/General.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,24 @@ import { OnboardingTitle } from "./Title";
55
type OnboardingGeneralProps = {
66
account: Account;
77
onSave: (email: string) => void;
8-
onCancel: () => void;
98
};
109

1110
export const OnboardingGeneral: React.FC<OnboardingGeneralProps> = ({
1211
account,
1312
onSave,
14-
onCancel,
1513
}) => {
1614
return (
1715
<>
1816
<OnboardingTitle
19-
heading={
20-
<>
21-
Welcome to <strong>thirdweb</strong>
22-
</>
23-
}
24-
description="Enter a name and email to manage your billing info, and receive our latest product updates."
17+
heading="Create your thirdweb account"
18+
description="Start building web3 apps and games, faster."
2519
/>
2620

2721
<AccountForm
28-
showCancelButton
2922
showSubscription
3023
optional
3124
account={account}
32-
buttonText="Next"
25+
buttonText="Get Started for Free"
3326
trackingCategory="onboarding"
3427
padded={false}
3528
buttonProps={{
@@ -39,7 +32,6 @@ export const OnboardingGeneral: React.FC<OnboardingGeneralProps> = ({
3932
variant: "inverted",
4033
}}
4134
onSave={onSave}
42-
onCancel={onCancel}
4335
/>
4436
</>
4537
);

components/onboarding/PaymentForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export const OnboardingPaymentForm: React.FC<OnboardingPaymentForm> = ({
119119
isDisabled={saving}
120120
onClick={onCancel}
121121
>
122-
Skip
122+
I&apos;ll do this later
123123
</Button>
124124
</Flex>
125125
)}

components/onboarding/index.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,11 @@ export const Onboarding: React.FC = () => {
7777
return;
7878
}
7979

80-
// user has never seen onboarding screen or
81-
// has set email but hasn't confirmed it (pre-email confirmation users)
82-
if (!account.onboardedAt || (account.email && !account.emailConfirmedAt)) {
80+
// user hasn't confirmed email
81+
if (!account.emailConfirmedAt) {
8382
setState("onboarding");
8483
}
85-
// user has changed email (via account settings) and needs to confirm only
84+
// user has changed email and needs to confirm
8685
else if (account.unconfirmedEmail) {
8786
setState("confirming");
8887
}
@@ -107,11 +106,7 @@ export const Onboarding: React.FC = () => {
107106
return (
108107
<OnboardingModal isOpen={!!state} onClose={() => setState("skipped")}>
109108
{state === "onboarding" && (
110-
<OnboardingGeneral
111-
account={account}
112-
onSave={handleSave}
113-
onCancel={() => setState("skipped")}
114-
/>
109+
<OnboardingGeneral account={account} onSave={handleSave} />
115110
)}
116111
{state === "confirming" && (
117112
<OnboardingConfirmEmail

components/settings/Account/AccountForm.tsx

Lines changed: 29 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,25 @@ interface AccountFormProps {
3535
previewEnabled?: boolean;
3636
showBillingButton?: boolean;
3737
showSubscription?: boolean;
38-
showCancelButton?: boolean;
3938
buttonProps?: ButtonProps;
4039
buttonText?: string;
4140
padded?: boolean;
4241
optional?: boolean;
4342
trackingCategory?: string;
4443
disableUnchanged?: boolean;
4544
onSave?: (email: string) => void;
46-
onCancel?: () => void;
4745
}
4846

4947
export const AccountForm: React.FC<AccountFormProps> = ({
5048
account,
5149
onSave,
52-
onCancel,
5350
buttonProps,
5451
buttonText = "Save",
5552
horizontal = false,
5653
previewEnabled = false,
5754
showBillingButton = false,
5855
showSubscription = false,
5956
disableUnchanged = false,
60-
showCancelButton = false,
6157
padded = true,
6258
optional = false,
6359
}) => {
@@ -87,11 +83,6 @@ export const AccountForm: React.FC<AccountFormProps> = ({
8783
);
8884

8985
const handleSubmit = form.handleSubmit((values) => {
90-
if (showCancelButton && !values.email) {
91-
handleCancel();
92-
return;
93-
}
94-
9586
if (onSave) {
9687
onSave(values.email);
9788
}
@@ -136,42 +127,6 @@ export const AccountForm: React.FC<AccountFormProps> = ({
136127
});
137128
});
138129

139-
const handleCancel = () => {
140-
if (onCancel) {
141-
onCancel();
142-
}
143-
144-
trackEvent({
145-
category: "account",
146-
action: "onboardSkipped",
147-
label: "attempt",
148-
});
149-
150-
updateMutation.mutate(
151-
{
152-
onboardSkipped: true,
153-
},
154-
{
155-
onSuccess: (data) => {
156-
trackEvent({
157-
category: "account",
158-
action: "onboardSkipped",
159-
label: "success",
160-
data,
161-
});
162-
},
163-
onError: (error) => {
164-
trackEvent({
165-
category: "account",
166-
action: "onboardSkipped",
167-
label: "error",
168-
error,
169-
});
170-
},
171-
},
172-
);
173-
};
174-
175130
return (
176131
<form onSubmit={handleSubmit}>
177132
<VStack
@@ -191,12 +146,10 @@ export const AccountForm: React.FC<AccountFormProps> = ({
191146
w="full"
192147
>
193148
<FormControl
194-
isRequired={!previewEnabled && !optional}
195-
isInvalid={!!form.getFieldState("name", form.formState).error}
149+
isRequired
150+
isInvalid={!!form.getFieldState("email", form.formState).error}
196151
>
197-
<FormLabel>
198-
Name {optional && <Text as="span">(optional)</Text>}
199-
</FormLabel>
152+
<FormLabel>Email</FormLabel>
200153

201154
{previewEnabled ? (
202155
<Flex
@@ -207,29 +160,29 @@ export const AccountForm: React.FC<AccountFormProps> = ({
207160
px={3}
208161
alignItems="center"
209162
>
210-
<Heading size="subtitle.sm">{form.getValues("name")}</Heading>
163+
<Heading size="subtitle.sm">{form.getValues("email")}</Heading>
211164
</Flex>
212165
) : (
213166
<Input
214-
placeholder="ACME Inc."
215-
type="text"
216-
{...form.register("name")}
167+
placeholder="[email protected]"
168+
type="email"
169+
{...form.register("email")}
217170
/>
218171
)}
219172

220-
{form.getFieldState("name", form.formState).error && (
173+
{form.getFieldState("email", form.formState).error && (
221174
<FormErrorMessage size="body.sm">
222-
{form.getFieldState("name", form.formState).error?.message}
175+
{form.getFieldState("email", form.formState).error?.message}
223176
</FormErrorMessage>
224177
)}
225178
</FormControl>
226179

227180
<FormControl
228181
isRequired={!previewEnabled && !optional}
229-
isInvalid={!!form.getFieldState("email", form.formState).error}
182+
isInvalid={!!form.getFieldState("name", form.formState).error}
230183
>
231184
<FormLabel>
232-
Billing email {optional && <Text as="span">(optional)</Text>}
185+
Name {optional && <Text as="span">(optional)</Text>}
233186
</FormLabel>
234187

235188
{previewEnabled ? (
@@ -241,29 +194,25 @@ export const AccountForm: React.FC<AccountFormProps> = ({
241194
px={3}
242195
alignItems="center"
243196
>
244-
<Heading size="subtitle.sm">{form.getValues("email")}</Heading>
197+
<Heading size="subtitle.sm">{form.getValues("name")}</Heading>
245198
</Flex>
246199
) : (
247200
<Input
248-
placeholder="[email protected]"
249-
type="email"
250-
{...form.register("email")}
201+
placeholder="Company Inc."
202+
type="text"
203+
{...form.register("name")}
251204
/>
252205
)}
253206

254-
{form.getFieldState("email", form.formState).error && (
207+
{form.getFieldState("name", form.formState).error && (
255208
<FormErrorMessage size="body.sm">
256-
{form.getFieldState("email", form.formState).error?.message}
209+
{form.getFieldState("name", form.formState).error?.message}
257210
</FormErrorMessage>
258211
)}
259212
</FormControl>
260213

261214
{showSubscription && (
262215
<Checkbox
263-
isDisabled={
264-
!form.getValues("email").length ||
265-
!!form.getFieldState("email", form.formState).error
266-
}
267216
defaultChecked
268217
onChange={(e: ChangeEvent<HTMLInputElement>) =>
269218
setIsSubscribing(e.target.checked)
@@ -281,37 +230,19 @@ export const AccountForm: React.FC<AccountFormProps> = ({
281230
{showBillingButton && <ManageBillingButton account={account} />}
282231

283232
{!previewEnabled && (
284-
<Flex
285-
flexDir="column"
286-
gap={3}
287-
w={showCancelButton ? "full" : "auto"}
233+
<Button
234+
{...buttonProps}
235+
type="button"
236+
onClick={handleSubmit}
237+
colorScheme={buttonProps?.variant ? undefined : "blue"}
238+
isDisabled={
239+
updateMutation.isLoading ||
240+
(disableUnchanged && !form.formState.isDirty)
241+
}
242+
isLoading={updateMutation.isLoading}
288243
>
289-
<Button
290-
{...buttonProps}
291-
type="button"
292-
onClick={handleSubmit}
293-
colorScheme={buttonProps?.variant ? undefined : "blue"}
294-
isDisabled={
295-
updateMutation.isLoading ||
296-
(disableUnchanged && !form.formState.isDirty)
297-
}
298-
isLoading={updateMutation.isLoading}
299-
>
300-
{buttonText}
301-
</Button>
302-
303-
{showCancelButton && (
304-
<Button
305-
w="full"
306-
size="lg"
307-
fontSize="md"
308-
variant="outline"
309-
onClick={handleCancel}
310-
>
311-
Cancel
312-
</Button>
313-
)}
314-
</Flex>
244+
{buttonText}
245+
</Button>
315246
)}
316247
</HStack>
317248
</VStack>

components/settings/Account/validations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export const accountValidationSchema = z.object({
1616
});
1717

1818
export const accountValidationOptionalSchema = z.object({
19+
email: emailValidation,
1920
name: nameValidation.or(z.literal("")),
20-
email: emailValidation.or(z.literal("")),
2121
});
2222

2323
export const emailConfirmationValidationSchema = z.object({

0 commit comments

Comments
 (0)