Resolve allocations disappearing after save. IO-577
This commit is contained in:
@@ -16,7 +16,7 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||||
});
|
});
|
||||||
|
|
||||||
export function JobsCloseLines({ bodyshop, joblines }) {
|
export function JobsCloseLines({ bodyshop, job }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -105,7 +105,7 @@ export function JobsCloseLines({ bodyshop, joblines }) {
|
|||||||
name={[field.name, "profitcenter_part"]}
|
name={[field.name, "profitcenter_part"]}
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: !!joblines[index].act_price,
|
required: !!job.joblines[index].act_price,
|
||||||
message: t("general.validation.required"),
|
message: t("general.validation.required"),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
@@ -137,7 +137,7 @@ export function JobsCloseLines({ bodyshop, joblines }) {
|
|||||||
name={[field.name, "profitcenter_labor"]}
|
name={[field.name, "profitcenter_labor"]}
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: !!joblines[index].mod_lbr_ty,
|
required: !!job.joblines[index].mod_lbr_ty,
|
||||||
message: t("general.validation.required"),
|
message: t("general.validation.required"),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
import { Descriptions, Statistic } from "antd";
|
|
||||||
import React from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import Dinero from "dinero.js";
|
|
||||||
|
|
||||||
export default function JobsCloseTotals({ jobTotals }) {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
------Should be removed-----
|
|
||||||
<Descriptions
|
|
||||||
bordered
|
|
||||||
size="small"
|
|
||||||
//column={1}
|
|
||||||
title={t("jobs.labels.totals")}
|
|
||||||
>
|
|
||||||
<Descriptions.Item label={t("jobs.labels.partstotal")}>
|
|
||||||
<Statistic
|
|
||||||
value={Dinero(jobTotals.parts.parts.total).toFormat()}
|
|
||||||
suffix={`(${Dinero(
|
|
||||||
jobTotals.parts.parts.subtotal
|
|
||||||
).toFormat()})`}
|
|
||||||
/>
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label={t("jobs.labels.subletstotal")}>
|
|
||||||
<Statistic
|
|
||||||
value={Dinero(jobTotals.parts.sublets.total).toFormat()}
|
|
||||||
suffix={`(${Dinero(
|
|
||||||
jobTotals.parts.sublets.subtotal
|
|
||||||
).toFormat()})`}
|
|
||||||
/>
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label={t("jobs.labels.subtotal")}>
|
|
||||||
<Statistic value={Dinero(jobTotals.totals.subtotal).toFormat()} />
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label={t("jobs.labels.federal_tax_amt")}>
|
|
||||||
<Statistic value={Dinero(jobTotals.totals.federal_tax).toFormat()} />
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label={t("jobs.labels.state_tax_amt")}>
|
|
||||||
<Statistic value={Dinero(jobTotals.totals.state_tax).toFormat()} />
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label={t("jobs.labels.local_tax_amt")}>
|
|
||||||
<Statistic value={Dinero(jobTotals.totals.local_tax).toFormat()} />
|
|
||||||
</Descriptions.Item>
|
|
||||||
</Descriptions>
|
|
||||||
<Statistic
|
|
||||||
title={t("jobs.labels.total_repairs")}
|
|
||||||
value={Dinero(jobTotals.totals.total_repairs).toFormat()}
|
|
||||||
/>
|
|
||||||
<Statistic
|
|
||||||
title={t("jobs.labels.net_repairs")}
|
|
||||||
value={Dinero(jobTotals.totals.net_repairs).toFormat()}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -34,7 +34,7 @@ export function LaborAllocationsTable({
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}, [joblines, timetickets, bodyshop, adjustments]);
|
}, [joblines, timetickets, bodyshop, adjustments]);
|
||||||
|
console.log("Rerender on the allocations table.");
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="imex-flex-row" style={{ margin: ".5rem" }}>
|
<div className="imex-flex-row" style={{ margin: ".5rem" }}>
|
||||||
|
|||||||
@@ -1,161 +1,64 @@
|
|||||||
import { DeleteFilled } from "@ant-design/icons";
|
import { Form, Input } from "antd";
|
||||||
import { Button, Form, Input, Select, Row, Col } from "antd";
|
import React from "react";
|
||||||
import React, { useState } from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component";
|
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||||
|
|
||||||
export default function ShopInfoOrderStatusComponent({ form }) {
|
export default function ShopInfoOrderStatusComponent({ form }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const [options, setOptions] = useState(
|
|
||||||
form.getFieldValue(["md_order_statuses", "statuses"]) || []
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleBlur = () => {
|
|
||||||
setOptions(form.getFieldValue(["md_order_statuses", "statuses"]));
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<strong>{t("bodyshop.labels.orderstatuses")}</strong>
|
<strong>{t("bodyshop.labels.orderstatuses")}</strong>
|
||||||
<Row>
|
<LayoutFormRow>
|
||||||
<Col span={12}>
|
<Form.Item
|
||||||
<Form.List name={["md_order_statuses", "statuses"]}>
|
label={t("bodyshop.fields.statuses.default_bo")}
|
||||||
{(fields, { add, remove, move }) => {
|
rules={[
|
||||||
return (
|
{
|
||||||
<div>
|
required: true,
|
||||||
{fields.map((field, index) => (
|
message: t("general.validation.required"),
|
||||||
<Form.Item
|
},
|
||||||
key={field.key}
|
]}
|
||||||
style={{ padding: 0, margin: 2 }}
|
name={["md_order_statuses", "default_bo"]}
|
||||||
>
|
>
|
||||||
<div style={{ display: "flex" }}>
|
<Input />
|
||||||
<Form.Item
|
</Form.Item>
|
||||||
style={{ padding: 0, margin: 2 }}
|
<Form.Item
|
||||||
label={t("bodyshop.fields.status")}
|
label={t("bodyshop.fields.statuses.default_ordered")}
|
||||||
key={`${index}`}
|
rules={[
|
||||||
name={[field.name]}
|
{
|
||||||
rules={[
|
required: true,
|
||||||
{
|
message: t("general.validation.required"),
|
||||||
required: true,
|
},
|
||||||
message: t("general.validation.required"),
|
]}
|
||||||
},
|
name={["md_order_statuses", "default_ordered"]}
|
||||||
]}
|
>
|
||||||
>
|
<Input />
|
||||||
<Input onBlur={handleBlur} />
|
</Form.Item>
|
||||||
</Form.Item>
|
|
||||||
<DeleteFilled
|
<Form.Item
|
||||||
onClick={() => {
|
label={t("bodyshop.fields.statuses.default_received")}
|
||||||
remove(field.name);
|
rules={[
|
||||||
}}
|
{
|
||||||
/>
|
required: true,
|
||||||
<FormListMoveArrows
|
message: t("general.validation.required"),
|
||||||
move={move}
|
},
|
||||||
index={index}
|
]}
|
||||||
total={fields.length}
|
name={["md_order_statuses", "default_received"]}
|
||||||
/>
|
>
|
||||||
</div>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
))}
|
<Form.Item
|
||||||
<Form.Item>
|
label={t("bodyshop.fields.statuses.default_returned")}
|
||||||
<Button
|
rules={[
|
||||||
type="dashed"
|
{
|
||||||
onClick={() => {
|
required: true,
|
||||||
add();
|
message: t("general.validation.required"),
|
||||||
}}
|
},
|
||||||
style={{ width: "100%" }}
|
]}
|
||||||
>
|
name={["md_order_statuses", "default_returned"]}
|
||||||
{t("bodyshop.actions.newstatus")}
|
>
|
||||||
</Button>
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</div>
|
</LayoutFormRow>
|
||||||
);
|
|
||||||
}}
|
|
||||||
</Form.List>
|
|
||||||
</Col>
|
|
||||||
<Col span={12}>
|
|
||||||
<Form.Item
|
|
||||||
label={t("bodyshop.fields.statuses.default_bo")}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: t("general.validation.required"),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
name={["md_order_statuses", "default_bo"]}
|
|
||||||
>
|
|
||||||
<Select>
|
|
||||||
{options.map((item, idx) => (
|
|
||||||
<Select.Option key={idx}>{item}</Select.Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
label={t("bodyshop.fields.statuses.default_ordered")}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: t("general.validation.required"),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
name={["md_order_statuses", "default_ordered"]}
|
|
||||||
>
|
|
||||||
<Select>
|
|
||||||
{options.map((item, idx) => (
|
|
||||||
<Select.Option key={idx}>{item}</Select.Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
label={t("bodyshop.fields.statuses.default_canceled")}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: t("general.validation.required"),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
name={["md_order_statuses", "default_canceled"]}
|
|
||||||
>
|
|
||||||
<Select>
|
|
||||||
{options.map((item, idx) => (
|
|
||||||
<Select.Option key={idx}>{item}</Select.Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
label={t("bodyshop.fields.statuses.default_received")}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: t("general.validation.required"),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
name={["md_order_statuses", "default_received"]}
|
|
||||||
>
|
|
||||||
<Select>
|
|
||||||
{options.map((item, idx) => (
|
|
||||||
<Select.Option key={idx}>{item}</Select.Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
label={t("bodyshop.fields.statuses.default_returned")}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: t("general.validation.required"),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
name={["md_order_statuses", "default_returned"]}
|
|
||||||
>
|
|
||||||
<Select>
|
|
||||||
{options.map((item, idx) => (
|
|
||||||
<Select.Option key={idx}>{item}</Select.Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</Form.Item>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
import { Button, Form, Space, notification, Popconfirm } from "antd";
|
import { Button, Form, notification, Popconfirm, Space } from "antd";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
import { useApolloClient, useMutation } from "react-apollo";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
import { useHistory } from "react-router-dom";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import FormsFieldChanged from "../../components/form-fields-changed-alert/form-fields-changed-alert.component";
|
import FormsFieldChanged from "../../components/form-fields-changed-alert/form-fields-changed-alert.component";
|
||||||
import JobsScoreboardAdd from "../../components/job-scoreboard-add-button/job-scoreboard-add-button.component";
|
import JobsScoreboardAdd from "../../components/job-scoreboard-add-button/job-scoreboard-add-button.component";
|
||||||
import JobsCloseAutoAllocate from "../../components/jobs-close-auto-allocate/jobs-close-auto-allocate.component";
|
import JobsCloseAutoAllocate from "../../components/jobs-close-auto-allocate/jobs-close-auto-allocate.component";
|
||||||
import JobsCloseExportButton from "../../components/jobs-close-export-button/jobs-close-export-button.component";
|
import JobsCloseExportButton from "../../components/jobs-close-export-button/jobs-close-export-button.component";
|
||||||
import JobsCloseLines from "../../components/jobs-close-lines/jobs-close-lines.component";
|
import JobsCloseLines from "../../components/jobs-close-lines/jobs-close-lines.component";
|
||||||
import JobsCloseTotals from "../../components/jobs-close-totals/jobs-close-totals.component";
|
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
|
||||||
import { useApolloClient, useMutation } from "react-apollo";
|
|
||||||
import { generateJobLinesUpdatesForInvoicing } from "../../graphql/jobs-lines.queries";
|
import { generateJobLinesUpdatesForInvoicing } from "../../graphql/jobs-lines.queries";
|
||||||
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
||||||
import { useHistory } from "react-router-dom";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
});
|
});
|
||||||
@@ -36,7 +35,7 @@ export function JobsCloseComponent({ job, bodyshop }) {
|
|||||||
});
|
});
|
||||||
if (!!!result.errors) {
|
if (!!!result.errors) {
|
||||||
notification["success"]({ message: t("job.successes.saved") });
|
notification["success"]({ message: t("job.successes.saved") });
|
||||||
form.resetFields();
|
// form.resetFields();
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("job.errors.saving", {
|
message: t("job.errors.saving", {
|
||||||
@@ -44,8 +43,8 @@ export function JobsCloseComponent({ job, bodyshop }) {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
form.resetFields();
|
// form.resetFields();
|
||||||
form.resetFields();
|
// form.resetFields();
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -109,8 +108,7 @@ export function JobsCloseComponent({ job, bodyshop }) {
|
|||||||
<JobsCloseExportButton jobId={job.id} disabled={false} />
|
<JobsCloseExportButton jobId={job.id} disabled={false} />
|
||||||
</Space>
|
</Space>
|
||||||
<FormsFieldChanged form={form} />
|
<FormsFieldChanged form={form} />
|
||||||
<JobsCloseTotals jobTotals={job.job_totals} form={form} />
|
<JobsCloseLines job={job} />
|
||||||
<JobsCloseLines joblines={job.joblines} />
|
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user