added styling for allocation table

This commit is contained in:
jfrye122
2023-06-09 17:19:09 -04:00
parent 7512377cbc
commit 576855c3b3
3 changed files with 277 additions and 198 deletions

View File

@@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { FlatList, RefreshControl, StyleSheet, Text, View } from "react-native";
import _ from "lodash";
import { Card, DataTable, Divider } from "react-native-paper";
import { ActivityIndicator, Card, DataTable, Divider } from "react-native-paper";
import { GET_LINE_TICKET_BY_PK } from "../../graphql/jobs.queries";
import ErrorDisplay from "../error-display/error-display.component";
import { useQuery } from "@apollo/client";
@@ -17,13 +17,13 @@ const mapStateToProps = createStructuredSelector({
technician: selectCurrentEmployee,
});
export function LaborAllocationsTable({ jobId, bodyshop, technician,costCenterDiff,selectedCostCenter}) {
export function LaborAllocationsTable({ jobId, bodyshop, technician,costCenterDiff,selectedCostCenter, style, shouldRefresh}) {
// console.log("LaborAllocationsTable, costCenterDiff", costCenterDiff);
// console.log("LaborAllocationsTable, selectedCostCenter", selectedCostCenter);
const { t } = useTranslation();
const onRefresh = async () => {
// console.log("LaborAllocationsTable refetch");
// console.log("LaborAllocationsTable refetch");
return refetch();
};
@@ -33,14 +33,16 @@ export function LaborAllocationsTable({ jobId, bodyshop, technician,costCenterDi
fetchPolicy: "network-only",
nextFetchPolicy: "network-only",
});
// console.log("LaborAllocationsTable, data", data);
if (error) return <ErrorDisplay errorMessage={error.message} />;
// if (loading) return <ActivityIndicator color="dodgerblue" size="large" />;
const [totals, setTotals] = useState([]);
useEffect(() => {
// console.log("LaborAllocationsTable useEffect on data change");
}, [data]);
// useEffect(() => {
// // console.log("LaborAllocationsTable useEffect on data change");
// }, [data]);
useEffect(() => {
// console.log("LaborAllocationsTable useEffect on [all inputs] change",data?.joblines,data?.adjustments);
@@ -65,7 +67,12 @@ export function LaborAllocationsTable({ jobId, bodyshop, technician,costCenterDi
);
}
if (!jobId) setTotals([]);
}, [data?.joblines, data?.timetickets, bodyshop, data?.adjustments, jobId,selectedCostCenter]);
}, [data?.joblines, data?.timetickets, bodyshop, data?.adjustments, jobId, selectedCostCenter]);
useEffect(() => {
// console.log("made it here, shouldRefresh is :", shouldRefresh );
!!shouldRefresh && shouldRefresh ? onRefresh() : null
},[shouldRefresh]);
const summary =
totals &&
@@ -80,9 +87,10 @@ export function LaborAllocationsTable({ jobId, bodyshop, technician,costCenterDi
{ hrs_total: 0, hrs_claimed: 0, adjustments: 0, difference: 0 }
);
// console.log("labor summary is:", summary);
if (loading) return <ActivityIndicator color="dodgerblue" size="large" />;
return (
<View style={{ flex: 1}}>
<View style={style}>
{typeof data !== "undefined" ? (
<Card style={{ flex: 1 }}>
<Card.Title title={"Labor Allocations"} />