feat(storefront): homepage, module gating, widget protocol, i18n fixes
Some checks failed
Some checks failed
Storefront homepage & module gating:
- CMS owns storefront GET / (slug="home" with 3-tier resolution)
- Catalog loses GET / (keeps /products only)
- Store root redirect (GET / → /store/dashboard or /store/login)
- Route gating: non-core modules return 404 when disabled for platform
- Seed store default homepages per platform
Widget protocol for customer dashboard:
- StorefrontDashboardCard contract in widgets.py
- Widget aggregator get_storefront_dashboard_cards()
- Orders and Loyalty module widget providers
- Dashboard template renders contributed cards (no module names)
Landing template module-agnostic:
- CTAs driven by storefront_nav (not hardcoded module names)
- Header actions check nav item IDs (not enabled_modules)
- Remove hardcoded "Add Product" sidebar button
- Remove all enabled_modules checks from storefront templates
i18n fixes:
- Title placeholder resolution ({{store_name}}) for store default pages
- Storefront nav label_keys prefixed with module code
- Add storefront.account.* keys to 6 modules (en/fr/de/lb)
- Header/footer CMS pages use get_translated_title(current_language)
- Footer labels use i18n keys instead of hardcoded English
Icon cleanup:
- Standardize on map-pin (remove location-marker alias)
- Replace all location-marker references across templates and docs
Docs:
- Storefront builder vision proposal (6 phases)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,13 @@ def _get_feature_provider():
|
||||
return order_feature_provider
|
||||
|
||||
|
||||
def _get_widget_provider():
|
||||
"""Lazy import of widget provider to avoid circular imports."""
|
||||
from app.modules.orders.services.order_widgets import order_widget_provider
|
||||
|
||||
return order_widget_provider
|
||||
|
||||
|
||||
# Orders module definition
|
||||
orders_module = ModuleDefinition(
|
||||
code="orders",
|
||||
@@ -146,7 +153,7 @@ orders_module = ModuleDefinition(
|
||||
items=[
|
||||
MenuItemDefinition(
|
||||
id="orders",
|
||||
label_key="storefront.account.orders",
|
||||
label_key="orders.storefront.account.orders",
|
||||
icon="clipboard-list",
|
||||
route="account/orders",
|
||||
order=40,
|
||||
@@ -168,6 +175,7 @@ orders_module = ModuleDefinition(
|
||||
# Metrics provider for dashboard statistics
|
||||
metrics_provider=_get_metrics_provider,
|
||||
feature_provider=_get_feature_provider,
|
||||
widget_provider=_get_widget_provider,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -89,5 +89,10 @@
|
||||
"orders_cancel_desc": "Ausstehende oder in Bearbeitung befindliche Bestellungen stornieren",
|
||||
"orders_refund": "Bestellungen erstatten",
|
||||
"orders_refund_desc": "Rückerstattungen für Bestellungen verarbeiten"
|
||||
},
|
||||
"storefront": {
|
||||
"account": {
|
||||
"orders": "Bestellungen"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,5 +89,10 @@
|
||||
"store_operations": "Store Operations",
|
||||
"sales_orders": "Sales & Orders",
|
||||
"orders": "Orders"
|
||||
},
|
||||
"storefront": {
|
||||
"account": {
|
||||
"orders": "Orders"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,5 +89,10 @@
|
||||
"orders_cancel_desc": "Annuler les commandes en attente ou en traitement",
|
||||
"orders_refund": "Rembourser les commandes",
|
||||
"orders_refund_desc": "Traiter les remboursements des commandes"
|
||||
},
|
||||
"storefront": {
|
||||
"account": {
|
||||
"orders": "Commandes"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,5 +89,10 @@
|
||||
"orders_cancel_desc": "Aussteesend oder a Veraarbechtung Bestellunge stornéieren",
|
||||
"orders_refund": "Bestellungen erstatten",
|
||||
"orders_refund_desc": "Réckerstattunge fir Bestellunge veraarbechten"
|
||||
},
|
||||
"storefront": {
|
||||
"account": {
|
||||
"orders": "Bestellungen"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
80
app/modules/orders/services/order_widgets.py
Normal file
80
app/modules/orders/services/order_widgets.py
Normal file
@@ -0,0 +1,80 @@
|
||||
# app/modules/orders/services/order_widgets.py
|
||||
"""
|
||||
Orders dashboard widget provider.
|
||||
|
||||
Provides storefront dashboard cards for order-related data.
|
||||
Implements get_storefront_dashboard_cards from DashboardWidgetProviderProtocol.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.modules.contracts.widgets import (
|
||||
DashboardWidget,
|
||||
StorefrontDashboardCard,
|
||||
WidgetContext,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class OrderWidgetProvider:
|
||||
"""Widget provider for orders module."""
|
||||
|
||||
@property
|
||||
def widgets_category(self) -> str:
|
||||
return "orders"
|
||||
|
||||
def get_store_widgets(
|
||||
self,
|
||||
db: Session,
|
||||
store_id: int,
|
||||
context: WidgetContext | None = None,
|
||||
) -> list[DashboardWidget]:
|
||||
return []
|
||||
|
||||
def get_platform_widgets(
|
||||
self,
|
||||
db: Session,
|
||||
platform_id: int,
|
||||
context: WidgetContext | None = None,
|
||||
) -> list[DashboardWidget]:
|
||||
return []
|
||||
|
||||
def get_storefront_dashboard_cards(
|
||||
self,
|
||||
db: Session,
|
||||
store_id: int,
|
||||
customer_id: int,
|
||||
context: WidgetContext | None = None,
|
||||
) -> list[StorefrontDashboardCard]:
|
||||
"""Provide the Orders card for the customer dashboard."""
|
||||
from app.modules.orders.models.customer_order_stats import CustomerOrderStats
|
||||
|
||||
stats = (
|
||||
db.query(CustomerOrderStats)
|
||||
.filter(
|
||||
CustomerOrderStats.store_id == store_id,
|
||||
CustomerOrderStats.customer_id == customer_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
total_orders = stats.total_orders if stats else 0
|
||||
|
||||
return [
|
||||
StorefrontDashboardCard(
|
||||
key="orders.summary",
|
||||
icon="shopping-bag",
|
||||
title="Orders",
|
||||
subtitle="View order history",
|
||||
route="account/orders",
|
||||
value=total_orders,
|
||||
value_label="Total Orders",
|
||||
order=10,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
order_widget_provider = OrderWidgetProvider()
|
||||
@@ -178,7 +178,7 @@
|
||||
<!-- Shipping Address -->
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700 p-6">
|
||||
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4 flex items-center">
|
||||
<span class="h-5 w-5 mr-2 text-gray-400" x-html="$icon('location-marker', 'h-5 w-5')"></span>
|
||||
<span class="h-5 w-5 mr-2 text-gray-400" x-html="$icon('map-pin', 'h-5 w-5')"></span>
|
||||
Shipping Address
|
||||
</h3>
|
||||
<div class="text-sm text-gray-600 dark:text-gray-300 space-y-1">
|
||||
@@ -302,7 +302,7 @@
|
||||
rel="noopener noreferrer"
|
||||
class="mt-3 w-full inline-flex justify-center items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white transition-colors"
|
||||
style="background-color: var(--color-primary)">
|
||||
<span class="h-4 w-4 mr-2" x-html="$icon('location-marker', 'h-4 w-4')"></span>
|
||||
<span class="h-4 w-4 mr-2" x-html="$icon('map-pin', 'h-4 w-4')"></span>
|
||||
Track Package
|
||||
</a>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user