* refactor: UserAvatarGroupWithOrg.tsx remove unecessary profile prop * chore: define event-type types in platform/types * feat: event-type transformes in lib and re-exported through platform-libraries * chore: define user types in platform/types * chore: add users endpoint to platform-constants * refactor: app-store use narrowed down booker event type * chore: version old event-types module * fix: old event-types e2e test * fix: libraries add missing export * fix: reset libraries version to 0 * feat: new event-types module and users endpoints * feat: make booker atom work with v2 event-types * updating event type * refactor: remove guard for get event-types * refactor: move private hook to public * Revert "refactor: remove guard for get event-types" This reverts commit d41204069f1d5bb1305b388ce53399f9175f4249. * Revert "refactor: move private hook to public" This reverts commit 09322e8fba102e57104959f79ed6bfa9a677dc9d. * refactor: get by username and slug in /event-types * remove console log * feat: locations handle displayEventPublicly * test e2e event-types * revert: user output from types * refactor: event-types hooks have private and public folders * refactor: require event-type.slug in input * refactor: demand that all labels of booking fields are unique * refactor: remove unused import * refactor: only have email and name by default in booker * refactor: add booking field slug * fix: display event-type location publicly / hide it in booker * fix: display event-type location publicly / hide it in booker * fix: packages/lib tests * fix: typescript in e2e test * fix: dynamic event types input * refactor: use IsIn instead of IsEnum * refactor: simplify getEventTypes * fix: use ApiAuthGuard instead of AccessTokenGuard * chore: export more stuff from libraries * refactor: SchedulingTypeEnum and Type --------- Co-authored-by: Morgan <[email protected]>
79 lines
2.8 KiB
TypeScript
79 lines
2.8 KiB
TypeScript
import { useIsEmbed } from "@calcom/embed-core/embed-iframe";
|
|
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
|
import type { BookerEvent } from "@calcom/features/bookings/types";
|
|
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
|
import { getBookerBaseUrlSync } from "@calcom/lib/getBookerUrl/client";
|
|
import { getTeamUrlSync } from "@calcom/lib/getBookerUrl/client";
|
|
import { SchedulingType } from "@calcom/prisma/enums";
|
|
import { AvatarGroup } from "@calcom/ui";
|
|
|
|
export interface EventMembersProps {
|
|
/**
|
|
* Used to determine whether all members should be shown or not.
|
|
* In case of Round Robin type, members aren't shown.
|
|
*/
|
|
schedulingType: BookerEvent["schedulingType"];
|
|
users: BookerEvent["users"];
|
|
profile: BookerEvent["profile"];
|
|
entity: BookerEvent["entity"];
|
|
}
|
|
|
|
export const EventMembers = ({ schedulingType, users, profile, entity }: EventMembersProps) => {
|
|
const username = useBookerStore((state) => state.username);
|
|
const isDynamic = !!(username && username.indexOf("+") > -1);
|
|
const isEmbed = useIsEmbed();
|
|
const showMembers = schedulingType !== SchedulingType.ROUND_ROBIN;
|
|
const shownUsers = showMembers ? users : [];
|
|
// In some cases we don't show the user's names, but only show the profile name.
|
|
const showOnlyProfileName =
|
|
(profile.name && schedulingType === SchedulingType.ROUND_ROBIN) ||
|
|
!users.length ||
|
|
(profile.name !== users[0].name && schedulingType === SchedulingType.COLLECTIVE);
|
|
|
|
const orgOrTeamAvatarItem =
|
|
isDynamic || (!profile.image && !entity.logoUrl) || !entity.teamSlug
|
|
? []
|
|
: [
|
|
{
|
|
// We don't want booker to be able to see the list of other users or teams inside the embed
|
|
href: isEmbed
|
|
? null
|
|
: entity.teamSlug
|
|
? getTeamUrlSync({ orgSlug: entity.orgSlug, teamSlug: entity.teamSlug })
|
|
: getBookerBaseUrlSync(entity.orgSlug),
|
|
image: entity.logoUrl ?? profile.image ?? "",
|
|
alt: entity.name ?? profile.name ?? "",
|
|
title: entity.name ?? profile.name ?? "",
|
|
},
|
|
];
|
|
|
|
return (
|
|
<>
|
|
<AvatarGroup
|
|
size="sm"
|
|
className="border-muted"
|
|
items={[
|
|
...orgOrTeamAvatarItem,
|
|
...shownUsers.map((user) => ({
|
|
href: `${getBookerBaseUrlSync(user.profile?.organization?.slug ?? null)}/${
|
|
user.profile?.username
|
|
}?redirect=false`,
|
|
alt: user.name || "",
|
|
title: user.name || "",
|
|
image: getUserAvatarUrl(user),
|
|
})),
|
|
]}
|
|
/>
|
|
|
|
<p className="text-subtle mt-2 text-sm font-semibold">
|
|
{showOnlyProfileName
|
|
? profile.name
|
|
: shownUsers
|
|
.map((user) => user.name)
|
|
.filter((name) => name)
|
|
.join(", ")}
|
|
</p>
|
|
</>
|
|
);
|
|
};
|