* fix: simplify workflow page and improve load time * chore: use new endpoint * chore: save progress * refactor: code * refactor: remove not requried code * chore: remove schema * chore: fix typ * chore: improve * chore: change name * chore: remove unused * chore: remove page * refactor: teams page * feat: add auto scroll * chore: create validate unique invite * fix: auth check * fix: optimistic update * chore * fix: add loading * fix: improvements * chore: remove * chore * chore: fix teams page * fix: team profile page * fix: appearance page * fix: sso view * fix: type err * feat: defer loading connected Apps * fix: type err * fix: type error * fix: type err * fix: connectedApps type * chore: move * chore: missing export * feat: add search by name * fix: display role change * fix: use setInfiniteData * chore: save progress * test: add unit tests for loading members * fix: test * chore: update name * fix: bugs and improvements * chore: change variable name * test: add tests for checkCanAccessMembers * refactor: performance --------- Co-authored-by: Joe Au-Yeung <[email protected]>
55 lines
1.5 KiB
TypeScript
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, SettingsToggle } from "@calcom/ui";
|
|
|
|
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();
|
|
await utils.viewer.teams.getMinimal.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;
|