From cdd533fc38a0e7637ce0b7432d8719a701c4b61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Torres=20Marroqu=C3=ADn?= Date: Wed, 11 Dec 2024 14:51:16 -0600 Subject: [PATCH] HJ-128 - Updating frontend to use the new API endpoint --- .../CustomReportCreationModal.tsx | 23 ++++++------ .../src/features/common/table/v2/util.ts | 4 +-- .../src/features/datamap/datamap.slice.ts | 7 ++-- .../datamap/reporting/DatamapReportTable.tsx | 33 ++++++++++------- .../reporting/DatamapReportTableColumns.tsx | 35 +++++++++---------- .../features/datamap/reporting/constants.tsx | 2 +- 6 files changed, 52 insertions(+), 52 deletions(-) diff --git a/clients/admin-ui/src/features/common/custom-reports/CustomReportCreationModal.tsx b/clients/admin-ui/src/features/common/custom-reports/CustomReportCreationModal.tsx index a5359894fa..e55e0bc4d6 100644 --- a/clients/admin-ui/src/features/common/custom-reports/CustomReportCreationModal.tsx +++ b/clients/admin-ui/src/features/common/custom-reports/CustomReportCreationModal.tsx @@ -63,25 +63,22 @@ export const CustomReportCreationModal = ({ ); const handleCreateReport = async (reportName: string) => { - // const columnMap: Record = {}; - // const columnVisibility: Record = - // tableStateToSave?.columnVisibility || {}; - // Object.keys(columnMapToSave).forEach((key) => { - // columnMap[key] = { - // label: columnMapToSave[key], - // enabled: columnVisibility[key], - // }; - // }); - - // console.log("columnMap", columnMap); + const columnMap: Record = {}; + const columnVisibility: Record = + tableStateToSave?.columnVisibility || {}; + Object.keys(columnMapToSave).forEach((key) => { + columnMap[key] = { + label: columnMapToSave[key], + enabled: columnVisibility[key], + }; + }); try { const newReportTemplate = { name: reportName.trim(), type: ReportType.DATAMAP, config: { - // column_map: columnMap, - column_map: columnMapToSave, + column_map: columnMap, table_state: tableStateToSave, }, }; diff --git a/clients/admin-ui/src/features/common/table/v2/util.ts b/clients/admin-ui/src/features/common/table/v2/util.ts index 323d43be10..401c26a8e8 100644 --- a/clients/admin-ui/src/features/common/table/v2/util.ts +++ b/clients/admin-ui/src/features/common/table/v2/util.ts @@ -26,7 +26,7 @@ export const columnExpandedVersion = ( interface GetColumnHeaderTextProps { columnId: string | undefined; - columnNameMap?: Record; + columnNameMap?: Record>; } /** * Get the header text for a column. @@ -56,5 +56,5 @@ export const getColumnHeaderText = ({ "", ); const nameFromId = _.upperFirst(keyWithoutPrefix.replaceAll("_", " ")); - return columnNameMap?.[columnId] || nameFromId; + return columnNameMap?.[columnId]?.label || nameFromId; }; diff --git a/clients/admin-ui/src/features/datamap/datamap.slice.ts b/clients/admin-ui/src/features/datamap/datamap.slice.ts index 363d16e115..a383763127 100644 --- a/clients/admin-ui/src/features/datamap/datamap.slice.ts +++ b/clients/admin-ui/src/features/datamap/datamap.slice.ts @@ -108,7 +108,7 @@ const datamapApi = baseApi.injectEndpoints({ dataSubjects?: string; format?: ExportFormat; report_id?: string; - report?: string; + report?: object; } >({ query: ({ @@ -139,11 +139,10 @@ const datamapApi = baseApi.injectEndpoints({ if (report_id) { queryString += `&report_id=${report_id}`; } - if (report) { - queryString += `&report=${report}`; - } return { url: `plus/datamap/minimal/${format}?${queryString}`, + method: "POST", + body: { report }, responseHandler: async (response) => { const filename = await getFileNameFromContentDisposition( response.headers.get("content-disposition"), diff --git a/clients/admin-ui/src/features/datamap/reporting/DatamapReportTable.tsx b/clients/admin-ui/src/features/datamap/reporting/DatamapReportTable.tsx index c0994f6aa5..91f2050368 100644 --- a/clients/admin-ui/src/features/datamap/reporting/DatamapReportTable.tsx +++ b/clients/admin-ui/src/features/datamap/reporting/DatamapReportTable.tsx @@ -235,23 +235,30 @@ export const DatamapReportTable = () => { } = useDisclosure(); const onExport = (downloadType: ExportFormat) => { + const columnMap: Record = {}; + Object.keys(columnNameMapOverrides).forEach((key) => { + columnMap[key] = { + label: columnNameMapOverrides[key], + enabled: columnVisibility[key], + }; + }); + exportMinimalDatamapReport({ ...reportQuery, format: downloadType, report_id: savedCustomReportId, - // report: JSON.stringify({ - // name: "temporary report", - // type: "datamap", - // config: { - // column_map: columnNameMapOverrides, - // table_state: { - // groupBy, - // filters: selectedFilters, - // columnOrder, - // columnVisibility, - // }, - // }, - // }), + report: { + name: "temporary report", + type: "datamap", + config: { + column_map: columnMap, + table_state: { + groupBy, + filters: selectedFilters, + columnOrder, + }, + }, + }, }).then(() => { if (isExportReportSuccess) { onExportReportClose(); diff --git a/clients/admin-ui/src/features/datamap/reporting/DatamapReportTableColumns.tsx b/clients/admin-ui/src/features/datamap/reporting/DatamapReportTableColumns.tsx index 9331380c62..a4dd638b51 100644 --- a/clients/admin-ui/src/features/datamap/reporting/DatamapReportTableColumns.tsx +++ b/clients/admin-ui/src/features/datamap/reporting/DatamapReportTableColumns.tsx @@ -27,25 +27,22 @@ export const getDefaultColumn: ( isRenamingColumns, ) => ({ cell: (props) => , - header: (props) => { - console.log("props", props); - console.log("columnNameMap", columnNameMap); - return null; - // - }, + header: (props) => ( + + ), }); const getCustomFieldColumns = ( diff --git a/clients/admin-ui/src/features/datamap/reporting/constants.tsx b/clients/admin-ui/src/features/datamap/reporting/constants.tsx index cb828ba60b..8ab825e1f4 100644 --- a/clients/admin-ui/src/features/datamap/reporting/constants.tsx +++ b/clients/admin-ui/src/features/datamap/reporting/constants.tsx @@ -15,7 +15,7 @@ export enum DATAMAP_LOCAL_STORAGE_KEYS { export enum COLUMN_IDS { SYSTEM_NAME = "system_name", - DATA_USE = "data_use", + DATA_USE = "data_uses", DATA_CATEGORY = "data_categories", DATA_SUBJECT = "data_subjects", LEGAL_NAME = "legal_name",