RO Closer bug fixes.

This commit is contained in:
Patrick Fic
2024-04-04 20:41:39 -07:00
parent c4d39cf3d3
commit 96242a555a
10 changed files with 340 additions and 154 deletions

View File

@@ -1,17 +1,17 @@
import React, { useEffect } from 'react';
import React, { useEffect } from "react";
import { Alert, Card, Table } from 'antd';
import { t } from 'i18next';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import { selectJobReadOnly } from '../../redux/application/application.selectors';
import { selectBodyshop } from '../../redux/user/user.selectors';
import CurrencyFormatter from '../../utils/CurrencyFormatter';
import { alphaSort } from '../../utils/sorters';
import { Alert, Card, Table } from "antd";
import { t } from "i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectJobReadOnly } from "../../redux/application/application.selectors";
import { selectBodyshop } from "../../redux/user/user.selectors";
import CurrencyFormatter from "../../utils/CurrencyFormatter";
import { alphaSort } from "../../utils/sorters";
const mapStateToProps = createStructuredSelector({
//currentUser: selectCurrentUser
bodyshop: selectBodyshop,
jobRO: selectJobReadOnly,
jobRO: selectJobReadOnly
});
const mapDispatchToProps = (dispatch) => ({
//setUserLanguage: language => dispatch(setUserLanguage(language))
@@ -19,79 +19,64 @@ const mapDispatchToProps = (dispatch) => ({
export default connect(mapStateToProps, mapDispatchToProps)(JobCloseRGuardPpd);
export function JobCloseRGuardPpd({ job, jobRO, bodyshop, form, warningCallback }) {
const linesWithPPD = job?.joblines.filter(
(j) => j.act_price_before_ppc !== 0 && j.act_price_before_ppc !== null
);
const linesWithPPD = job?.joblines.filter((j) => j.act_price_before_ppc !== 0 && j.act_price_before_ppc !== null);
useEffect(() => {
if (linesWithPPD.length > 0) {
warningCallback({ key: 'ppd', warning: t('jobs.labels.outstanding_sublets') });
warningCallback({ key: "ppd", warning: t("jobs.labels.outstanding_sublets") });
}
}, [linesWithPPD.length, warningCallback]);
const columns = [
{
title: t('joblines.fields.line_desc'),
dataIndex: 'line_desc',
fixed: 'left',
key: 'line_desc',
title: t("joblines.fields.line_desc"),
dataIndex: "line_desc",
fixed: "left",
key: "line_desc",
sorter: (a, b) => alphaSort(a.line_desc, b.line_desc),
onCell: (record) => ({
className: record.manual_line && 'job-line-manual',
className: record.manual_line && "job-line-manual",
style: {
...(record.critical ? { boxShadow: ' -.5em 0 0 #FFC107' } : {}),
},
...(record.critical ? { boxShadow: " -.5em 0 0 #FFC107" } : {})
}
}),
ellipsis: true,
ellipsis: true
},
{
title: t('joblines.fields.act_price'),
dataIndex: 'act_price',
key: 'act_price',
title: t("joblines.fields.act_price"),
dataIndex: "act_price",
key: "act_price",
sorter: (a, b) => a.act_price - b.act_price,
ellipsis: true,
render: (text, record) => <CurrencyFormatter>{record.act_price}</CurrencyFormatter>,
render: (text, record) => <CurrencyFormatter>{record.act_price}</CurrencyFormatter>
},
{
title: t('joblines.fields.act_price_before_ppc'),
dataIndex: 'act_price_before_ppc',
key: 'act_price_before_ppc',
title: t("joblines.fields.act_price_before_ppc"),
dataIndex: "act_price_before_ppc",
key: "act_price_before_ppc",
sorter: (a, b) => a.act_price_before_ppc - b.act_price_before_ppc,
ellipsis: true,
render: (text, record) => (
<CurrencyFormatter>{record.act_price_before_ppc}</CurrencyFormatter>
),
render: (text, record) => <CurrencyFormatter>{record.act_price_before_ppc}</CurrencyFormatter>
},
{
title: t('joblines.fields.part_qty'),
dataIndex: 'part_qty',
key: 'part_qty',
title: t("joblines.fields.part_qty"),
dataIndex: "part_qty",
key: "part_qty"
},
{
title: t('joblines.fields.notes'),
dataIndex: 'notes',
key: 'notes',
},
title: t("joblines.fields.notes"),
dataIndex: "notes",
key: "notes"
}
];
return (
<Card title={t('jobs.labels.ppdnotexported')}>
<Table
dataSource={linesWithPPD}
columns={columns}
pagination={false}
rowKey="id"
bordered
size="small"
/>
<Card title={t("jobs.labels.ppdnotexported")}>
<Table dataSource={linesWithPPD} columns={columns} pagination={false} rowKey="id" bordered size="small" />
{linesWithPPD.length > 0 && (
<Alert
style={{ margin: '8px 0px' }}
type="warning"
message={t('jobs.labels.outstanding_ppd')}
/>
<Alert style={{ margin: "8px 0px" }} type="warning" message={t("jobs.labels.outstanding_ppd")} />
)}
</Card>
);