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

FunctionRole
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)

ValueBehavior
reloadtriggerTableReload() + reset clicked action
deleteRowSame as reload
refetchDataReplace tableData with response.items
refetchRowMerge response.data.row into matching id
downloadData / download_pdf / generatePdf / downloadPdfFile download helpers
OpenModalFormSets customControlAction — modal stays open until closed
DisplayOnModalSets clickedRowActionResponse for ViewRowData

Bulk action success (onSuccess / onBulkSuccess)

Handled in handleBulkActionReponse and TableBulkActions effects:

  • reload, deleteRow → table reload
  • export-excel-blob → blob download
  • Stream / URL responses → downloadURL or PDF helpers

Cross-store side effects

Uses global store from @/store/store:

TriggerGlobal dispatch
Bulk POST start_setMainLoader({ status, msg, icon })
Packing materials path + reloadsetCartCount 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();

On this page