import { MembershipRole } from "@prisma/client"; import { useRouter } from "next/router"; import { Controller, useForm } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import { Button, Form, showToast, Switch } from "@calcom/ui/v2/core"; import Meta from "@calcom/ui/v2/core/Meta"; import { getLayout } from "@calcom/ui/v2/core/layouts/SettingsLayout"; interface TeamAppearanceValues { hideBranding: boolean; } const ProfileView = () => { const { t } = useLocale(); const router = useRouter(); const utils = trpc.useContext(); const mutation = trpc.useMutation("viewer.teams.update", { onError: (err) => { showToast(err.message, "error"); }, async onSuccess() { await utils.invalidateQueries(["viewer.teams.get"]); showToast(t("your_team_updated_successfully"), "success"); }, }); const form = useForm(); const { data: team, isLoading } = trpc.useQuery(["viewer.teams.get", { teamId: Number(router.query.id) }], { onError: () => { router.push("/settings"); }, onSuccess: (team) => { if (team) { form.setValue("hideBranding", team.hideBranding); } }, }); const isAdmin = team && (team.membership.role === MembershipRole.OWNER || team.membership.role === MembershipRole.ADMIN); return ( <> {!isLoading && ( <> {isAdmin ? (
{ if (team) { const hideBranding = form.getValues("hideBranding"); if (team.hideBranding !== hideBranding) { mutation.mutate({ id: team.id, hideBranding }); } } }}>

{t("team_disable_cal_branding_description")}

( { form.setValue("hideBranding", isChecked); }} /> )} />
) : (
{t("only_owner_change")}
)} )} ); }; ProfileView.getLayout = getLayout; export default ProfileView;