sodexo-shop-list-template
The sodexo-shop-list-template component displays a list of shops organized by site, with filtering capabilities by site or shop type.
Properties
| Property | HTML Attribute | Type | Default | Description |
|---|---|---|---|---|
defaultSiteExternalId | default-site-external-id | string | - | Use it to select a shop by default. The external ID is provided by Sodexo |
showBadge | show-badge | boolean | true | Show or hide the balance banner |
Events
| Event | Type | Description |
|---|---|---|
sodexoShopSelected | CustomEvent<ShopSelected> | Emitted when a shop card is clicked. Returns siteId and shopId. Recommended action: Navigate to shop menu page |
sodexoShopBalanceBannerClicked | CustomEvent<void> | Emitted when the balance banner is clicked. Recommended action: Navigate to wallet page |
Event Details
sodexoShopSelected
interface ShopSelected {
siteId: string;
shopId: string;
}
Usage
- HTML
<!DOCTYPE html>
<html>
<body>
<sodexo-shop-list-template></sodexo-shop-list-template>
<script>
const element = document.querySelector('sodexo-shop-list-template');
// Handle shop selection
element.addEventListener('sodexoShopSelected', (event) => {
console.log('Selected shop:', {
siteId: event.detail.siteId,
shopId: event.detail.shopId
});
// Redirect to shop menu
window.location.href = `/shop-menu?shopId=${event.detail.shopId}`;
});
// Handle balance banner click
element.addEventListener('sodexoShopBalanceBannerClicked', () => {
console.log('Balance banner clicked');
// Redirect to wallet
window.location.href = '/wallet';
});
</script>
</body>
</html>
Property Naming Convention
Naming Syntax
When using properties:
- In HTML: Use kebab-case (e.g.,
api-key,token) - In JavaScript: Use camelCase (e.g.,
apiKey,token) - Events: Can only be handled in JavaScript, not in HTML attributes
Navigation Flow
This diagram shows the recommended navigation flow when handling events from this template:
Recommended Actions
- On
sodexoShopSelected: Navigate to the shop menu page with the selected shop
// Pass shopId to shop menu template
navigate(`/shop-menu?shopId=${event.detail.shopId}`);
- On
sodexoShopBalanceBannerClicked: Navigate to the wallet/balance page
navigate("/wallet");
Features
- Site Filtering: Filter shops by site location
- Shop Type Filtering: Filter by type of shop (restaurant, café, etc.)
- Balance Banner: Quick access to wallet/balance information
- Responsive Design: Adapts to all screen sizes
TypeScript Types
interface ShopSelected {
siteId: string;
shopId: string;
}