sodexo-shop-menu-template
The sodexo-shop-menu-template component contains all menu features including API integration, i18n, cart management, and theme provider.
Authentication Required
This template requires a valid authentication token to access shop menu data.
Properties
| Property | HTML Attribute | Type | Default | Description |
|---|---|---|---|---|
theme | theme | Theme | Default Sodexo theme | Customization variables for Sodexo components theme |
apiKey | api-key | string | - | X-API-key for Sodexo API |
token | token | string | - | Authentication token for Sodexo API |
siteId | site-id | string | - | Site identifier |
shopId | shop-id | string | - | Shop identifier |
siteExternalId | site-external-id | string | - | Site external identifier. Use with shopExternalId instead of shopId. Provided by Sodexo |
shopExternalId | shop-external-id | string | - | Shop external identifier. Use with siteExternalId instead of siteId. Provided by Sodexo |
serviceDate | service-date | string | - | Optional service date in ISO format (e.g., "2025-01-13") |
Property Usage
- External IDs: Use
siteExternalId+shopExternalIdtogether (provided by Sodexo) - Internal IDs: Use
siteId+shopIdtogether - Do not mix both approaches
Events
| Event | Type | Description |
|---|---|---|
sodexoShopMenuTemplateInfoDishClicked | CustomEvent<DishSelected> | Emitted when a dish info button is clicked. Recommended action: Navigate to dish detail page |
sodexoShopMenuTemplateAddFormulaClicked | CustomEvent<FormulaSelected> | Emitted when a formula add button is clicked. Recommended action: Navigate to formula selection page |
sodexoShopMenuTemplatePlaceOrderClicked | CustomEvent<void> | Emitted when the place order button is clicked. Recommended action: Navigate to cart page |
Event Details
DishSelected
interface DishSelected {
dishId: string;
siteId: string;
shopId: string;
serviceDate: string;
}
FormulaSelected
interface FormulaSelected {
formulaId: string;
serviceDate: string;
siteId: string;
shopId: string;
}
Usage
- HTML
<!DOCTYPE html>
<html>
<body>
<sodexo-shop-menu-template
api-key="your-api-key"
token="user-auth-token"
site-id="123"
shop-id="456"
service-date="2025-02-10"
></sodexo-shop-menu-template>
<script>
const element = document.querySelector('sodexo-shop-menu-template');
// Apply custom theme
element.theme = {
'--sodexo-primary-color': '#283897',
'--sodexo-primary-text-color': '#283897',
'--sodexo-primary-background-color': '#f7f8ff',
'--sodexo-font-family': 'Open Sans',
};
// Handle dish info click
element.addEventListener('sodexoShopMenuTemplateInfoDishClicked', (event) => {
console.log('Dish info clicked:', event.detail);
const { dishId, siteId, shopId, serviceDate } = event.detail;
// Redirect to dish detail
window.location.href = `/dish/${dishId}?siteId=${siteId}&shopId=${shopId}&serviceDate=${serviceDate}`;
});
// Handle formula add click
element.addEventListener('sodexoShopMenuTemplateAddFormulaClicked', (event) => {
console.log('Formula add clicked:', event.detail);
const { formulaId, siteId, shopId, serviceDate } = event.detail;
// Redirect to formula selection
window.location.href = `/formula/${formulaId}?siteId=${siteId}&shopId=${shopId}&serviceDate=${serviceDate}`;
});
// Handle place order click
element.addEventListener('sodexoShopMenuTemplatePlaceOrderClicked', (event) => {
console.log('Place order clicked with cart:', event.detail);
// Save cart and redirect to cart page
localStorage.setItem('cart', JSON.stringify(event.detail));
window.location.href = '/cart';
});
</script>
</body>
</html>
Property Naming Convention
Naming Syntax
When using properties:
- In HTML: Use kebab-case (e.g.,
api-key,site-id,service-date) - In JavaScript: Use camelCase (e.g.,
apiKey,siteId,serviceDate) - Events: Can only be handled in JavaScript, not in HTML attributes
Navigation Flow
This diagram shows the recommended navigation flow for the shop menu template:
Recommended Actions
- On
sodexoShopMenuTemplateInfoDishClicked: Navigate to dish detail page
const { dishId, siteId, shopId, serviceDate } = event.detail;
navigate(
`/dish/${dishId}?siteId=${siteId}&shopId=${shopId}&serviceDate=${serviceDate}`,
);
- On
sodexoShopMenuTemplateAddFormulaClicked: Navigate to formula selection page
const { formulaId, siteId, shopId, serviceDate } = event.detail;
navigate(
`/formula/${formulaId}?siteId=${siteId}&shopId=${shopId}&serviceDate=${serviceDate}`,
);
- On
sodexoShopMenuTemplatePlaceOrderClicked: Save cart and navigate to cart page
navigate("/cart");