useUtilsProvider
Central row and bulk action HTTP handlers and success side effects
File: ./ApiTables/table-providers/useUtilsProvider.tsx
This hook is the action execution layer. Row and bulk UI components call it instead of calling axiosTable directly.
Exports
| Function | Role |
|---|---|
triggerTableReload() | dispatch(_triggerTableReload()) |
rowActionsPostHandler(method, url, payload, action, customHeader?) | Single-row or selection POST |
bulkActionsPostHandler(method, url, payload, loaderInfo, action) | Bulk POST + global loader |
resetClickedRowAction() | Clears row action state and selection |
URL handling
Action URLs from structure often include /api. Handlers call:
url.replace("/api", "")before passing to axiosTable.
Row action success handlers (onSuccess)
| Value | Behavior |
|---|---|
reload | triggerTableReload() + reset clicked action |
deleteRow | Same as reload |
refetchData | Replace tableData with response.items |
refetchRow | Merge response.data.row into matching id |
downloadData / download_pdf / generatePdf / downloadPdf | File download helpers |
OpenModalForm | Sets customControlAction — modal stays open until closed |
DisplayOnModal | Sets clickedRowActionResponse for ViewRowData |
Bulk action success (onSuccess / onBulkSuccess)
Handled in handleBulkActionReponse and TableBulkActions effects:
reload,deleteRow→ table reloadexport-excel-blob→ blob download- Stream / URL responses →
downloadURLor PDF helpers
Cross-store side effects
Uses global store from @/store/store:
| Trigger | Global dispatch |
|---|---|
| Bulk POST start | _setMainLoader({ status, msg, icon }) |
| Packing materials path + reload | setCartCount from response cart total |
Pathname is read via usePathname() for route-specific behavior.
Custom control prefetch
For action_type: "custom_control", GeneralRowActionElement dispatches clicked action and immediately POSTs so OpenModalForm receives form defaults in customControlAction.
Usage in custom controls
Custom modal components should import useUtilsProvider to submit saves and call triggerTableReload() or resetClickedRowAction() on success.
const { rowActionsPostHandler, triggerTableReload } = useUtilsProvider();