Added parts table for job close BOD-131
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import Dinero from "dinero.js";
|
||||
import AllocationButton from "../jobs-close-allocation-button/jobs-close-allocation-button.component";
|
||||
import AllocationTags from "../jobs-close-allocation-tags/jobs-close-allocation-tags.component";
|
||||
|
||||
export default function JobsClosePartsAllocation({
|
||||
partsAllocations,
|
||||
setPartsAllocations,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<div>
|
||||
{
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t("jobs.labels.laborallocations")}</th>
|
||||
<th>{t("jobs.labels.totals")}</th>
|
||||
<th>{t("jobs.labels.available")}</th>
|
||||
<th>{t("jobs.actions.allocate")}</th>
|
||||
<th>{t("jobs.labels.allocations")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{Object.keys(partsAllocations).map((alloc, idx) => {
|
||||
return (
|
||||
<tr key={idx}>
|
||||
<td>{t(`jobs.fields.${alloc}`)}</td>
|
||||
<td>
|
||||
{partsAllocations[alloc].total &&
|
||||
partsAllocations[alloc].total.toFormat()}
|
||||
</td>
|
||||
<td>
|
||||
{partsAllocations[alloc].total
|
||||
.subtract(
|
||||
Dinero({
|
||||
amount: partsAllocations[alloc].allocations.reduce(
|
||||
(acc, val) => {
|
||||
return acc + val.amount.getAmount();
|
||||
},
|
||||
0
|
||||
),
|
||||
})
|
||||
)
|
||||
.toFormat()}
|
||||
</td>
|
||||
<td>
|
||||
<AllocationButton
|
||||
allocationKey={alloc}
|
||||
allocation={partsAllocations[alloc]}
|
||||
setAllocations={setPartsAllocations}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<AllocationTags
|
||||
allocationKey={alloc}
|
||||
allocation={partsAllocations[alloc]}
|
||||
setAllocations={setPartsAllocations}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user