Computing for good
Atlanta Food Consortium/Feature Docs

Supplier Route

Supplier dashboard for managing product listings. Restricted to users with the SUPPLIER role.

Overview

The Supplier route (/supplier) lets food suppliers manage their active product listings, view claim activity, and track metrics. Access is restricted to users with the SUPPLIER role.

Source directory: src/app/supplier/

Access control

CheckValue
Required roleSUPPLIER
Redirect on failure/

Tabs

TabDescription
My ProductsTable of the supplier's current listings with edit and delete actions
AnalyticsKPI cards and charts showing claim rates and product performance

Data hooks

HookFileReturns
useSupplierData()src/hooks/useSupplierData.tsSupplier's product listings and claim history
useSupplierMetrics()src/hooks/useSupplierMetrics.tsAggregate stats - total listed, total claimed, claim rate
useSupplierForm()src/hooks/useSupplierForm.tsForm state and submit handler for posting a new product

Posting a new product

const { register, handleSubmit, errors, isSubmitting } = useSupplierForm();

// Posts to POST /api/products
<form onSubmit={handleSubmit}>
  <input {...register('name')} placeholder='Product name' />
  <input {...register('quantity')} type='number' />
  {errors.name && <p>{errors.name.message}</p>}
  <button type='submit' disabled={isSubmitting}>
    Post Product
  </button>
</form>;

API routes used

EndpointMethodPurpose
/api/productsGETFetch supplier's own products
/api/productsPOSTCreate a new product listing
/api/products/[id]PUTUpdate an existing listing
/api/products/[id]DELETERemove a listing
/api/supplier/metricsGETFetch supplier-level aggregate stats