frontend


frontend / api/suppliers/hooks/useSupplierByIdQuery / useSupplierByIdQuery

Function: useSupplierByIdQuery()

useSupplierByIdQuery(supplierId, enabled): UseQueryResult<null | SupplierRow, Error>

Defined in: src/api/suppliers/hooks/useSupplierByIdQuery.ts:38

Hook to load a single supplier by ID. Useful for edit dialogs that need to display current supplier data.

Parameters

supplierId

The ID of the supplier to load

null | string

enabled

boolean = true

Whether to fetch (defaults to true)

Returns

UseQueryResult<null | SupplierRow, Error>

React Query result with supplier data or null

Remarks

Currently fetches via the list endpoint with search filter. A dedicated GET /api/suppliers/:id endpoint would be more efficient.

Example

const { data: supplier } = useSupplierByIdQuery(selectedSupplierId);

return <TextField value={supplier?.name} />;