IO-1023 receive parts modal updates.
This commit is contained in:
@@ -101,6 +101,7 @@ export function PartsOrderListTableComponent({
|
||||
partsorderlines: record.parts_order_lines.map((pol) => {
|
||||
return {
|
||||
joblineid: pol.job_line_id,
|
||||
id: pol.id,
|
||||
line_desc: pol.line_desc,
|
||||
quantity: pol.quantity,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DeleteFilled } from "@ant-design/icons";
|
||||
import { Form, Input, Select, Typography } from "antd";
|
||||
import { Form, Input, InputNumber, Select, Typography } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
@@ -58,6 +58,13 @@ export function PartsReceiveModalComponent({ bodyshop, form }) {
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
style={{ display: "none" }}
|
||||
key={`${index}id`}
|
||||
name={[field.name, "id"]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<LayoutFormRow grow style={{ flex: 1 }}>
|
||||
<Form.Item
|
||||
label={t("parts_orders.fields.line_desc")}
|
||||
@@ -85,6 +92,13 @@ export function PartsReceiveModalComponent({ bodyshop, form }) {
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("parts_orders.fields.quantity")}
|
||||
key={`${index}quantity`}
|
||||
name={[field.name, "quantity"]}
|
||||
>
|
||||
<InputNumber min={0} />
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
<DeleteFilled
|
||||
style={{ margin: "1rem" }}
|
||||
|
||||
@@ -5,7 +5,10 @@ import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { UPDATE_JOB_LINE } from "../../graphql/jobs-lines.queries";
|
||||
import {
|
||||
RECEIVE_PARTS_LINE,
|
||||
UPDATE_JOB_LINE,
|
||||
} from "../../graphql/jobs-lines.queries";
|
||||
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
||||
import { selectPartsReceive } from "../../redux/modals/modals.selectors";
|
||||
import {
|
||||
@@ -17,7 +20,7 @@ import PartsReceiveModalComponent from "./parts-receive-modal.component";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
bodyshop: selectBodyshop,
|
||||
partsOrderModal: selectPartsReceive,
|
||||
partsReceiveModal: selectPartsReceive,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
@@ -25,27 +28,27 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
});
|
||||
|
||||
export function PartsReceiveModalContainer({
|
||||
partsOrderModal,
|
||||
partsReceiveModal,
|
||||
toggleModalVisible,
|
||||
currentUser,
|
||||
bodyshop,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { visible, context, actions } = partsOrderModal;
|
||||
const { visible, context, actions } = partsReceiveModal;
|
||||
const { partsorderlines } = context;
|
||||
|
||||
const { refetch } = actions;
|
||||
const [form] = Form.useForm();
|
||||
|
||||
const [updateJobLines] = useMutation(UPDATE_JOB_LINE);
|
||||
const [receivePartsLine] = useMutation(RECEIVE_PARTS_LINE);
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
logImEXEvent("parts_order_receive");
|
||||
|
||||
const result = await Promise.all(
|
||||
values.partsorderlines.map((li) => {
|
||||
return updateJobLines({
|
||||
return receivePartsLine({
|
||||
variables: {
|
||||
lineId: li.joblineid,
|
||||
line: {
|
||||
@@ -53,6 +56,11 @@ export function PartsReceiveModalContainer({
|
||||
status:
|
||||
bodyshop.md_order_statuses.default_received || "Received*",
|
||||
},
|
||||
orderLineId: li.id,
|
||||
orderLine: {
|
||||
status:
|
||||
bodyshop.md_order_statuses.default_received || "Received*",
|
||||
},
|
||||
},
|
||||
});
|
||||
})
|
||||
@@ -93,6 +101,7 @@ export function PartsReceiveModalContainer({
|
||||
onOk={() => form.submit()}
|
||||
destroyOnClose
|
||||
forceRender
|
||||
width="50%"
|
||||
>
|
||||
<Form
|
||||
form={form}
|
||||
|
||||
@@ -111,6 +111,42 @@ export const INSERT_NEW_JOB_LINE = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const RECEIVE_PARTS_LINE = gql`
|
||||
mutation RECEIVE_PARTS_LINE(
|
||||
$lineId: uuid!
|
||||
$line: joblines_set_input!
|
||||
$orderLineId: uuid!
|
||||
$orderLine: parts_order_lines_set_input!
|
||||
) {
|
||||
update_joblines(where: { id: { _eq: $lineId } }, _set: $line) {
|
||||
returning {
|
||||
id
|
||||
notes
|
||||
mod_lbr_ty
|
||||
part_qty
|
||||
db_price
|
||||
act_price
|
||||
line_desc
|
||||
oem_partno
|
||||
notes
|
||||
location
|
||||
status
|
||||
removed
|
||||
}
|
||||
}
|
||||
update_parts_order_lines_by_pk(
|
||||
pk_columns: { id: $orderLineId }
|
||||
_set: $orderLine
|
||||
) {
|
||||
id
|
||||
line_desc
|
||||
backordered_on
|
||||
backordered_eta
|
||||
status
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const UPDATE_JOB_LINE = gql`
|
||||
mutation UPDATE_JOB_LINE($lineId: uuid!, $line: joblines_set_input!) {
|
||||
update_joblines(where: { id: { _eq: $lineId } }, _set: $line) {
|
||||
|
||||
Reference in New Issue
Block a user