replaced uses of getGrainUnit to the users grainUnit function to pull form logged in users settings rather than local storage
This commit is contained in:
parent
dc54f99abd
commit
cabc0146ed
22 changed files with 146 additions and 250 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 { or, getGrainUnit } from "utils";
|
||||
import { or } from "utils";
|
||||
import { makeStyles } from "@mui/styles";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import BinSelector from "./BinSelector";
|
||||
|
|
@ -240,16 +240,16 @@ export default function BinSettings(props: Props) {
|
|||
initForm.inventory.bushelsPerTonne = grain.bushelsPerTonne;
|
||||
}
|
||||
|
||||
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
|
||||
if(user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
|
||||
setBushelConversion(initForm.inventory.bushelsPerTonne)
|
||||
}else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
|
||||
}else if (user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
|
||||
setBushelConversion(initForm.inventory.bushelsPerTonne * 0.907)
|
||||
}
|
||||
if (initForm.inventory.customGrain){
|
||||
setCustomGrain(initForm.inventory.customGrain)
|
||||
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
|
||||
if(user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
|
||||
setBushelConversion(initForm.inventory.customGrain.bushelsPerTonne)
|
||||
}else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
|
||||
}else if (user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
|
||||
setBushelConversion(initForm.inventory.customGrain.bushelsPerTonne * 0.907)
|
||||
}
|
||||
}
|
||||
|
|
@ -304,15 +304,15 @@ export default function BinSettings(props: Props) {
|
|||
: initForm.inventory?.grainBushels ?? 0;
|
||||
let weight = ""
|
||||
if(initForm.inventory){
|
||||
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
|
||||
if(user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
|
||||
weight = (gb/initForm.inventory.bushelsPerTonne).toFixed(2)
|
||||
}else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
|
||||
}else if (user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
|
||||
weight = (gb/(initForm.inventory.bushelsPerTonne * 0.907)).toFixed(2)
|
||||
}
|
||||
if(initForm.inventory.customGrain){
|
||||
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
|
||||
if(user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
|
||||
weight = (gb/initForm.inventory.customGrain.bushelsPerTonne).toFixed(2)
|
||||
}else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
|
||||
}else if (user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
|
||||
weight = (gb/(initForm.inventory.customGrain.bushelsPerTonne * 0.907)).toFixed(2)
|
||||
}
|
||||
}
|
||||
|
|
@ -804,7 +804,7 @@ export default function BinSettings(props: Props) {
|
|||
const binQuantity = formExtension.grainBushels;
|
||||
|
||||
//as long as the storage type is not fertilizer it is some sort of grain, whether it is supported or custom is not important in this instance so we do not need to check for unknown
|
||||
if(storageType !== pond.BinStorage.BIN_STORAGE_FERTILIZER && ((getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE || getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON) && bushelConversion !== 0 && grainWeight !== "")){
|
||||
if(storageType !== pond.BinStorage.BIN_STORAGE_FERTILIZER && ((user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE || user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TON) && bushelConversion !== 0 && grainWeight !== "")){
|
||||
return (
|
||||
<TextField
|
||||
label="Amount"
|
||||
|
|
@ -830,7 +830,7 @@ export default function BinSettings(props: Props) {
|
|||
variant="outlined"
|
||||
disabled={!canEdit}
|
||||
InputProps={{
|
||||
endAdornment: <InputAdornment position="end">{getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE ? "mT" : "t"}</InputAdornment>
|
||||
endAdornment: <InputAdornment position="end">{user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE ? "mT" : "t"}</InputAdornment>
|
||||
}}
|
||||
className={classes.bottomSpacing}
|
||||
/>
|
||||
|
|
@ -1179,9 +1179,9 @@ export default function BinSettings(props: Props) {
|
|||
setCustomGrain(newGrainSettings)
|
||||
let conversion = 0
|
||||
|
||||
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
|
||||
if(user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
|
||||
conversion = newGrainSettings.bushelsPerTonne
|
||||
}else if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
|
||||
}else if(user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
|
||||
conversion = newGrainSettings.bushelsPerTonne * 0.907
|
||||
}
|
||||
updateForm(
|
||||
|
|
@ -1218,9 +1218,9 @@ export default function BinSettings(props: Props) {
|
|||
})
|
||||
);
|
||||
let conversion = 0
|
||||
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
|
||||
if(user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
|
||||
conversion = GrainDescriber(newGrainType).bushelsPerTonne
|
||||
}else if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
|
||||
}else if(user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
|
||||
conversion = GrainDescriber(newGrainType).bushelsPerTon
|
||||
}
|
||||
setBushelConversion(conversion)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue