BOD-23 Added labor pages tab + finalized time ticket tab + created allocation calculations

This commit is contained in:
Patrick Fic
2020-04-15 15:39:05 -07:00
parent 325a82ac86
commit 8e12320c19
20 changed files with 724 additions and 132 deletions

View File

@@ -0,0 +1,54 @@
import React, { useState, useEffect } from "react";
import { Typography, Row, Col } from "antd";
import { useTranslation } from "react-i18next";
import { CalculateAllocationsTotals } from "./labor-allocations-table.utility";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
});
export function LaborAllocationsTable({ joblines, timetickets, bodyshop }) {
const { t } = useTranslation();
const [totals, setTotals] = useState([]);
useEffect(() => {
if (!!joblines && !!timetickets && !!bodyshop);
setTotals(
CalculateAllocationsTotals(
bodyshop.md_responsibility_centers,
joblines,
timetickets
)
);
}, [joblines, timetickets, bodyshop]);
return (
<div>
<Typography.Title level={3}>
{t("jobs.labels.laborallocations")}
</Typography.Title>
<Row>
<Col span={12}>
<strong>{t("timetickets.fields.cost_center")}</strong>
</Col>
<Col span={6}>
<strong>{t("jobs.labels.hrs_total")}</strong>
</Col>
<Col span={6}>
<strong>{t("jobs.labels.hrs_claimed")}</strong>
</Col>
</Row>
{totals.map((t, idx) => (
<Row key={idx}>
<Col span={12}>{t.cost_center}</Col>
<Col span={6}>{t.total}</Col>
<Col span={6}>{t.claimed}</Col>
</Row>
))}
</div>
);
}
export default connect(mapStateToProps, null)(LaborAllocationsTable);