modified th api's for bin, contract and task to have as passed in as a prop and not get it ffrom the global state directly in the api
This commit is contained in:
parent
4bcac4e346
commit
e2f5eb0557
31 changed files with 155 additions and 507 deletions
|
|
@ -4,7 +4,7 @@ import MapMarkerSettings from "maps/MapMarkerSettings";
|
|||
import { Bin as IBin } from "models";
|
||||
//import Bin from "pages/Bin";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { useBinAPI, useSnackbar } from "providers";
|
||||
import { useBinAPI, useGlobalState, useSnackbar } from "providers";
|
||||
import React, { lazy, useEffect, useState } from "react";
|
||||
|
||||
const Bin = lazy(() => import("pages/Bin"));
|
||||
|
|
@ -21,6 +21,7 @@ interface Props {
|
|||
|
||||
export default function BinDrawer(props: Props) {
|
||||
const { open, onClose, selectedBin, bins, removeMarker, updateMarker, moveMap } = props;
|
||||
const [{as}] = useGlobalState()
|
||||
const [bin, setBin] = useState<IBin>(IBin.create());
|
||||
const [openMarkerSettings, setOpenMarkerSettings] = useState(false);
|
||||
const binAPI = useBinAPI();
|
||||
|
|
@ -96,7 +97,7 @@ export default function BinDrawer(props: Props) {
|
|||
settings.location = null;
|
||||
|
||||
binAPI
|
||||
.updateBin(bin.key(), settings)
|
||||
.updateBin(bin.key(), settings, as)
|
||||
.then(resp => {
|
||||
openSnack("Removed bin marker");
|
||||
removeMarker(bin.key());
|
||||
|
|
@ -135,7 +136,7 @@ export default function BinDrawer(props: Props) {
|
|||
let settings = bin.settings;
|
||||
settings.theme = newTheme;
|
||||
binAPI
|
||||
.updateBin(bin.key(), settings)
|
||||
.updateBin(bin.key(), settings, as)
|
||||
.then(resp => {
|
||||
openSnack("marker settings updated");
|
||||
updateMarker(bin.key(), settings);
|
||||
|
|
|
|||
|
|
@ -983,7 +983,7 @@ import { Result } from "@mapbox/mapbox-gl-geocoder";
|
|||
const updateBinMarkers = (bin: IBin, long: number, lat: number, newMarker?: boolean) => {
|
||||
bin.setLocation(long, lat);
|
||||
binAPI
|
||||
.updateBin(bin.key(), bin.settings)
|
||||
.updateBin(bin.key(), bin.settings, as)
|
||||
.then(resp => {
|
||||
openSnack("Bin Location Updated");
|
||||
//remove from options
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue