apilar ulandi

This commit is contained in:
Samandar Turgunboyev
2025-12-02 19:31:37 +05:00
parent 40036322cb
commit f7dbb665a0
56 changed files with 3235 additions and 1189 deletions

View 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;
},
};

View File

@@ -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;
}[];
}