feat: banner and avatars for Booker atom (#17821)
* init * added bannerUrl to output * cleanup * fixup * fix response DTOs * remove logs * send back avatar url for user * enable passing avatar urls for managed user * dont include urls for platform * remove logs * add team banner * update docs * nit * PR feedback * fix type error * add prop to pass in bannerUrl * update DTOs * update tests * fix tests --------- Co-authored-by: Somay Chauhan <[email protected]> Co-authored-by: Morgan <[email protected]>
This commit is contained in:
18 files changed
+173
-25
No files matched your search
@@ -335,7 +335,7 @@ const BookerComponent = ({
|
||||
<BookerSection
|
||||
area="meta"
|
||||
className="max-w-screen flex w-full flex-col md:w-[var(--booker-meta-width)]">
|
||||
{!hideEventTypeDetails && orgBannerUrl && !isPlatform && (
|
||||
{!hideEventTypeDetails && orgBannerUrl && (
|
||||
<img
|
||||
loading="eager"
|
||||
className="-mb-9 h-16 object-cover object-top ltr:rounded-tl-md rtl:rounded-tr-md sm:h-auto"
|
||||
|
||||
@@ -127,14 +127,12 @@ export const EventMeta = ({
|
||||
)}
|
||||
{!isPending && !!event && (
|
||||
<m.div {...fadeInUp} layout transition={{ ...fadeInUp.transition, delay: 0.3 }}>
|
||||
{!isPlatform && (
|
||||
<EventMembers
|
||||
schedulingType={event.schedulingType}
|
||||
users={event.users}
|
||||
profile={event.profile}
|
||||
entity={event.entity}
|
||||
/>
|
||||
)}
|
||||
<EventMembers
|
||||
schedulingType={event.schedulingType}
|
||||
users={event.users}
|
||||
profile={event.profile}
|
||||
entity={event.entity}
|
||||
/>
|
||||
<EventTitle className={`${classNames?.eventMetaTitle} my-2`}>{event?.title}</EventTitle>
|
||||
{(event.description || translatedDescription) && (
|
||||
<EventMetaBlock contentClassName="mb-8 break-words max-w-full max-h-[180px] scroll-bar pr-4">
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useIsPlatform } from "@calcom/atoms/monorepo";
|
||||
import { useIsEmbed } from "@calcom/embed-core/embed-iframe";
|
||||
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
@@ -22,6 +23,7 @@ export const EventMembers = ({ schedulingType, users, profile, entity }: EventMe
|
||||
const username = useBookerStore((state) => state.username);
|
||||
const isDynamic = !!(username && username.indexOf("+") > -1);
|
||||
const isEmbed = useIsEmbed();
|
||||
const isPlatform = useIsPlatform();
|
||||
|
||||
const showMembers = schedulingType !== SchedulingType.ROUND_ROBIN;
|
||||
const shownUsers = showMembers ? users : [];
|
||||
@@ -56,9 +58,11 @@ export const EventMembers = ({ schedulingType, users, profile, entity }: EventMe
|
||||
items={[
|
||||
...orgOrTeamAvatarItem,
|
||||
...shownUsers.map((user) => ({
|
||||
href: `${getBookerBaseUrlSync(user.profile?.organization?.slug ?? null)}/${
|
||||
user.profile?.username
|
||||
}?redirect=false`,
|
||||
href: isPlatform
|
||||
? null
|
||||
: `${getBookerBaseUrlSync(user.profile?.organization?.slug ?? null)}/${
|
||||
user.profile?.username
|
||||
}?redirect=false`,
|
||||
alt: user.name || "",
|
||||
title: user.name || "",
|
||||
image: getUserAvatarUrl(user),
|
||||
|
||||
@@ -77,6 +77,7 @@ export type BookerPlatformWrapperAtomProps = Omit<
|
||||
locationUrl?: string;
|
||||
view?: VIEW_TYPE;
|
||||
metadata?: Record<string, string>;
|
||||
bannerUrl?: string;
|
||||
};
|
||||
|
||||
type VIEW_TYPE = keyof typeof BookerLayouts;
|
||||
@@ -95,7 +96,7 @@ export type BookerPlatformWrapperAtomPropsForTeam = BookerPlatformWrapperAtomPro
|
||||
export const BookerPlatformWrapper = (
|
||||
props: BookerPlatformWrapperAtomPropsForIndividual | BookerPlatformWrapperAtomPropsForTeam
|
||||
) => {
|
||||
const { view = "MONTH_VIEW" } = props;
|
||||
const { view = "MONTH_VIEW", bannerUrl } = props;
|
||||
const layout = BookerLayouts[view];
|
||||
|
||||
const { clientId } = useAtomsContext();
|
||||
@@ -482,6 +483,7 @@ export const BookerPlatformWrapper = (
|
||||
bookerForm={bookerForm}
|
||||
event={event}
|
||||
schedule={schedule}
|
||||
orgBannerUrl={bannerUrl ?? event.data?.bannerUrl}
|
||||
bookerLayout={bookerLayout}
|
||||
verifyCode={undefined}
|
||||
isPlatform
|
||||
|
||||
+3
-2
@@ -29,7 +29,7 @@ import {
|
||||
import type { BookerPlatformWrapperAtomProps } from "../../booker/BookerPlatformWrapper";
|
||||
|
||||
export function transformApiEventTypeForAtom(
|
||||
eventType: Omit<EventTypeOutput_2024_06_14, "ownerId">,
|
||||
eventType: Omit<EventTypeOutput_2024_06_14, "ownerId"> & { bannerUrl?: string },
|
||||
entity: BookerPlatformWrapperAtomProps["entity"] | undefined,
|
||||
defaultFormValues: BookerPlatformWrapperAtomProps["defaultFormValues"] | undefined
|
||||
) {
|
||||
@@ -132,7 +132,7 @@ export function transformApiTeamEventTypeForAtom(
|
||||
isDynamic: false,
|
||||
profile: {
|
||||
username: "team",
|
||||
name: "team",
|
||||
name: "Team",
|
||||
weekStart: "Sunday",
|
||||
image: "",
|
||||
brandColor: null,
|
||||
@@ -171,6 +171,7 @@ export function transformApiTeamEventTypeForAtom(
|
||||
},
|
||||
})),
|
||||
users: hosts.map((host) => ({
|
||||
...host,
|
||||
metadata: undefined,
|
||||
bookerUrl: getBookerBaseUrlSync(null),
|
||||
profile: {
|
||||
|
||||
@@ -54,6 +54,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
||||
body: JSON.stringify({
|
||||
email: emailOne,
|
||||
name: "John Jones",
|
||||
avatarUrl:
|
||||
"https://images.unsplash.com/photo-1527980965255-d3b416303d12?q=80&w=3023&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
|
||||
}),
|
||||
}
|
||||
);
|
||||
@@ -83,6 +85,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
||||
body: JSON.stringify({
|
||||
email: emailTwo,
|
||||
name: "Jane Doe",
|
||||
avatarUrl:
|
||||
"https://plus.unsplash.com/premium_photo-1668319915476-5cc7717e00f1?q=80&w=3164&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
|
||||
}),
|
||||
}
|
||||
);
|
||||
@@ -139,6 +143,7 @@ async function createTeam(orgId: number, name: string) {
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name,
|
||||
bannerUrl: "https://i.cal.com/api/avatar/949be534-7a88-4185-967c-c020b0c0bef3.png",
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
+10
@@ -362,6 +362,11 @@ export class TeamEventTypeResponseHost extends TeamEventTypeHostInput {
|
||||
@IsString()
|
||||
@DocsProperty({ example: "John Doe" })
|
||||
name!: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@DocsProperty({ example: "https://cal.com/api/avatar/d95949bc-ccb1-400f-acf6-045c51a16856.png" })
|
||||
avatarUrl?: string | null;
|
||||
}
|
||||
|
||||
export class EventTypeOutput_2024_06_14 extends BaseEventTypeOutput_2024_06_14 {
|
||||
@@ -413,4 +418,9 @@ export class TeamEventTypeOutput_2024_06_14 extends BaseEventTypeOutput_2024_06_
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
hideCalendarEventDetails?: boolean;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
bannerUrl?: string;
|
||||
}
|
||||
Reference in new issue
Block a user