Files
cal.diy/packages/features/ee/teams/components/MakeTeamPrivateSwitch.tsx
T
Benny JooandKeith Williams 853f9bc436 perf: do not import from @calcom/ui barrel file (#20184)
* Icon and IconName

* Button and ButtonGroup

* UserAvatar

* AvatarGroup

* Avatar

* WizardLayout

* Dialogs

* EmptyScreen

* showToast and TextField

* Editor

* Skeleton

* Skeleton

* TopBanner and showToast

* Button again

* more

* perf: Remove app-store reference from @calcom/ui

* more

* Fixing types

* Icon

* Fixed casing

* dropdown

* more

* Select

* more

* Badge

* List

* more

* Divider

* more

* fix

* fix type check

* refactor

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix type check

* fix

* fix

* fix

* fix

* more

* more

* more

* more

* add index file to components/command

* fix

* fix

* fix

* fix imports

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix build errors

* fix build errors

* fix

---------

Co-authored-by: Keith Williams <[email protected]>
2025-03-19 19:00:55 -03:00

55 lines
1.5 KiB
TypeScript

import { useState } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { showToast } from "@calcom/ui/components/toast";
import { SettingsToggle } from "@calcom/ui/components/form";
const MakeTeamPrivateSwitch = ({
teamId,
isPrivate,
disabled,
isOrg,
}: {
teamId: number;
isPrivate: boolean;
disabled: boolean;
isOrg: boolean;
}) => {
const { t } = useLocale();
const utils = trpc.useUtils();
const mutation = trpc.viewer.teams.update.useMutation({
onError: (err) => {
showToast(err.message, "error");
},
async onSuccess() {
await utils.viewer.teams.get.invalidate();
showToast(t(isOrg ? "your_org_updated_successfully" : "your_team_updated_successfully"), "success");
},
});
const [isTeamPrivate, setTeamPrivate] = useState(isPrivate);
return (
<>
<SettingsToggle
toggleSwitchAtTheEnd={true}
title={t(isOrg ? "make_org_private" : "make_team_private")}
disabled={disabled || mutation?.isPending}
description={t(isOrg ? "make_org_private_description" : "make_team_private_description")}
checked={isTeamPrivate}
onCheckedChange={(checked) => {
setTeamPrivate(checked);
mutation.mutate({ id: teamId, isPrivate: checked });
}}
switchContainerClassName="my-6"
data-testid="make-team-private-check"
/>
</>
);
};
export default MakeTeamPrivateSwitch;