Skip to content

Commit 33e966d

Browse files
committed
Merge branch 'fix-custom-event-redirect-routing-forms' of https://github.com/calcom/cal.com into fix-custom-event-redirect-routing-forms
2 parents 672f5ca + f7bbb69 commit 33e966d

6 files changed

Lines changed: 56 additions & 246 deletions

File tree

packages/app-store/routing-forms/lib/reportingUtils.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/app-store/routing-forms/trpc/_router.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { ZFormQueryInputSchema } from "./formQuery.schema";
99
import { ZGetAttributesForTeamInputSchema } from "./getAttributesForTeam.schema";
1010
import { ZGetIncompleteBookingSettingsInputSchema } from "./getIncompleteBookingSettings.schema";
1111
import { forms } from "./procedures/forms";
12-
import { ZReportInputSchema } from "./report.schema";
1312
import { ZSaveIncompleteBookingSettingsInputSchema } from "./saveIncompleteBookingSettings.schema";
1413

1514
// eslint-disable-next-line @typescript-eslint/ban-types
@@ -76,11 +75,6 @@ const appRoutingForms = router({
7675
return handler({ ctx, input });
7776
}),
7877

79-
report: authedProcedure.input(ZReportInputSchema).query(async ({ ctx, input }) => {
80-
const handler = await getHandler("report", () => import("./report.handler"));
81-
return handler({ ctx, input });
82-
}),
83-
8478
getAttributesForTeam: authedProcedure
8579
.input(ZGetAttributesForTeamInputSchema)
8680
.query(async ({ ctx, input }) => {

packages/app-store/routing-forms/trpc/report.handler.ts

Lines changed: 0 additions & 182 deletions
This file was deleted.

packages/lib/server/service/routingForm/responseData/ensureStringOrStringArray.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/lib/server/service/routingForm/responseData/getHumanReadableFieldResponseValue.ts

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,61 @@
11
import type { Field, FormResponse } from "@calcom/app-store/routing-forms/types/types";
22

3-
import { ensureStringOrStringArray } from "./ensureStringOrStringArray";
4-
import { getLabelsFromOptionIds } from "./getLabelsFromOptionIds";
3+
4+
/**
5+
* Ensures a value is either a string or string array.
6+
* Converts numbers to strings.
7+
*
8+
* @param value - The value to normalize
9+
* @returns String or string array
10+
*/
11+
12+
function ensureStringOrStringArray(value: string | number | (string | number)[]): string | string[] {
13+
if (typeof value === "string") {
14+
return value;
15+
} else if (value instanceof Array) {
16+
return value.map((v) => v.toString());
17+
}
18+
return [value.toString()];
19+
}
20+
21+
22+
import type { Field } from "@calcom/app-store/routing-forms/types/types";
23+
24+
/**
25+
* Get labels from option IDs for fields with options (select, multiselect, radio).
26+
* Handles legacy cases where the value might already be a label.
27+
*
28+
* @param options - The field options array
29+
* @param optionIds - The option ID(s) to get labels for
30+
* @returns The label(s) corresponding to the option ID(s)
31+
*/
32+
33+
function getLabelsFromOptionIds({
34+
options,
35+
optionIds,
36+
}: {
37+
options: NonNullable<Field["options"]>;
38+
optionIds: string | string[];
39+
}) {
40+
if (optionIds instanceof Array) {
41+
const labels = optionIds.map((optionId) => {
42+
const foundOption = options.find((option) => option.id === optionId);
43+
// It would mean that the optionId is actually a label which is why it isn't matching any option id.
44+
// Fallback to optionId(i.e. label) which was the case with legacy options
45+
if (!foundOption) {
46+
return optionId;
47+
}
48+
return foundOption.label;
49+
});
50+
return labels;
51+
} else {
52+
const foundOption = options.find((option) => option.id === optionIds);
53+
if (!foundOption) {
54+
return [optionIds];
55+
}
56+
return [foundOption.label];
57+
}
58+
}
559

660
/**
761
* Get the human-readable value for a field response.

packages/lib/server/service/routingForm/responseData/getLabelsFromOptionIds.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)