Skip to content

Commit

Permalink
feat: Render assignment reason on routing form report (calcom#17791)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeauyeung authored Nov 22, 2024
1 parent 9c10ecf commit e7495e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
9 changes: 8 additions & 1 deletion packages/app-store/routing-forms/trpc/report.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
},
Expand Down Expand Up @@ -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),
];
Expand Down

0 comments on commit e7495e3

Please sign in to comment.