fix: display all responses (#13999)

* fix: display all responses

* fix: type err

* chore: rename variable
This commit is contained in:
Udit Takkar
2024-03-12 15:30:02 +00:00
committed by GitHub
parent 4585199b5e
commit 8402dfa3a2
5 changed files with 24 additions and 4 deletions
@@ -24,7 +24,11 @@ import {
useIsEmbed,
} from "@calcom/embed-core/embed-iframe";
import { Price } from "@calcom/features/bookings/components/event-meta/Price";
import { SMS_REMINDER_NUMBER_FIELD, SystemField } from "@calcom/features/bookings/lib/SystemField";
import {
SMS_REMINDER_NUMBER_FIELD,
SystemField,
TITLE_FIELD,
} from "@calcom/features/bookings/lib/SystemField";
import { APP_NAME } from "@calcom/lib/constants";
import {
formatToLocalizedDate,
@@ -91,6 +95,7 @@ export default function Success(props: PageProps) {
const pathname = usePathname();
const searchParams = useCompatSearchParams();
const { eventType, bookingInfo, requiresLoginToUpdate } = props;
const {
allRemainingBookings,
isSuccessBookingPage,
@@ -518,7 +523,13 @@ export default function Success(props: PageProps) {
if (!field) return null;
const isSystemField = SystemField.safeParse(field.name);
// SMS_REMINDER_NUMBER_FIELD is a system field but doesn't have a dedicated place in the UI. So, it would be shown through the following responses list
if (isSystemField.success && field.name !== SMS_REMINDER_NUMBER_FIELD) return null;
// TITLE is also an identifier for booking question "What is this meeting about?"
if (
isSystemField.success &&
field.name !== SMS_REMINDER_NUMBER_FIELD &&
field.name !== TITLE_FIELD
)
return null;
const label = field.label || t(field.defaultLabel || "");
@@ -16,7 +16,7 @@ export function UserFieldsResponses(props: { calEvent: CalendarEvent; t: TFuncti
labelValueMap[key] !== "" ? (
<Info
key={key}
label={key}
label={t(key)}
description={
typeof labelValueMap[key] === "boolean"
? labelValueMap[key]
@@ -12,3 +12,4 @@ export const SystemField = z.enum([
]);
export const SMS_REMINDER_NUMBER_FIELD = "smsReminderNumber";
export const TITLE_FIELD = "title";
@@ -2069,6 +2069,7 @@ async function handler(
calEvent: getPiiFreeCalendarEvent(evt),
})
);
await sendScheduledEmails(
{
...evt,
@@ -1,13 +1,20 @@
import type z from "zod";
import { TITLE_FIELD } from "@calcom/features/bookings/lib/SystemField";
import type { bookingResponse } from "@calcom/features/bookings/lib/getBookingResponsesSchema";
import type { CalendarEvent } from "@calcom/types/Calendar";
export default function getLabelValueMapFromResponses(calEvent: CalendarEvent) {
const { customInputs, userFieldsResponses } = calEvent;
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];
}
for (const [, value] of Object.entries(userFieldsResponses)) {
if (!value.label) {
continue;