Labor allocation on job close BOD-131

This commit is contained in:
Patrick Fic
2020-05-19 16:14:25 -07:00
parent 51ea04bf2c
commit bdead5b4a0
10 changed files with 345 additions and 33 deletions

View File

@@ -1,24 +1,25 @@
import React, { useCallback, useState } from "react";
import React, { useState } from "react";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { CalculateJob } from "../../components/job-totals-table/job-totals.utility";
import JobsCloseLaborMaterialAllocation from "../../components/jobs-close-labmat-allocation/jobs-close-labmat-allocation.component";
import { selectBodyshop } from "../../redux/user/user.selectors";
const mapStateToProps = createStructuredSelector({
//currentUser: selectCurrentUser
bodyshop: selectBodyshop,
});
export function JobsCloseComponent({ job, bodyshop }) {
const CalcJobMemoized = useCallback(
() => CalculateJob(job, bodyshop.shoprates),
[job, bodyshop.shoprates]
export function JobsCloseComponent({ job, bodyshop, jobTotals }) {
const [labmatAllocations, setLabmatAllocations] = useState(
Object.keys(jobTotals.rates).reduce((acc, val) => {
acc[val] = jobTotals.rates[val];
if (val.includes("subtotal")) return acc;
//Not a subtotal - therefore can be allocated.
acc[val].allocations = [];
return acc;
}, {})
);
const jobTotals = CalcJobMemoized();
const [labmatAllocations, setLabmatAllocations] = useState(jobTotals.rates);
return (
<div>
<JobsCloseLaborMaterialAllocation