From bb3d6f001212959df87bc31d2909e00ebb72c372 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Wed, 15 Apr 2026 22:31:53 +0200 Subject: [PATCH] =?UTF-8?q?fix(loyalty):=20card=20detail=20=E2=80=94=20enr?= =?UTF-8?q?olled=20store=20name=20+=20copy=20buttons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix "Enrolled at: Unknown" by resolving enrolled_at_store_name from the store service and adding it to CardDetailResponse schema. - Add clipboard-copy buttons next to card number, customer name, email, and phone fields using the shared Utils.copyToClipboard() utility with toast feedback. Co-Authored-By: Claude Opus 4.6 (1M context) --- app/modules/loyalty/routes/api/store.py | 12 ++++++++ app/modules/loyalty/schemas/card.py | 1 + .../templates/loyalty/store/card-detail.html | 28 ++++++++++++++++--- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/app/modules/loyalty/routes/api/store.py b/app/modules/loyalty/routes/api/store.py index 870626b1..d4d8d136 100644 --- a/app/modules/loyalty/routes/api/store.py +++ b/app/modules/loyalty/routes/api/store.py @@ -514,6 +514,17 @@ def get_card_detail( program = card.program customer = card.customer + # Resolve enrolled store name + enrolled_store_name = None + if card.enrolled_at_store_id: + from app.modules.tenancy.services.store_service import store_service + + enrolled_store = store_service.get_store_by_id_optional( + db, card.enrolled_at_store_id + ) + if enrolled_store: + enrolled_store_name = enrolled_store.name + return CardDetailResponse( id=card.id, card_number=card.card_number, @@ -521,6 +532,7 @@ def get_card_detail( merchant_id=card.merchant_id, program_id=card.program_id, enrolled_at_store_id=card.enrolled_at_store_id, + enrolled_at_store_name=enrolled_store_name, customer_name=customer.full_name if customer else None, customer_email=customer.email if customer else None, merchant_name=card.merchant.name if card.merchant else None, diff --git a/app/modules/loyalty/schemas/card.py b/app/modules/loyalty/schemas/card.py index 0eb490b6..ce5a0c56 100644 --- a/app/modules/loyalty/schemas/card.py +++ b/app/modules/loyalty/schemas/card.py @@ -100,6 +100,7 @@ class CardDetailResponse(CardResponse): # Merchant info merchant_name: str | None = None + enrolled_at_store_name: str | None = None # Program info program_name: str diff --git a/app/modules/loyalty/templates/loyalty/store/card-detail.html b/app/modules/loyalty/templates/loyalty/store/card-detail.html index 5f2ff473..213600f4 100644 --- a/app/modules/loyalty/templates/loyalty/store/card-detail.html +++ b/app/modules/loyalty/templates/loyalty/store/card-detail.html @@ -70,15 +70,30 @@

{{ _('loyalty.store.card_detail.name') }}

-

-

+
+

-

+ +

{{ _('loyalty.store.card_detail.email') }}

-

-

+
+

-

+ +

{{ _('loyalty.store.card_detail.phone') }}

-

-

+
+

-

+ +

{{ _('loyalty.store.card_detail.birthday') }}

@@ -96,7 +111,12 @@

{{ _('loyalty.store.card_detail.card_number') }}

-

-

+
+

-

+ +

{{ _('loyalty.store.card_detail.status') }}