Skip to content

Commit 97e1f9c

Browse files
committed
add daily recommendation
1 parent 47f6f47 commit 97e1f9c

File tree

2 files changed

+50
-8
lines changed

2 files changed

+50
-8
lines changed

web/src/App.vue

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,26 @@ const filteredMenuItems = computed(() => {
260260
return items;
261261
});
262262
263+
// Get a seeded random number based on the current date (consistent for the whole day)
264+
const getSeededRandom = (seed) => {
265+
const x = Math.sin(seed) * 10000;
266+
return x - Math.floor(x);
267+
};
268+
269+
// Daily recommendation - pick a random menu item (consistent for the day)
270+
const dailyRecommendation = computed(() => {
271+
// Exclude foodtrucks as they aren't consistently there
272+
const items = filteredMenuItems.value.filter(item => item.restaurant !== 'Foodtrucks');
273+
if (items.length === 0) return null;
274+
275+
// Use date as seed so recommendation stays consistent throughout the day
276+
const today = new Date();
277+
const seed = today.getFullYear() * 10000 + (today.getMonth() + 1) * 100 + today.getDate();
278+
const randomIndex = Math.floor(getSeededRandom(seed) * items.length);
279+
280+
return items[randomIndex];
281+
});
282+
263283
// Group menu items by restaurant for display
264284
const groupedMenuItems = computed(() => {
265285
const items = filteredMenuItems.value;
@@ -357,12 +377,30 @@ onUnmounted(() => {
357377
</div>
358378
<!-- menu items list grouped by restaurant -->
359379
<div v-else-if="hasMenuForSelectedDay" class="space-y-6">
360-
<div v-for="(group, groupIndex) in groupedMenuItems" :key="group.restaurant">
380+
<!-- Daily recommendation -->
381+
<div v-if="dailyRecommendation" class="mb-6">
361382
<div class="flex items-center justify-between mb-3 max-w-md mx-auto">
362-
<h2 class="text-lg font-semibold text-gray-700">{{ group.restaurant }}</h2>
363-
<ViewToggle v-if="groupIndex === 0" v-model:compactView="compactView" />
383+
<h2 class="text-lg font-semibold text-gray-700">Tagesempfehlung</h2>
384+
<ViewToggle v-model:compactView="compactView" />
364385
</div>
365-
<div :class="compactView ? 'max-w-md mx-auto rounded-lg shadow-md overflow-hidden bg-white p-6' : 'space-y-4'">
386+
<div :class="compactView ? 'max-w-md mx-auto rounded-lg shadow-md overflow-hidden bg-white p-4' : ''">
387+
<MenuItem
388+
:name="dailyRecommendation.name"
389+
:description="dailyRecommendation.description"
390+
:type="dailyRecommendation.type"
391+
:link="dailyRecommendation.link || ''"
392+
:icon="dailyRecommendation.icon || ''"
393+
:restaurant="dailyRecommendation.restaurant || ''"
394+
:foodtruck="dailyRecommendation.foodtruck || ''"
395+
:compact="compactView"
396+
:always-show-restaurant="true"
397+
/>
398+
</div>
399+
</div>
400+
401+
<div v-for="group in groupedMenuItems" :key="group.restaurant">
402+
<h2 class="text-lg font-semibold text-gray-700 mb-3 max-w-md mx-auto">{{ group.restaurant }}</h2>
403+
<div :class="compactView ? 'max-w-md mx-auto rounded-lg shadow-md overflow-hidden bg-white p-4' : 'space-y-4'">
366404
<MenuItem
367405
v-for="(item, index) in group.items"
368406
:key="index"

web/src/components/MenuItem.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ const props = defineProps({
3636
type: Boolean,
3737
default: false
3838
},
39+
alwaysShowRestaurant: {
40+
type: Boolean,
41+
default: false
42+
},
3943
foodtruck: {
4044
type: String,
4145
default: ""
@@ -52,7 +56,7 @@ const props = defineProps({
5256
<template>
5357
<div :class="[
5458
'bg-white relative',
55-
compact ? 'px-2 py-2' : 'max-w-lg rounded-lg shadow-md mx-auto transition-transform duration-200 hover:scale-[1.02]'
59+
compact ? 'px-2 py-2' : 'max-w-md rounded-lg shadow-md mx-auto transition-transform duration-200 hover:scale-[1.02]'
5660
]">
5761
<div :class="compact ? '' : 'px-6 py-4 pb-6'">
5862
<!-- Title row with vegi icon -->
@@ -69,9 +73,9 @@ const props = defineProps({
6973
<MenuIcon v-if="icon && !compact" :icon="icon" />
7074
<p :class="[compact ? 'text-xs text-gray-500' : 'text-gray-600']">{{ description }}</p>
7175
</div>
72-
<!-- Badges row (only shown if needed, hidden in compact mode) -->
73-
<div v-if="!compact && ((restaurant && showRestaurant) || foodtruck)" class="mt-3 flex gap-2">
74-
<div v-if="restaurant && showRestaurant" class="flex items-center px-3 py-1 bg-gray-200 rounded-full">
76+
<!-- Badges row (only shown if needed, hidden in compact mode unless alwaysShowRestaurant) -->
77+
<div v-if="(restaurant && alwaysShowRestaurant) || (!compact && ((restaurant && showRestaurant) || foodtruck))" class="mt-3 flex gap-2">
78+
<div v-if="restaurant && (showRestaurant || alwaysShowRestaurant)" class="flex items-center px-3 py-1 bg-gray-200 rounded-full">
7579
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
7680
<path stroke-linecap="round" stroke-linejoin="round" d="M13.5 21v-7.5a.75.75 0 0 1 .75-.75h3a.75.75 0 0 1 .75.75V21m-4.5 0H2.36m11.14 0H18m0 0h3.64m-1.39 0V9.349M3.75 21V9.349m0 0a3.001 3.001 0 0 0 3.75-.615A2.993 2.993 0 0 0 9.75 9.75c.896 0 1.7-.393 2.25-1.016a2.993 2.993 0 0 0 2.25 1.016c.896 0 1.7-.393 2.25-1.015a3.001 3.001 0 0 0 3.75.614m-16.5 0a3.004 3.004 0 0 1-.621-4.72l1.189-1.19A1.5 1.5 0 0 1 5.378 3h13.243a1.5 1.5 0 0 1 1.06.44l1.19 1.189a3 3 0 0 1-.621 4.72M6.75 18h3.75a.75.75 0 0 0 .75-.75V13.5a.75.75 0 0 0-.75-.75H6.75a.75.75 0 0 0-.75.75v3.75c0 .414.336.75.75.75Z" />
7781
</svg>

0 commit comments

Comments
 (0)