first commit
This commit is contained in:
31
src/composables/api/orders.ts
Normal file
31
src/composables/api/orders.ts
Normal file
@ -0,0 +1,31 @@
|
||||
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 };
|
||||
}
|
Reference in New Issue
Block a user