frontend


frontend / api/suppliers/hooks/useSupplierByIdQuery / useSupplierByIdQuery

Function: useSupplierByIdQuery()

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

Defined in: 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

string | null

enabled

boolean = true

Whether to fetch (defaults to true)

Returns

UseQueryResult<SupplierRow | null, 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} />;