import { PizzaOrder } from "../types";
import { api } from "./Api";

const PIZZADAY_API_PREFIX = '/api/pizzaDay';

export const createPizzaDay = async () => {
    return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/create`, undefined);
}

export const deletePizzaDay = async () => {
    return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/delete`, undefined);
}

export const lockPizzaDay = async () => {
    return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/lock`, undefined);
}

export const unlockPizzaDay = async () => {
    return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/unlock`, undefined);
}

export const finishOrder = async () => {
    return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/finishOrder`, undefined);
}

export const finishDelivery = async (bankAccount?: string, bankAccountHolder?: string) => {
    return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/finishDelivery`, JSON.stringify({ bankAccount, bankAccountHolder }));
}

export const addPizza = async (pizzaIndex: number, pizzaSizeIndex: number) => {
    return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/add`, JSON.stringify({ pizzaIndex, pizzaSizeIndex }));
}

export const removePizza = async (pizzaOrder: PizzaOrder) => {
    return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/remove`, JSON.stringify({ pizzaOrder }));
}

export const updatePizzaDayNote = async (note?: string) => {
    return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/updatePizzaDayNote`, JSON.stringify({ note }));
}

export const updatePizzaFee = async (login: string, text?: string, price?: number) => {
    return await api.post<any, any>(`${PIZZADAY_API_PREFIX}/updatePizzaFee`, JSON.stringify({ login, text, price }));
}
