diff --git a/packages/modules/web_themes/koala/source/src/components/ChargePointScheduledPlanDetails.vue b/packages/modules/web_themes/koala/source/src/components/ChargePointScheduledPlanDetails.vue index b5e15f14e9..448b2c27b8 100644 --- a/packages/modules/web_themes/koala/source/src/components/ChargePointScheduledPlanDetails.vue +++ b/packages/modules/web_themes/koala/source/src/components/ChargePointScheduledPlanDetails.vue @@ -22,14 +22,7 @@ color="positive" /> -
- -
+
Wiederholungen
@@ -52,18 +45,10 @@ label="Wöchentlich" /> -
- -
+
Ziel-Termin
+
+ + + +
+ { + if (!dateString) return ''; + const [year, month, day] = dateString.split('-'); + return `${day}.${month}.${year}`; +}; +const today = formatDateDayMonthYear(new Date().toISOString().split('T')[0]); const weekDays = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So']; -const phaseOptions = [ - { value: 1, label: '1' }, - { value: 3, label: 'Maximum' }, - { value: 0, label: 'Automatik' }, -]; - const selectDay = (index: number) => { const newArray = [...selectedWeekDays.value]; newArray[index] = !newArray[index]; selectedWeekDays.value = newArray; }; +const firstSelectedWeekday = computed(() => { + const today = new Date(); + // 0=Sonntag, ..., 6=Samstag >> 0=Montag, ..., 6=Sonntag + const todayIndex = (today.getDay() + 6) % 7; + const userSelection = selectedWeekDays.value + .map((isSelected, index) => (isSelected ? index : -1)) + .filter((index) => index !== -1); + if (userSelection.length === 0) return ''; + // For all selected days, calculate the distance to today + const daysUntilSelected = userSelection.map((idx) => { + let daysUntil = idx - todayIndex; + if (daysUntil < 0) daysUntil += 7; + return daysUntil; + }); + // Take the smallest distance (this is the next day) + const nearestDay = Math.min(...daysUntilSelected); + const dateNextDay = new Date(today); + dateNextDay.setDate(today.getDate() + nearestDay); + return formatDateDayMonthYear(dateNextDay.toISOString().split('T')[0]); +}); + +const phaseOptions = [ + { value: 1, label: '1' }, + { value: 3, label: 'Maximum' }, + { value: 0, label: 'Automatik' }, +]; + const planActive = computed(() => mqttStore.vehicleScheduledChargingPlanActive( props.chargePointId,