chore: UX Fixes (#26643)

* Copy changes

* Move search bar inline with new button

* Get rid of no more results message

* Change hidden badge to (hidden)

* Remove Cal.ai badge from sidebar

* Add dropdown to create button when there is multiple options

* Fix delete dialog

* Saved filters updates

* More string fixes

* Switch members table to use names

* Fix member spacing

* Fix routing form identifier field

* Fix routing forms stuff

* Only show SMS hint on SMS options

* Make workflow delete button minimal

* Fix padding on workflow steps

* Remove min width on workflow title

* Fix delete workflow PR

* Fix org profile buttons

* Fix org profile screen partially scrolled down

* Improve logos & banner uploads

* Personal profile fixes

* Fix settings general view stuff

* Sentence case consistency

* Fix stuff I broke

* Fix fab

* Fix hidden translation string

* Fix text fields

* Make button small for solo users too

* fix: update E2E tests to match sentence case labels in routing forms

* fix: update tests to match sentence case label changes

- insights.e2e.ts: chart titles (14 strings)
- event-types.e2e.ts: Organizer phone number location
- EditLocationDialog.test.tsx: phone number labels

* fix: address Cubic AI review feedback (confidence 9+)

- Replace hardcoded text-gray-500 with text-muted in TextField.tsx hint section
- Replace text locator with data-testid in E2E test for location select

Co-Authored-By: unknown <>

* fix: update E2E tests for sentence case label changes

- Use data-testid selectors for location options (more reliable than text)
- Update field identifiers in routing-forms tests to match new labels
- Fix Long text selector in manage-booking-questions test

* fix: replace text locator with data-testid in manage-booking-questions E2E test

Replace fragile text="Long text" locator with resilient
page.getByTestId("select-option-textarea") selector per E2E best practices.

Addresses Cubic AI review feedback (confidence 9/10).

Co-Authored-By: unknown <>

* fix: use .last() for multiple location select items

---------

Co-authored-by: Pedro Castro <[email protected]>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-01-13 00:56:08 -05:00
1 parent 32d97fbea4
commit 7c66f33de2
31 files changed
+3350 -1887

No files matched your search

@@ -107,16 +107,22 @@ const GeneralView = ({ user, travelSchedules }: GeneralViewProps) => {
defaultValues: {
locale: {
value: localeProp || "",
label: localeOptions.find((option) => option.value === localeProp)?.label || "",
label:
localeOptions.find((option) => option.value === localeProp)?.label ||
"",
},
timeZone: user.timeZone || "",
timeFormat: {
value: user.timeFormat || 12,
label: timeFormatOptions.find((option) => option.value === user.timeFormat)?.label || 12,
label:
timeFormatOptions.find((option) => option.value === user.timeFormat)
?.label || 12,
},
weekStart: {
value: user.weekStart,
label: weekStartOptions.find((option) => option.value === user.weekStart)?.label || "",
label:
weekStartOptions.find((option) => option.value === user.weekStart)
?.label || "",
},
travelSchedules:
travelSchedules.map((schedule) => {
@@ -136,25 +142,30 @@ const GeneralView = ({ user, travelSchedules }: GeneralViewProps) => {
} = formMethods;
const isDisabled = isSubmitting || !isDirty;
const [isAllowDynamicBookingChecked, setIsAllowDynamicBookingChecked] = useState(
!!user.allowDynamicBooking
);
const [isAllowDynamicBookingChecked, setIsAllowDynamicBookingChecked] =
useState(!!user.allowDynamicBooking);
const [isAllowSEOIndexingChecked, setIsAllowSEOIndexingChecked] = useState(
user.organizationSettings?.allowSEOIndexing === false
? !!user.organizationSettings?.allowSEOIndexing
: !!user.allowSEOIndexing
);
const [isReceiveMonthlyDigestEmailChecked, setIsReceiveMonthlyDigestEmailChecked] = useState(
!!user.receiveMonthlyDigestEmail
);
const [isRequireBookerEmailVerificationChecked, setIsRequireBookerEmailVerificationChecked] = useState(
!!user.requiresBookerEmailVerification
);
const [
isReceiveMonthlyDigestEmailChecked,
setIsReceiveMonthlyDigestEmailChecked,
] = useState(!!user.receiveMonthlyDigestEmail);
const [
isRequireBookerEmailVerificationChecked,
setIsRequireBookerEmailVerificationChecked,
] = useState(!!user.requiresBookerEmailVerification);
const watchedTzSchedules = formMethods.watch("travelSchedules");
return (
<SettingsHeader title={t("general")} description={t("general_description")} borderInShellHeader={true}>
<SettingsHeader
title={t("general")}
description={t("general_description")}
borderInShellHeader={true}
>
<div>
<Form
form={formMethods}
@@ -166,7 +177,8 @@ const GeneralView = ({ user, travelSchedules }: GeneralViewProps) => {
timeFormat: values.timeFormat.value,
weekStart: values.weekStart.value,
});
}}>
}}
>
<div className="border-subtle border-x border-y-0 px-4 py-8 sm:px-6">
<Controller
name="locale"
@@ -192,25 +204,33 @@ const GeneralView = ({ user, travelSchedules }: GeneralViewProps) => {
<Label className="text-emphasis mt-6">
<>{t("timezone")}</>
</Label>
<TimezoneSelect
id="timezone"
value={value}
onChange={(event) => {
if (event) formMethods.setValue("timeZone", event.value, { shouldDirty: true });
}}
/>
<div className="flex items-end gap-2">
<div className="flex-1">
<TimezoneSelect
id="timezone"
value={value}
onChange={(event) => {
if (event)
formMethods.setValue("timeZone", event.value, {
shouldDirty: true,
});
}}
/>
</div>
{!watchedTzSchedules.length && (
<Button
color="secondary"
StartIcon="calendar"
onClick={() => setIsTZScheduleOpen(true)}
>
{t("schedule_timezone_change")}
</Button>
)}
</div>
</>
)}
/>
{!watchedTzSchedules.length ? (
<Button
color="secondary"
className="mt-2"
StartIcon="calendar"
onClick={() => setIsTZScheduleOpen(true)}>
{t("schedule_timezone_change")}
</Button>
) : (
{watchedTzSchedules.length > 0 && (
<div className="bg-cal-muted border-subtle mt-2 rounded-md border p-4">
<Label>{t("travel_schedule")}</Label>
<div className="border-subtle bg-default mt-4 rounded-md border text-sm">
@@ -221,7 +241,8 @@ const GeneralView = ({ user, travelSchedules }: GeneralViewProps) => {
"flex items-center p-4",
index !== 0 ? "border-subtle border-t" : ""
)}
key={index}>
key={index}
>
<div>
<div className="text-emphasis font-semibold">{`${formatLocalizedDateTime(
schedule.startDate,
@@ -236,7 +257,9 @@ const GeneralView = ({ user, travelSchedules }: GeneralViewProps) => {
)}`
: ``
}`}</div>
<div className="text-subtle">{schedule.timeZone.replace(/_/g, " ")}</div>
<div className="text-subtle">
{schedule.timeZone.replace(/_/g, " ")}
</div>
</div>
<Button
color="destructive"
@@ -247,7 +270,11 @@ const GeneralView = ({ user, travelSchedules }: GeneralViewProps) => {
const updatedSchedules = watchedTzSchedules.filter(
(s, filterIndex) => filterIndex !== index
);
formMethods.setValue("travelSchedules", updatedSchedules, { shouldDirty: true });
formMethods.setValue(
"travelSchedules",
updatedSchedules,
{ shouldDirty: true }
);
}}
/>
</div>
@@ -258,7 +285,8 @@ const GeneralView = ({ user, travelSchedules }: GeneralViewProps) => {
StartIcon="plus"
color="secondary"
className="mt-4"
onClick={() => setIsTZScheduleOpen(true)}>
onClick={() => setIsTZScheduleOpen(true)}
>
{t("add")}
</Button>
</div>
@@ -276,7 +304,12 @@ const GeneralView = ({ user, travelSchedules }: GeneralViewProps) => {
value={value}
options={timeFormatOptions}
onChange={(event) => {
if (event) formMethods.setValue("timeFormat", { ...event }, { shouldDirty: true });
if (event)
formMethods.setValue(
"timeFormat",
{ ...event },
{ shouldDirty: true }
);
}}
/>
</>
@@ -297,7 +330,12 @@ const GeneralView = ({ user, travelSchedules }: GeneralViewProps) => {
value={value}
options={weekStartOptions}
onChange={(event) => {
if (event) formMethods.setValue("weekStart", { ...event }, { shouldDirty: true });
if (event)
formMethods.setValue(
"weekStart",
{ ...event },
{ shouldDirty: true }
);
}}
/>
</>
@@ -311,7 +349,8 @@ const GeneralView = ({ user, travelSchedules }: GeneralViewProps) => {
disabled={isDisabled}
color="primary"
type="submit"
data-testid="general-submit-button">
data-testid="general-submit-button"
>
<>{t("update")}</>
</Button>
</SectionBottomActions>
@@ -335,7 +374,10 @@ const GeneralView = ({ user, travelSchedules }: GeneralViewProps) => {
toggleSwitchAtTheEnd={true}
title={t("seo_indexing")}
description={t("allow_seo_indexing")}
disabled={mutation.isPending || user.organizationSettings?.allowSEOIndexing === false}
disabled={
mutation.isPending ||
user.organizationSettings?.allowSEOIndexing === false
}
checked={isAllowSEOIndexingChecked}
onCheckedChange={(checked) => {
setIsAllowSEOIndexingChecked(checked);
@@ -28,7 +28,12 @@ import type { AppRouter } from "@calcom/trpc/types/server/routers/_app";
import { Alert } from "@calcom/ui/components/alert";
import { UserAvatar } from "@calcom/ui/components/avatar";
import { Button } from "@calcom/ui/components/button";
import { DialogContent, DialogFooter, DialogTrigger, DialogClose } from "@calcom/ui/components/dialog";
import {
DialogContent,
DialogFooter,
DialogTrigger,
DialogClose,
} from "@calcom/ui/components/dialog";
import { Editor } from "@calcom/ui/components/editor";
import { Form } from "@calcom/ui/components/form";
import { PasswordField } from "@calcom/ui/components/form";
@@ -85,7 +90,10 @@ const ProfileView = ({ user }: Props) => {
revalidateSettingsProfile();
if (res.hasEmailBeenChanged && res.sendEmailVerification) {
showToast(t("change_of_email_toast", { email: tempFormValues?.email }), "success");
showToast(
t("change_of_email_toast", { email: tempFormValues?.email }),
"success"
);
} else {
showToast(t("settings_updated_successfully"), "success");
}
@@ -105,44 +113,56 @@ const ProfileView = ({ user }: Props) => {
}
},
});
const unlinkConnectedAccountMutation = trpc.viewer.loggedInViewerRouter.unlinkConnectedAccount.useMutation({
onSuccess: async (res) => {
showToast(t(res.message), "success");
utils.viewer.me.invalidate();
revalidateSettingsProfile();
},
onError: (e) => {
showToast(t(e.message), "error");
},
});
const unlinkConnectedAccountMutation =
trpc.viewer.loggedInViewerRouter.unlinkConnectedAccount.useMutation({
onSuccess: async (res) => {
showToast(t(res.message), "success");
utils.viewer.me.invalidate();
revalidateSettingsProfile();
},
onError: (e) => {
showToast(t(e.message), "error");
},
});
const addSecondaryEmailMutation = trpc.viewer.loggedInViewerRouter.addSecondaryEmail.useMutation({
onSuccess: (res) => {
setShowSecondaryEmailModalOpen(false);
setNewlyAddedSecondaryEmail(res?.data?.email);
utils.viewer.me.invalidate();
revalidateSettingsProfile();
},
onError: (error) => {
setSecondaryEmailAddErrorMessage(error?.message || "");
},
});
const addSecondaryEmailMutation =
trpc.viewer.loggedInViewerRouter.addSecondaryEmail.useMutation({
onSuccess: (res) => {
setShowSecondaryEmailModalOpen(false);
setNewlyAddedSecondaryEmail(res?.data?.email);
utils.viewer.me.invalidate();
revalidateSettingsProfile();
},
onError: (error) => {
setSecondaryEmailAddErrorMessage(error?.message || "");
},
});
const resendVerifyEmailMutation = trpc.viewer.auth.resendVerifyEmail.useMutation();
const resendVerifyEmailMutation =
trpc.viewer.auth.resendVerifyEmail.useMutation();
const [confirmPasswordOpen, setConfirmPasswordOpen] = useState(false);
const [tempFormValues, setTempFormValues] = useState<ExtendedFormValues | null>(null);
const [confirmPasswordErrorMessage, setConfirmPasswordDeleteErrorMessage] = useState("");
const [showCreateAccountPasswordDialog, setShowCreateAccountPasswordDialog] = useState(false);
const [showAccountDisconnectWarning, setShowAccountDisconnectWarning] = useState(false);
const [showSecondaryEmailModalOpen, setShowSecondaryEmailModalOpen] = useState(false);
const [secondaryEmailAddErrorMessage, setSecondaryEmailAddErrorMessage] = useState("");
const [newlyAddedSecondaryEmail, setNewlyAddedSecondaryEmail] = useState<undefined | string>(undefined);
const [tempFormValues, setTempFormValues] =
useState<ExtendedFormValues | null>(null);
const [confirmPasswordErrorMessage, setConfirmPasswordDeleteErrorMessage] =
useState("");
const [showCreateAccountPasswordDialog, setShowCreateAccountPasswordDialog] =
useState(false);
const [showAccountDisconnectWarning, setShowAccountDisconnectWarning] =
useState(false);
const [showSecondaryEmailModalOpen, setShowSecondaryEmailModalOpen] =
useState(false);
const [secondaryEmailAddErrorMessage, setSecondaryEmailAddErrorMessage] =
useState("");
const [newlyAddedSecondaryEmail, setNewlyAddedSecondaryEmail] = useState<
undefined | string
>(undefined);
const [deleteAccountOpen, setDeleteAccountOpen] = useState(false);
const [hasDeleteErrors, setHasDeleteErrors] = useState(false);
const [deleteErrorMessage, setDeleteErrorMessage] = useState("");
const [isCompanyEmailAlertDismissed, setIsCompanyEmailAlertDismissed] = useState(false);
const [isCompanyEmailAlertDismissed, setIsCompanyEmailAlertDismissed] =
useState(false);
const form = useForm<DeleteAccountValues>();
const onDeleteMeSuccessMutation = async () => {
@@ -181,25 +201,30 @@ const ProfileView = ({ user }: Props) => {
revalidateSettingsProfile();
},
});
const deleteMeWithoutPasswordMutation = trpc.viewer.me.deleteMeWithoutPassword.useMutation({
onSuccess: onDeleteMeSuccessMutation,
onError: onDeleteMeErrorMutation,
async onSettled() {
await utils.viewer.me.invalidate();
revalidateSettingsProfile();
},
});
const deleteMeWithoutPasswordMutation =
trpc.viewer.me.deleteMeWithoutPassword.useMutation({
onSuccess: onDeleteMeSuccessMutation,
onError: onDeleteMeErrorMutation,
async onSettled() {
await utils.viewer.me.invalidate();
revalidateSettingsProfile();
},
});
const isCALIdentityProvider = user?.identityProvider === IdentityProvider.CAL;
const onConfirmPassword = (e: Event | React.MouseEvent<HTMLElement, MouseEvent>) => {
const onConfirmPassword = (
e: Event | React.MouseEvent<HTMLElement, MouseEvent>
) => {
e.preventDefault();
const password = passwordRef.current.value;
confirmPasswordMutation.mutate({ passwordInput: password });
};
const onConfirmButton = (e: Event | React.MouseEvent<HTMLElement, MouseEvent>) => {
const onConfirmButton = (
e: Event | React.MouseEvent<HTMLElement, MouseEvent>
) => {
e.preventDefault();
if (isCALIdentityProvider) {
const totpCode = form.getValues("totpCode");
@@ -210,7 +235,10 @@ const ProfileView = ({ user }: Props) => {
}
};
const onConfirm = ({ totpCode }: DeleteAccountValues, e: BaseSyntheticEvent | undefined) => {
const onConfirm = (
{ totpCode }: DeleteAccountValues,
e: BaseSyntheticEvent | undefined
) => {
e?.preventDefault();
if (isCALIdentityProvider) {
const password = passwordRef.current.value;
@@ -225,11 +253,19 @@ const ProfileView = ({ user }: Props) => {
const errorMessages: { [key: string]: string } = {
[ErrorCode.SecondFactorRequired]: t("2fa_enabled_instructions"),
[ErrorCode.IncorrectPassword]: `${t("incorrect_password")} ${t("please_try_again")}`,
[ErrorCode.IncorrectPassword]: `${t("incorrect_password")} ${t(
"please_try_again"
)}`,
[ErrorCode.UserNotFound]: t("no_account_exists"),
[ErrorCode.IncorrectTwoFactorCode]: `${t("incorrect_2fa_code")} ${t("please_try_again")}`,
[ErrorCode.InternalServerError]: `${t("something_went_wrong")} ${t("please_try_again_and_contact_us")}`,
[ErrorCode.ThirdPartyIdentityProviderEnabled]: t("account_created_with_identity_provider"),
[ErrorCode.IncorrectTwoFactorCode]: `${t("incorrect_2fa_code")} ${t(
"please_try_again"
)}`,
[ErrorCode.InternalServerError]: `${t("something_went_wrong")} ${t(
"please_try_again_and_contact_us"
)}`,
[ErrorCode.ThirdPartyIdentityProviderEnabled]: t(
"account_created_with_identity_provider"
),
};
const userEmail = user.email || "";
@@ -267,7 +303,8 @@ const ProfileView = ({ user }: Props) => {
<SettingsHeader
title={t("profile")}
description={t("profile_description", { appName: APP_NAME })}
borderInShellHeader={true}>
borderInShellHeader={true}
>
<ProfileForm
key={JSON.stringify(defaultValues)}
defaultValues={defaultValues}
@@ -316,19 +353,30 @@ const ProfileView = ({ user }: Props) => {
{shouldShowCompanyEmailAlert && (
<div className="mt-6">
<CompanyEmailOrganizationBanner onDismissAction={() => setIsCompanyEmailAlertDismissed(true)} />
<CompanyEmailOrganizationBanner
onDismissAction={() => setIsCompanyEmailAlertDismissed(true)}
/>
</div>
)}
<div className="border-subtle mt-6 rounded-lg rounded-b-none border border-b-0 p-6">
<Label className="mb-0 text-base font-semibold text-red-700">{t("danger_zone")}</Label>
<p className="text-subtle text-sm">{t("account_deletion_cannot_be_undone")}</p>
<Label className="mb-0 text-base font-semibold text-red-700">
{t("danger_zone")}
</Label>
<p className="text-subtle text-sm">
{t("account_deletion_cannot_be_undone")}
</p>
</div>
{/* Delete account Dialog */}
<Dialog open={deleteAccountOpen} onOpenChange={setDeleteAccountOpen}>
<SectionBottomActions align="end">
<DialogTrigger asChild>
<Button data-testid="delete-account" color="destructive" className="mt-1" StartIcon="trash-2">
<Button
data-testid="delete-account"
color="destructive"
className="mt-1"
StartIcon="trash-2"
>
{t("delete_account")}
</Button>
</DialogTrigger>
@@ -337,10 +385,13 @@ const ProfileView = ({ user }: Props) => {
title={t("delete_account_modal_title")}
description={t("confirm_delete_account_modal", { appName: APP_NAME })}
type="creation"
Icon="triangle-alert">
Icon="triangle-alert"
>
<>
<div className="mb-10">
<p className="text-subtle mb-4 text-sm">{t("delete_account_confirmation_message")}</p>
<p className="text-subtle mb-4 text-sm">
{t("delete_account_confirmation_message")}
</p>
{isCALIdentityProvider && (
<PasswordField
data-testid="password"
@@ -359,7 +410,9 @@ const ProfileView = ({ user }: Props) => {
</Form>
)}
{hasDeleteErrors && <Alert severity="error" title={deleteErrorMessage} />}
{hasDeleteErrors && (
<Alert severity="error" title={deleteErrorMessage} />
)}
</div>
<DialogFooter showDivider>
<DialogClose />
@@ -367,7 +420,8 @@ const ProfileView = ({ user }: Props) => {
color="destructive"
data-testid="delete-account-confirm"
onClick={(e) => onConfirmButton(e)}
loading={deleteMeMutation.isPending}>
loading={deleteMeMutation.isPending}
>
{t("delete_my_account")}
</Button>
</DialogFooter>
@@ -381,7 +435,8 @@ const ProfileView = ({ user }: Props) => {
title={t("confirm_password")}
description={t("confirm_password_change_email")}
type="creation"
Icon="triangle-alert">
Icon="triangle-alert"
>
<div className="mb-10">
<div className="mb-4 grid gap-2 md:grid-cols-2">
<div>
@@ -394,7 +449,9 @@ const ProfileView = ({ user }: Props) => {
<span className="text-emphasis mb-2 block text-sm font-medium leading-none">
{t("new_email_address")}
</span>
<p className="text-subtle leading-none">{tempFormValues?.email}</p>
<p className="text-subtle leading-none">
{tempFormValues?.email}
</p>
</div>
</div>
<PasswordField
@@ -407,14 +464,17 @@ const ProfileView = ({ user }: Props) => {
ref={passwordRef}
/>
{confirmPasswordErrorMessage && <Alert severity="error" title={confirmPasswordErrorMessage} />}
{confirmPasswordErrorMessage && (
<Alert severity="error" title={confirmPasswordErrorMessage} />
)}
</div>
<DialogFooter showDivider>
<Button
data-testid="profile-update-email-submit-button"
color="primary"
loading={confirmPasswordMutation.isPending}
onClick={(e) => onConfirmPassword(e)}>
onClick={(e) => onConfirmPassword(e)}
>
{t("confirm")}
</Button>
<DialogClose />
@@ -422,31 +482,40 @@ const ProfileView = ({ user }: Props) => {
</DialogContent>
</Dialog>
<Dialog open={showCreateAccountPasswordDialog} onOpenChange={setShowCreateAccountPasswordDialog}>
<Dialog
open={showCreateAccountPasswordDialog}
onOpenChange={setShowCreateAccountPasswordDialog}
>
<DialogContent
title={t("create_account_password")}
description={t("create_account_password_hint")}
type="creation"
Icon="triangle-alert">
Icon="triangle-alert"
>
<DialogFooter>
<DialogClose />
</DialogFooter>
</DialogContent>
</Dialog>
<Dialog open={showAccountDisconnectWarning} onOpenChange={setShowAccountDisconnectWarning}>
<Dialog
open={showAccountDisconnectWarning}
onOpenChange={setShowAccountDisconnectWarning}
>
<DialogContent
title={t("disconnect_account")}
description={t("disconnect_account_hint")}
type="creation"
Icon="triangle-alert">
Icon="triangle-alert"
>
<DialogFooter>
<Button
color="primary"
onClick={() => {
unlinkConnectedAccountMutation.mutate();
setShowAccountDisconnectWarning(false);
}}>
}}
>
{t("confirm")}
</Button>
<DialogClose />
@@ -528,7 +597,9 @@ const ProfileForm = ({
.trim()
.min(1, t("you_need_to_add_a_name"))
.max(FULL_NAME_LENGTH_MAX_LIMIT, {
message: t("max_limit_allowed_hint", { limit: FULL_NAME_LENGTH_MAX_LIMIT }),
message: t("max_limit_allowed_hint", {
limit: FULL_NAME_LENGTH_MAX_LIMIT,
}),
}),
email: emailSchema.toLowerCase(),
bio: z.string(),
@@ -558,7 +629,8 @@ const ProfileForm = ({
});
const getUpdatedFormValues = (values: FormValues) => {
const changedFields = formMethods.formState.dirtyFields?.secondaryEmails || [];
const changedFields =
formMethods.formState.dirtyFields?.secondaryEmails || [];
const updatedValues: FormValues = {
...values,
};
@@ -569,7 +641,8 @@ const ProfileForm = ({
);
if (primaryEmailIndex >= 0) {
// Add the new updated value as primary email
updatedValues.email = updatedValues.secondaryEmails[primaryEmailIndex].email;
updatedValues.email =
updatedValues.secondaryEmails[primaryEmailIndex].email;
}
// We will only send the emails which have already changed
@@ -583,12 +656,17 @@ const ProfileForm = ({
});
const deletedEmails = (user?.secondaryEmails || []).filter(
(secondaryEmail) => !updatedValues.secondaryEmails.find((val) => val.id && val.id === secondaryEmail.id)
(secondaryEmail) =>
!updatedValues.secondaryEmails.find(
(val) => val.id && val.id === secondaryEmail.id
)
);
const secondaryEmails = [
...updatedEmails.map((email) => ({ ...email, isDeleted: false })),
...deletedEmails.map((email) => ({ ...email, isDeleted: true })),
].map((secondaryEmail) => pick(secondaryEmail, ["id", "email", "isDeleted"]));
].map((secondaryEmail) =>
pick(secondaryEmail, ["id", "email", "isDeleted"])
);
return {
...updatedValues,
@@ -625,9 +703,16 @@ const ProfileForm = ({
const showRemoveAvatarButton = value !== null;
return (
<>
<UserAvatar data-testid="profile-upload-avatar" previewSrc={value} size="lg" user={user} />
<UserAvatar
data-testid="profile-upload-avatar"
previewSrc={value}
size="lg"
user={user}
/>
<div className="ms-4">
<h2 className="mb-2 text-sm font-medium">{t("profile_picture")}</h2>
<h2 className="mb-2 text-sm font-medium">
{t("profile_picture")}
</h2>
<div className="flex gap-2">
<ImageUploader
target="avatar"
@@ -637,15 +722,18 @@ const ProfileForm = ({
onChange(newAvatar);
}}
imageSrc={getUserAvatarUrl({ avatarUrl: value })}
triggerButtonColor={showRemoveAvatarButton ? "secondary" : "secondary"}
triggerButtonColor={
showRemoveAvatarButton ? "secondary" : "secondary"
}
/>
{showRemoveAvatarButton && (
<Button
color="destructive"
color="minimal"
onClick={() => {
onChange(null);
}}>
}}
>
{t("remove")}
</Button>
)}
@@ -669,22 +757,32 @@ const ProfileForm = ({
<div className="-mt-2 flex flex-wrap items-start gap-2">
<div
className={
secondaryEmailFields.length > 1 ? "grid w-full grid-cols-1 gap-2 sm:grid-cols-2" : "flex-1"
}>
secondaryEmailFields.length > 1
? "grid w-full grid-cols-1 gap-2 sm:grid-cols-2"
: "flex-1"
}
>
{secondaryEmailFields.map((field, index) => (
<CustomEmailTextField
key={field.itemId}
formMethods={formMethods}
formMethodFieldName={`secondaryEmails.${index}.email` as keyof FormValues}
errorMessage={get(formMethods.formState.errors, `secondaryEmails.${index}.email.message`)}
formMethodFieldName={
`secondaryEmails.${index}.email` as keyof FormValues
}
errorMessage={get(
formMethods.formState.errors,
`secondaryEmails.${index}.email.message`
)}
emailVerified={Boolean(field.emailVerified)}
emailPrimary={field.emailPrimary}
dataTestId={`profile-form-email-${index}`}
handleChangePrimary={() => {
const fields = secondaryEmailFields.map((secondaryField, cIndex) => ({
...secondaryField,
emailPrimary: cIndex === index,
}));
const fields = secondaryEmailFields.map(
(secondaryField, cIndex) => ({
...secondaryField,
emailPrimary: cIndex === index,
})
);
updateAllSecondaryEmailFields(fields);
}}
handleVerifyEmail={() => handleResendVerifyEmail(field.email)}
@@ -697,7 +795,8 @@ const ProfileForm = ({
StartIcon="plus"
className="mt-2"
onClick={() => handleAddSecondaryEmail()}
data-testid="add-secondary-email">
data-testid="add-secondary-email"
>
{t("add_email")}
</Button>
</div>
@@ -707,7 +806,9 @@ const ProfileForm = ({
<Editor
getText={() => md.render(formMethods.getValues("bio") || "")}
setText={(value: string) => {
formMethods.setValue("bio", turndown(value), { shouldDirty: true });
formMethods.setValue("bio", turndown(value), {
shouldDirty: true,
});
}}
excludedToolbarItems={["blockType"]}
disableLists
@@ -728,7 +829,9 @@ const ProfileForm = ({
labelClassname="font-normal text-sm text-subtle"
valueClassname="text-emphasis inline-flex items-center gap-1 font-normal text-sm leading-5"
value={
["TEXT", "NUMBER", "SINGLE_SELECT"].includes(attribute.type)
["TEXT", "NUMBER", "SINGLE_SELECT"].includes(
attribute.type
)
? attribute.options[0].value
: attribute.options.map((option) => option.value)
}
@@ -740,22 +843,27 @@ const ProfileForm = ({
)}
{/* // For Non-Cal identities, we merge the values from DB and the user logging in,
so essentially there's no point in allowing them to disconnect, since when they log in they will get logged into the same account */}
{!isCALIdentityProvider && user.email !== user.identityProviderEmail && (
<div className="mt-6">
<Label>Connected accounts</Label>
<div className="flex items-center">
<span className="text-default text-sm capitalize">{user.identityProvider.toLowerCase()}</span>
{user.identityProviderEmail && (
<span className="text-default ml-2 text-sm">{user.identityProviderEmail}</span>
)}
<div className="flex flex-1 justify-end">
<Button color="destructive" onClick={onDisconnect}>
{t("disconnect")}
</Button>
{!isCALIdentityProvider &&
user.email !== user.identityProviderEmail && (
<div className="mt-6">
<Label>Connected accounts</Label>
<div className="flex items-center">
<span className="text-default text-sm capitalize">
{user.identityProvider.toLowerCase()}
</span>
{user.identityProviderEmail && (
<span className="text-default ml-2 text-sm">
{user.identityProviderEmail}
</span>
)}
<div className="flex flex-1 justify-end">
<Button color="destructive" onClick={onDisconnect}>
{t("disconnect")}
</Button>
</div>
</div>
</div>
</div>
)}
)}
</div>
<SectionBottomActions align="end">
<Button
@@ -763,7 +871,8 @@ const ProfileForm = ({
disabled={isDisabled}
color="primary"
type="submit"
data-testid="profile-submit-button">
data-testid="profile-submit-button"
>
{t("update")}
</Button>
</SectionBottomActions>