Merge branch 'staging_environment' into field_dashboard
This commit is contained in:
commit
1028f0639b
38 changed files with 992 additions and 231 deletions
|
|
@ -1214,37 +1214,6 @@ export default function Bins(props: Props) {
|
|||
}
|
||||
]}
|
||||
/>
|
||||
{/* <StyledToggleButtonGroup
|
||||
id="cardValueDisplay"
|
||||
value={cardValDisplay}
|
||||
exclusive
|
||||
size="small"
|
||||
aria-label="card detail">
|
||||
<StyledToggle
|
||||
value={"low"}
|
||||
aria-label="low"
|
||||
onClick={() => {
|
||||
setCardValDisplay("low");
|
||||
}}>
|
||||
Low
|
||||
</StyledToggle>
|
||||
<StyledToggle
|
||||
value={"average"}
|
||||
aria-label="average"
|
||||
onClick={() => {
|
||||
setCardValDisplay("average");
|
||||
}}>
|
||||
Average
|
||||
</StyledToggle>
|
||||
<StyledToggle
|
||||
value={"high"}
|
||||
aria-label="high"
|
||||
onClick={() => {
|
||||
setCardValDisplay("high");
|
||||
}}>
|
||||
High
|
||||
</StyledToggle>
|
||||
</StyledToggleButtonGroup> */}
|
||||
</Box>
|
||||
</Grid>
|
||||
<Grid >
|
||||
|
|
@ -1270,41 +1239,6 @@ export default function Bins(props: Props) {
|
|||
}
|
||||
]}
|
||||
/>
|
||||
{/* <StyledToggleButtonGroup
|
||||
id="tour-graph-tabs"
|
||||
value={binView}
|
||||
exclusive
|
||||
size="small"
|
||||
aria-label="detail">
|
||||
<StyledToggle
|
||||
value={"grid"}
|
||||
aria-label="grid view"
|
||||
onClick={() => {
|
||||
setBinView("grid");
|
||||
sessionStorage.setItem("binsView", "grid");
|
||||
}}>
|
||||
<ViewComfy />
|
||||
</StyledToggle> */}
|
||||
{/* hidden at dustins request so that grid view and list are the only two */}
|
||||
{/* <StyledToggle
|
||||
value={"scroll"}
|
||||
aria-label="scroll view"
|
||||
onClick={() => {
|
||||
setBinView("scroll");
|
||||
sessionStorage.setItem("binsView", "scroll");
|
||||
}}>
|
||||
<ViewColumn />
|
||||
</StyledToggle> */}
|
||||
{/* <StyledToggle
|
||||
value={"list"}
|
||||
aria-label="list view"
|
||||
onClick={() => {
|
||||
setBinView("list");
|
||||
sessionStorage.setItem("binsView", "list");
|
||||
}}>
|
||||
<ViewList />
|
||||
</StyledToggle>
|
||||
</StyledToggleButtonGroup> */}
|
||||
<MoreVert
|
||||
className={classes.icon}
|
||||
onClick={event => {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import PageContainer from "./PageContainer";
|
|||
export default function CNHi() {
|
||||
const [currentOrg, setCurrentOrg] = useState("");
|
||||
const cnhiAPI = useCNHiProxyAPI();
|
||||
const [organizations, setOrganizations] = useState<Map<string, pond.JDAccount>>(new Map());
|
||||
const [organizations, setOrganizations] = useState<Map<string, pond.CNHiAccount>>(new Map());
|
||||
const [fieldAccordion, setFieldAccordion] = useState(false);
|
||||
const [dataOptions, setDataOptions] = useState<pond.DataOption[]>([]);
|
||||
const [{ as }] = useGlobalState();
|
||||
|
|
|
|||
134
src/pages/LibraCart.tsx
Normal file
134
src/pages/LibraCart.tsx
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
import {
|
||||
Box,
|
||||
Button,
|
||||
Checkbox,
|
||||
FormControlLabel,
|
||||
Grid2 as Grid,
|
||||
MenuItem,
|
||||
Select
|
||||
} from "@mui/material";
|
||||
import LibraCartAccess from "integrations/LibraCart/LibraCartAccess";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { useGlobalState } from "providers";
|
||||
import { useLibraCartProxyAPI } from "providers/pond/libracartProxyAPI";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import PageContainer from "./PageContainer";
|
||||
|
||||
export default function LibraCart() {
|
||||
const [currentOrg, setCurrentOrg] = useState("");
|
||||
const libracartAPI = useLibraCartProxyAPI();
|
||||
const [organizations, setOrganizations] = useState<Map<string, pond.LibraCartAccount>>(new Map());
|
||||
const [dataOptions, setDataOptions] = useState<pond.DataOption[]>([]);
|
||||
const [{ as }] = useGlobalState();
|
||||
|
||||
//load organizations for the user
|
||||
useEffect(() => {
|
||||
setCurrentOrg("");
|
||||
libracartAPI
|
||||
.listAccounts(0, 0, as)
|
||||
.then(resp => {
|
||||
let tempOrgs: Map<string, pond.LibraCartAccount> = new Map();
|
||||
resp.data.accounts.forEach(org => {
|
||||
let organization = pond.LibraCartAccount.fromObject(org);
|
||||
tempOrgs.set(organization.key, organization);
|
||||
});
|
||||
setOrganizations(tempOrgs);
|
||||
})
|
||||
.catch(err => {});
|
||||
}, [libracartAPI, as]);
|
||||
|
||||
useEffect(() => {
|
||||
let organization = organizations.get(currentOrg);
|
||||
if (organization) {
|
||||
let currentOptions: pond.DataOption[] = organization.options ?? [];
|
||||
setDataOptions(currentOptions);
|
||||
}
|
||||
}, [currentOrg, organizations]);
|
||||
|
||||
const updateOrgData = (checked: boolean, option: pond.DataOption) => {
|
||||
let currentOps: pond.DataOption[] = dataOptions;
|
||||
if (checked && !currentOps.includes(option)) {
|
||||
currentOps.push(option);
|
||||
} else if (!checked && currentOps.includes(option)) {
|
||||
currentOps.splice(currentOps.indexOf(option), 1);
|
||||
}
|
||||
setDataOptions([...currentOps]);
|
||||
};
|
||||
|
||||
const submit = () => {
|
||||
libracartAPI.updateAccount(currentOrg, dataOptions, as ?? undefined).then(resp => {
|
||||
//update the organization in the map to have the correct dataOptions
|
||||
let org = organizations.get(currentOrg);
|
||||
if (org) {
|
||||
org.options = dataOptions;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const fieldOptions = () => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Grid container direction="row" spacing={2} alignItems="center" alignContent="center">
|
||||
<Grid size={6}>
|
||||
<FormControlLabel
|
||||
label="Destinations"
|
||||
control={
|
||||
<Checkbox
|
||||
checked={dataOptions.includes(pond.DataOption.DATA_OPTION_DESTINATIONS)}
|
||||
onChange={(_, checked) => {
|
||||
//setFields(!fields);
|
||||
updateOrgData(checked, pond.DataOption.DATA_OPTION_DESTINATIONS);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid size={6}>
|
||||
Import your destinations for the option to link it to a bin
|
||||
</Grid>
|
||||
</Grid>
|
||||
</React.Fragment>
|
||||
);
|
||||
};
|
||||
return (
|
||||
<PageContainer>
|
||||
<LibraCartAccess />
|
||||
<Grid
|
||||
container
|
||||
direction="row"
|
||||
justifyContent="space-between"
|
||||
alignContent="center"
|
||||
alignItems="center"
|
||||
style={{ padding: 10 }}>
|
||||
<Grid>
|
||||
<Select
|
||||
//style={{ maxWidth: 110 }}
|
||||
title="LibraCart Account"
|
||||
displayEmpty
|
||||
disableUnderline={true}
|
||||
value={currentOrg}
|
||||
onChange={(event: any) => {
|
||||
setCurrentOrg(event.target.value);
|
||||
}}>
|
||||
<MenuItem key={""} value={""}>
|
||||
Select account to adjust accessable data
|
||||
</MenuItem>
|
||||
{Array.from(organizations.values()).map(org => {
|
||||
return (
|
||||
<MenuItem key={org.key} value={org.key}>
|
||||
{org.username}
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
</Select>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Button onClick={submit} variant="contained" color="primary">
|
||||
Update
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Box style={{ padding: 10 }}>{fieldOptions()}</Box>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
|
|
@ -128,7 +128,8 @@ export default function Users() {
|
|||
"developer",
|
||||
"marketplace",
|
||||
"installer",
|
||||
"cnhi"
|
||||
"cnhi",
|
||||
"libracart"
|
||||
].sort();
|
||||
|
||||
const [rows, setRows] = useState<User[]>([])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue