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