Saltar al contenido principal

Table export (PWA)

Client-side CSV, Excel, and PDF export for paginated grids in frontend-pwa.

Architecture

LayerLocationResponsibility
Pure utilitiesapps/frontend-pwa/src/lib/table-export/Fetch all pages, build rows, write files
Hookapps/frontend-pwa/src/hooks/useTableExport.tsOrchestration, toasts, loading state
UIapps/frontend-pwa/src/components/ui/TableExportMenu.tsxExport dropdown
Integration*List.tsx / *Search.tsxColumn definitions + filtered fetch
Servicesapps/frontend-pwa/src/services/*Service.tsgetAll*Filtered using same API params as grid

TablePagination accepts an optional exportActions slot (rendered before Refresh / Print).

Integration checklist

  1. Add getAll<Entity>Filtered in *Service.ts via createOffsetExportFetcher or getAllSearchFiltered for search-only catalogs.
  2. Create <entity>ExportColumns.ts with explicit ExportColumn[] (omit action columns).
  3. Wire useTableExport + TableExportMenu in the list/search component.
  4. Pass totalRecordsCount to pagination and export hook.
  5. Apply the same client sort used in the grid after fetching all rows.
  6. Build a filterSummary string for PDF headers.

Products reference

  • Columns: apps/frontend-pwa/src/components/forms/product/productExportColumns.ts
  • Fetch: getAllProductsFiltered in productService.ts
  • UI: ProductList.tsxTablePagination.exportActions

Search-only catalogs

For grids with a single search query param, use getAllSearchFiltered from lib/table-export/get-all-search-filtered.ts and buildSearchFilterSummary for PDF headers.

ScreenColumns fileServiceList
CustomerscustomerExportColumns.tsgetAllCustomersFilteredCustomerList.tsx
SupplierssupplierExportColumns.tsgetAllSuppliersFilteredSupplierList.tsx
BrandsbrandExportColumns.tsgetAllBrandsFilteredBrandList.tsx
CategoriescategoryExportColumns.tsgetAllCategoriesFilteredCategoryList.tsx
ColorscolorExportColumns.tsgetAllColorsFilteredColorList.tsx
SizessizeExportColumns.tsgetAllSizesFilteredSizeList.tsx
Units of measureunitOfMeasureExportColumns.tsgetAllUnitsOfMeasureFilteredUnitOfMeasureList.tsx
LocationslocationExportColumns.tsgetAllLocationsFilteredLocationList.tsx
EmployeesemployeeExportColumns.tsgetAllEmployeesFilteredEmployeeList.tsx
StylesstyleExportColumns.tsgetAllStylesFilteredStyleList.tsx
ModelsmodelExportColumns.tsgetAllModelsFilteredModelList.tsx
AttributesattributeExportColumns.tsgetAllAttributesFilteredAttributeList.tsx
CurrenciescurrencyExportColumns.tsgetAllCurrenciesFilteredCurrencyList.tsx
Payment methodspaymentMethodExportColumns.tsgetAllPaymentMethodsFilteredPaymentMethodList.tsx
Service typesserviceTypeExportColumns.tsgetAllServiceTypesFilteredServiceTypeList.tsx
AddressesaddressExportColumns.tsgetAllAddressesFilteredAddressList.tsx
FormsformExportColumns.tsgetAllFormsFilteredFormList.tsx
Document templatestemplateExportColumns.tsgetAllTemplatesFilteredTemplateManagementPage.tsx
InventoryinventoryExportColumns.tsgetAllInventoriesFilteredInventoryList.tsx
ServicesserviceExportColumns.tsgetAllServicesFilteredServiceList.tsx
Exchange ratesexchangeRateExportColumns.tsgetAllExchangeRatesFilteredExchangeRateList.tsx
Inventory batch detailsinventoryDetailExportColumns.tsgetAllInventoryDetailsFilteredInventoryDetailBatchList.tsx
Inventory serial detailsinventoryDetailExportColumns.tsgetAllInventoryDetailsFilteredInventoryDetailSerialList.tsx

Pagination empty state

TablePagination normalizes empty grids: when totalPages is 0, navigation buttons are disabled and the label shows Page 1 of 1 instead of Page 1 of 0.

Limits

  • MAX_EXPORT_ROWS: 10,000
  • EXPORT_WARN_ROWS: 2,000 (warning toast)
  • EXPORT_PAGE_SIZE: 500 per API request (sequential pages)

Out of scope

  • Activity Log (async backend CSV export)
  • Editable POS line-item tables
  • Metabase embeds