mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
fix: mismatch dto marketings
This commit is contained in:
+13
-3
@@ -190,8 +190,15 @@ const DeliveryOrderProductForm = ({
|
|||||||
const deliveryOrder = useMemo(() => {
|
const deliveryOrder = useMemo(() => {
|
||||||
if (!hasDeliveryOrder || !deliveryOrders) return null;
|
if (!hasDeliveryOrder || !deliveryOrders) return null;
|
||||||
|
|
||||||
|
const marketingProductId =
|
||||||
|
initialValues?.marketing_product_id ?? initialValues?.id;
|
||||||
|
|
||||||
for (const doItem of deliveryOrders) {
|
for (const doItem of deliveryOrders) {
|
||||||
const found = doItem.deliveries.find(
|
const found =
|
||||||
|
doItem.deliveries.find(
|
||||||
|
(d) => d.marketing_product_id === marketingProductId
|
||||||
|
) ??
|
||||||
|
doItem.deliveries.find(
|
||||||
(d) =>
|
(d) =>
|
||||||
d.product_warehouse.id ===
|
d.product_warehouse.id ===
|
||||||
initialValues?.marketing_product?.product_warehouse_id
|
initialValues?.marketing_product?.product_warehouse_id
|
||||||
@@ -403,7 +410,10 @@ const DeliveryOrderProductForm = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (initialValues) {
|
if (initialValues) {
|
||||||
if (!Boolean(initialValues.qty)) {
|
if (
|
||||||
|
!Boolean(initialValues.qty) &&
|
||||||
|
!Boolean(initialValues.marketing_product_id)
|
||||||
|
) {
|
||||||
handleResetForm();
|
handleResetForm();
|
||||||
} else {
|
} else {
|
||||||
setFormikValues({
|
setFormikValues({
|
||||||
@@ -413,7 +423,7 @@ const DeliveryOrderProductForm = ({
|
|||||||
});
|
});
|
||||||
if (initialValues?.marketing_product_id) {
|
if (initialValues?.marketing_product_id) {
|
||||||
setSelectedProduct({
|
setSelectedProduct({
|
||||||
value: initialValues?.id,
|
value: initialValues?.marketing_product_id,
|
||||||
label: `${initialValues?.marketing_product?.product_warehouse?.label} - ${initialValues?.marketing_product?.warehouse?.label ?? initialValues?.marketing_product?.kandang?.label}`,
|
label: `${initialValues?.marketing_product?.product_warehouse?.label} - ${initialValues?.marketing_product?.warehouse?.label ?? initialValues?.marketing_product?.kandang?.label}`,
|
||||||
} as OptionType);
|
} as OptionType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,9 @@ const DeliveryOrderProductTable = ({
|
|||||||
<tr>
|
<tr>
|
||||||
<td className='text-sm px-4 py-3'>Qty</td>
|
<td className='text-sm px-4 py-3'>Qty</td>
|
||||||
<td className='text-sm px-4 py-3'>
|
<td className='text-sm px-4 py-3'>
|
||||||
{item.qty
|
{item.qty !== undefined &&
|
||||||
|
item.qty !== null &&
|
||||||
|
item.qty !== ''
|
||||||
? `${formatNumber(parseFloat(item.qty as string))} ${item.marketing_product?.uom ?? ''}`
|
? `${formatNumber(parseFloat(item.qty as string))} ${item.marketing_product?.uom ?? ''}`
|
||||||
: '-'}
|
: '-'}
|
||||||
</td>
|
</td>
|
||||||
@@ -273,7 +275,9 @@ const DeliveryOrderProductTable = ({
|
|||||||
<tr>
|
<tr>
|
||||||
<td className='text-sm px-4 py-3'>Qty</td>
|
<td className='text-sm px-4 py-3'>Qty</td>
|
||||||
<td className='text-sm px-4 py-3'>
|
<td className='text-sm px-4 py-3'>
|
||||||
{item.qty
|
{item.qty !== undefined &&
|
||||||
|
item.qty !== null &&
|
||||||
|
item.qty !== ''
|
||||||
? `${formatNumber(Number(item.qty))} ${item.marketing_product?.product_warehouse_data?.product.uom.name ?? ''}`
|
? `${formatNumber(Number(item.qty))} ${item.marketing_product?.product_warehouse_data?.product.uom.name ?? ''}`
|
||||||
: '-'}
|
: '-'}
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user