Skip to content

Scheduling infrastructure for absolutely everyone.

fix: Hide personal booking theme when in an organization (#16117)

sean-brydon53ec5daa1b37
diff --git a/apps/web/pages/settings/my-account/appearance.tsx b/apps/web/pages/settings/my-account/appearance.tsx
index dacdf8dd3ff..a2f0bb36b9f 100644
--- a/apps/web/pages/settings/my-account/appearance.tsx
+++ b/apps/web/pages/settings/my-account/appearance.tsx
@@ -1,5 +1,6 @@
"use client";
+import { useSession } from "next-auth/react";
import { useState } from "react";
import { Controller, useForm } from "react-hook-form";
import type { z } from "zod";
@@ -94,6 +95,8 @@ const AppearanceView = ({
}) => {
const { t } = useLocale();
const utils = trpc.useUtils();
+ const session = useSession();
+ const isApartOfOrganization = session.data?.user.org?.id;
const [darkModeError, setDarkModeError] = useState(false);
const [lightModeError, setLightModeError] = useState(false);
const [isCustomBrandColorChecked, setIsCustomBranColorChecked] = useState(
@@ -237,172 +240,176 @@ const AppearanceView = ({
</SectionBottomActions>
</Form>
- <div className="border-subtle mt-6 flex items-center rounded-t-lg border p-6 text-sm">
- <div>
- <p className="text-default text-base font-semibold">{t("theme")}</p>
- <p className="text-default">{t("theme_applies_note")}</p>
- </div>
- </div>
- <Form
- form={userThemeFormMethods}
- handleSubmit={(values) => {
- mutation.mutate({
- // Radio values don't support null as values, therefore we convert an empty string
- // back to null here.
- theme: values.theme === "" ? null : values.theme,
- });
- }}>
- <div className="border-subtle flex flex-col justify-between border-x px-6 py-8 sm:flex-row">
- <ThemeLabel
- variant="system"
- value={undefined}
- label={t("theme_system")}
- defaultChecked={user.theme === null}
- register={userThemeFormMethods.register}
- />
- <ThemeLabel
- variant="light"
- value="light"
- label={t("light")}
- defaultChecked={user.theme === "light"}
- register={userThemeFormMethods.register}
- />
- <ThemeLabel
- variant="dark"
- value="dark"
- label={t("dark")}
- defaultChecked={user.theme === "dark"}
- register={userThemeFormMethods.register}
- />
- </div>
- <SectionBottomActions className="mb-6" align="end">
- <Button
- loading={mutation.isPending}
- disabled={isUserThemeSubmitting || !isUserThemeDirty}
- type="submit"
- data-testid="update-theme-btn"
- color="primary">
- {t("update")}
- </Button>
- </SectionBottomActions>
- </Form>
-
- <Form
- form={bookerLayoutFormMethods}
- handleSubmit={(values) => {
- const layoutError = validateBookerLayouts(values?.metadata?.defaultBookerLayouts || null);
- if (layoutError) {
- showToast(t(layoutError), "error");
- return;
- } else {
- mutation.mutate(values);
- }
- }}>
- <BookerLayoutSelector
- isDark={selectedThemeIsDark}
- name="metadata.defaultBookerLayouts"
- title={t("bookerlayout_user_settings_title")}
- description={t("bookerlayout_user_settings_description")}
- isDisabled={isBookerLayoutFormSubmitting || !isBookerLayoutFormDirty}
- isLoading={mutation.isPending}
- />
- </Form>
-
- <Form
- form={brandColorsFormMethods}
- handleSubmit={(values) => {
- mutation.mutate(values);
- }}>
- <div className="mt-6">
- <SettingsToggle
- toggleSwitchAtTheEnd={true}
- title={t("custom_brand_colors")}
- description={t("customize_your_brand_colors")}
- checked={isCustomBrandColorChecked}
- onCheckedChange={(checked) => {
- setIsCustomBranColorChecked(checked);
- if (!checked) {
- mutation.mutate({
- brandColor: DEFAULT_LIGHT_BRAND_COLOR,
- darkBrandColor: DEFAULT_DARK_BRAND_COLOR,
- });
- }
- }}
- childrenClassName="lg:ml-0">
- <div className="border-subtle flex flex-col gap-6 border-x p-6">
- <Controller
- name="brandColor"
- control={brandColorsFormMethods.control}
- defaultValue={DEFAULT_BRAND_COLOURS.light}
- render={() => (
- <div>
- <p className="text-default mb-2 block text-sm font-medium">{t("light_brand_color")}</p>
- <ColorPicker
- defaultValue={DEFAULT_BRAND_COLOURS.light}
- resetDefaultValue={DEFAULT_LIGHT_BRAND_COLOR}
- onChange={(value) => {
- try {
- checkWCAGContrastColor("#ffffff", value);
- setLightModeError(false);
- brandColorsFormMethods.setValue("brandColor", value, { shouldDirty: true });
- } catch (err) {
- setLightModeError(false);
- }
- }}
- />
- {lightModeError ? (
- <div className="mt-4">
- <Alert severity="warning" message={t("light_theme_contrast_error")} />
- </div>
- ) : null}
- </div>
- )}
+ {isApartOfOrganization ? null : (
+ <>
+ <div className="border-subtle mt-6 flex items-center rounded-t-lg border p-6 text-sm">
+ <div>
+ <p className="text-default text-base font-semibold">{t("theme")}</p>
+ <p className="text-default">{t("theme_applies_note")}</p>
+ </div>
+ </div>
+ <Form
+ form={userThemeFormMethods}
+ handleSubmit={(values) => {
+ mutation.mutate({
+ // Radio values don't support null as values, therefore we convert an empty string
+ // back to null here.
+ theme: values.theme === "" ? null : values.theme,
+ });
+ }}>
+ <div className="border-subtle flex flex-col justify-between border-x px-6 py-8 sm:flex-row">
+ <ThemeLabel
+ variant="system"
+ value={undefined}
+ label={t("theme_system")}
+ defaultChecked={user.theme === null}
+ register={userThemeFormMethods.register}
/>
-
- <Controller
- name="darkBrandColor"
- control={brandColorsFormMethods.control}
- defaultValue={DEFAULT_BRAND_COLOURS.dark}
- render={() => (
- <div className="mt-6 sm:mt-0">
- <p className="text-default mb-2 block text-sm font-medium">{t("dark_brand_color")}</p>
- <ColorPicker
- defaultValue={DEFAULT_BRAND_COLOURS.dark}
- resetDefaultValue={DEFAULT_DARK_BRAND_COLOR}
- onChange={(value) => {
- try {
- checkWCAGContrastColor("#101010", value);
- setDarkModeError(false);
- brandColorsFormMethods.setValue("darkBrandColor", value, { shouldDirty: true });
- } catch (err) {
- setDarkModeError(true);
- }
- }}
- />
- {darkModeError ? (
- <div className="mt-4">
- <Alert severity="warning" message={t("dark_theme_contrast_error")} />
- </div>
- ) : null}
- </div>
- )}
+ <ThemeLabel
+ variant="light"
+ value="light"
+ label={t("light")}
+ defaultChecked={user.theme === "light"}
+ register={userThemeFormMethods.register}
+ />
+ <ThemeLabel
+ variant="dark"
+ value="dark"
+ label={t("dark")}
+ defaultChecked={user.theme === "dark"}
+ register={userThemeFormMethods.register}
/>
</div>
- <SectionBottomActions align="end">
+ <SectionBottomActions className="mb-6" align="end">
<Button
loading={mutation.isPending}
- disabled={isBrandColorsFormSubmitting || !isBrandColorsFormDirty}
- color="primary"
- type="submit">
+ disabled={isUserThemeSubmitting || !isUserThemeDirty}
+ type="submit"
+ data-testid="update-theme-btn"
+ color="primary">
{t("update")}
</Button>
</SectionBottomActions>
- </SettingsToggle>
- </div>
- </Form>
+ </Form>
+
+ <Form
+ form={bookerLayoutFormMethods}
+ handleSubmit={(values) => {
+ const layoutError = validateBookerLayouts(values?.metadata?.defaultBookerLayouts || null);
+ if (layoutError) {
+ showToast(t(layoutError), "error");
+ return;
+ } else {
+ mutation.mutate(values);
+ }
+ }}>
+ <BookerLayoutSelector
+ isDark={selectedThemeIsDark}
+ name="metadata.defaultBookerLayouts"
+ title={t("bookerlayout_user_settings_title")}
+ description={t("bookerlayout_user_settings_description")}
+ isDisabled={isBookerLayoutFormSubmitting || !isBookerLayoutFormDirty}
+ isLoading={mutation.isPending}
+ />
+ </Form>
+
+ <Form
+ form={brandColorsFormMethods}
+ handleSubmit={(values) => {
+ mutation.mutate(values);
+ }}>
+ <div className="mt-6">
+ <SettingsToggle
+ toggleSwitchAtTheEnd={true}
+ title={t("custom_brand_colors")}
+ description={t("customize_your_brand_colors")}
+ checked={isCustomBrandColorChecked}
+ onCheckedChange={(checked) => {
+ setIsCustomBranColorChecked(checked);
+ if (!checked) {
+ mutation.mutate({
+ brandColor: DEFAULT_LIGHT_BRAND_COLOR,
+ darkBrandColor: DEFAULT_DARK_BRAND_COLOR,
+ });
+ }
+ }}
+ childrenClassName="lg:ml-0">
+ <div className="border-subtle flex flex-col gap-6 border-x p-6">
+ <Controller
+ name="brandColor"
+ control={brandColorsFormMethods.control}
+ defaultValue={DEFAULT_BRAND_COLOURS.light}
+ render={() => (
+ <div>
+ <p className="text-default mb-2 block text-sm font-medium">
+ {t("light_brand_color")}
+ </p>
+ <ColorPicker
+ defaultValue={DEFAULT_BRAND_COLOURS.light}
+ resetDefaultValue={DEFAULT_LIGHT_BRAND_COLOR}
+ onChange={(value) => {
+ try {
+ checkWCAGContrastColor("#ffffff", value);
+ setLightModeError(false);
+ brandColorsFormMethods.setValue("brandColor", value, { shouldDirty: true });
+ } catch (err) {
+ setLightModeError(false);
+ }
+ }}
+ />
+ {lightModeError ? (
+ <div className="mt-4">
+ <Alert severity="warning" message={t("light_theme_contrast_error")} />
+ </div>
+ ) : null}
+ </div>
+ )}
+ />
- {/* TODO future PR to preview brandColors */}
- {/* <Button
+ <Controller
+ name="darkBrandColor"
+ control={brandColorsFormMethods.control}
+ defaultValue={DEFAULT_BRAND_COLOURS.dark}
+ render={() => (
+ <div className="mt-6 sm:mt-0">
+ <p className="text-default mb-2 block text-sm font-medium">{t("dark_brand_color")}</p>
+ <ColorPicker
+ defaultValue={DEFAULT_BRAND_COLOURS.dark}
+ resetDefaultValue={DEFAULT_DARK_BRAND_COLOR}
+ onChange={(value) => {
+ try {
+ checkWCAGContrastColor("#101010", value);
+ setDarkModeError(false);
+ brandColorsFormMethods.setValue("darkBrandColor", value, { shouldDirty: true });
+ } catch (err) {
+ setDarkModeError(true);
+ }
+ }}
+ />
+ {darkModeError ? (
+ <div className="mt-4">
+ <Alert severity="warning" message={t("dark_theme_contrast_error")} />
+ </div>
+ ) : null}
+ </div>
+ )}
+ />
+ </div>
+ <SectionBottomActions align="end">
+ <Button
+ loading={mutation.isPending}
+ disabled={isBrandColorsFormSubmitting || !isBrandColorsFormDirty}
+ color="primary"
+ type="submit">
+ {t("update")}
+ </Button>
+ </SectionBottomActions>
+ </SettingsToggle>
+ </div>
+ </Form>
+
+ {/* TODO future PR to preview brandColors */}
+ {/* <Button
color="secondary"
EndIcon="external-link"
className="mt-6"
@@ -410,19 +417,21 @@ const AppearanceView = ({
Preview
</Button> */}
- <SettingsToggle
- toggleSwitchAtTheEnd={true}
- title={t("disable_cal_branding", { appName: APP_NAME })}
- disabled={!hasPaidPlan || mutation?.isPending}
- description={t("removes_cal_branding", { appName: APP_NAME })}
- checked={hasPaidPlan ? hideBrandingValue : false}
- Badge={<UpgradeTeamsBadge />}
- onCheckedChange={(checked) => {
- setHideBrandingValue(checked);
- mutation.mutate({ hideBranding: checked });
- }}
- switchContainerClassName="mt-6"
- />
+ <SettingsToggle
+ toggleSwitchAtTheEnd={true}
+ title={t("disable_cal_branding", { appName: APP_NAME })}
+ disabled={!hasPaidPlan || mutation?.isPending}
+ description={t("removes_cal_branding", { appName: APP_NAME })}
+ checked={hasPaidPlan ? hideBrandingValue : false}
+ Badge={<UpgradeTeamsBadge />}
+ onCheckedChange={(checked) => {
+ setHideBrandingValue(checked);
+ mutation.mutate({ hideBranding: checked });
+ }}
+ switchContainerClassName="mt-6"
+ />
+ </>
+ )}
</div>
);
};
diff --git a/packages/features/settings/layouts/SettingsLayout.tsx b/packages/features/settings/layouts/SettingsLayout.tsx
index a0504f084bd..8513eee80ac 100644
--- a/packages/features/settings/layouts/SettingsLayout.tsx
+++ b/packages/features/settings/layouts/SettingsLayout.tsx
@@ -156,9 +156,6 @@ const useTabs = () => {
const processTabsMemod = useMemo(() => {
const processedTabs = tabs.map((tab) => {
if (tab.href === "/settings/my-account") {
- if (!!session.data?.user?.org?.id) {
- tab.children = tab?.children?.filter((child) => child.href !== "/settings/my-account/appearance");
- }
return {
...tab,
name: user?.name || "my_account",