2022-07-31 19:48:17 +00:00
|
|
|
import { useState } from "react";
|
|
|
|
|
2023-02-01 20:41:47 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-03-15 19:09:43 +00:00
|
|
|
import type { RouterOutputs } from "@calcom/trpc/react";
|
|
|
|
import { trpc } from "@calcom/trpc/react";
|
2023-02-01 20:41:47 +00:00
|
|
|
import { Card, showToast } from "@calcom/ui";
|
2023-04-12 15:26:31 +00:00
|
|
|
import { UserPlus, Users, Edit } from "@calcom/ui/components/icon";
|
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 {
|
2022-11-10 23:40:01 +00:00
|
|
|
teams: RouterOutputs["viewer"]["teams"]["list"];
|
2023-03-15 19:09:43 +00:00
|
|
|
pending?: boolean;
|
2021-12-09 23:51:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default function TeamList(props: Props) {
|
|
|
|
const utils = trpc.useContext();
|
|
|
|
|
2023-02-01 20:41:47 +00:00
|
|
|
const { t } = useLocale();
|
|
|
|
|
2022-07-31 19:48:17 +00:00
|
|
|
const [hideDropdown, setHideDropdown] = useState(false);
|
|
|
|
|
2021-12-09 23:51:30 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-11-10 23:40:01 +00:00
|
|
|
const deleteTeamMutation = trpc.viewer.teams.delete.useMutation({
|
2021-12-09 23:51:30 +00:00
|
|
|
async onSuccess() {
|
2022-11-10 23:40:01 +00:00
|
|
|
await utils.viewer.teams.list.invalidate();
|
2023-02-01 21:23:34 +00:00
|
|
|
await utils.viewer.teams.hasTeamPlan.invalidate();
|
2021-12-09 23:51:30 +00:00
|
|
|
},
|
|
|
|
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 (
|
2023-07-11 15:11:08 +00:00
|
|
|
<ul className="bg-default divide-subtle border-subtle mb-2 divide-y overflow-hidden rounded-md border">
|
2023-01-24 15:27:05 +00:00
|
|
|
{props.teams.map((team) => (
|
|
|
|
<TeamListItem
|
|
|
|
key={team?.id as number}
|
|
|
|
team={team}
|
|
|
|
onActionSelect={(action: string) => selectAction(action, team?.id as number)}
|
|
|
|
isLoading={deleteTeamMutation.isLoading}
|
|
|
|
hideDropdown={hideDropdown}
|
|
|
|
setHideDropdown={setHideDropdown}
|
|
|
|
/>
|
|
|
|
))}
|
2023-02-01 20:41:47 +00:00
|
|
|
|
|
|
|
{/* only show recommended steps when there is only one team */}
|
2023-03-15 19:09:43 +00:00
|
|
|
{!props.pending && props.teams.length === 1 && (
|
2023-02-01 20:41:47 +00:00
|
|
|
<>
|
|
|
|
{props.teams.map(
|
|
|
|
(team, i) =>
|
2023-04-02 10:03:28 +00:00
|
|
|
team.role !== "MEMBER" &&
|
2023-02-01 20:41:47 +00:00
|
|
|
i === 0 && (
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="bg-subtle p-6">
|
|
|
|
<h3 className="text-emphasis mb-4 text-sm font-semibold">{t("recommended_next_steps")}</h3>
|
2023-02-01 20:41:47 +00:00
|
|
|
<div className="grid-col-1 grid gap-2 md:grid-cols-3">
|
|
|
|
<Card
|
2023-04-12 15:26:31 +00:00
|
|
|
icon={<UserPlus className="h-5 w-5 text-green-700" />}
|
2023-02-01 20:41:47 +00:00
|
|
|
variant="basic"
|
|
|
|
title={t("invite_team_member")}
|
2023-02-02 11:49:11 +00:00
|
|
|
description={t("meetings_are_better_with_the_right")}
|
2023-02-01 20:41:47 +00:00
|
|
|
actionButton={{
|
|
|
|
href: "/settings/teams/" + team.id + "/members",
|
|
|
|
child: t("invite"),
|
|
|
|
}}
|
|
|
|
/>
|
2023-04-05 18:14:46 +00:00
|
|
|
{/* @TODO: uncomment once managed event types is live
|
2023-02-01 20:41:47 +00:00
|
|
|
<Card
|
2023-04-12 15:26:31 +00:00
|
|
|
icon={<Unlock className="h-5 w-5 text-blue-700" />}
|
2023-02-01 20:41:47 +00:00
|
|
|
variant="basic"
|
|
|
|
title={t("create_a_managed_event")}
|
2023-02-02 11:50:28 +00:00
|
|
|
description={t("create_a_one_one_template")}
|
2023-02-01 20:41:47 +00:00
|
|
|
actionButton={{
|
|
|
|
href:
|
|
|
|
"/event-types?dialog=new-eventtype&eventPage=team%2F" +
|
|
|
|
team.slug +
|
|
|
|
"&teamId=" +
|
|
|
|
team.id +
|
|
|
|
"&managed=true",
|
|
|
|
child: t("create"),
|
|
|
|
}}
|
|
|
|
/> */}
|
|
|
|
<Card
|
2023-04-12 15:26:31 +00:00
|
|
|
icon={<Users className="h-5 w-5 text-orange-700" />}
|
2023-02-01 20:41:47 +00:00
|
|
|
variant="basic"
|
|
|
|
title={t("collective_or_roundrobin")}
|
|
|
|
description={t("book_your_team_members")}
|
|
|
|
actionButton={{
|
2023-03-28 08:36:19 +00:00
|
|
|
href: "/event-types?dialog=new&eventPage=team%2F" + team.slug + "&teamId=" + team.id,
|
2023-02-01 20:41:47 +00:00
|
|
|
child: t("create"),
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Card
|
2023-04-12 15:26:31 +00:00
|
|
|
icon={<Edit className="h-5 w-5 text-purple-700" />}
|
2023-02-01 20:41:47 +00:00
|
|
|
variant="basic"
|
|
|
|
title={t("appearance")}
|
2023-06-08 13:37:54 +00:00
|
|
|
description={t("appearance_description")}
|
2023-02-01 20:41:47 +00:00
|
|
|
actionButton={{
|
|
|
|
href: "/settings/teams/" + team.id + "/appearance",
|
|
|
|
child: t("edit"),
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)}
|
2023-01-24 15:27:05 +00:00
|
|
|
</ul>
|
2021-08-02 20:51:57 +00:00
|
|
|
);
|
2021-07-30 23:05:38 +00:00
|
|
|
}
|