fix(loyalty): align /locations endpoint shape with template bindings
The shared loyalty list partials (pins, cards, transactions, devices,
admin merchant detail) bind store filter dropdowns to
loc.store_id/loc.store_name, but the /merchants/loyalty/locations and
/admin/loyalty/merchants/{id}/locations endpoints were returning
{id, name, code}. Result: every store-filter dropdown was silently
empty across the loyalty module.
Switch both endpoints to {store_id, store_name, store_code}, matching
the shape used everywhere else (analytics, location stats). Storefront
locations come from a different code path and are unaffected.
Drop the temporary normalizer in the devices Alpine factory now that
the endpoint speaks the right shape.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -482,13 +482,17 @@ def list_merchant_locations(
|
||||
current_user: User = Depends(get_current_admin_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Get active store locations for a merchant."""
|
||||
"""Get active store locations for a merchant.
|
||||
|
||||
Shape matches what the shared loyalty list partials bind to
|
||||
(`loc.store_id` / `loc.store_name` / `loc.store_code`).
|
||||
"""
|
||||
locations = program_service.get_merchant_locations(db, merchant_id)
|
||||
return [
|
||||
{
|
||||
"id": store.id,
|
||||
"name": store.name,
|
||||
"code": store.store_code,
|
||||
"store_id": store.id,
|
||||
"store_name": store.name,
|
||||
"store_code": store.store_code,
|
||||
}
|
||||
for store in locations
|
||||
]
|
||||
|
||||
@@ -530,9 +530,17 @@ def list_locations(
|
||||
merchant: Merchant = Depends(get_merchant_for_current_user),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""List merchant stores (for filter dropdowns)."""
|
||||
"""List merchant stores (for filter dropdowns).
|
||||
|
||||
Shape matches what the shared loyalty list partials bind to
|
||||
(`loc.store_id` / `loc.store_name` / `loc.store_code`).
|
||||
"""
|
||||
locations = program_service.get_merchant_locations(db, merchant.id)
|
||||
return [
|
||||
{"id": loc.id, "name": loc.name, "code": loc.store_code}
|
||||
{
|
||||
"store_id": loc.id,
|
||||
"store_name": loc.name,
|
||||
"store_code": loc.store_code,
|
||||
}
|
||||
for loc in locations
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user