realbox edit components

This commit is contained in:
Samandar Turg'unboev
2025-05-24 23:02:52 +05:00
parent 417ab7dd74
commit ce2b8f3a62
7 changed files with 227 additions and 257 deletions

View File

@@ -1,74 +1,44 @@
export type BoxStatus = 'READY_TO_INVOICE' | 'READY';
export const BoxStatusList: BoxStatus[] = ['READY_TO_INVOICE', 'READY'];
export interface IBox {
packetNetWeight: string;
totalNetWeight: string;
cargoId: string;
passportName: string;
export interface IRealBox {
boxName: string;
id: number;
packetsCount: number;
partyName: string;
boxType: string;
name: string;
volume: string;
boxWeight: number;
brutto: number;
hasInvoice: boolean;
totalItems: number;
status: BoxStatus;
totalBrutto: number;
}
export interface IBoxDetail {
packet: {
id: number;
cargoId: string;
packetNetWeight: number;
passportName: string;
totalItems: number;
totalNetWeight: number;
partyName: string;
partyId: string;
boxType: string;
name: string;
volume: string;
boxWeight: number;
brutto: number;
hasInvoice: boolean;
status: BoxStatus;
};
client: {
passportId: number;
passportName: string;
};
items: [
{
export interface IRealBoxDetail {
message: string;
data: {
boxName: string;
party: {
id: number;
partyName: string;
boxName: string;
cargoId: string;
trekId: string;
name: string;
nameRu: string;
amount: number;
weight: number;
price: number;
totalPrice: number;
hasImage: boolean;
imageUrl: string | null;
};
packets: Array<{
id: number;
packetName: string;
status: BoxStatus;
},
];
}>;
};
}
export type RealCreateBoxBodyType = {
partyName: string,
packetDtos: number[]
};
export interface RealCreateBoxBodyType {
partyName: string;
packetDtos: number[];
}
export type UpdateRealBoxBodyType = {
boxId: string,
partyName: string,
packetDtos: number[]
};
export interface UpdateRealBoxBodyType {
boxId: string;
partyName: string;
packetDtos: number[];
}
export interface FormValues {
partyName: string;
paketIds: Array<{ id: string | number }>;
id?: number;
boxId?: string;
partyId?: number;
}

View File

@@ -2,7 +2,7 @@ import { IBox, UpdateBoxBodyType, IBoxDetail, BoxStatus } from '@/data/box/box.m
import { CommonResponseType, PageAble } from '@/helpers/types';
import { request } from '@/services/request';
import axios from 'axios';
import { RealCreateBoxBodyType, UpdateRealBoxBodyType } from './real-box.model';
import { IRealBox, IRealBoxDetail, RealCreateBoxBodyType, UpdateRealBoxBodyType } from './real-box.model';
export const real_box_requests = {
async getAll(params?: {
@@ -10,27 +10,31 @@ export const real_box_requests = {
sort?: string;
direction?: string;
cargoId?: string;
boxName?: string,
partyId?: string | number;
status?: BoxStatus;
}) {
return request.get<CommonResponseType<PageAble<IBox>>>('/boxes/list', { params });
return request.get<CommonResponseType<PageAble<IRealBox>>>('/boxes/list', { params });
},
async create({ ...body }: RealCreateBoxBodyType) {
return request.post<CommonResponseType>('/boxes/create', body);
},
async update({ boxId, ...body }: UpdateRealBoxBodyType) {
return request.put<CommonResponseType>('/packets/update', body, {
return request.put<CommonResponseType>('/boxes/change', body, {
params: { boxId },
});
},
async find(params: { packetId?: number | string }) {
return request.get<CommonResponseType<IBoxDetail>>('/packets/find', { params });
async find(params: { boxId?: number | string }) {
return request.get<any>(`/boxes/find/${params.boxId}`,);
},
async delete(params: { packetId: number | string }) {
return request.delete<CommonResponseType>('/packets/delete', { params });
async delete(params: { boxId: number | string }) {
return request.delete<CommonResponseType>('/boxes/delete', { params });
},
async downloadExcel(params: { packetId: number | string }) {
return request.get<Blob>('/packets/download', { params, responseType: 'blob' });
async downloadExcel(params: { boxId: number | string }) {
return request.get<Blob>(`/boxes/download/`, { params });
},
async downloadQrCode(params: { boxId: number | string }) {
return request.get(`/qr/${params.boxId}`, { responseType: 'blob' });
},
async translateWithGoogleApi(params: { text: string }): Promise<string> {
const response = await axios.post('https://translation.googleapis.com/language/translate/v2', undefined, {