sodexo-formula-selection-template
The sodexo-formula-selection-template component provides a complete interface for selecting and customizing meal formulas (menus). This template includes built-in API integration, i18n, and theme provider.
Authentication Required
This template requires a valid authentication token to access formula options.
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 |
serviceDate | service-date | string | - | Service date in ISO format (e.g., "2025-01-13") |
formulaId | formula-id | string | - | Formula identifier to configure |
Events
| Event | Type | Description |
|---|---|---|
sodexoFormulaSelectionTemplateFormulaAdded | CustomEvent<FormulaSelected> | Emitted when user adds a configured formula to cart. Recommended action: Navigate back to shop menu |
Event Details
FormulaSelected
interface FormulaSelected {
formulaId: string;
siteId: string;
shopId: string;
serviceDate: string;
}
Usage
- HTML
<!DOCTYPE html>
<html>
<body>
<sodexo-formula-selection-template
api-key="your-api-key"
token="user-auth-token"
site-id="site-123"
shop-id="shop-456"
formula-id="formula-789"
service-date="2025-01-13"
></sodexo-formula-selection-template>
<script>
const element = document.querySelector('sodexo-formula-selection-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 formula added to cart
element.addEventListener('sodexoFormulaSelectionTemplateFormulaAdded', (event) => {
console.log('Formula added:', event.detail);
const { formulaId, siteId, shopId, serviceDate } = event.detail;
// Navigate back to menu
window.history.back();
// Or redirect to menu
// window.location.href = `/menu?siteId=${event.detail.siteId}&shopId=${event.detail.shopId}&serviceDate=${serviceDate}`;
});
</script>
</body>
</html>
Property Naming Convention
Naming Syntax
When using properties:
- In HTML: Use kebab-case (e.g.,
api-key,site-id,formula-id) - In JavaScript: Use camelCase (e.g.,
apiKey,siteId,formulaId) - Events: Can only be handled in JavaScript, not in HTML attributes
Navigation Flow
This diagram shows the recommended navigation flow for the formula selection template:
Recommended Actions
On sodexoFormulaSelectionTemplateFormulaAdded: Navigate back to shop menu with confirmation
const { formulaId, siteId, shopId, serviceDate } = event.detail;
// Navigate back
navigate(`site/${siteId}/shop/${shopId}/service-date/${serviceDate}`); // or history.back()