Možnost zadání preferovaného času odchodu
This commit is contained in:
@@ -372,4 +372,26 @@ export async function updateNote(login: string, note?: string) {
|
||||
myOrder.note = note;
|
||||
await storage.setData(today, clientData);
|
||||
return clientData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualizuje preferovaný čas odchodu strávníka.
|
||||
*
|
||||
* @param login login uživatele
|
||||
* @param time preferovaný čas odchodu
|
||||
*/
|
||||
export async function updateDepartureTime(login: string, time?: string) {
|
||||
const today = formatDate(getToday());
|
||||
let clientData: ClientData = await storage.getData(today);
|
||||
const found = Object.values(clientData.choices).find(location => login in location);
|
||||
// TODO validace, že se jedná o restauraci
|
||||
if (found) {
|
||||
if (!time?.length) {
|
||||
delete found[login].departureTime;
|
||||
} else {
|
||||
found[login].departureTime = time;
|
||||
}
|
||||
await storage.setData(today, clientData);
|
||||
}
|
||||
return clientData;
|
||||
}
|
||||
Reference in New Issue
Block a user