From 6a82d7c12d8538e95d923ed5f0e6daf33bf12d78 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Wed, 25 Feb 2026 23:29:48 +0100 Subject: [PATCH] refactor(loyalty): replace inline modals with shared modal macros Replace hand-written inline modal HTML in programs.html, merchant-detail.html, and program-edit.html with the project's confirm_modal, confirm_modal_dynamic, and modal macros from shared/macros/modals.html. Resolves all 4 FE-004 architecture warnings. Co-Authored-By: Claude Opus 4.6 --- .../loyalty/admin/merchant-detail.html | 30 ++-- .../templates/loyalty/admin/program-edit.html | 31 ++-- .../templates/loyalty/admin/programs.html | 167 ++++++++---------- 3 files changed, 98 insertions(+), 130 deletions(-) diff --git a/app/modules/loyalty/templates/loyalty/admin/merchant-detail.html b/app/modules/loyalty/templates/loyalty/admin/merchant-detail.html index a39a71ed..a7e83a80 100644 --- a/app/modules/loyalty/templates/loyalty/admin/merchant-detail.html +++ b/app/modules/loyalty/templates/loyalty/admin/merchant-detail.html @@ -3,6 +3,7 @@ {% from 'shared/macros/alerts.html' import loading_state, error_state %} {% from 'shared/macros/headers.html' import detail_page_header %} {% from 'shared/macros/tables.html' import table_wrapper, table_header %} +{% from 'shared/macros/modals.html' import confirm_modal %} {% block title %}Merchant Loyalty Details{% endblock %} @@ -182,25 +183,16 @@ -
-
-

Delete Loyalty Program

-

- This will permanently delete the loyalty program and all associated data. This action cannot be undone. -

-
- - -
-
-
+ {{ confirm_modal( + 'deleteProgramModal', + 'Delete Loyalty Program', + 'This will permanently delete the loyalty program and all associated data. This action cannot be undone.', + 'deleteProgram()', + 'showDeleteModal', + 'Delete Program', + 'Cancel', + 'danger' + ) }}
diff --git a/app/modules/loyalty/templates/loyalty/admin/program-edit.html b/app/modules/loyalty/templates/loyalty/admin/program-edit.html index 606639e1..ec85096a 100644 --- a/app/modules/loyalty/templates/loyalty/admin/program-edit.html +++ b/app/modules/loyalty/templates/loyalty/admin/program-edit.html @@ -2,6 +2,7 @@ {% extends "admin/base.html" %} {% from 'shared/macros/headers.html' import detail_page_header %} {% from 'shared/macros/alerts.html' import loading_state, error_state %} +{% from 'shared/macros/modals.html' import confirm_modal %} {% block title %}Program Configuration{% endblock %} @@ -225,26 +226,16 @@
-
-
-

Delete Loyalty Program

-

- This will permanently delete the loyalty program and all associated data (cards, transactions, rewards). - This action cannot be undone. -

-
- - -
-
-
+{{ confirm_modal( + 'deleteProgramModal', + 'Delete Loyalty Program', + 'This will permanently delete the loyalty program and all associated data (cards, transactions, rewards). This action cannot be undone.', + 'deleteProgram()', + 'showDeleteModal', + 'Delete Program', + 'Cancel', + 'danger' +) }} {% endblock %} {% block extra_scripts %} diff --git a/app/modules/loyalty/templates/loyalty/admin/programs.html b/app/modules/loyalty/templates/loyalty/admin/programs.html index 1c0756c3..6d484f49 100644 --- a/app/modules/loyalty/templates/loyalty/admin/programs.html +++ b/app/modules/loyalty/templates/loyalty/admin/programs.html @@ -4,6 +4,7 @@ {% from 'shared/macros/headers.html' import page_header %} {% from 'shared/macros/alerts.html' import loading_state, error_state %} {% from 'shared/macros/tables.html' import table_wrapper, table_header %} +{% from 'shared/macros/modals.html' import modal, confirm_modal_dynamic %} {% block title %}Loyalty Programs{% endblock %} @@ -255,102 +256,86 @@ -
-
-

Delete Loyalty Program

-

- Delete the loyalty program for ? -

-

- This will permanently remove the program and all associated data (cards, transactions, rewards). This cannot be undone. -

-
- - -
-
-
+{{ confirm_modal_dynamic( + 'deleteProgramModal', + 'Delete Loyalty Program', + "'Delete the loyalty program for \"' + (deletingProgram?.merchant_name || '') + '\"? This will permanently remove all associated data (cards, transactions, rewards). This cannot be undone.'", + 'deleteProgram()', + 'showDeleteModal', + 'Delete Program', + 'Cancel', + 'danger' +) }} -
-
-

Create Loyalty Program

-

- Select a merchant to create a loyalty program for. -

+{% call modal('createProgramModal', 'Create Loyalty Program', 'showCreateModal', show_footer=false) %} +

+ Select a merchant to create a loyalty program for. +

- -
- -
- - - - -
-
- - -
- -
- -
- No merchants found -
- - -
-
- -
-

This merchant already has a loyalty program.

- - - View / Edit existing program - -
-
-
- - -
- - + +
+ +
+ + + +
-
+ + +
+ +
+ +
+ No merchants found +
+ + +
+
+ +
+

This merchant already has a loyalty program.

+ + + View / Edit existing program + +
+
+
+ + +
+ + +
+{% endcall %} {% endblock %} {% block extra_scripts %}