made the bins page use url context, added bins link to team page
This commit is contained in:
parent
84ed63a765
commit
6996ab0e77
2 changed files with 30 additions and 3 deletions
|
|
@ -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[] = [];
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<PageContainer spacing={isMobile ? 0 : 2}>
|
||||
|
|
@ -255,6 +263,14 @@ export default function TeamPage() {
|
|||
<ListItemButton onClick={toGroups}>
|
||||
Groups
|
||||
</ListItemButton>
|
||||
{((isAg || isStreamline) || user.hasFeature("admin")) &&
|
||||
<>
|
||||
<Divider />
|
||||
<ListItemButton onClick={toBins}>
|
||||
Bins
|
||||
</ListItemButton>
|
||||
</>
|
||||
}
|
||||
<Divider />
|
||||
</List>
|
||||
</Card>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue