Skip to content
Closed
11 changes: 10 additions & 1 deletion apps/web/modules/event-types/views/event-types-listing-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type EventTypeGroup = EventTypeGroups[number];
type EventType = EventTypeGroup["eventTypes"][number];

const LIMIT = 10;
const BOOKING_LIMIT = 50;

interface InfiniteEventTypeListProps {
group: InfiniteEventTypeGroup;
Expand Down Expand Up @@ -169,6 +170,13 @@ const Item = ({
const parsedeventTypeColor = parseEventTypeColor(type.eventTypeColor);
const eventTypeColor =
parsedeventTypeColor && parsedeventTypeColor[hasDarkTheme ? "darkEventTypeColor" : "lightEventTypeColor"];
const totalBookings = trpc.viewer.bookings.get.useQuery({
filters: {
eventTypeIds: [type.id],
status: "past",
},
limit: BOOKING_LIMIT,
}).data?.bookings.length;
Comment on lines +173 to +179
Copy link
Copy Markdown
Contributor

@Udit-takkar Udit-takkar Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PeerRich the total booking badge would be useless for orgs and big teams. As they would have more than 50 bookings for most of the event types

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus this would be really slow query for them

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Udit-takkar any ideas how to fix this?


const content = () => (
<div>
Expand Down Expand Up @@ -203,7 +211,7 @@ const Item = ({
{readOnly ? (
<div>
{content()}
<EventTypeDescription eventType={type} shortenDescription />
<EventTypeDescription eventType={type} shortenDescription totalBookings={totalBookings} />
</div>
) : (
<Link href={`/event-types/${type.id}?tabName=setup`} title={type.title}>
Expand All @@ -229,6 +237,7 @@ const Item = ({
<EventTypeDescription
eventType={{ ...type, descriptionAsSafeHTML: type.safeDescription }}
shortenDescription
totalBookings={totalBookings}
/>
</Link>
)}
Expand Down
1 change: 1 addition & 0 deletions apps/web/public/static/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,7 @@
"under_maintenance": "Down for maintenance",
"under_maintenance_description": "The {{appName}} team are performing scheduled maintenance. If you have any questions, please contact support.",
"event_type_seats": "{{numberOfSeats}} seats",
"event_type_insights": "{{numberOfBookings}} booking",
"booking_questions_title": "Booking questions",
"booking_questions_description": "Customize the questions asked on the booking page",
"add_a_booking_question": "Add a question",
Expand Down
11 changes: 11 additions & 0 deletions packages/features/eventtypes/components/EventTypeDescription.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Prisma } from "@prisma/client";
import Link from "next/link";
import { useMemo } from "react";
import type { z } from "zod";

Expand All @@ -25,13 +26,15 @@ export type EventTypeDescriptionProps = {
className?: string;
shortenDescription?: boolean;
isPublic?: boolean;
totalBookings?: number;
};

export const EventTypeDescription = ({
eventType,
className,
shortenDescription,
isPublic,
totalBookings,
}: EventTypeDescriptionProps) => {
const { t, i18n } = useLocale();

Expand Down Expand Up @@ -76,6 +79,7 @@ export const EventTypeDescription = ({
</Badge>
</li>
)}

{eventType.schedulingType && eventType.schedulingType !== SchedulingType.MANAGED && (
<li>
<Badge variant="gray" startIcon="users">
Expand Down Expand Up @@ -134,6 +138,13 @@ export const EventTypeDescription = ({
</Badge>
</li>
) : null}
<li>
<Link href={`/insights?isAll=false&filter=event-type&eventTypeId=${eventType.id}`}>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eunjae-lee @sean-brydon this is currently not working consistently because the URL-param are borked. that PR needs to go live first

<Badge variant="gray" startIcon="chart-bar">
<p>{t("event_type_insights", { numberOfBookings: totalBookings })} </p>
</Badge>
</Link>
</li>
</ul>
</div>
</>
Expand Down
19 changes: 19 additions & 0 deletions packages/features/eventtypes/components/EventTypeLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ function EventTypeSingleLayout({
)}
</>
)}
<Tooltip content={t("insights")} side="bottom" sideOffset={4}>
<Button
color="secondary"
target="_blank"
variant="icon"
href={`/insights?isAll=false&filter=event-type&eventTypeId=${eventType.id}`}
rel="noreferrer"
StartIcon="chart-bar"
/>
</Tooltip>
{!isChildrenManagedEventType && allowDelete && (
<Button
color="destructive"
Expand Down Expand Up @@ -232,6 +242,15 @@ function EventTypeSingleLayout({
{t("copy_link")}
</DropdownItem>
</DropdownMenuItem>
<DropdownMenuItem className="focus:ring-muted">
<DropdownItem
type="button"
StartIcon="chart-bar"
href={`/insights?isAll=false&filter=event-type&eventTypeId=${eventType.id}`}>
{t("insights")}
</DropdownItem>
</DropdownMenuItem>

{allowDelete && (
<DropdownMenuItem className="focus:ring-muted">
<DropdownItem
Expand Down