feat: export resource tables to pdf

This commit is contained in:
Ahmed Bouhuolia
2024-05-23 14:23:49 +02:00
parent 1227111fae
commit fe41f7976d
10 changed files with 195 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
import { flatMap } from 'lodash';
import { flatMap, get } from 'lodash';
/**
* Flattens the data based on a specified attribute.
* @param data - The data to be flattened.
@@ -25,3 +25,18 @@ export const flatDataCollections = (
export const getDataAccessor = (col: any) => {
return col.group ? `${col.group}.${col.accessor}` : col.accessor;
};
/**
*
* @param columns
* @param data
* @returns
*/
export const mapPdfRows = (columns: any, data: Record<string, any>) => {
return data.map((item) => {
const cells = columns.map((column) => {
return { key: column.accessor, value: get(item, column.accessor) };
});
return { cells, classNames: '' };
});
};