feat: automatický výběr výchozího času
Some checks are pending
ci/woodpecker/push/workflow Pipeline is running
Some checks are pending
ci/woodpecker/push/workflow Pipeline is running
This commit is contained in:
@@ -287,6 +287,7 @@ function App() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await addChoice({ body: { locationKey: location, foodIndex, dayIndex } });
|
await addChoice({ body: { locationKey: location, foodIndex, dayIndex } });
|
||||||
|
await tryAutoSelectDepartureTime();
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
alert(`Chyba při změně volby: ${error.message || error}`);
|
alert(`Chyba při změně volby: ${error.message || error}`);
|
||||||
}
|
}
|
||||||
@@ -313,6 +314,10 @@ function App() {
|
|||||||
foodChoiceRef.current.value = "";
|
foodChoiceRef.current.value = "";
|
||||||
}
|
}
|
||||||
choiceRef.current?.blur();
|
choiceRef.current?.blur();
|
||||||
|
// Automatický výběr času odchodu pouze pro restaurace s menu
|
||||||
|
if (Object.keys(Restaurant).includes(locationKey)) {
|
||||||
|
await tryAutoSelectDepartureTime();
|
||||||
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
alert(`Chyba při změně volby: ${error.message || error}`);
|
alert(`Chyba při změně volby: ${error.message || error}`);
|
||||||
// Reset výběru zpět
|
// Reset výběru zpět
|
||||||
@@ -337,6 +342,7 @@ function App() {
|
|||||||
const locationKey = choiceRef.current.value as LunchChoice;
|
const locationKey = choiceRef.current.value as LunchChoice;
|
||||||
if (auth?.login) {
|
if (auth?.login) {
|
||||||
await addChoice({ body: { locationKey, foodIndex: Number(event.target.value), dayIndex } });
|
await addChoice({ body: { locationKey, foodIndex: Number(event.target.value), dayIndex } });
|
||||||
|
await tryAutoSelectDepartureTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -468,6 +474,15 @@ function App() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Automaticky nastaví preferovaný čas odchodu 10:45, pokud tento čas ještě nenastal
|
||||||
|
const tryAutoSelectDepartureTime = async () => {
|
||||||
|
const preferredTime = "10:45" as DepartureTime;
|
||||||
|
if (isInTheFuture(preferredTime) && departureChoiceRef.current) {
|
||||||
|
departureChoiceRef.current.value = preferredTime;
|
||||||
|
await changeDepartureTime({ body: { time: preferredTime, dayIndex } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleDayChange = async (dayIndex: number) => {
|
const handleDayChange = async (dayIndex: number) => {
|
||||||
setDayIndex(dayIndex);
|
setDayIndex(dayIndex);
|
||||||
dayIndexRef.current = dayIndex;
|
dayIndexRef.current = dayIndex;
|
||||||
@@ -629,7 +644,7 @@ function App() {
|
|||||||
<Form.Select ref={departureChoiceRef} onChange={handleChangeDepartureTime}>
|
<Form.Select ref={departureChoiceRef} onChange={handleChangeDepartureTime}>
|
||||||
<option value="">Vyber čas...</option>
|
<option value="">Vyber čas...</option>
|
||||||
{Object.values(DepartureTime)
|
{Object.values(DepartureTime)
|
||||||
.filter(time => isInTheFuture(time))
|
.filter(time => dayIndex !== data.todayDayIndex || isInTheFuture(time))
|
||||||
.map(time => <option key={time} value={time}>{time}</option>)}
|
.map(time => <option key={time} value={time}>{time}</option>)}
|
||||||
</Form.Select>
|
</Form.Select>
|
||||||
</>}
|
</>}
|
||||||
|
|||||||
3
server/changelogs/2026-03-09.json
Normal file
3
server/changelogs/2026-03-09.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[
|
||||||
|
"Automatický výběr výchozího času preferovaného odchodu"
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user