2022-03-16 23:36:43 +00:00
|
|
|
import showToast from "@calcom/lib/notification";
|
2022-07-22 17:27:06 +00:00
|
|
|
import { inferQueryOutput, trpc } from "@calcom/trpc/react";
|
2021-06-05 22:53:33 +00:00
|
|
|
|
2021-09-22 19:52:38 +00:00
|
|
|
import TeamListItem from "./TeamListItem";
|
|
|
|
|
2021-12-09 23:51:30 +00:00
|
|
|
interface Props {
|
|
|
|
teams: inferQueryOutput<"viewer.teams.list">;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function TeamList(props: Props) {
|
|
|
|
const utils = trpc.useContext();
|
|
|
|
|
|
|
|
function selectAction(action: string, teamId: number) {
|
2021-06-05 22:53:33 +00:00
|
|
|
switch (action) {
|
Cal 262 refactor edit teams according to the design reference (#516)
* refactored settings/team landing page
* changed team edit flow, WIP
* merge conflict fix for teams.tsx
* minor fixes to edit team, WIP
* invite-member and disband team APIs attached inside edit-team page
* added remove-member API in edit-team page, minor fixes
* minor code fix, WIP
* WIP
* add logo, bio, branding to team schema
* bio, logo, branding, slug patch API and minor code fix-- WIP
* fn to Disband team directly from the dropdown menu in settings/teams page, removed debug remnants --WIP
* Pull latest data after an action in settings/teams-edit page
* added slug conflict check at Patch time
* code clean-up
* initial change request fixes --WIP
* prop type fix and add warn button color theme --WIP
* added warn Button to Dialog
* remaining change request fixes
* added noop from react-query
* updated invited team-list design
* prettier fix for api/teams/profile
* removed noop import and added custom noop
* minor Button fix
* requested changes addressed
2021-09-06 13:22:22 +00:00
|
|
|
case "disband":
|
2021-12-09 23:51:30 +00:00
|
|
|
deleteTeam(teamId);
|
2021-06-05 22:53:33 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-12-09 23:51:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const deleteTeamMutation = trpc.useMutation("viewer.teams.delete", {
|
|
|
|
async onSuccess() {
|
|
|
|
await utils.invalidateQueries(["viewer.teams.list"]);
|
|
|
|
},
|
|
|
|
async onError(err) {
|
|
|
|
showToast(err.message, "error");
|
|
|
|
},
|
|
|
|
});
|
2021-06-05 22:53:33 +00:00
|
|
|
|
2021-12-09 23:51:30 +00:00
|
|
|
function deleteTeam(teamId: number) {
|
|
|
|
deleteTeamMutation.mutate({ teamId });
|
|
|
|
}
|
Cal 262 refactor edit teams according to the design reference (#516)
* refactored settings/team landing page
* changed team edit flow, WIP
* merge conflict fix for teams.tsx
* minor fixes to edit team, WIP
* invite-member and disband team APIs attached inside edit-team page
* added remove-member API in edit-team page, minor fixes
* minor code fix, WIP
* WIP
* add logo, bio, branding to team schema
* bio, logo, branding, slug patch API and minor code fix-- WIP
* fn to Disband team directly from the dropdown menu in settings/teams page, removed debug remnants --WIP
* Pull latest data after an action in settings/teams-edit page
* added slug conflict check at Patch time
* code clean-up
* initial change request fixes --WIP
* prop type fix and add warn button color theme --WIP
* added warn Button to Dialog
* remaining change request fixes
* added noop from react-query
* updated invited team-list design
* prettier fix for api/teams/profile
* removed noop import and added custom noop
* minor Button fix
* requested changes addressed
2021-09-06 13:22:22 +00:00
|
|
|
|
2021-08-02 20:51:57 +00:00
|
|
|
return (
|
|
|
|
<div>
|
2022-02-09 00:05:13 +00:00
|
|
|
<ul className="mb-2 divide-y divide-neutral-200 rounded border bg-white">
|
2021-12-09 23:51:30 +00:00
|
|
|
{props.teams.map((team) => (
|
2021-08-02 20:51:57 +00:00
|
|
|
<TeamListItem
|
2021-12-09 23:51:30 +00:00
|
|
|
key={team?.id as number}
|
2021-08-02 20:51:57 +00:00
|
|
|
team={team}
|
2022-05-14 18:47:23 +00:00
|
|
|
onActionSelect={(action: string) => selectAction(action, team?.id as number)}
|
|
|
|
isLoading={deleteTeamMutation.isLoading}
|
|
|
|
/>
|
2021-08-02 20:51:57 +00:00
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
);
|
2021-07-30 23:05:38 +00:00
|
|
|
}
|