Files
la_front/src/composables/api/orders.ts
work-sklizkiygad ec014db3f9 first commit
2023-02-01 17:36:25 +03:00

32 lines
888 B
TypeScript

import { order } from "@/types";
import { useHookahStore } from "@/store";
export function useOrdersApi() {
const hookahStore = useHookahStore();
async function createOrder(order: { table: number; heavinessId: number; tasteIds: number[] }) {
const heaviness = hookahStore.heavinessList.find((x) => x.id === order.heavinessId);
const tastes = hookahStore.tastesList.filter((x) => order.tasteIds.includes(x.id));
const resp: order = {
id: 0,
status: "new",
table: order.table,
heaviness: heaviness ?? hookahStore.heavinessList[0],
tastes: tastes,
price: 123,
favourite: false,
};
return resp;
}
async function toggleFavourite(order: order) {
const resp = true;
return resp;
}
return { createOrder, toggleFavourite };
}