2021-12-17 00:16:59 +00:00
|
|
|
import classNames from "classnames";
|
2022-01-29 00:46:35 +00:00
|
|
|
import { Trans } from "next-i18next";
|
2021-12-09 23:51:30 +00:00
|
|
|
import { useState } from "react";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2022-05-26 17:07:14 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2022-07-22 17:27:06 +00:00
|
|
|
import { trpc } from "@calcom/trpc/react";
|
2022-03-16 23:36:43 +00:00
|
|
|
import { Alert } from "@calcom/ui/Alert";
|
|
|
|
import Button from "@calcom/ui/Button";
|
2022-06-01 17:24:41 +00:00
|
|
|
import EmptyScreen from "@calcom/ui/EmptyScreen";
|
2022-07-27 02:24:00 +00:00
|
|
|
import { Icon } from "@calcom/ui/Icon";
|
2022-03-16 23:36:43 +00:00
|
|
|
|
2022-05-04 21:13:01 +00:00
|
|
|
import useMeQuery from "@lib/hooks/useMeQuery";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2021-09-29 21:33:18 +00:00
|
|
|
import SettingsShell from "@components/SettingsShell";
|
2022-06-24 22:44:49 +00:00
|
|
|
import SkeletonLoaderTeamList from "@components/team/SkeletonloaderTeamList";
|
2021-12-09 23:51:30 +00:00
|
|
|
import TeamCreateModal from "@components/team/TeamCreateModal";
|
2021-09-22 19:52:38 +00:00
|
|
|
import TeamList from "@components/team/TeamList";
|
2021-06-03 20:55:34 +00:00
|
|
|
|
2022-05-26 17:07:14 +00:00
|
|
|
function Teams() {
|
2021-10-13 09:34:55 +00:00
|
|
|
const { t } = useLocale();
|
2021-06-08 16:00:06 +00:00
|
|
|
const [showCreateTeamModal, setShowCreateTeamModal] = useState(false);
|
2021-12-07 15:04:34 +00:00
|
|
|
const [errorMessage, setErrorMessage] = useState("");
|
2021-06-05 22:53:33 +00:00
|
|
|
|
2021-12-17 00:16:59 +00:00
|
|
|
const me = useMeQuery();
|
|
|
|
|
2022-02-07 23:35:26 +00:00
|
|
|
const { data, isLoading } = trpc.useQuery(["viewer.teams.list"], {
|
2021-12-09 23:51:30 +00:00
|
|
|
onError: (e) => {
|
|
|
|
setErrorMessage(e.message);
|
|
|
|
},
|
|
|
|
});
|
2021-06-05 22:53:33 +00:00
|
|
|
|
2021-12-09 23:51:30 +00:00
|
|
|
const teams = data?.filter((m) => m.accepted) || [];
|
|
|
|
const invites = data?.filter((m) => !m.accepted) || [];
|
2021-12-17 00:16:59 +00:00
|
|
|
const isFreePlan = me.data?.plan === "FREE";
|
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-06-08 16:00:06 +00:00
|
|
|
return (
|
2022-05-26 17:07:14 +00:00
|
|
|
<SettingsShell heading={t("teams")} subtitle={t("create_manage_teams_collaborative")}>
|
|
|
|
<>
|
2021-12-09 23:51:30 +00:00
|
|
|
{!!errorMessage && <Alert severity="error" title={errorMessage} />}
|
2021-12-17 00:16:59 +00:00
|
|
|
{isFreePlan && (
|
|
|
|
<Alert
|
|
|
|
severity="warning"
|
|
|
|
title={<>{t("plan_upgrade_teams")}</>}
|
|
|
|
message={
|
2022-01-29 00:46:35 +00:00
|
|
|
<Trans i18nKey="plan_upgrade_instructions">
|
|
|
|
You can
|
|
|
|
<a href="/api/upgrade" className="underline">
|
|
|
|
upgrade here
|
2021-12-17 00:16:59 +00:00
|
|
|
</a>
|
2022-01-29 00:46:35 +00:00
|
|
|
.
|
|
|
|
</Trans>
|
2021-12-17 00:16:59 +00:00
|
|
|
}
|
|
|
|
className="my-4"
|
|
|
|
/>
|
|
|
|
)}
|
2022-03-17 13:20:49 +00:00
|
|
|
{showCreateTeamModal && (
|
|
|
|
<TeamCreateModal isOpen={showCreateTeamModal} onClose={() => setShowCreateTeamModal(false)} />
|
|
|
|
)}
|
2022-02-09 00:05:13 +00:00
|
|
|
<div className={classNames("my-4 flex justify-end", isFreePlan && "opacity-50")}>
|
2021-12-17 00:16:59 +00:00
|
|
|
<Button
|
|
|
|
disabled={isFreePlan}
|
|
|
|
type="button"
|
2022-07-27 02:24:00 +00:00
|
|
|
color="secondary"
|
2021-12-17 00:16:59 +00:00
|
|
|
onClick={() => setShowCreateTeamModal(true)}>
|
2022-08-03 16:01:29 +00:00
|
|
|
<Icon.FiPlus className="inline-block h-3.5 w-3.5 text-gray-700 group-hover:text-black ltr:mr-2 rtl:ml-2" />
|
2021-12-09 23:51:30 +00:00
|
|
|
{t("new_team")}
|
|
|
|
</Button>
|
|
|
|
</div>
|
2022-02-07 23:35:26 +00:00
|
|
|
|
2021-12-09 23:51:30 +00:00
|
|
|
{invites.length > 0 && (
|
|
|
|
<div className="mb-4">
|
|
|
|
<h1 className="mb-2 text-lg font-medium">{t("open_invitations")}</h1>
|
2022-07-13 21:14:16 +00:00
|
|
|
<TeamList teams={invites} />
|
2021-06-05 22:53:33 +00:00
|
|
|
</div>
|
2021-07-07 10:43:13 +00:00
|
|
|
)}
|
2022-06-24 22:44:49 +00:00
|
|
|
{isLoading && <SkeletonLoaderTeamList />}
|
|
|
|
{!teams.length && !isLoading && (
|
2022-08-03 16:01:29 +00:00
|
|
|
<EmptyScreen Icon={Icon.FiUsers} headline={t("no_teams")} description={t("no_teams_description")} />
|
2022-02-07 23:35:26 +00:00
|
|
|
)}
|
2022-07-13 21:14:16 +00:00
|
|
|
{teams.length > 0 && <TeamList teams={teams} />}
|
2022-05-26 17:07:14 +00:00
|
|
|
</>
|
|
|
|
</SettingsShell>
|
2021-06-03 20:55:34 +00:00
|
|
|
);
|
2021-06-30 13:48:34 +00:00
|
|
|
}
|
2022-05-26 17:07:14 +00:00
|
|
|
|
|
|
|
Teams.requiresLicense = false;
|
|
|
|
|
|
|
|
export default Teams;
|