28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import useAxios from "@/utils/useAxios";
|
|
import type {Order} from "@/models/order";
|
|
import type {TableInput, TableOutput} from "@/models/table";
|
|
import type {Ref, UnwrapRef} from "vue";
|
|
import type {Transaction} from "@/models/transaction";
|
|
import {useUserStore} from "@/store/userStore";
|
|
|
|
function customerOrderPrefix() {
|
|
// lazy: این ماژول ممکن است قبل از app.use(pinia) لود شود
|
|
return `/customer${!useUserStore().isSingle ? '' : '/single'}`
|
|
}
|
|
|
|
export const createOrder = async (obj: Order): Promise<any> => {
|
|
return await useAxios.post<Order>(`${customerOrderPrefix()}/order`, obj)
|
|
}
|
|
|
|
export const getPendingColleagueOrder = async (): Promise<any> => {
|
|
return await useAxios.get(`${customerOrderPrefix()}/order/pending`)
|
|
}
|
|
|
|
export const getColleagueOrderStatus = async (id: number): Promise<any> => {
|
|
return await useAxios.get(`${customerOrderPrefix()}/order/${id}/status`)
|
|
}
|
|
|
|
export const getOrders = async (tbl: Ref<UnwrapRef<TableInput>>): Promise<TableOutput<Transaction>> => {
|
|
return await useAxios.post<TableOutput<Order>>(`${customerOrderPrefix()}/order/table`, tbl)
|
|
}
|