saving preferred units on success
This commit is contained in:
parent
a43ff1a8ad
commit
674763de24
1 changed files with 8 additions and 6 deletions
|
|
@ -13,7 +13,7 @@ import {
|
||||||
import { AppBar, Box, Button, Checkbox, CircularProgress, Collapse, Divider, FormControl, FormControlLabel, FormGroup, FormHelperText, FormLabel, Grid2, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText, MenuItem, Radio, RadioGroup, TextField, Theme, ToggleButton, ToggleButtonGroup, Toolbar, Tooltip, Typography } from "@mui/material";
|
import { AppBar, Box, Button, Checkbox, CircularProgress, Collapse, Divider, FormControl, FormControlLabel, FormGroup, FormHelperText, FormLabel, Grid2, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText, MenuItem, Radio, RadioGroup, TextField, Theme, ToggleButton, ToggleButtonGroup, Toolbar, Tooltip, Typography } from "@mui/material";
|
||||||
import ResponsiveDialog from "common/ResponsiveDialog";
|
import ResponsiveDialog from "common/ResponsiveDialog";
|
||||||
import UserAvatar from "./UserAvatar";
|
import UserAvatar from "./UserAvatar";
|
||||||
import { useGlobalState, useUserAPI } from "providers";
|
import { useGlobalState, useSnackbar, useUserAPI } from "providers";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { makeStyles } from "@mui/styles";
|
import { makeStyles } from "@mui/styles";
|
||||||
import { blue } from "@mui/material/colors";
|
import { blue } from "@mui/material/colors";
|
||||||
|
|
@ -30,6 +30,7 @@ import { useThemeMode } from "theme/AppThemeProvider";
|
||||||
import UnitsIcon from "@mui/icons-material/Category";
|
import UnitsIcon from "@mui/icons-material/Category";
|
||||||
import { setThemeType } from "theme";
|
import { setThemeType } from "theme";
|
||||||
import { IsAdaptiveAgriculture } from "services/whiteLabel";
|
import { IsAdaptiveAgriculture } from "services/whiteLabel";
|
||||||
|
import { setDistanceUnit, setGrainUnit, setPressureUnit, setTemperatureUnit } from "utils";
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) => {
|
const useStyles = makeStyles((theme: Theme) => {
|
||||||
return ({
|
return ({
|
||||||
|
|
@ -73,6 +74,7 @@ export default function UserSettings(props: Props) {
|
||||||
const [sharing, setSharing] = useState(false)
|
const [sharing, setSharing] = useState(false)
|
||||||
const userAPI = useUserAPI();
|
const userAPI = useUserAPI();
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
const { success } = useSnackbar();
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||||
const [user, setUser] = useState<User>(globalState.user);
|
const [user, setUser] = useState<User>(globalState.user);
|
||||||
|
|
@ -102,11 +104,11 @@ export default function UserSettings(props: Props) {
|
||||||
.updateUser(user.id(), user.protobuf())
|
.updateUser(user.id(), user.protobuf())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
dispatch({ key: "user", value: user });
|
dispatch({ key: "user", value: user });
|
||||||
// success("User settings successfully updated!");
|
success("User settings successfully updated!");
|
||||||
// setTemperatureUnit(user.settings.temperatureUnit);
|
setTemperatureUnit(user.settings.temperatureUnit);
|
||||||
// setPressureUnit(user.settings.pressureUnit);
|
setPressureUnit(user.settings.pressureUnit);
|
||||||
// setDistanceUnit(user.settings.distanceUnit);
|
setDistanceUnit(user.settings.distanceUnit);
|
||||||
// setGrainUnit(user.settings.grainUnit);
|
setGrainUnit(user.settings.grainUnit);
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
error("Error occurred while updating your profile");
|
error("Error occurred while updating your profile");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue