Files
cal.diy/packages/features/ee/teams/components/TeamInviteList.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

69 lines
1.8 KiB
TypeScript

import { useState } from "react";
import { trackFormbricksAction } from "@calcom/lib/formbricks-client";
import type { MembershipRole } from "@calcom/prisma/enums";
import { trpc } from "@calcom/trpc/react";
import { showToast } from "@calcom/ui/components/toast";
import TeamInviteListItem from "./TeamInviteListItem";
interface Props {
teams: {
id?: number;
name?: string | null;
slug?: string | null;
bio?: string | null;
hideBranding?: boolean | undefined;
role: MembershipRole;
logoUrl?: string | null;
accepted: boolean;
}[];
}
export default function TeamInviteList(props: Props) {
const utils = trpc.useUtils();
const [hideDropdown, setHideDropdown] = useState(false);
function selectAction(action: string, teamId: number) {
switch (action) {
case "disband":
deleteTeam(teamId);
break;
}
}
const deleteTeamMutation = trpc.viewer.teams.delete.useMutation({
async onSuccess() {
await utils.viewer.teams.list.invalidate();
await utils.viewer.teams.get.invalidate();
await utils.viewer.organizations.listMembers.invalidate();
trackFormbricksAction("team_disbanded");
},
async onError(err) {
showToast(err.message, "error");
},
});
function deleteTeam(teamId: number) {
deleteTeamMutation.mutate({ teamId });
}
return (
<div>
<ul className="bg-default divide-subtle mb-8 divide-y rounded">
{props.teams.map((team) => (
<TeamInviteListItem
key={team?.id as number}
team={team}
onActionSelect={(action: string) => selectAction(action, team?.id as number)}
isPending={deleteTeamMutation.isPending}
hideDropdown={hideDropdown}
setHideDropdown={setHideDropdown}
/>
))}
</ul>
</div>
);
}