From 6996ab0e77b302f3b908613b9e984d65f78a26ec Mon Sep 17 00:00:00 2001 From: Carter Date: Tue, 22 Jul 2025 15:55:16 -0600 Subject: [PATCH 1/2] made the bins page use url context, added bins link to team page --- src/pages/Bins.tsx | 13 ++++++++++++- src/pages/Team.tsx | 20 ++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/pages/Bins.tsx b/src/pages/Bins.tsx index 476b66f..5bda174 100644 --- a/src/pages/Bins.tsx +++ b/src/pages/Bins.tsx @@ -81,6 +81,7 @@ import GrainBagList from "grainBag/grainBagList"; import BinYards from "bin/BinYards"; import ButtonGroup from "common/ButtonGroup"; import TeamDialog from "teams/TeamDialog"; +import { getContextKeys, getContextTypes } from "pbHelpers/Context"; // import { useHistory } from "react-router"; const useStyles = makeStyles((theme: Theme) => { @@ -311,6 +312,16 @@ export default function Bins(props: Props) { } }, [props.yardFilter]); + const getKeys = () => { + if (as) return undefined + return getContextKeys() + } + + const getTypes = () => { + if (as) return undefined + return getContextTypes() + } + const loadBins = useCallback(() => { //let filter = grainFilter; let filter = yardFilter; @@ -325,7 +336,7 @@ export default function Bins(props: Props) { setDisplayFert(false); binAPI - .listBinsAndData(binsLimit, 0, order, orderBy, filter, as, false) + .listBinsAndData(binsLimit, 0, order, orderBy, filter, as, false, getKeys(), getTypes()) .then(resp => { let grain: Bin[] = []; let empty: Bin[] = []; diff --git a/src/pages/Team.tsx b/src/pages/Team.tsx index dd88fdd..1cf19c9 100644 --- a/src/pages/Team.tsx +++ b/src/pages/Team.tsx @@ -12,10 +12,10 @@ import { appendToUrl } from "navigation/Router"; import PageContainer from "pages/PageContainer"; import { getContextKeys, getContextTypes } from "pbHelpers/Context"; import { pond } from "protobuf-ts/pond"; -import { useSnackbar, useTeamAPI, useUserAPI } from "providers"; +import { useGlobalState, useSnackbar, useTeamAPI, useUserAPI } from "providers"; import { useEffect, useState } from "react"; import { useLocation, useNavigate, useParams } from 'react-router-dom'; -import { getSignatureAccentColour } from "services/whiteLabel"; +import { getSignatureAccentColour, IsAdaptiveAgriculture, IsStreamline } from "services/whiteLabel"; import TeamActions from "teams/TeamActions"; import TeamKeyManager from "teams/TeamKeyManager"; import ObjectUsers from "user/ObjectUsers"; @@ -88,6 +88,7 @@ export default function TeamPage() { const [loadingUsers, setLoadingUsers] = useState(false) const [userDialog, setUserDialog] = useState(false) const teamKey = teamID ? teamID : ""; + const [{ user }] = useGlobalState() const getTeam = () => { @@ -212,6 +213,13 @@ export default function TeamPage() { const toGroups = () => { navigate(appendToUrl("groups")) } + + const toBins = () => { + navigate(appendToUrl("bins")) + } + + const isAg = IsAdaptiveAgriculture() + const isStreamline = IsStreamline() return ( @@ -255,6 +263,14 @@ export default function TeamPage() { Groups + {((isAg || isStreamline) || user.hasFeature("admin")) && + <> + + + Bins + + + } From e5d4aee4a1f6181f756c929bcbee46abccb6ec55 Mon Sep 17 00:00:00 2001 From: Carter Date: Wed, 23 Jul 2025 09:54:42 -0600 Subject: [PATCH 2/2] relative pathing for bins page --- src/bin/BinsList.tsx | 2 +- src/pages/Bins.tsx | 5 +++-- src/pages/Team.tsx | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bin/BinsList.tsx b/src/bin/BinsList.tsx index 6779258..540877a 100644 --- a/src/bin/BinsList.tsx +++ b/src/bin/BinsList.tsx @@ -49,7 +49,7 @@ export default function BinsList(props: Props) { //const scrollRef = useRef(null); const goToBin = (i: number) => { - let path = "/bins/" + bins[i].key(); + let path = bins[i].key(); navigate(path, { state: {bin: bins[i]} }); }; diff --git a/src/pages/Bins.tsx b/src/pages/Bins.tsx index 5bda174..71675f8 100644 --- a/src/pages/Bins.tsx +++ b/src/pages/Bins.tsx @@ -634,8 +634,9 @@ export default function Bins(props: Props) { preLoadedData={paginatedBins.bins} rowClickFunction={data => { let bin = data as Bin; - let path = "/bins/" + bin.key(); - navigate(path, { state: { bin: bin }}); + // let path = "bins/" + bin.key(); + // navigate(path, { state: { bin: bin }}); + navigate(bin.key(), { state: { bin: bin }, relative: "path"}); }} customButtons={[ { diff --git a/src/pages/Team.tsx b/src/pages/Team.tsx index 1cf19c9..329c95d 100644 --- a/src/pages/Team.tsx +++ b/src/pages/Team.tsx @@ -215,7 +215,8 @@ export default function TeamPage() { } const toBins = () => { - navigate(appendToUrl("bins")) + // navigate(appendToUrl("bins")) + navigate("bins") } const isAg = IsAdaptiveAgriculture()