import { MembershipRole } from "@prisma/client"; import Link from "next/link"; import { useRouter } from "next/router"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { TeamWithMembers } from "@calcom/lib/server/queries/teams"; import { trpc } from "@calcom/trpc/react"; import { ConfirmationDialogContent, Dialog, DialogTrigger, Icon, LinkIconButton, showToast } from "../../.."; import CreateEventTypeButton from "../event-types/CreateEventType"; export default function TeamSettingsRightSidebar(props: { team: TeamWithMembers; role: MembershipRole }) { const { t } = useLocale(); const utils = trpc.useContext(); const router = useRouter(); const permalink = `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team/${props.team?.slug}`; const deleteTeamMutation = trpc.viewer.teams.delete.useMutation({ async onSuccess() { await utils.viewer.teams.get.invalidate(); router.push(`/settings/teams`); showToast(t("your_team_updated_successfully"), "success"); }, }); const acceptOrLeaveMutation = trpc.viewer.teams.acceptOrLeave.useMutation({ onSuccess: () => { utils.viewer.teams.list.invalidate(); router.push(`/settings/teams`); }, }); function deleteTeam() { if (props.team?.id) deleteTeamMutation.mutate({ teamId: props.team.id }); } function leaveTeam() { if (props.team?.id) acceptOrLeaveMutation.mutate({ teamId: props.team.id, accept: false, }); } return (
{(props.role === MembershipRole.OWNER || props.role === MembershipRole.ADMIN) && ( )}
{t("preview")} { navigator.clipboard.writeText(permalink); showToast("Copied to clipboard", "success"); }}> {t("copy_link_team")} {props.role === "OWNER" ? ( { e.stopPropagation(); }} Icon={Icon.FiTrash}> {t("disband_team")} {t("disband_team_confirmation_message")} ) : ( { e.stopPropagation(); }}> {t("leave_team")} {t("leave_team_confirmation_message")} )}
{props.team?.id && props.role !== MembershipRole.MEMBER && (
View Availability

See your team members availability at a glance.

)}
); }