Možnost označení objednávajícího

This commit is contained in:
2026-01-13 14:06:16 +01:00
parent 20f4ee0427
commit e03ba45415
6 changed files with 61 additions and 5 deletions

View File

@@ -477,6 +477,24 @@ export async function updateDepartureTime(login: string, time?: string, date?: D
return clientData;
}
/**
* Nastaví/odnastaví uživatele jako objednatele pro dnešní den.
* Objednatelů může být více.
*
* @param login přihlašovací jméno uživatele
*/
export async function updateBuyer(login: string) {
const usedDate = getToday();
let clientData = await getClientData(usedDate);
const userEntry = clientData.choices?.['OBJEDNAVAM']?.[login];
if (!userEntry) {
throw new Error("Nelze nastavit objednatele pro uživatele s jinou volbou než \"Budu objednávat\"");
}
userEntry.isBuyer = !(userEntry.isBuyer || false);
await storage.setData(formatDate(usedDate), clientData);
return clientData;
}
/**
* Vrátí data pro klienta pro předaný nebo aktuální den.
*