From 203da400710274b70b302a77ee27ff3bcfa9f89f Mon Sep 17 00:00:00 2001 From: Tord Austad Date: Mon, 6 Nov 2023 11:36:36 +0100 Subject: [PATCH] . --- .../EquipmentListView/EquipmentListTable.tsx | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/Components/EquipmentListView/EquipmentListTable.tsx b/src/Components/EquipmentListView/EquipmentListTable.tsx index c937461..724f1ba 100644 --- a/src/Components/EquipmentListView/EquipmentListTable.tsx +++ b/src/Components/EquipmentListView/EquipmentListTable.tsx @@ -14,6 +14,7 @@ import { Link, useLocation } from "react-router-dom" import { TagData } from "../../Models/TagData" import { ViewContext } from "../../Context/ViewContext" import { GetTagReviewerService } from "../../api/TagReviewerService" +import { GetContainerService } from "../../api/ContainerService" interface Props { tags: TagData[] @@ -47,7 +48,8 @@ function EquipmentListTable({ const location = useLocation() const styles = useStyles() - const [tagReviewers, setTagReviewers] = useState() + const [tagReviewers, setTagReviewers] = useState([]) + const [containers, setContainers] = useState([]) const { currentUserId, @@ -70,6 +72,9 @@ function EquipmentListTable({ if (currentUserId) { const myReviewsFromServer = await (await GetTagReviewerService()).getTagReviewers(currentUserId) setTagReviewers(myReviewsFromServer.data) + + const containerResults = await (await GetContainerService()).getContainers() + setContainers(containerResults) } } catch { if (!isCancelled) { @@ -121,13 +126,13 @@ function EquipmentListTable({ const reviewDeadlineRenderer = (params: ICellRendererParams) => { if ( - params.data.revisionContainer === null - || params.data.revisionContainer === undefined + params.data.container === null + || params.data.container === undefined ) { return null } const packageDate = new Date( - params.data.revisionContainer.revisionContainerDate, + params.data.container.containerDate, ) const deadline = new Date( packageDate.setDate(packageDate.getDate() + 10), @@ -168,6 +173,15 @@ function EquipmentListTable({ return ( handleTagReviewerCheckboxClick(rowState)} />) } + const buildEquipmentListRowData = () => { + const tagDataWithContainer = tags.map((t) => { + const container = containers.find((c) => c.tagNos?.includes(t.tagNo ?? "")) + return { ...t, container } + }) + + return tagDataWithContainer + } + const columns = [ { headerName: "Tag info", @@ -184,11 +198,11 @@ function EquipmentListTable({ }, { field: "version", headerName: "Version number" }, { - field: "revisionContainer.revisionNumber", + field: "container.revisionNumber", headerName: "Revision number", }, { - field: "revisionContainer.revisionContainerName", + field: "container.containerName", headerName: "Collection group", }, { @@ -230,7 +244,7 @@ function EquipmentListTable({ className="ag-theme-alpine-fusion" >