SansiStore gives sellers a self-service promotions tool on theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ProcesosAgilesUMSS/sansistore/llms.txt
Use this file to discover all available pages before exploring further.
/seller/offers page. A seller selects any active product, sets a discount percentage, and defines a validity window. The platform computes the final offer price automatically, persists it to Firestore, and immediately reflects it in the buyer-facing catalog — no admin approval needed.
How Offers Work
When a seller creates an offer, two things happen atomically:- A new document is added to the
offerscollection with the discount percentage, date range, and status. - The corresponding product document in
products/{productId}is updated withhasOffer: true, a computedofferPrice, and abadgelabel of"Oferta".
DiscountBadge component uses these two product fields to render the price display for buyers: the original price is struck through and the offerPrice is shown prominently.
Offers Page — /seller/offers
Activate Offer
Select any active product from the dropdown. The list is sorted alphabetically and loaded via
getProductsService, which queries products where active == true.Set Offer Price
Enter a discount percentage between 1 and 100. The form computes
offerPrice = price × (1 − discount / 100) and shows a live preview using DiscountBadge before the seller saves.Set Validity Window
Choose a start date and an end date. The form validates that the end date is not before the start date. The
status field is set to 'active' at creation time.Offer in Catalog
Once saved, buyers see the offer price in the product catalog. The original price appears with a strikethrough and a red animated
-X% Oferta badge is shown alongside the discounted price.Offer Service
The entire offer creation flow is handled bycreateOfferService in src/features/offers/services/offerService.ts:
updateProductWithOffer helper computes the price and patches the product:
Product Offer Fields
The following fields on theproducts collection document control offer display throughout the catalog:
| Field | Type | Description |
|---|---|---|
price | number | Regular selling price in BOB |
hasOffer | boolean | true when an active offer is in effect |
offerPrice | number | Discounted price, calculated as price × (1 − discount/100) and rounded to 2 decimal places |
badge | string | Label shown on the product card — set to "Oferta" when an offer is active |
The
offerPrice is always derived from the discount percentage applied to the product’s price at the time the offer is saved. If the regular price changes later, the seller must create a new offer to recalculate.Offer Display in the Catalog — DiscountBadge
TheDiscountBadge component in src/features/offers/components/DiscountBadge.tsx renders the buyer-facing price preview. It is also embedded in the OfferForm as a live preview while the seller types a discount value:
line-through, the discounted price is highlighted in the primary brand color, and the percentage badge pulses in red to attract buyer attention.
OfferForm Validation
TheOfferForm component (src/features/offers/components/OfferForm.tsx) enforces the following rules before calling createOfferService:
Validation rules applied by OfferForm
Validation rules applied by OfferForm
- All fields are required — product, discount percentage, start date, and end date must all be filled.
- Discount range — the discount must be a whole number between 1 and 100 (inclusive). Values outside this range produce: “El descuento debe ser un número entre 1 y 100.”
- Date order — the end date cannot be earlier than the start date. Violation produces: “La fecha de finalización no puede ser anterior a la de inicio.”
- Product must exist — the product must be found in the loaded list. A stale selection triggers: “Producto no encontrado. Recarga la página e intenta de nuevo.”
- No duplicate offers — submitting a second offer for the same product while a previous one is active will overwrite
hasOfferandofferPriceon the product document with the newer values.
“¡Oferta guardada! ahora aparece con % de descuento en el catálogo.”
Procurement — /seller/purchase
Sellers can register new stock purchases via the /seller/purchase page, powered by PurchaseForm and purchaseService.ts. When a purchase is registered, registerPurchase performs a batched Firestore write that:
- Creates a document in the
purchasescollection withproductId,quantity,unitCost,totalCost,purchaseDate,supplier, andsellerId. - Increments
stockAvailableandstockTotalon the matchinginventory/{productId}document. - Appends an
INGRESO_COMPRAmovement toinventoryMovements.