IO-1250 Mark job as PST Exempt

This commit is contained in:
Patrick Fic
2021-07-13 11:49:27 -07:00
parent 33e2201524
commit a288a1a2a4
8 changed files with 136 additions and 8 deletions

View File

@@ -0,0 +1,55 @@
import { Popconfirm, Button } from "antd";
import React from "react";
import { createStructuredSelector } from "reselect";
import { selectJobReadOnly } from "../../redux/application/application.selectors";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import _ from "lodash";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
jobRO: selectJobReadOnly,
});
export function JobsMarkPstExempt({ jobRO, form }) {
const { t } = useTranslation();
const handleConfirm = () => {
const newPartRates = _.cloneDeep(form.getFieldValue("parts_tax_rates"));
Object.keys(newPartRates).forEach((key) => {
newPartRates[key] = {
...newPartRates[key],
prt_tax_in: false,
prt_tax_rt: 0,
};
});
form.setFieldsValue({
state_tax_rate: 0,
tax_lbr_rt: 0,
tax_levies_rt: 0,
tax_sub_rt: 0,
tax_shop_mat_rt: 0,
tax_paint_mat_rt: 0,
tax_str_rt: 0,
tax_tow_rt: 0,
parts_tax_rates: newPartRates,
});
};
return (
<Popconfirm
onConfirm={handleConfirm}
disabled={jobRO}
okText={t("general.labels.yes")}
cancelText={t("general.labels.no")}
title={t("jobs.actions.markpstexemptconfirm")}
>
<Button type="link" disabled={jobRO}>
{t("jobs.actions.markpstexempt")}
</Button>
</Popconfirm>
);
}
export default connect(mapStateToProps, null)(JobsMarkPstExempt);