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