fix: Display option label in the routing form response email (#17898)
* fix: display option label int the routing form response email * Update * fix type error * type error
This commit is contained in:
1 parent
a3ceefc00e
commit
410558f822
3 files changed
+14
-14
No files matched your search
@@ -3,17 +3,18 @@ import type { App_RoutingForms_Form } from "@prisma/client";
|
||||
import { BaseEmailHtml, Info } from "@calcom/emails/src/components";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
|
||||
import type { OrderedResponses } from "../../types/types";
|
||||
import type { Fields, OrderedResponses } from "../../types/types";
|
||||
|
||||
export const ResponseEmail = ({
|
||||
form,
|
||||
orderedResponses,
|
||||
...props
|
||||
}: {
|
||||
form: Pick<App_RoutingForms_Form, "id" | "name">;
|
||||
form: Pick<App_RoutingForms_Form, "id" | "name" | "fields">;
|
||||
orderedResponses: OrderedResponses;
|
||||
subject: string;
|
||||
} & Partial<React.ComponentProps<typeof BaseEmailHtml>>) => {
|
||||
const formFields = form.fields as Fields;
|
||||
return (
|
||||
<BaseEmailHtml
|
||||
callToAction={
|
||||
@@ -37,16 +38,15 @@ export const ResponseEmail = ({
|
||||
subtitle="New Response Received"
|
||||
{...props}>
|
||||
{orderedResponses.map((fieldResponse, index) => {
|
||||
return (
|
||||
<Info
|
||||
withSpacer
|
||||
key={index}
|
||||
label={fieldResponse.label}
|
||||
description={
|
||||
fieldResponse.value instanceof Array ? fieldResponse.value.join(",") : fieldResponse.value
|
||||
}
|
||||
/>
|
||||
);
|
||||
const field = formFields?.find((f) => f.label === fieldResponse.label);
|
||||
const description =
|
||||
fieldResponse.value instanceof Array
|
||||
? fieldResponse.value
|
||||
.map((id) => field?.options?.find((opt) => opt.id === id)?.label || id)
|
||||
.join(", ")
|
||||
: field?.options?.find((opt) => opt.id === fieldResponse.value)?.label || fieldResponse.value;
|
||||
|
||||
return <Info withSpacer key={index} label={fieldResponse.label} description={description} />;
|
||||
})}
|
||||
</BaseEmailHtml>
|
||||
);
|
||||
|
||||
@@ -5,7 +5,7 @@ import BaseEmail from "@calcom/emails/templates/_base-email";
|
||||
|
||||
import type { OrderedResponses } from "../../types/types";
|
||||
|
||||
type Form = Pick<App_RoutingForms_Form, "id" | "name">;
|
||||
type Form = Pick<App_RoutingForms_Form, "id" | "name" | "fields">;
|
||||
export default class ResponseEmail extends BaseEmail {
|
||||
orderedResponses: OrderedResponses;
|
||||
toAddresses: string[];
|
||||
|
||||
@@ -205,7 +205,7 @@ export async function onFormSubmission(
|
||||
}
|
||||
|
||||
export const sendResponseEmail = async (
|
||||
form: Pick<App_RoutingForms_Form, "id" | "name">,
|
||||
form: Pick<App_RoutingForms_Form, "id" | "name" | "fields">,
|
||||
orderedResponses: OrderedResponses,
|
||||
toAddresses: string[]
|
||||
) => {
|
||||
|
||||
Reference in new issue
Block a user