apilar ulandi
This commit is contained in:
33
src/features/specifications/lib/api.ts
Normal file
33
src/features/specifications/lib/api.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type {
|
||||
OrderCreateReq,
|
||||
OrderListRes,
|
||||
OrderUpdateReq,
|
||||
} from "@/features/specifications/lib/data";
|
||||
import httpClient from "@/shared/config/api/httpClient";
|
||||
import { API_URLS } from "@/shared/config/api/URLs";
|
||||
import type { AxiosResponse } from "axios";
|
||||
|
||||
export const order_api = {
|
||||
async list(params: {
|
||||
limit: number;
|
||||
offset: number;
|
||||
}): Promise<AxiosResponse<OrderListRes>> {
|
||||
const res = await httpClient.get(`${API_URLS.ORDER}list/`, { params });
|
||||
return res;
|
||||
},
|
||||
|
||||
async create(body: OrderCreateReq) {
|
||||
const res = await httpClient.post(`${API_URLS.ORDER}create/`, body);
|
||||
return res;
|
||||
},
|
||||
|
||||
async update({ body, id }: { id: number; body: OrderUpdateReq }) {
|
||||
const res = await httpClient.patch(`${API_URLS.ORDER}${id}/update/`, body);
|
||||
return res;
|
||||
},
|
||||
|
||||
async delete(id: number) {
|
||||
const res = await httpClient.delete(`${API_URLS.ORDER}${id}/delete/`);
|
||||
return res;
|
||||
},
|
||||
};
|
||||
@@ -79,3 +79,71 @@ export const FakeSpecifications: SpecificationsType[] = [
|
||||
paidPrice: 22400,
|
||||
},
|
||||
];
|
||||
|
||||
export interface OrderListRes {
|
||||
status_code: number;
|
||||
status: string;
|
||||
message: string;
|
||||
data: {
|
||||
count: number;
|
||||
next: null | string;
|
||||
previous: null | string;
|
||||
results: OrderListDataRes[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface OrderListDataRes {
|
||||
id: number;
|
||||
factory: {
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
total_price: string;
|
||||
paid_price: string;
|
||||
advance: number;
|
||||
employee_name: string;
|
||||
overdue_price: string;
|
||||
order_items: [
|
||||
{
|
||||
id: number;
|
||||
product: number;
|
||||
quantity: number;
|
||||
total_price: string;
|
||||
},
|
||||
];
|
||||
file: string;
|
||||
user: {
|
||||
id: number;
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface OrderCreateReq {
|
||||
factory_id: number;
|
||||
paid_price: string;
|
||||
total_price: string;
|
||||
advance: number;
|
||||
employee_name: string;
|
||||
user_id: number;
|
||||
items: {
|
||||
product: number;
|
||||
quantity: number;
|
||||
total_price: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface OrderUpdateReq {
|
||||
total_price: string;
|
||||
user_id: number;
|
||||
factory_id: number;
|
||||
paid_price: string;
|
||||
advance: number;
|
||||
employee_name: string;
|
||||
overdue_price?: string;
|
||||
items: {
|
||||
product_id: number;
|
||||
quantity: number;
|
||||
total_price: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user