<ProtectedRoute>.
Routes
| Route | Component | Description |
|---|---|---|
/profile | Profile | Edit name, phone, WhatsApp, birthdate |
/addresses | Addresses | Manage shipping and billing addresses |
/notifications | Notifications | Notification center and preferences |
/stats | Stats | Personal purchase statistics |
Updating Profile Data
updateProfile() from auth.service.ts performs a Supabase upsert on the customer_profiles table:
src/pages/Profile.tsx) accesses the current profile via useAuth().profile and submits changes through a controlled form that calls updateProfile(user.id, formData).
Address Management
Addresses are stored in theaddresses table with a one-to-many relationship to customer_profiles.
Address Interface
CRUD Operations
All address operations are insrc/services/addresses.service.ts:
getAddresses(customerId)
Returns all addresses for the authenticated customer. Used by
useAddresses() hook with query key ['addresses'].createAddress(data)
Inserts a new address. If
is_default: true, the service first clears the default flag on all other addresses of the same type.updateAddress(id, data)
Partial update on an existing address row.
deleteAddress(id)
Deletes the address. The
Addresses page shows a confirmation dialog before deletion.setDefault(addressId, customerId, type) — Sets a specific address as the default for its type ('shipping' or 'billing'), clearing all other defaults for that type.
useAddresses() Hook
Loyalty Tier Badges
The Profile page prominently displays the customer’s current loyalty tier using theLoyaltyBadge component (src/components/loyalty/LoyaltyBadge.tsx).
Tier Definitions
| Tier | Minimum Spent | Badge Color | Benefits |
|---|---|---|---|
bronze | $0 MXN | Copper | Base earn rate |
silver | $5,000 MXN | Silver | 5% discount, free shipping above $1,000 |
gold | $20,000 MXN | Gold | 10% discount, free shipping always |
platinum | $50,000 MXN | Platinum | 15% discount, express shipping, VIP access |
Tier thresholds are configurable from the admin panel via
store_settings and the loyalty_config JSON field. The defaults are defined in src/lib/domain/loyalty.ts as LOYALTY_TIERS.getProgressToNextTier(totalSpent) from loyalty.service.ts, which returns:
Personal Statistics (/stats)
The Stats page (src/pages/Stats.tsx) displays aggregated purchase statistics for the authenticated customer.
Notifications (/notifications)
The Notifications page (src/pages/user/Notifications.tsx) renders the in-app notification history from the Zustand notifications.store.ts:
useNotification() hook (src/hooks/useNotification.ts). Notifications are in-memory only — they reset on page refresh.