9fcddbf27b
* refactor: calEventParser CalendarEvent ISP
* update
* fix: complete CalEventParser ISP refactoring - update call sites and fix type errors
- Update getUid call sites to pass only uid instead of whole CalendarEvent
- Update getLocation call sites to pass narrow shape with videoCallData, additionalInformation, location, uid
- Update narrow input shapes to accept null for location (matching CalendarEvent type)
- Update recurringEvent type to accept RecurringEvent | null instead of boolean
- Update videoCallData type to be more flexible ({ type?: string; url?: string })
- Fix ManageLink.tsx to pass recurringEvent directly instead of converting to boolean
Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
* test: update CalEventParser tests to use narrow input shapes
- Update getPublicVideoCallUrl test to pass uid instead of calEvent
- Update getVideoCallPassword tests to pass videoCallData instead of calEvent
Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
* few fix
* fix type error
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import type z from "zod";
|
|
|
|
import { TITLE_FIELD, SMS_REMINDER_NUMBER_FIELD } from "@calcom/lib/bookings/SystemField";
|
|
import type { dbReadResponseSchema as bookingResponse } from "@calcom/lib/dbReadResponseSchema";
|
|
import type { CalEventResponses } from "@calcom/types/Calendar";
|
|
import type { Prisma } from "@calcom/prisma/client";
|
|
|
|
export default function getLabelValueMapFromResponses(
|
|
calEvent: {
|
|
customInputs?: Prisma.JsonObject | null;
|
|
userFieldsResponses?: CalEventResponses | null;
|
|
responses?: CalEventResponses | null;
|
|
eventTypeId?: number | null;
|
|
},
|
|
isOrganizer = false
|
|
) {
|
|
const { customInputs, userFieldsResponses, responses, eventTypeId } = calEvent;
|
|
|
|
const isDynamicEvent = !eventTypeId;
|
|
|
|
let labelValueMap: Record<string, z.infer<typeof bookingResponse>> = {};
|
|
if (userFieldsResponses) {
|
|
if (!!responses?.[TITLE_FIELD] && !isDynamicEvent) {
|
|
userFieldsResponses[TITLE_FIELD] = responses[TITLE_FIELD];
|
|
}
|
|
if (!!responses?.[SMS_REMINDER_NUMBER_FIELD] && !isDynamicEvent) {
|
|
userFieldsResponses[SMS_REMINDER_NUMBER_FIELD] = responses[SMS_REMINDER_NUMBER_FIELD];
|
|
}
|
|
|
|
for (const [, value] of Object.entries(userFieldsResponses)) {
|
|
if (!value.label || (!isOrganizer && value.isHidden)) {
|
|
continue;
|
|
}
|
|
labelValueMap[value.label] = value.value;
|
|
}
|
|
} else {
|
|
labelValueMap = customInputs as Record<string, string | string[]>;
|
|
}
|
|
return labelValueMap;
|
|
}
|