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:
csawatzky 2026-03-26 12:47:16 -06:00
parent dc54f99abd
commit cabc0146ed
22 changed files with 146 additions and 250 deletions

View file

@ -63,7 +63,7 @@ import {
} from "providers";
import React, { SetStateAction, useCallback, useEffect, useState } from "react";
// import { getThemeType } from "theme";
import { getGrainUnit, stringToMaterialColour } from "utils";
import { stringToMaterialColour } from "utils";
//import InfiniteScroll from "react-infinite-scroller";
import PageContainer from "./PageContainer";
import ObjectTable from "objects/ObjectTable";
@ -934,7 +934,7 @@ export default function Bins(props: Props) {
return " bu";
}
switch (getGrainUnit()) {
switch (user.grainUnit()) {
case pond.GrainUnit.GRAIN_UNIT_TONNE:
return " mT";
case pond.GrainUnit.GRAIN_UNIT_TON:
@ -947,9 +947,9 @@ export default function Bins(props: Props) {
const customQuantityDisplay = (customInventory: pond.CustomInventory, bushels: number) => {
let amount = bushels
if(customInventory.bushelsPerTonne > 1){
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
if(user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
amount = bushels/customInventory.bushelsPerTonne
}else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
}else if (user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
amount = bushels/(customInventory.bushelsPerTonne*0.907)
}
}
@ -959,9 +959,9 @@ export default function Bins(props: Props) {
const supportedGrainDisplay = (grain: pond.Grain, bushels: number) => {
const describer = GrainDescriber(grain)
let amount = bushels
if(getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
if(user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TONNE){
amount = bushels/describer.bushelsPerTonne
}else if (getGrainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
}else if (user.grainUnit() === pond.GrainUnit.GRAIN_UNIT_TON){
amount = bushels/describer.bushelsPerTon
}
return Math.round(amount*100)/100

View file

@ -11,7 +11,7 @@ import PageContainer from "./PageContainer";
export default function Contracts() {
const [openSettings, setOpenSettings] = useState(false);
const [{ as }] = useGlobalState()
const [{ as, user }] = useGlobalState()
const contractAPI = useContractAPI();
const [contracts, setContracts] = useState<Contract[]>([]);
const [loading, setLoading] = useState(false);
@ -42,7 +42,7 @@ export default function Contracts() {
let contractPermissions: Map<string, pond.Permission[]> = new Map();
if (resp.data.contracts){
resp.data.contracts.forEach(contract => {
let c = Contract.create(contract);
let c = Contract.create(contract, user);
contracts.push(c);
let p = pond.EvaluatePermissionsResponse.fromObject(
resp.data.contractPermissions[c.key()]
@ -56,7 +56,7 @@ export default function Contracts() {
})
.catch(err => {});
}
}, [contractAPI, year, as]); // eslint-disable-line react-hooks/exhaustive-deps
}, [contractAPI, year, as, user]); // eslint-disable-line react-hooks/exhaustive-deps
return (
<PageContainer>