2023-01-24 15:27:05 +00:00
|
|
|
import { useState, useMemo } from "react";
|
2022-11-10 20:23:56 +00:00
|
|
|
|
|
|
|
import { WEBAPP_URL } from "@calcom/lib/constants";
|
2023-01-15 17:54:52 +00:00
|
|
|
import { APP_NAME } from "@calcom/lib/constants";
|
2022-11-10 20:23:56 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
|
|
import { trpc } from "@calcom/trpc/react";
|
2023-01-24 15:27:05 +00:00
|
|
|
import { Alert, Button, ButtonGroup, Label } from "@calcom/ui";
|
2023-01-23 23:08:01 +00:00
|
|
|
import { FiUsers, FiRefreshCcw, FiUserPlus, FiMail, FiVideo, FiEyeOff } from "@calcom/ui/components/icon";
|
2022-11-10 20:23:56 +00:00
|
|
|
|
2023-01-23 09:58:41 +00:00
|
|
|
import { UpgradeTip } from "../../../tips";
|
2022-11-10 20:23:56 +00:00
|
|
|
import SkeletonLoaderTeamList from "./SkeletonloaderTeamList";
|
|
|
|
import TeamList from "./TeamList";
|
|
|
|
|
|
|
|
export function TeamsListing() {
|
|
|
|
const { t } = useLocale();
|
|
|
|
const [errorMessage, setErrorMessage] = useState("");
|
|
|
|
|
2022-11-10 23:40:01 +00:00
|
|
|
const { data, isLoading } = trpc.viewer.teams.list.useQuery(undefined, {
|
2022-11-10 20:23:56 +00:00
|
|
|
onError: (e) => {
|
|
|
|
setErrorMessage(e.message);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2023-01-24 15:27:05 +00:00
|
|
|
const teams = useMemo(() => data?.filter((m) => m.accepted) || [], [data]);
|
|
|
|
const invites = useMemo(() => data?.filter((m) => !m.accepted) || [], [data]);
|
2022-11-10 20:23:56 +00:00
|
|
|
|
2022-12-05 22:20:33 +00:00
|
|
|
const features = [
|
|
|
|
{
|
2023-01-23 23:08:01 +00:00
|
|
|
icon: <FiUsers className="h-5 w-5 text-red-500" />,
|
2022-12-05 22:20:33 +00:00
|
|
|
title: t("collective_scheduling"),
|
|
|
|
description: t("make_it_easy_to_book"),
|
|
|
|
},
|
|
|
|
{
|
2023-01-23 23:08:01 +00:00
|
|
|
icon: <FiRefreshCcw className="h-5 w-5 text-blue-500" />,
|
2022-12-05 22:20:33 +00:00
|
|
|
title: t("round_robin"),
|
|
|
|
description: t("find_the_best_person"),
|
|
|
|
},
|
|
|
|
{
|
2023-01-23 23:08:01 +00:00
|
|
|
icon: <FiUserPlus className="h-5 w-5 text-green-500" />,
|
2022-12-05 22:20:33 +00:00
|
|
|
title: t("fixed_round_robin"),
|
|
|
|
description: t("add_one_fixed_attendee"),
|
|
|
|
},
|
2023-01-15 17:54:52 +00:00
|
|
|
{
|
2023-01-23 23:08:01 +00:00
|
|
|
icon: <FiMail className="h-5 w-5 text-orange-500" />,
|
2023-01-15 17:54:52 +00:00
|
|
|
title: t("sms_attendee_action"),
|
|
|
|
description: t("make_it_easy_to_book"),
|
|
|
|
},
|
|
|
|
{
|
2023-01-23 23:08:01 +00:00
|
|
|
icon: <FiVideo className="h-5 w-5 text-purple-500" />,
|
2023-01-15 17:54:52 +00:00
|
|
|
title: "Cal Video" + " " + t("recordings_title"),
|
|
|
|
description: t("upgrade_to_access_recordings_description"),
|
|
|
|
},
|
|
|
|
{
|
2023-01-23 23:08:01 +00:00
|
|
|
icon: <FiEyeOff className="h-5 w-5 text-indigo-500" />,
|
2023-01-15 17:54:52 +00:00
|
|
|
title: t("disable_cal_branding", { appName: APP_NAME }),
|
|
|
|
description: t("disable_cal_branding_description", { appName: APP_NAME }),
|
|
|
|
},
|
2022-12-05 22:20:33 +00:00
|
|
|
];
|
|
|
|
|
2023-01-24 15:27:05 +00:00
|
|
|
if (isLoading) {
|
|
|
|
return <SkeletonLoaderTeamList />;
|
|
|
|
}
|
|
|
|
|
2022-11-10 20:23:56 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{!!errorMessage && <Alert severity="error" title={errorMessage} />}
|
2023-01-24 15:27:05 +00:00
|
|
|
|
2023-01-23 09:58:41 +00:00
|
|
|
<UpgradeTip
|
|
|
|
title="calcom_is_better_with_team"
|
|
|
|
description="add_your_team_members"
|
|
|
|
features={features}
|
2023-04-10 21:14:28 +00:00
|
|
|
background="/tips/teams"
|
2023-01-23 09:58:41 +00:00
|
|
|
buttons={
|
|
|
|
<div className="space-y-2 rtl:space-x-reverse sm:space-x-2">
|
|
|
|
<ButtonGroup>
|
|
|
|
<Button color="primary" href={`${WEBAPP_URL}/settings/teams/new`}>
|
|
|
|
{t("create_team")}
|
|
|
|
</Button>
|
2023-03-23 22:10:01 +00:00
|
|
|
<Button color="minimal" href="https://go.cal.com/teams-video" target="_blank">
|
2023-01-23 09:58:41 +00:00
|
|
|
{t("learn_more")}
|
|
|
|
</Button>
|
|
|
|
</ButtonGroup>
|
|
|
|
</div>
|
|
|
|
}>
|
2023-01-24 15:27:05 +00:00
|
|
|
<>
|
|
|
|
{invites.length > 0 && (
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="bg-subtle mb-6 rounded-md p-5">
|
|
|
|
<Label className=" text-emphasis pb-2 font-semibold">{t("pending_invites")}</Label>
|
2023-03-15 19:09:43 +00:00
|
|
|
<TeamList teams={invites} pending />
|
2023-01-24 15:27:05 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{teams.length > 0 && <TeamList teams={teams} />}
|
|
|
|
</>
|
2023-01-23 09:58:41 +00:00
|
|
|
</UpgradeTip>
|
2022-11-10 20:23:56 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|