Fixed parts ordering issue where lines were not populated due to rerender.
This commit is contained in:
@@ -58,7 +58,6 @@ export default function JobLinesUpsertModalContainer({
|
||||
refetch();
|
||||
changeVisibility(!visible);
|
||||
};
|
||||
console.log("lineSTate", lineState);
|
||||
return (
|
||||
<JobLinesUpdsertModal
|
||||
visible={visible}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Modal, notification } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useMutation, useQuery } from "react-apollo";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
@@ -60,8 +60,31 @@ export default connect(
|
||||
return acc;
|
||||
}, [])
|
||||
);
|
||||
const orderLines = orderLinesState[0];
|
||||
const [orderLines, setOrderLinesState] = orderLinesState;
|
||||
useEffect(() => {
|
||||
if (modalVisible)
|
||||
setOrderLinesState(
|
||||
linesToOrder.reduce((acc, value) => {
|
||||
acc.push({
|
||||
line_desc: value.line_desc,
|
||||
oem_partno: value.oem_partno,
|
||||
db_price: value.db_price,
|
||||
act_price: value.act_price,
|
||||
line_remarks: "Alalala",
|
||||
job_line_id: value.id,
|
||||
status: bodyshop.md_order_statuses.default_ordered || "Ordered*"
|
||||
});
|
||||
return acc;
|
||||
}, [])
|
||||
);
|
||||
}, [
|
||||
modalVisible,
|
||||
setOrderLinesState,
|
||||
linesToOrder,
|
||||
bodyshop.md_order_statuses.default_ordered
|
||||
]);
|
||||
|
||||
console.log("orderLines", orderLines);
|
||||
const sendTypeState = useState("e");
|
||||
const sendType = sendTypeState[0];
|
||||
const partsOrderState = useState({
|
||||
|
||||
Reference in New Issue
Block a user