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"
|
2023-02-01 20:41:47 +00:00
|
|
|
emptyTitle="no_teams"
|
|
|
|
emptyDescription="no_teams_description"
|
2023-01-23 09:58:41 +00:00
|
|
|
features={features}
|
|
|
|
background="/team-banner-background.jpg"
|
|
|
|
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>
|
|
|
|
<Button color="secondary" href="https://go.cal.com/teams-video" target="_blank">
|
|
|
|
{t("learn_more")}
|
|
|
|
</Button>
|
|
|
|
</ButtonGroup>
|
|
|
|
</div>
|
|
|
|
}>
|
2023-01-24 15:27:05 +00:00
|
|
|
<>
|
|
|
|
{invites.length > 0 && (
|
|
|
|
<div className="mb-6 rounded-md bg-gray-100 p-5">
|
|
|
|
<Label className="dark:text-darkgray-900 pb-2 font-semibold text-gray-900">
|
|
|
|
{t("pending_invites")}
|
|
|
|
</Label>
|
|
|
|
<TeamList teams={invites} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{teams.length > 0 && <TeamList teams={teams} />}
|
|
|
|
</>
|
2023-01-23 09:58:41 +00:00
|
|
|
</UpgradeTip>
|
2022-11-10 20:23:56 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|