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 MapMarkerSettings from "maps/MapMarkerSettings";
|
|||
import { GrainBag as BagModel } from "models/GrainBag";
|
||||
import GrainBag from "pages/grainBag";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { useGrainBagAPI, useSnackbar } from "providers";
|
||||
import { useGlobalState, useGrainBagAPI, useSnackbar } from "providers";
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
interface Props {
|
||||
|
|
@ -23,6 +23,7 @@ export default function GrainBagDrawer(props: Props) {
|
|||
const [openMarkerSettings, setOpenMarkerSettings] = useState(false);
|
||||
const bagAPI = useGrainBagAPI();
|
||||
const { openSnack } = useSnackbar();
|
||||
const [{as}] = useGlobalState();
|
||||
|
||||
useEffect(() => {
|
||||
let b = grainBags.get(selectedBag);
|
||||
|
|
@ -99,7 +100,7 @@ export default function GrainBagDrawer(props: Props) {
|
|||
settings.startLocation = undefined;
|
||||
settings.endLocation = undefined;
|
||||
bagAPI
|
||||
.updateGrainBag(bag.key(), bag.name(), settings)
|
||||
.updateGrainBag(bag.key(), bag.name(), settings, as)
|
||||
.then(resp => {
|
||||
openSnack("Grain bag location removed");
|
||||
removeMarker(bag.key());
|
||||
|
|
@ -133,7 +134,7 @@ export default function GrainBagDrawer(props: Props) {
|
|||
let settings = bag.settings;
|
||||
settings.theme = newTheme;
|
||||
bagAPI
|
||||
.updateGrainBag(bag.key(), bag.name(), settings)
|
||||
.updateGrainBag(bag.key(), bag.name(), settings, as)
|
||||
.then(resp => {
|
||||
openSnack("marker settings updated");
|
||||
updateMarker(bag.key(), settings);
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
|
|||
|
||||
const loadGrainBags = useCallback(() => {
|
||||
grainBagAPI
|
||||
.listGrainBags(100, 0)
|
||||
.listGrainBags(100, 0, undefined, undefined, undefined, undefined, undefined, undefined, undefined, as)
|
||||
.then(resp => {
|
||||
let bags: Map<string, BagModel> = new Map();
|
||||
let bagOp: BagModel[] = [];
|
||||
|
|
@ -367,7 +367,7 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
|
|||
.catch(err => {
|
||||
openSnack("Failed to load Grain Bags");
|
||||
});
|
||||
}, [grainBagAPI, openSnack]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
}, [grainBagAPI, openSnack, as]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const loadYards = useCallback(() => {
|
||||
let yardMap: Map<string, pond.BinYardSettings> = new Map();
|
||||
|
|
@ -1286,7 +1286,7 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
|
|||
const updateBag = (bag: BagModel) => {
|
||||
//update the bag
|
||||
grainBagAPI
|
||||
.updateGrainBag(bag.key(), bag.name(), bag.settings)
|
||||
.updateGrainBag(bag.key(), bag.name(), bag.settings, as)
|
||||
.then(resp => {
|
||||
openSnack("Grain Bag location set");
|
||||
//if the update succeeded than update the geo state and ref
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue