Inversed ignoring of lines and included default filter. RPS-1 RPS-5

This commit is contained in:
Patrick Fic
2020-10-22 19:37:09 -07:00
parent e9e95935fc
commit 5ef32c5465
8 changed files with 58 additions and 16 deletions

View File

@@ -9,15 +9,16 @@ export default function IgnoreJobLineAtom({ ignore, lineId, line_desc }) {
const [updateJobLine] = useMutation(UPDATE_JOB_LINE);
const [loading, setLoading] = useState(false);
const handleChange = async (checked) => {
console.log("handleChange -> checked", checked);
setLoading(true);
ipcRenderer.send(ipcTypes.default.app.toMain.track, {
event: "TOGGLE_IGNORE_LINE",
line_desc: line_desc,
ignore: checked,
ignore: !checked,
});
const result = await updateJobLine({
variables: { lineId: lineId, line: { ignore: checked } },
variables: { lineId: lineId, line: { ignore: !checked } },
});
if (result.errors) {
message.error("Error updating line.");
@@ -27,5 +28,5 @@ export default function IgnoreJobLineAtom({ ignore, lineId, line_desc }) {
setLoading(false);
};
return <Switch checked={ignore} onChange={handleChange} loading={loading} />;
return <Switch checked={!ignore} onChange={handleChange} loading={loading} />;
}

View File

@@ -48,9 +48,6 @@ export default function JobPartsGraphAtom({
alignItems: "center",
}}
>
<Typography.Title level={4}>
{price === "act_price" ? "Actual Price" : "Database Price"}
</Typography.Title>
<ResponsiveContainer>
<PieChart>
<Pie
@@ -71,6 +68,9 @@ export default function JobPartsGraphAtom({
</Pie>
</PieChart>
</ResponsiveContainer>
<Typography.Title level={4}>
{price === "act_price" ? "Actual Price" : "Database Price"}
</Typography.Title>
</div>
);
}

View File

@@ -6,11 +6,12 @@ import CurrencyFormatterAtom from "../../atoms/currency-formatter/currency-forma
import IgnoreJobLine from "../../atoms/ignore-job-line/ignore-job-line.atom";
import partTypeConverterAtom from "../../atoms/part-type-converter/part-type-converter.atom";
import PriceDiffPcFormatterAtom from "../../atoms/price-diff-pc-formatter/price-diff-pc-formatter.atom";
import { CalculatorOutlined } from "@ant-design/icons";
const { ipcRenderer } = window;
export default function JobLinesTableMolecule({ loading, job }) {
const [searchText, setSearchText] = useState("");
const [filters, setFilters] = useState({ ignore: ["false"] });
const { joblines } = job;
const columns = [
@@ -19,23 +20,27 @@ export default function JobLinesTableMolecule({ loading, job }) {
dataIndex: "line_no",
key: "line_no",
sorter: (a, b) => a.line_no - b.line_no,
width: "5%",
},
{
title: "S#",
dataIndex: "line_ind",
key: "line_ind",
width: "5%",
sorter: (a, b) => alphaSort(a.line_ind, b.line_ind),
},
{
title: "Line Description",
dataIndex: "line_desc",
key: "line_desc",
width: "25%",
sorter: (a, b) => alphaSort(a.line_desc, b.line_desc),
},
{
title: "Part Type",
dataIndex: "part_type",
key: "part_type",
width: "5%",
sorter: (a, b) => alphaSort(a.part_type, b.part_type),
render: (text, record) => partTypeConverterAtom(text),
},
@@ -43,12 +48,14 @@ export default function JobLinesTableMolecule({ loading, job }) {
title: "Part Number",
dataIndex: "oem_partno",
key: "oem_partno",
width: "15%",
sorter: (a, b) => alphaSort(a.oem_partno, b.oem_partno),
},
{
title: "Database Price",
dataIndex: "db_price",
key: "db_price",
width: "10%",
sorter: (a, b) => a.db_price - b.db_price,
render: (text, record) => (
<CurrencyFormatterAtom>{record.db_price}</CurrencyFormatterAtom>
@@ -58,6 +65,7 @@ export default function JobLinesTableMolecule({ loading, job }) {
title: "Actual Price",
dataIndex: "act_price",
key: "act_price",
width: "10%",
sorter: (a, b) => a.act_price - b.act_price,
render: (text, record) => (
<CurrencyFormatterAtom>{record.act_price}</CurrencyFormatterAtom>
@@ -67,6 +75,7 @@ export default function JobLinesTableMolecule({ loading, job }) {
title: "Price Diff.",
dataIndex: "price_diff",
key: "price_diff",
width: "10%",
sorter: (a, b) => a.price_diff - b.price_diff,
render: (text, record) => (
<CurrencyFormatterAtom>{record.price_diff}</CurrencyFormatterAtom>
@@ -76,6 +85,7 @@ export default function JobLinesTableMolecule({ loading, job }) {
title: "Price Diff. %",
dataIndex: "price_diff_pc",
key: "price_diff_pc",
width: "10%",
sorter: (a, b) => a.price_diff_pc - b.price_diff_pc,
render: (text, record) => (
<PriceDiffPcFormatterAtom
@@ -86,13 +96,15 @@ export default function JobLinesTableMolecule({ loading, job }) {
),
},
{
title: "Ignore?",
title: <CalculatorOutlined />,
dataIndex: "ignore",
key: "ignore",
filters: [
{ text: "True", value: true },
{ text: "False", value: false },
{ text: "Eligible for RPS Calculation", value: false },
{ text: "Ineligible RPS Calculation", value: true },
],
width: "5%",
filteredValue: filters.ignore || null,
onFilter: (value, record) => value === record.ignore,
render: (text, record) => (
<IgnoreJobLine
@@ -111,6 +123,11 @@ export default function JobLinesTableMolecule({ loading, job }) {
)
: joblines;
const handleChange = (pagination, filters, sorter) => {
console.log("Various parameters", pagination, filters, sorter);
setFilters(filters);
};
return (
<div>
<Table
@@ -134,6 +151,7 @@ export default function JobLinesTableMolecule({ loading, job }) {
size="small"
pagination={false}
dataSource={data}
onChange={handleChange}
scroll={{
x: true,
y: "20rem",

View File

@@ -43,7 +43,7 @@ export function JobsTargetsStatsMolecule({
display: "flex",
alignItems: "center",
justifyContent: "space-around",
marginTop: "1rem",
marginTop: "2rem",
marginBottom: "1rem",
}}
>

View File

@@ -1,5 +1,5 @@
import { useQuery } from "@apollo/client";
import { Result } from "antd";
import { Divider, Result } from "antd";
import React, { useEffect } from "react";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
@@ -78,7 +78,9 @@ export function JobsDetailOrganism({ selectedJobId, setSelectedJobTargetPc }) {
loading={loading}
/>
</div>
<DeleteJobAtom jobId={data ? data.jobs_by_pk.id : null} />
<DeleteJobAtom
jobId={data ? data.jobs_by_pk && data.jobs_by_pk.id : null}
/>
</div>
);
}