Add Prestation Wizard Controller
add-prestation/provider/add_product_provider.dart
Overview
Drives the multi-step wizard: holds the form state, exposes category providers, and runs the 4-6-call submission pipeline (create → assign → location → policy).
User Flow
- vendorProductCategoriesProvider + vendorSubCategoriesProvider load top-level + nested categories on demand.
- Form state mutations (title, thumbnail, options, variants, working hours, location, policy).
- Submit pipeline: VendorService.createProvision → /vendor/members → assignProvisionsToMember (provision + workingHour + slotDuration + location) → addProductLocation → upsertBookingPolicy.
- Each step bubbles errors to a single 'submitError' state slot.
Cases & Edge Cases
- If member assignment fails after createProvision, the provision is created but orphaned — backend cleanup is manual today.
- Policy upsert is the last step; it can run independently after the rest succeeds (idempotent).
- Geoapify is used to resolve the address into lat/lng before /vendor/product-location.
- Currency, sub-category, and option values are validated client-side before the submit fires.
Code References
- lib/src/features/seller/add-prestation/provider/add_product_provider.dart:21 // vendorProductCategoriesProvider
- lib/src/features/seller/add-prestation/provider/add_product_provider.dart:44 // vendorSubCategoriesProvider
- lib/src/features/seller/add-prestation/CLAUDE.md // canonical create-flow doc
API Calls
- GET
/vendor/categoriesno statusTop-level seller_services categories for the category picker.
Response{ seller_services: [{ id, name, ... }, ...] }lib/src/features/seller/add-prestation/provider/add_product_provider.dart:21 // vendorProductCategoriesProviderauth: seller. Direct DioHelper call from the Riverpod provider.
- GET
/vendor/categories/:parentIdno statusSub-categories of a chosen parent category.
Response{ categories: Category[] }lib/src/features/seller/add-prestation/provider/add_product_provider.dart:44 // vendorSubCategoriesProviderauth: seller.
- POST
/vendor/filesno statusMultipart upload of the wizard's thumbnail / images before submit.
RequestFormData({ file: File, purpose: 'public' })Response{ url: string }lib/src/features/seller/add-prestation/add-prestation.dart + thumbnail.dart // via VendorService.uploadPublicFileauth: seller.
Notes
CLAUDE.md in this folder is the source of truth for the multi-call sequence — keep it in lockstep with the controller. After these calls the wizard chains VendorService contracts (createProvision → assignProvisionsToMember → addProductLocation → upsertBookingPolicy) listed on the vendor-service node.