Skip to content

Commit 81ccdce

Browse files
committed
feat: added firstname and lastname logic
1 parent 2abefc4 commit 81ccdce

20 files changed

+757
-4060
lines changed

apps/web/modules/settings/my-account/profile-view.tsx

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ type Email = {
6161
};
6262

6363
export type FormValues = {
64+
firstName?: string;
65+
lastName?: string;
6466
username: string;
6567
avatarUrl: string | null;
6668
name: string;
@@ -77,21 +79,23 @@ const ProfileView = ({ user }: Props) => {
7779
const utils = trpc.useUtils();
7880
const session = useSession();
7981
const { update } = session;
82+
8083
const updateProfileMutation = trpc.viewer.me.updateProfile.useMutation({
81-
onSuccess: async (res) => {
82-
await update(res);
83-
utils.viewer.me.invalidate();
84-
utils.viewer.me.shouldVerifyEmail.invalidate();
85-
revalidateSettingsProfile();
84+
onSuccess: async (res) => {
85+
await update(res);
8686

87-
if (res.hasEmailBeenChanged && res.sendEmailVerification) {
88-
showToast(t("change_of_email_toast", { email: tempFormValues?.email }), "success");
89-
} else {
90-
showToast(t("settings_updated_successfully"), "success");
91-
}
87+
utils.viewer.me.invalidate();
88+
utils.viewer.me.shouldVerifyEmail.invalidate();
89+
revalidateSettingsProfile();
9290

93-
setTempFormValues(null);
94-
},
91+
if (res.hasEmailBeenChanged && res.sendEmailVerification) {
92+
showToast(t("change_of_email_toast", { email: tempFormValues?.email }), "success");
93+
} else {
94+
showToast(t("settings_updated_successfully"), "success");
95+
}
96+
97+
setTempFormValues(null);
98+
},
9599
onError: (e) => {
96100
switch (e.message) {
97101
// TODO: Add error codes.
@@ -237,6 +241,8 @@ const ProfileView = ({ user }: Props) => {
237241
username: user.username || "",
238242
avatarUrl: user.avatarUrl,
239243
name: user.name || "",
244+
firstName: user.firstName || "",
245+
lastName: user.lastName || "",
240246
email: userEmail,
241247
bio: user.bio || "",
242248
// We add the primary email as the first item in the list
@@ -521,6 +527,8 @@ const ProfileForm = ({
521527
const [firstRender, setFirstRender] = useState(true);
522528

523529
const profileFormSchema = z.object({
530+
firstName: z.string().optional(),
531+
lastName: z.string().optional(),
524532
username: z.string(),
525533
avatarUrl: z.string().nullable(),
526534
name: z
@@ -545,8 +553,12 @@ const ProfileForm = ({
545553
});
546554

547555
const formMethods = useForm<FormValues>({
548-
defaultValues,
549556
resolver: zodResolver(profileFormSchema),
557+
defaultValues: {
558+
...defaultValues,
559+
firstName: user.firstName || "",
560+
lastName: user.lastName || "",
561+
},
550562
});
551563

552564
const {
@@ -663,9 +675,22 @@ const ProfileForm = ({
663675
<InfoIcon className="mt-0.5 shrink-0" />
664676
<span className="flex-1">{t("tip_username_plus")}</span>
665677
</p>
666-
<div className="mt-6">
667-
<TextField label={t("full_name")} {...formMethods.register("name")} />
668-
</div>
678+
<div className="mt-6 flex flex-col gap-6 sm:flex-row sm:gap-4">
679+
<div className="flex-1">
680+
<TextField
681+
label="First Name"
682+
{...formMethods.register("firstName")}
683+
placeholder="e.g. Jane"
684+
/>
685+
</div>
686+
<div className="flex-1">
687+
<TextField
688+
label="Last Name"
689+
{...formMethods.register("lastName")}
690+
placeholder="e.g. Doe"
691+
/>
692+
</div>
693+
</div>
669694
<div className="mt-6">
670695
<Label>{t("email")}</Label>
671696
<div className="-mt-2 flex flex-wrap items-start gap-2">

packages/app-store/analytics.services.generated.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
This file is autogenerated using the command `yarn app-store:build --watch`.
33
Don't modify this file manually.
44
**/
5-
export const AnalyticsServiceMap =
6-
process.env.NEXT_PUBLIC_IS_E2E === "1"
7-
? {}
8-
: {
9-
dub: import("./dub/lib/AnalyticsService"),
10-
};
5+
export const AnalyticsServiceMap = process.env.NEXT_PUBLIC_IS_E2E === '1' ? {} : {
6+
"dub": import("./dub/lib/AnalyticsService"),
7+
};

packages/app-store/apps.browser.generated.tsx

Lines changed: 51 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,61 @@
22
This file is autogenerated using the command `yarn app-store:build --watch`.
33
Don't modify this file manually.
44
**/
5-
import dynamic from "next/dynamic";
5+
import dynamic from "next/dynamic"
66
export const InstallAppButtonMap = {
7-
exchange2013calendar: dynamic(() => import("./exchange2013calendar/components/InstallAppButton")),
8-
exchange2016calendar: dynamic(() => import("./exchange2016calendar/components/InstallAppButton")),
9-
office365video: dynamic(() => import("./office365video/components/InstallAppButton")),
10-
vital: dynamic(() => import("./vital/components/InstallAppButton")),
7+
"exchange2013calendar": dynamic(() => import("./exchange2013calendar/components/InstallAppButton")),
8+
"exchange2016calendar": dynamic(() => import("./exchange2016calendar/components/InstallAppButton")),
9+
"office365video": dynamic(() => import("./office365video/components/InstallAppButton")),
10+
"vital": dynamic(() => import("./vital/components/InstallAppButton")),
1111
};
1212
export const AppSettingsComponentsMap = {
13-
"general-app-settings": dynamic(
14-
() => import("./templates/general-app-settings/components/AppSettingsInterface")
15-
),
16-
weather_in_your_calendar: dynamic(
17-
() => import("./weather_in_your_calendar/components/AppSettingsInterface")
18-
),
19-
zapier: dynamic(() => import("./zapier/components/AppSettingsInterface")),
13+
"general-app-settings": dynamic(() => import("./templates/general-app-settings/components/AppSettingsInterface")),
14+
"weather_in_your_calendar": dynamic(() => import("./weather_in_your_calendar/components/AppSettingsInterface")),
15+
"zapier": dynamic(() => import("./zapier/components/AppSettingsInterface")),
2016
};
2117
export const EventTypeAddonMap = {
22-
alby: dynamic(() => import("./alby/components/EventTypeAppCardInterface")),
23-
basecamp3: dynamic(() => import("./basecamp3/components/EventTypeAppCardInterface")),
24-
btcpayserver: dynamic(() => import("./btcpayserver/components/EventTypeAppCardInterface")),
25-
closecom: dynamic(() => import("./closecom/components/EventTypeAppCardInterface")),
26-
databuddy: dynamic(() => import("./databuddy/components/EventTypeAppCardInterface")),
27-
fathom: dynamic(() => import("./fathom/components/EventTypeAppCardInterface")),
28-
ga4: dynamic(() => import("./ga4/components/EventTypeAppCardInterface")),
29-
giphy: dynamic(() => import("./giphy/components/EventTypeAppCardInterface")),
30-
gtm: dynamic(() => import("./gtm/components/EventTypeAppCardInterface")),
31-
hitpay: dynamic(() => import("./hitpay/components/EventTypeAppCardInterface")),
32-
hubspot: dynamic(() => import("./hubspot/components/EventTypeAppCardInterface")),
33-
insihts: dynamic(() => import("./insihts/components/EventTypeAppCardInterface")),
34-
matomo: dynamic(() => import("./matomo/components/EventTypeAppCardInterface")),
35-
metapixel: dynamic(() => import("./metapixel/components/EventTypeAppCardInterface")),
36-
"mock-payment-app": dynamic(() => import("./mock-payment-app/components/EventTypeAppCardInterface")),
37-
paypal: dynamic(() => import("./paypal/components/EventTypeAppCardInterface")),
38-
"pipedrive-crm": dynamic(() => import("./pipedrive-crm/components/EventTypeAppCardInterface")),
39-
plausible: dynamic(() => import("./plausible/components/EventTypeAppCardInterface")),
40-
posthog: dynamic(() => import("./posthog/components/EventTypeAppCardInterface")),
41-
qr_code: dynamic(() => import("./qr_code/components/EventTypeAppCardInterface")),
42-
salesforce: dynamic(() => import("./salesforce/components/EventTypeAppCardInterface")),
43-
stripepayment: dynamic(() => import("./stripepayment/components/EventTypeAppCardInterface")),
44-
"booking-pages-tag": dynamic(
45-
() => import("./templates/booking-pages-tag/components/EventTypeAppCardInterface")
46-
),
47-
"event-type-app-card": dynamic(
48-
() => import("./templates/event-type-app-card/components/EventTypeAppCardInterface")
49-
),
50-
twipla: dynamic(() => import("./twipla/components/EventTypeAppCardInterface")),
51-
umami: dynamic(() => import("./umami/components/EventTypeAppCardInterface")),
52-
"zoho-bigin": dynamic(() => import("./zoho-bigin/components/EventTypeAppCardInterface")),
53-
zohocrm: dynamic(() => import("./zohocrm/components/EventTypeAppCardInterface")),
18+
"alby": dynamic(() => import("./alby/components/EventTypeAppCardInterface")),
19+
"basecamp3": dynamic(() => import("./basecamp3/components/EventTypeAppCardInterface")),
20+
"btcpayserver": dynamic(() => import("./btcpayserver/components/EventTypeAppCardInterface")),
21+
"closecom": dynamic(() => import("./closecom/components/EventTypeAppCardInterface")),
22+
"databuddy": dynamic(() => import("./databuddy/components/EventTypeAppCardInterface")),
23+
"fathom": dynamic(() => import("./fathom/components/EventTypeAppCardInterface")),
24+
"ga4": dynamic(() => import("./ga4/components/EventTypeAppCardInterface")),
25+
"giphy": dynamic(() => import("./giphy/components/EventTypeAppCardInterface")),
26+
"gtm": dynamic(() => import("./gtm/components/EventTypeAppCardInterface")),
27+
"hitpay": dynamic(() => import("./hitpay/components/EventTypeAppCardInterface")),
28+
"hubspot": dynamic(() => import("./hubspot/components/EventTypeAppCardInterface")),
29+
"insihts": dynamic(() => import("./insihts/components/EventTypeAppCardInterface")),
30+
"matomo": dynamic(() => import("./matomo/components/EventTypeAppCardInterface")),
31+
"metapixel": dynamic(() => import("./metapixel/components/EventTypeAppCardInterface")),
32+
"mock-payment-app": dynamic(() => import("./mock-payment-app/components/EventTypeAppCardInterface")),
33+
"paypal": dynamic(() => import("./paypal/components/EventTypeAppCardInterface")),
34+
"pipedrive-crm": dynamic(() => import("./pipedrive-crm/components/EventTypeAppCardInterface")),
35+
"plausible": dynamic(() => import("./plausible/components/EventTypeAppCardInterface")),
36+
"posthog": dynamic(() => import("./posthog/components/EventTypeAppCardInterface")),
37+
"qr_code": dynamic(() => import("./qr_code/components/EventTypeAppCardInterface")),
38+
"salesforce": dynamic(() => import("./salesforce/components/EventTypeAppCardInterface")),
39+
"stripepayment": dynamic(() => import("./stripepayment/components/EventTypeAppCardInterface")),
40+
"booking-pages-tag": dynamic(() => import("./templates/booking-pages-tag/components/EventTypeAppCardInterface")),
41+
"event-type-app-card": dynamic(() => import("./templates/event-type-app-card/components/EventTypeAppCardInterface")),
42+
"twipla": dynamic(() => import("./twipla/components/EventTypeAppCardInterface")),
43+
"umami": dynamic(() => import("./umami/components/EventTypeAppCardInterface")),
44+
"zoho-bigin": dynamic(() => import("./zoho-bigin/components/EventTypeAppCardInterface")),
45+
"zohocrm": dynamic(() => import("./zohocrm/components/EventTypeAppCardInterface")),
5446
};
5547
export const EventTypeSettingsMap = {
56-
alby: dynamic(() => import("./alby/components/EventTypeAppSettingsInterface")),
57-
basecamp3: dynamic(() => import("./basecamp3/components/EventTypeAppSettingsInterface")),
58-
btcpayserver: dynamic(() => import("./btcpayserver/components/EventTypeAppSettingsInterface")),
59-
databuddy: dynamic(() => import("./databuddy/components/EventTypeAppSettingsInterface")),
60-
fathom: dynamic(() => import("./fathom/components/EventTypeAppSettingsInterface")),
61-
ga4: dynamic(() => import("./ga4/components/EventTypeAppSettingsInterface")),
62-
giphy: dynamic(() => import("./giphy/components/EventTypeAppSettingsInterface")),
63-
gtm: dynamic(() => import("./gtm/components/EventTypeAppSettingsInterface")),
64-
hitpay: dynamic(() => import("./hitpay/components/EventTypeAppSettingsInterface")),
65-
metapixel: dynamic(() => import("./metapixel/components/EventTypeAppSettingsInterface")),
66-
paypal: dynamic(() => import("./paypal/components/EventTypeAppSettingsInterface")),
67-
plausible: dynamic(() => import("./plausible/components/EventTypeAppSettingsInterface")),
68-
qr_code: dynamic(() => import("./qr_code/components/EventTypeAppSettingsInterface")),
69-
stripepayment: dynamic(() => import("./stripepayment/components/EventTypeAppSettingsInterface")),
70-
};
48+
"alby": dynamic(() => import("./alby/components/EventTypeAppSettingsInterface")),
49+
"basecamp3": dynamic(() => import("./basecamp3/components/EventTypeAppSettingsInterface")),
50+
"btcpayserver": dynamic(() => import("./btcpayserver/components/EventTypeAppSettingsInterface")),
51+
"databuddy": dynamic(() => import("./databuddy/components/EventTypeAppSettingsInterface")),
52+
"fathom": dynamic(() => import("./fathom/components/EventTypeAppSettingsInterface")),
53+
"ga4": dynamic(() => import("./ga4/components/EventTypeAppSettingsInterface")),
54+
"giphy": dynamic(() => import("./giphy/components/EventTypeAppSettingsInterface")),
55+
"gtm": dynamic(() => import("./gtm/components/EventTypeAppSettingsInterface")),
56+
"hitpay": dynamic(() => import("./hitpay/components/EventTypeAppSettingsInterface")),
57+
"metapixel": dynamic(() => import("./metapixel/components/EventTypeAppSettingsInterface")),
58+
"paypal": dynamic(() => import("./paypal/components/EventTypeAppSettingsInterface")),
59+
"plausible": dynamic(() => import("./plausible/components/EventTypeAppSettingsInterface")),
60+
"qr_code": dynamic(() => import("./qr_code/components/EventTypeAppSettingsInterface")),
61+
"stripepayment": dynamic(() => import("./stripepayment/components/EventTypeAppSettingsInterface")),
62+
};

0 commit comments

Comments
 (0)