replacing the getTemperatureUnit function in units that uses the local storage with a function in the user model to just get it from the user settings
This commit is contained in:
parent
a288c9503a
commit
ce41a2dc05
16 changed files with 188 additions and 178 deletions
|
|
@ -61,7 +61,7 @@ import { pond } from "protobuf-ts/pond";
|
|||
import { useBinAPI, useBinYardAPI, useGlobalState, useLibraCartProxyAPI } from "providers";
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
// import { useHistory } from "react-router";
|
||||
import { getDistanceUnit, or, getTemperatureUnit, getGrainUnit } from "utils";
|
||||
import { getDistanceUnit, or, getGrainUnit } from "utils";
|
||||
import { makeStyles } from "@mui/styles";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import BinSelector from "./BinSelector";
|
||||
|
|
@ -290,7 +290,7 @@ export default function BinSettings(props: Props) {
|
|||
let high = initForm.highTemp ?? 20;
|
||||
let low = initForm.lowTemp ?? 10;
|
||||
let target = initForm.inventory?.targetTemperature ?? 15;
|
||||
if (getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) {
|
||||
if (user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) {
|
||||
high = parseFloat((high * 1.8 + 32).toFixed(2));
|
||||
low = parseFloat((low * 1.8 + 32).toFixed(2));
|
||||
target = parseFloat((target * 1.8 + 32).toFixed(2));
|
||||
|
|
@ -364,7 +364,7 @@ export default function BinSettings(props: Props) {
|
|||
} else {
|
||||
setInitialized(false);
|
||||
}
|
||||
}, [bin, open, mode, openedBinYard]);
|
||||
}, [bin, open, mode, openedBinYard, user]);
|
||||
|
||||
useEffect(() => {
|
||||
if (mode === "remove") {
|
||||
|
|
@ -2308,7 +2308,7 @@ export default function BinSettings(props: Props) {
|
|||
onChange={event => {
|
||||
let value = event?.target.value;
|
||||
let valueC = value;
|
||||
if (getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) {
|
||||
if (user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) {
|
||||
valueC = ((Number(value) - 32) * (5 / 9)).toFixed(2);
|
||||
}
|
||||
|
||||
|
|
@ -2320,7 +2320,7 @@ export default function BinSettings(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT
|
||||
{user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT
|
||||
? "F"
|
||||
: "C"}
|
||||
</InputAdornment>
|
||||
|
|
@ -2348,7 +2348,7 @@ export default function BinSettings(props: Props) {
|
|||
onChange={event => {
|
||||
let value = event?.target.value;
|
||||
let valueC = value;
|
||||
if (getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) {
|
||||
if (user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) {
|
||||
valueC = ((Number(value) - 32) * (5 / 9)).toFixed(2);
|
||||
}
|
||||
setLowTempC(+valueC);
|
||||
|
|
@ -2357,7 +2357,7 @@ export default function BinSettings(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT
|
||||
{user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT
|
||||
? "F"
|
||||
: "C"}
|
||||
</InputAdornment>
|
||||
|
|
@ -2383,7 +2383,7 @@ export default function BinSettings(props: Props) {
|
|||
onChange={event => {
|
||||
let value = event?.target.value;
|
||||
let valueC = value;
|
||||
if (getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) {
|
||||
if (user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT) {
|
||||
valueC = ((Number(value) - 32) * (5 / 9)).toFixed(2);
|
||||
}
|
||||
setHighTempC(+valueC);
|
||||
|
|
@ -2392,7 +2392,7 @@ export default function BinSettings(props: Props) {
|
|||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
{getTemperatureUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT
|
||||
{user.tempUnit() === pond.TemperatureUnit.TEMPERATURE_UNIT_FAHRENHEIT
|
||||
? "F"
|
||||
: "C"}
|
||||
</InputAdornment>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue