From caf136129139cec05b126462bfd5e71930cf06b0 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Sat, 16 May 2026 19:45:25 +0200 Subject: [PATCH] fix(loyalty): admin/store/merchant card detail return phone + birthday MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The shared card-detail-view template already renders card.customer_phone and card.customer_birthday, but CardDetailResponse was missing both fields, so every consumer (admin, store, merchant) silently returned them as undefined and the UI showed "-". Added the two fields to the schema and populated them from customer.phone / customer.birth_date in all three endpoints. Data was persisting correctly all along — purely a serialization gap. Co-Authored-By: Claude Opus 4.7 (1M context) --- app/modules/loyalty/routes/api/admin.py | 2 ++ app/modules/loyalty/routes/api/merchant.py | 2 ++ app/modules/loyalty/routes/api/store.py | 2 ++ app/modules/loyalty/schemas/card.py | 2 ++ 4 files changed, 8 insertions(+) diff --git a/app/modules/loyalty/routes/api/admin.py b/app/modules/loyalty/routes/api/admin.py index 6dd948d9..c4607fd3 100644 --- a/app/modules/loyalty/routes/api/admin.py +++ b/app/modules/loyalty/routes/api/admin.py @@ -381,6 +381,8 @@ def get_merchant_card( enrolled_at_store_id=card.enrolled_at_store_id, customer_name=customer.full_name if customer else None, customer_email=customer.email if customer else None, + customer_phone=customer.phone if customer else None, + customer_birthday=customer.birth_date if customer else None, merchant_name=card.merchant.name if card.merchant else None, qr_code_data=card.qr_code_data or card.card_number, program_name=program.display_name, diff --git a/app/modules/loyalty/routes/api/merchant.py b/app/modules/loyalty/routes/api/merchant.py index 58d2a604..649c40aa 100644 --- a/app/modules/loyalty/routes/api/merchant.py +++ b/app/modules/loyalty/routes/api/merchant.py @@ -228,6 +228,8 @@ def get_card_detail( enrolled_at_store_id=card.enrolled_at_store_id, customer_name=customer.full_name if customer else None, customer_email=customer.email if customer else None, + customer_phone=customer.phone if customer else None, + customer_birthday=customer.birth_date if customer else None, merchant_name=card.merchant.name if card.merchant else None, qr_code_data=card.qr_code_data or card.card_number, program_name=program.display_name, diff --git a/app/modules/loyalty/routes/api/store.py b/app/modules/loyalty/routes/api/store.py index 148d907a..0e7771bf 100644 --- a/app/modules/loyalty/routes/api/store.py +++ b/app/modules/loyalty/routes/api/store.py @@ -656,6 +656,8 @@ def get_card_detail( enrolled_at_store_name=enrolled_store_name, customer_name=customer.full_name if customer else None, customer_email=customer.email if customer else None, + customer_phone=customer.phone if customer else None, + customer_birthday=customer.birth_date if customer else None, merchant_name=card.merchant.name if card.merchant else None, qr_code_data=card.qr_code_data or card.card_number, program_name=program.display_name, diff --git a/app/modules/loyalty/schemas/card.py b/app/modules/loyalty/schemas/card.py index 30490f0b..24d766a0 100644 --- a/app/modules/loyalty/schemas/card.py +++ b/app/modules/loyalty/schemas/card.py @@ -97,6 +97,8 @@ class CardDetailResponse(CardResponse): # Customer info customer_name: str | None = None customer_email: str | None = None + customer_phone: str | None = None + customer_birthday: date | None = None # Merchant info merchant_name: str | None = None