Labor allocation on job close BOD-131
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user