arch-atlas

Add Prestation Wizard Controller

add-prestation/provider/add_product_provider.dart

domain

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

  1. vendorProductCategoriesProvider + vendorSubCategoriesProvider load top-level + nested categories on demand.
  2. Form state mutations (title, thumbnail, options, variants, working hours, location, policy).
  3. Submit pipeline: VendorService.createProvision → /vendor/members → assignProvisionsToMember (provision + workingHour + slotDuration + location) → addProductLocation → upsertBookingPolicy.
  4. 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 status

    Top-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 // vendorProductCategoriesProvider

    auth: seller. Direct DioHelper call from the Riverpod provider.

  • GET/vendor/categories/:parentIdno status

    Sub-categories of a chosen parent category.

    Response
    { categories: Category[] }
    lib/src/features/seller/add-prestation/provider/add_product_provider.dart:44 // vendorSubCategoriesProvider

    auth: seller.

  • POST/vendor/filesno status

    Multipart upload of the wizard's thumbnail / images before submit.

    Request
    FormData({ file: File, purpose: 'public' })
    Response
    { url: string }
    lib/src/features/seller/add-prestation/add-prestation.dart + thumbnail.dart // via VendorService.uploadPublicFile

    auth: 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.