fix: api/routing-forms/responses (#17473)
* add i18n * fix api/routing-forms/responses
This commit is contained in:
@@ -2,6 +2,7 @@ import type { App_RoutingForms_Form } from "@prisma/client";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { getSession } from "next-auth/react";
|
||||
|
||||
import { sanitizeValue } from "@calcom/lib/csvUtils";
|
||||
import { entityPrismaWhereClause, canEditEntity } from "@calcom/lib/entityPermissionUtils";
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
@@ -10,9 +11,6 @@ import { ensureStringOrStringArray, getLabelsFromOptionIds } from "../../lib/rep
|
||||
import type { FormResponse, SerializableForm } from "../../types/types";
|
||||
|
||||
type Fields = NonNullable<SerializableForm<App_RoutingForms_Form>["fields"]>;
|
||||
function escapeCsvText(str: string) {
|
||||
return str.replace(/,/, "%2C");
|
||||
}
|
||||
|
||||
function getHumanReadableFieldResponseValue({
|
||||
field,
|
||||
@@ -52,9 +50,8 @@ async function* getResponses(formId: string, fields: Fields) {
|
||||
fields.forEach((field) => {
|
||||
const fieldResponse = fieldResponses[field.id];
|
||||
const value = fieldResponse?.value || "";
|
||||
const serializedValue = getHumanReadableFieldResponseValue({ field, value })
|
||||
.map((value) => escapeCsvText(value))
|
||||
.join(" | ");
|
||||
const readableValues = getHumanReadableFieldResponseValue({ field, value });
|
||||
const serializedValue = readableValues.map((value) => sanitizeValue(value)).join(" | ");
|
||||
csvCells.push(serializedValue);
|
||||
});
|
||||
csvCells.push(response.createdAt.toISOString());
|
||||
|
||||
@@ -98,7 +98,7 @@ const Actions = ({
|
||||
tooltip={t("copy_link_to_form")}
|
||||
/>
|
||||
|
||||
<Tooltip content="Download Responses">
|
||||
<Tooltip content={t("download_responses")}>
|
||||
<FormAction
|
||||
data-testid="download-responses"
|
||||
routingForm={form}
|
||||
|
||||
Reference in New Issue
Block a user