Files
calendar/packages/features/ee/teams/components/createButton/CreateButtonWithTeamsList.tsx
T
4cdb8f3bae feat: make calcom UI dumb again (#19658)
* remove create button for teams from calcom ui

* migrate timezone select to features

* remove trpc from phone and storybook provider

* new-yarn.lock

* fix imports + test file for select

* fix platform timezone select to use Raw timezone select

* fix timezone type import

* use correct select in timezone-select.tsx - needs trpc version

* fix lock and remove test-utils

* fix log file

* Updated yarn.lock

* Fixed types

* Fixed tests

---------

Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2025-03-05 11:58:52 -03:00

46 lines
1.2 KiB
TypeScript

"use client";
import { trpc } from "@calcom/trpc/react";
import type { CreateBtnProps, Option } from "./CreateButton";
import { CreateButton } from "./CreateButton";
export function CreateButtonWithTeamsList(
props: Omit<CreateBtnProps, "options"> & {
onlyShowWithTeams?: boolean;
onlyShowWithNoTeams?: boolean;
isAdmin?: boolean;
includeOrg?: boolean;
}
) {
const query = trpc.viewer.teamsAndUserProfilesQuery.useQuery({ includeOrg: props.includeOrg });
if (!query.data) return null;
const teamsAndUserProfiles: Option[] = query.data
.filter((profile) => !profile.readOnly)
.map((profile) => {
return {
teamId: profile.teamId,
label: profile.name || profile.slug,
image: profile.image,
slug: profile.slug,
};
});
if (props.isAdmin) {
teamsAndUserProfiles.push({
platform: true,
label: "Platform",
image: null,
slug: null,
teamId: null,
});
}
if (props.onlyShowWithTeams && teamsAndUserProfiles.length < 2) return null;
if (props.onlyShowWithNoTeams && teamsAndUserProfiles.length > 1) return null;
return <CreateButton {...props} options={teamsAndUserProfiles} />;
}