Parsování jídel na celý týden
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { formatDate } from "./utils";
|
||||
import { callNotifikace } from "./notifikace";
|
||||
import { generateQr } from "./qr";
|
||||
import { ClientData, PizzaDayState, UdalostEnum, Pizza, PizzaSize, Order, PizzaOrder } from "../../types";
|
||||
import { ClientData, PizzaDayState, UdalostEnum, Pizza, PizzaSize, Order, PizzaOrder, DayData } from "../../types";
|
||||
import getStorage from "./storage";
|
||||
import { downloadPizzy } from "./chefie";
|
||||
import { getToday, initIfNeeded } from "./service";
|
||||
@@ -15,7 +15,7 @@ const storage = getStorage();
|
||||
export async function getPizzaList(): Promise<Pizza[] | undefined> {
|
||||
await initIfNeeded();
|
||||
const today = formatDate(getToday());
|
||||
let clientData: ClientData = await storage.getData(today);
|
||||
let clientData: DayData = await storage.getData(today);
|
||||
if (!clientData.pizzaList) {
|
||||
const mock = process.env.MOCK_DATA === 'true';
|
||||
clientData = await savePizzaList(await downloadPizzy(mock));
|
||||
@@ -31,7 +31,7 @@ export async function getPizzaList(): Promise<Pizza[] | undefined> {
|
||||
export async function savePizzaList(pizzaList: Pizza[]): Promise<ClientData> {
|
||||
await initIfNeeded();
|
||||
const today = formatDate(getToday());
|
||||
const clientData: ClientData = await storage.getData(today);
|
||||
const clientData: DayData = await storage.getData(today);
|
||||
clientData.pizzaList = pizzaList;
|
||||
clientData.pizzaListLastUpdate = new Date();
|
||||
await storage.setData(today, clientData);
|
||||
@@ -44,7 +44,7 @@ export async function savePizzaList(pizzaList: Pizza[]): Promise<ClientData> {
|
||||
export async function createPizzaDay(creator: string): Promise<ClientData> {
|
||||
await initIfNeeded();
|
||||
const today = formatDate(getToday());
|
||||
const clientData: ClientData = await storage.getData(today);
|
||||
const clientData: DayData = await storage.getData(today);
|
||||
if (clientData.pizzaDay) {
|
||||
throw Error("Pizza day pro dnešní den již existuje");
|
||||
}
|
||||
@@ -61,7 +61,7 @@ export async function createPizzaDay(creator: string): Promise<ClientData> {
|
||||
*/
|
||||
export async function deletePizzaDay(login: string): Promise<ClientData> {
|
||||
const today = formatDate(getToday());
|
||||
const clientData: ClientData = await storage.getData(today);
|
||||
const clientData: DayData = await storage.getData(today);
|
||||
if (!clientData.pizzaDay) {
|
||||
throw Error("Pizza day pro dnešní den neexistuje");
|
||||
}
|
||||
@@ -82,7 +82,7 @@ export async function deletePizzaDay(login: string): Promise<ClientData> {
|
||||
*/
|
||||
export async function addPizzaOrder(login: string, pizza: Pizza, size: PizzaSize) {
|
||||
const today = formatDate(getToday());
|
||||
const clientData: ClientData = await storage.getData(today);
|
||||
const clientData: DayData = await storage.getData(today);
|
||||
if (!clientData.pizzaDay) {
|
||||
throw Error("Pizza day pro dnešní den neexistuje");
|
||||
}
|
||||
@@ -118,7 +118,7 @@ export async function addPizzaOrder(login: string, pizza: Pizza, size: PizzaSize
|
||||
*/
|
||||
export async function removePizzaOrder(login: string, pizzaOrder: PizzaOrder) {
|
||||
const today = formatDate(getToday());
|
||||
const clientData: ClientData = await storage.getData(today);
|
||||
const clientData: DayData = await storage.getData(today);
|
||||
if (!clientData.pizzaDay) {
|
||||
throw Error("Pizza day pro dnešní den neexistuje");
|
||||
}
|
||||
@@ -149,7 +149,7 @@ export async function removePizzaOrder(login: string, pizzaOrder: PizzaOrder) {
|
||||
*/
|
||||
export async function lockPizzaDay(login: string) {
|
||||
const today = formatDate(getToday());
|
||||
const clientData: ClientData = await storage.getData(today);
|
||||
const clientData: DayData = await storage.getData(today);
|
||||
if (!clientData.pizzaDay) {
|
||||
throw Error("Pizza day pro dnešní den neexistuje");
|
||||
}
|
||||
@@ -172,7 +172,7 @@ export async function lockPizzaDay(login: string) {
|
||||
*/
|
||||
export async function unlockPizzaDay(login: string) {
|
||||
const today = formatDate(getToday());
|
||||
const clientData: ClientData = await storage.getData(today);
|
||||
const clientData: DayData = await storage.getData(today);
|
||||
if (!clientData.pizzaDay) {
|
||||
throw Error("Pizza day pro dnešní den neexistuje");
|
||||
}
|
||||
@@ -195,7 +195,7 @@ export async function unlockPizzaDay(login: string) {
|
||||
*/
|
||||
export async function finishPizzaOrder(login: string) {
|
||||
const today = formatDate(getToday());
|
||||
const clientData: ClientData = await storage.getData(today);
|
||||
const clientData: DayData = await storage.getData(today);
|
||||
if (!clientData.pizzaDay) {
|
||||
throw Error("Pizza day pro dnešní den neexistuje");
|
||||
}
|
||||
@@ -220,7 +220,7 @@ export async function finishPizzaOrder(login: string) {
|
||||
*/
|
||||
export async function finishPizzaDelivery(login: string, bankAccount?: string, bankAccountHolder?: string) {
|
||||
const today = formatDate(getToday());
|
||||
const clientData: ClientData = await storage.getData(today);
|
||||
const clientData: DayData = await storage.getData(today);
|
||||
if (!clientData.pizzaDay) {
|
||||
throw Error("Pizza day pro dnešní den neexistuje");
|
||||
}
|
||||
@@ -255,7 +255,7 @@ export async function finishPizzaDelivery(login: string, bankAccount?: string, b
|
||||
*/
|
||||
export async function updatePizzaDayNote(login: string, note?: string) {
|
||||
const today = formatDate(getToday());
|
||||
let clientData: ClientData = await storage.getData(today);
|
||||
let clientData: DayData = await storage.getData(today);
|
||||
if (!clientData.pizzaDay) {
|
||||
throw Error("Pizza day pro dnešní den neexistuje");
|
||||
}
|
||||
@@ -282,7 +282,7 @@ export async function updatePizzaDayNote(login: string, note?: string) {
|
||||
*/
|
||||
export async function updatePizzaFee(login: string, targetLogin: string, text?: string, price?: number) {
|
||||
const today = formatDate(getToday());
|
||||
let clientData: ClientData = await storage.getData(today);
|
||||
let clientData: DayData = await storage.getData(today);
|
||||
if (!clientData.pizzaDay) {
|
||||
throw Error("Pizza day pro dnešní den neexistuje");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user