feat: Add feature to download routing form reports (#17400)

* remove unused code

* add i18n for some strings in widget

* improve UI and add download button to routing forms reporting page

* add more margin

* add downloadAsCsv util

* integrate download button to routing forms report

* refactor

* address comment

* escape comma multiselect items

* fix

* preserve new lines and wrapping

* refactor

* ensure fetching all rows
This commit is contained in:
Benny Joo authored and GitHub committed 2024-11-05 11:21:13 -05:00
1 parent 423b284278
commit 803fc488c5
7 files changed
+97 -35

No files matched your search

@@ -1,4 +1,5 @@
import { useFilterContext } from "@calcom/features/insights/context/provider";
import { downloadAsCsv } from "@calcom/lib/csvUtils";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { RouterOutputs } from "@calcom/trpc";
import { trpc } from "@calcom/trpc";
@@ -33,23 +34,7 @@ const Download = () => {
const handleDownloadClick = async (data: RawData) => {
if (!data) return;
const { data: csvRaw, filename } = data;
// Create a Blob from the text data
const blob = new Blob([csvRaw], { type: "text/plain" });
// Create an Object URL for the Blob
const url = window.URL.createObjectURL(blob);
// Create a download link
const a = document.createElement("a");
a.href = url;
a.download = filename; // Specify the filename
// Simulate a click event to trigger the download
a.click();
// Release the Object URL to free up memory
window.URL.revokeObjectURL(url);
downloadAsCsv(csvRaw, filename);
};
return (
@@ -7,12 +7,6 @@ import type { RawDataInput } from "./raw-data.schema";
type TimeViewType = "week" | "month" | "year" | "day";
type DateRange = {
startDate: string; // ISO string format
endDate: string; // ISO string format
formattedDate: string;
};
type StatusAggregate = {
completed: number;
rescheduled: number;