fix: Custom Event Redirect in Routing Form with Dropdown Based fields (#17870)
Co-authored-by: [email protected] <[email protected]> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
8d2a072645
commit
13cbb59e5e
8 files changed
+599
-73
No files matched your search
@@ -4,29 +4,14 @@ import { getSession } from "next-auth/react";
|
||||
|
||||
import { sanitizeValue } from "@calcom/lib/csvUtils";
|
||||
import { entityPrismaWhereClause, canEditEntity } from "@calcom/lib/entityPermissionUtils.server";
|
||||
import { getHumanReadableFieldResponseValue } from "@calcom/lib/server/service/routingForm/responseData/getHumanReadableFieldResponseValue";
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
import { getSerializableForm } from "../../lib/getSerializableForm";
|
||||
import { ensureStringOrStringArray, getLabelsFromOptionIds } from "../../lib/reportingUtils";
|
||||
import type { FormResponse, SerializableForm } from "../../types/types";
|
||||
|
||||
type Fields = NonNullable<SerializableForm<App_RoutingForms_Form>["fields"]>;
|
||||
|
||||
function getHumanReadableFieldResponseValue({
|
||||
field,
|
||||
value,
|
||||
}: {
|
||||
field: Fields[number];
|
||||
value: string | number | string[];
|
||||
}) {
|
||||
if (field.options) {
|
||||
const optionIds = ensureStringOrStringArray(value);
|
||||
return getLabelsFromOptionIds({ options: field.options, optionIds });
|
||||
} else {
|
||||
return (value instanceof Array ? value : [value]).map(String);
|
||||
}
|
||||
}
|
||||
|
||||
async function* getResponses(formId: string, fields: Fields) {
|
||||
let responses;
|
||||
let skip = 0;
|
||||
@@ -50,7 +35,10 @@ async function* getResponses(formId: string, fields: Fields) {
|
||||
fields.forEach((field) => {
|
||||
const fieldResponse = fieldResponses[field.id];
|
||||
const value = fieldResponse?.value || "";
|
||||
const readableValues = getHumanReadableFieldResponseValue({ field, value });
|
||||
const humanReadableResponseValue = getHumanReadableFieldResponseValue({ field, value });
|
||||
const readableValues = Array.isArray(humanReadableResponseValue)
|
||||
? humanReadableResponseValue
|
||||
: [humanReadableResponseValue];
|
||||
const serializedValue = readableValues.map((value) => sanitizeValue(value)).join(" | ");
|
||||
csvCells.push(serializedValue);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user