Merge branch 'dev' into 'main'

Dev

See merge request azizziy/cpost!10
This commit is contained in:
Azizbek Usmonov
2025-05-28 15:02:06 +05:00

View File

@@ -119,23 +119,23 @@ const DashboardCreateBoxPage = ({ initialValues, partiesData }: Props) => {
box_size: '50x40x40',
status: 'READY_TO_INVOICE',
cargoId: initialValues?.client_id,
// passportId: {value: initialValues?.passportId},
passportId: { value: initialValues?.passportId },
...(editMode
? {}
: {
products_list: [
{
id: '',
cargoId: '',
trekId: '',
name: '',
nameRu: '',
amount: '',
weight: '',
price: '',
},
],
}),
products_list: [
{
id: '',
cargoId: '',
trekId: '',
name: '',
nameRu: '',
amount: '',
weight: '',
price: '',
},
],
}),
...initialValues,
},
});
@@ -184,11 +184,11 @@ const DashboardCreateBoxPage = ({ initialValues, partiesData }: Props) => {
dependencies: [cargoId],
placeholderData: [], // Kerak emas, chunki server PageAble qaytarmayapti
onSuccess(data) {
// if (data?.data.data?.[0]?.id) {
// setValue("passportId", initialValues?.passportId)
// setValue('passport_id', data.data.data[0].id);
// setSelectedPassport(data.data.data[0]); // Birinchi elementni tanlash
// }
if (data?.data.data?.[0]?.id) {
setValue("passportId", initialValues?.passportId)
setValue('passport_id', data.data.data[0].id);
setSelectedPassport(data.data.data[0]); // Birinchi elementni tanlash
}
},
});
@@ -258,10 +258,9 @@ const DashboardCreateBoxPage = ({ initialValues, partiesData }: Props) => {
if (editMode) {
const updateBody: UpdateBoxBodyType = {
cargoId: values.client_id,
passportId: values.passportId.value,
passportId: values.passportId?.value || values.passport_id,
status: values.status,
packetId: initialValues?.packetId,
items: values.products_list.map((item: any) => {
const _price = +item.price ? +item.price : 0;
const _amount = +item.amount ? +item.amount : 0;
@@ -269,9 +268,7 @@ const DashboardCreateBoxPage = ({ initialValues, partiesData }: Props) => {
return {
id: item.id,
// cargoId: item.cargoId,
trekId: item.trekId,
// name: item.name + (item.nameRu ? ` / ${item.nameRu}` : ''),
name: item.name,
nameRu: item?.nameRu,
weight: +item.weight,
@@ -380,11 +377,11 @@ const DashboardCreateBoxPage = ({ initialValues, partiesData }: Props) => {
label: string;
value: BoxStatus;
}[] = [
{
label: t('READY_TO_INVOICE'),
value: 'READY_TO_INVOICE',
},
];
{
label: t('READY_TO_INVOICE'),
value: 'READY_TO_INVOICE',
},
];
if (isAdmin) {
p.push({
@@ -429,15 +426,15 @@ const DashboardCreateBoxPage = ({ initialValues, partiesData }: Props) => {
defaultValue={
editMode
? {
value: initialValues.partyId,
label: initialValues.partyName,
}
value: initialValues.partyId,
label: initialValues.partyName,
}
: partiesData?.length
? {
? {
value: partiesData[0].value,
label: partiesData[0].label,
}
: null
: null
}
styles={selectDefaultStyles}
noOptionsMessage={() => t('not_found')}
@@ -555,7 +552,7 @@ const DashboardCreateBoxPage = ({ initialValues, partiesData }: Props) => {
if (!Number.isNaN(p)) {
totalPrice = p;
}
} catch (error) {}
} catch (error) { }
return (
<Box key={product.key} mb={1.5}>
@@ -710,7 +707,7 @@ const DashboardCreateBoxPage = ({ initialValues, partiesData }: Props) => {
value={totalPrice}
mainBorderColor='#D8D8D8'
placeholder={t('total_price')}
// {...register(`products_list.${index}.totalPrice`, { required: requiredText })}
// {...register(`products_list.${index}.totalPrice`, { required: requiredText })}
/>
</Box>
</React.Fragment>