diff --git a/components/labor-allocations-table/labor-allocations-table.component.jsx b/components/labor-allocations-table/labor-allocations-table.component.jsx
index a058c4a..31c3e53 100644
--- a/components/labor-allocations-table/labor-allocations-table.component.jsx
+++ b/components/labor-allocations-table/labor-allocations-table.component.jsx
@@ -18,55 +18,31 @@ const mapStateToProps = createStructuredSelector({
});
export function LaborAllocationsTable({ jobId, bodyshop, technician }) {
- console.log("LaborAllocationsTable, jobId", jobId);
- //, loading, refetch
- //const jobid = jobid !== undefined ? jobid : "";
+ // console.log("LaborAllocationsTable, jobId", jobId);
const { t } = useTranslation();
const onRefresh = async () => {
-
console.log("LaborAllocationsTable refetch");
return refetch();
};
- //maybe use this
const { loading, error, data, refetch } = useQuery(GET_LINE_TICKET_BY_PK, {
variables: { id: jobId },
skip: !!!jobId,
fetchPolicy: "network-only",
nextFetchPolicy: "network-only",
});
-
// console.log("LaborAllocationsTable, data", data);
if (error) return ;
- // let joblines = [];
- // let timetickets = [];
- // let adjustments = [];
-
const [totals, setTotals] = useState([]);
- const [state, setState] = useState({
- sortedInfo: {
- columnKey: "cost_center",
- field: "cost_center",
- order: "ascend",
- },
- filteredInfo: {},
- });
useEffect(() => {
console.log("LaborAllocationsTable useEffect on data change");
- // joblines = data?.joblines ? data.joblines : [];
- // timetickets = data?.timetickets ? data.timetickets : [];
- // adjustments = data?.adjustments ? data.adjustments : [];
}, [data]);
useEffect(() => {
- console.log(
- "LaborAllocationsTable useEffect on [joblines, timetickets, bodyshop, adjustments, jobId] change",
- data?.joblines,
- data?.adjustments
- );
+ // console.log("LaborAllocationsTable useEffect on [all inputs] change",data?.joblines,data?.adjustments);
if (!!data?.joblines && !!data?.timetickets && !!bodyshop)
setTotals(
CalculateAllocationsTotals(
@@ -79,11 +55,6 @@ export function LaborAllocationsTable({ jobId, bodyshop, technician }) {
if (!jobId) setTotals([]);
}, [data?.joblines, data?.timetickets, bodyshop, data?.adjustments, jobId]);
- // const convertedLines = useMemo(
- // () => data?.joblines && data?.joblines.filter((j) => j.convertedtolbr),
- // [data?.joblines]
- // );
-
const summary =
totals &&
totals.reduce(
@@ -96,8 +67,7 @@ export function LaborAllocationsTable({ jobId, bodyshop, technician }) {
},
{ hrs_total: 0, hrs_claimed: 0, adjustments: 0, difference: 0 }
);
-
- console.log("labor summary is:", summary);
+ // console.log("labor summary is:", summary);
return (
@@ -115,120 +85,70 @@ export function LaborAllocationsTable({ jobId, bodyshop, technician }) {
-
- }
- keyExtractor={(item) => item.cost_center}
- ItemSeparatorComponent={}
- renderItem={(object) => (
-
-
-
-
- {object.item.cost_center} {" ("}
- {object.item.mod_lbr_ty}{")"}
-
-
-
- {object.item.total && object.item.total.toFixed(1)}
-
-
- {object.item.claimed && object.item.claimed.toFixed(1)}
-
-
-
- {object.item.adjustments && object.item.adjustments.toFixed(1)}
- {/* {!technician && (
-
-
-
- )} */}
-
-
-
- = 0 ? "green" : "red",
- }}>
- {/*
+ }
+ keyExtractor={(item) => item.cost_center}
+ ItemSeparatorComponent={}
+ renderItem={(object) => (
+
+
+
+ {object.item.cost_center} {" ("}
+ {object.item.mod_lbr_ty}
+ {")"}
+
+
+
+
+ {object.item.total && object.item.total.toFixed(1)}
+
+
+
+
+ {object.item.claimed && object.item.claimed.toFixed(1)}
+
+
+
+
+ {object.item.adjustments &&
+ object.item.adjustments.toFixed(1)}
+
+
+
+ = 0 ? "green" : "red",
+ color: object.item.difference >= 0 ? "green" : "red",
}}
>
- {_.round(object.difference, 1)}
- */}
- {_.round(object.item.difference, 1)}
-
-
-
+ {_.round(object.item.difference, 1)}
+
+
+
+ )}
+ />
+ {summary && (
+
+ Totals
+
+ {summary.hrs_total.toFixed(1)}
+
+
+ {summary.hrs_claimed.toFixed(1)}
+
+
+ {summary.adjustments.toFixed(1)}
+
+
+ {summary.difference.toFixed(1)}
+
+
)}
- />
- {summary && (
- Totals
- {summary.hrs_total.toFixed(1)}
- {summary.hrs_claimed.toFixed(1)}
- {summary.adjustments.toFixed(1)}
- {summary.difference.toFixed(1)}
- )
- }
) : null}
- {/*
-
-
- {t("jobdetail.labels.lines_desc")}
-
-
- {t("jobdetail.labels.lines_lbr_ty")}
-
-
- {t("jobdetail.labels.lines_lb_hrs")}
-
-
- {t("jobdetail.labels.lines_part_type")}
-
-
- {t("jobdetail.labels.lines_qty")}
-
-
- */}
-
- {/*
- }
- keyExtractor={(item) => item.id}
- renderItem={(object) => (
-
-
- {object.item.line_desc}
-
-
- {object.item.mod_lbr_ty &&
- t(`jobdetail.lbr_types.${object.item.mod_lbr_ty}`)}
-
-
- {object.item.mod_lb_hrs}
-
-
- {object.item.part_type &&
- t(`jobdetail.part_types.${object.item.part_type}`)}
-
-
- {object.item.part_qty}
-
-
- )}
- /> */}
-
{/* use "totals" for the rows in the table */}
{/* use "summary" for the totals at the bottom */}
@@ -236,22 +156,33 @@ export function LaborAllocationsTable({ jobId, bodyshop, technician }) {
}
const localStyles = StyleSheet.create({
-headerArea:{
- flexDirection:"row",
- justifyContent:"center",
- alignItems:"center",
- margin:1
-},
-footertext:{
- flex:1, textAlign:'center', textAlignVertical:'center',margin:1,paddingBottom:8
-},
-headertext:{
- flex:1, textAlign:'center', textAlignVertical:'center',margin:1,paddingBottom:8
-},
-headertextAdjusts:{
- flex:1, textAlign:'center', textAlignVertical:'center',margin:1,paddingBottom:8
-},
-
-
+ headerArea: {
+ flexDirection: "row",
+ justifyContent: "center",
+ alignItems: "center",
+ margin: 1,
+ },
+ footertext: {
+ flex: 1,
+ textAlign: "center",
+ textAlignVertical: "center",
+ margin: 1,
+ paddingBottom: 8,
+ },
+ headertext: {
+ flex: 1,
+ textAlign: "center",
+ textAlignVertical: "center",
+ margin: 1,
+ paddingBottom: 8,
+ },
+ headertextAdjusts: {
+ flex: 1,
+ textAlign: "center",
+ textAlignVertical: "center",
+ margin: 1,
+ paddingBottom: 8,
+ },
});
+
export default connect(mapStateToProps, null)(LaborAllocationsTable);