feat: Assign colors to events (#15298)

* feat: Assign colors to events

* update

* final update

* update

* fix requested changes error

* Update EventAdvancedTab.tsx

* add contrast check

* update

* fix contrsterror message visibility

* fix type error

* fix

* update test

---------

Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: sean-brydon <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-08-14 15:10:40 +02:00
1 parent 95e2ad3007
commit 528a4fbb97
23 files changed
+289 -120

No files matched your search

@@ -1,4 +1,4 @@
import { parseRecurringEvent } from "@calcom/lib";
import { parseRecurringEvent, parseEventTypeColor } from "@calcom/lib";
import getAllUserBookings from "@calcom/lib/bookings/getAllUserBookings";
import type { PrismaClient } from "@calcom/prisma";
import { bookingMinimalSelect } from "@calcom/prisma";
@@ -179,6 +179,7 @@ export async function getBookings({
metadata: true,
seatsShowAttendees: true,
seatsShowAvailabilityCount: true,
eventTypeColor: true,
schedulingType: true,
team: {
select: {
@@ -409,6 +410,7 @@ export async function getBookings({
eventType: {
...booking.eventType,
recurringEvent: parseRecurringEvent(booking.eventType?.recurringEvent),
eventTypeColor: parseEventTypeColor(booking.eventType?.eventTypeColor),
price: booking.eventType?.price || 0,
currency: booking.eventType?.currency || "usd",
metadata: EventTypeMetaDataSchema.parse(booking.eventType?.metadata || {}),
@@ -75,6 +75,7 @@ export const duplicateHandler = async ({ ctx, input }: DuplicateOptions) => {
recurringEvent,
bookingLimits,
durationLimits,
eventTypeColor,
metadata,
workflows,
hashedLink,
@@ -112,6 +113,7 @@ export const duplicateHandler = async ({ ctx, input }: DuplicateOptions) => {
recurringEvent: recurringEvent || undefined,
bookingLimits: bookingLimits ?? undefined,
durationLimits: durationLimits ?? undefined,
eventTypeColor: eventTypeColor ?? undefined,
metadata: metadata === null ? Prisma.DbNull : metadata,
bookingFields: eventType.bookingFields === null ? Prisma.DbNull : eventType.bookingFields,
};
@@ -53,6 +53,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
destinationCalendar,
customInputs,
recurringEvent,
eventTypeColor,
users,
children,
assignAllTeamMembers,
@@ -137,6 +138,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
...rest,
bookingFields,
metadata: rest.metadata === null ? Prisma.DbNull : (rest.metadata as Prisma.InputJsonObject),
eventTypeColor: eventTypeColor === null ? Prisma.DbNull : (eventTypeColor as Prisma.InputJsonObject),
};
data.locations = locations ?? undefined;
if (periodType) {