update as in the grain bag api
This commit is contained in:
parent
9b9f4cdf63
commit
1acbfe36b0
9 changed files with 42 additions and 33 deletions
|
|
@ -4,7 +4,7 @@ import GrainDescriber from "grain/GrainDescriber";
|
|||
import { GrainBag } from "models/GrainBag";
|
||||
import moment, { Moment } from "moment";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { useGrainBagAPI, useSnackbar } from "providers";
|
||||
import { useGlobalState, useGrainBagAPI, useSnackbar } from "providers";
|
||||
import { useEffect, useState } from "react";
|
||||
import { getGrainUnit } from "utils";
|
||||
|
||||
|
|
@ -21,12 +21,13 @@ export default function GrainBagInventoryGraph(props: Props) {
|
|||
const [data, setData] = useState<BarData[]>([]);
|
||||
const [loadingData, setLoadingData] = useState<boolean>(false);
|
||||
const { openSnack } = useSnackbar();
|
||||
const [{as}] = useGlobalState();
|
||||
|
||||
useEffect(() => {
|
||||
if (grainBag.key() && !loadingData) {
|
||||
setLoadingData(true);
|
||||
grainBagAPI
|
||||
.listHistory(grainBag.key(), 500, 0, startDate.toISOString(), endDate.toISOString())
|
||||
.listHistory(grainBag.key(), 500, 0, startDate.toISOString(), endDate.toISOString(), as)
|
||||
.then(resp => {
|
||||
let barData: BarData[] = [];
|
||||
let lastBushels = 0;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export default function GrainBagSettings(props: Props) {
|
|||
const [bagLengthM, setBagLengthM] = useState(0);
|
||||
const [bagDiameterDisplay, setBagDiameterDisplay] = useState(0);
|
||||
const [bagLengthDispla, setBagLengthDisplay] = useState(0);
|
||||
const [{ user }] = useGlobalState();
|
||||
const [{ user, as }] = useGlobalState();
|
||||
const [isCustom, setIsCustom] = useState<boolean>(false);
|
||||
const [customType, setCustomType] = useState("");
|
||||
const [supportedGrainType, setSupportedGrainType] = useState(pond.Grain.GRAIN_INVALID);
|
||||
|
|
@ -104,7 +104,7 @@ export default function GrainBagSettings(props: Props) {
|
|||
const removeGrainBag = () => {
|
||||
if (!grainBag) return;
|
||||
grainBagAPI
|
||||
.removeGrainBag(grainBag.key())
|
||||
.removeGrainBag(grainBag.key(), as)
|
||||
.then(resp => {
|
||||
openSnack("Removed Grain Bag");
|
||||
close();
|
||||
|
|
@ -138,7 +138,7 @@ export default function GrainBagSettings(props: Props) {
|
|||
setGrainUpdate(true);
|
||||
} else {
|
||||
grainBagAPI
|
||||
.updateGrainBag(grainBag.key(), bagName, grainBag.settings)
|
||||
.updateGrainBag(grainBag.key(), bagName, grainBag.settings, as)
|
||||
.then(resp => {
|
||||
openSnack("Grain Bag Updated");
|
||||
let updatedBag = clone(grainBag);
|
||||
|
|
@ -170,7 +170,7 @@ export default function GrainBagSettings(props: Props) {
|
|||
}
|
||||
|
||||
grainBagAPI
|
||||
.addGrainBag(bagName, settings)
|
||||
.addGrainBag(bagName, settings, as)
|
||||
.then(resp => {
|
||||
openSnack("New grain bag added");
|
||||
let newBag = GrainBag.create(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue