import { GetServerSidePropsContext } from "next"; import { Controller, useForm } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import prisma from "@calcom/prisma"; import { trpc } from "@calcom/trpc/react"; import Badge from "@calcom/ui/v2/core/Badge"; import { Button } from "@calcom/ui/v2/core/Button"; import Meta from "@calcom/ui/v2/core/Meta"; import Switch from "@calcom/ui/v2/core/Switch"; import ColorPicker from "@calcom/ui/v2/core/colorpicker"; import { Form } from "@calcom/ui/v2/core/form/fields"; import { getLayout } from "@calcom/ui/v2/core/layouts/SettingsLayout"; import showToast from "@calcom/ui/v2/core/notifications"; import { getSession } from "@lib/auth"; import { inferSSRProps } from "@lib/types/inferSSRProps"; const AppearanceView = (props: inferSSRProps) => { const { t } = useLocale(); const { user } = props; const mutation = trpc.useMutation("viewer.updateProfile", { onSuccess: () => { showToast(t("settings_updated_successfully"), "success"); }, onError: () => { showToast(t("error_updating_settings"), "error"); }, }); const formMethods = useForm(); return (
{ mutation.mutate({ ...values, // Radio values don't support null as values, therefore we convert an empty string // back to null here. theme: values.theme || null, }); }}>

{t("theme")}

{t("theme_applies_note")}


{t("custom_brand_colors")}

{t("customize_your_brand_colors")}

(

{t("light_brand_color")}

formMethods.setValue("brandColor", value)} />
)} /> (

{t("dark_brand_color")}

formMethods.setValue("darkBrandColor", value)} />
)} />
{/* TODO future PR to preview brandColors */} {/* */}
( <>

{t("disable_cal_branding")}

{" "} {t("pro")}

{t("removes_cal_branding")}

formMethods.setValue("hideBranding", checked)} checked={value} />
)} /> ); }; AppearanceView.getLayout = getLayout; export default AppearanceView; export const getServerSideProps = async (context: GetServerSidePropsContext) => { const session = await getSession(context); if (!session?.user?.id) { return { redirect: { permanent: false, destination: "/auth/login" } }; } const user = await prisma.user.findUnique({ where: { id: session.user.id, }, select: { username: true, timeZone: true, timeFormat: true, weekStart: true, brandColor: true, darkBrandColor: true, hideBranding: true, theme: true, eventTypes: { select: { title: true, }, }, }, }); if (!user) { throw new Error("User seems logged in but cannot be found in the db"); } return { props: { user, }, }; }; interface ThemeLabelProps { variant: "light" | "dark" | "system"; value?: "light" | "dark" | null; label: string; defaultChecked?: boolean; register: any; } const ThemeLabel = ({ variant, label, value, defaultChecked, register }: ThemeLabelProps) => { return ( ); };