feat: Render assignment reason on routing form report (#17791)

This commit is contained in:
Joe Au-Yeung
2024-11-22 10:57:16 -07:00
committed by GitHub
parent 9c10ecf8ea
commit e7495e311b
2 changed files with 12 additions and 4 deletions
@@ -325,14 +325,15 @@ test.describe("Routing Forms", () => {
// TODO: Find a way to incorporate Routed To and Booked At into the report
// @see https://github.com/calcom/cal.com/pull/17229
"Routed To",
"Assignment Reason",
"Booked At",
"Submitted At",
]);
/* Last two columns are "Routed To" and "Booked At" */
expect(responses).toEqual([
["custom-page", "Option-2", "Option-2", "Option-2", "Option-2", "", "", expect.any(String)],
["external-redirect", "Option-2", "Option-2", "Option-2", "Option-2", "", "", expect.any(String)],
["event-routing", "Option-2", "Option-2", "Option-2", "Option-2", "", "", expect.any(String)],
["custom-page", "Option-2", "Option-2", "Option-2", "Option-2", "", "", "", expect.any(String)],
["external-redirect", "Option-2", "Option-2", "Option-2", "Option-2", "", "", "", expect.any(String)],
["event-routing", "Option-2", "Option-2", "Option-2", "Option-2", "", "", "", expect.any(String)],
]);
await page.goto(`apps/routing-forms/route-builder/${routingForm.id}`);
@@ -58,6 +58,12 @@ const getRows = async ({ ctx: { prisma }, input }: ReportHandlerOptions) => {
user: {
select: { id: true, name: true, email: true },
},
assignmentReason: {
orderBy: {
createdAt: "desc",
},
take: 1,
},
},
},
},
@@ -123,12 +129,13 @@ function presenter(args: {
const formatDate = makeFormatDate(ctx.user.locale, ctx.user.timeZone);
return {
nextCursor,
headers: [...headers, "Routed To", "Booked At", "Submitted At"],
headers: [...headers, "Routed To", "Assignment Reason", "Booked At", "Submitted At"],
responses: responses.map((r, i) => {
const currentRow = rows[i];
return [
...r,
currentRow.routedToBooking?.user?.email || "",
currentRow.routedToBooking?.assignmentReason[0].reasonString || "",
currentRow.routedToBooking?.createdAt ? formatDate(currentRow.routedToBooking.createdAt) : "",
formatDate(currentRow.createdAt),
];