diff --git a/src/field/FieldSettings.tsx b/src/field/FieldSettings.tsx index ca865a0..33f0c5d 100644 --- a/src/field/FieldSettings.tsx +++ b/src/field/FieldSettings.tsx @@ -152,9 +152,7 @@ export default function FieldSettings(props: Props) { const fieldInformation = () => { return ( - - - Field Information + setFeatColor(color)} /> - + + ); + }; + + return ( + + Field Information + {fieldInformation()} @@ -282,13 +287,6 @@ export default function FieldSettings(props: Props) { - - ); - }; - - return ( - - {fieldInformation()} ); } diff --git a/src/harvestPlan/HarvestPlanTable.tsx b/src/harvestPlan/HarvestPlanTable.tsx index cf9348c..a4f48c1 100644 --- a/src/harvestPlan/HarvestPlanTable.tsx +++ b/src/harvestPlan/HarvestPlanTable.tsx @@ -1,13 +1,29 @@ -import { Box, Typography } from "@mui/material" +import { ExpandMore } from "@mui/icons-material" +import { Accordion, AccordionDetails, AccordionSummary, Box, Theme, Typography } from "@mui/material" +import { makeStyles } from "@mui/styles" import ResponsiveTable, { Column } from "common/ResponsiveTable" import GrainDescriber from "grain/GrainDescriber" -import { HarvestPlan } from "models" +import { cloneDeep } from "lodash" +import { Field, HarvestPlan } from "models" import { useHarvestPlanAPI } from "providers" import { useCallback, useEffect, useState } from "react" +import { getThemeType } from "theme" interface Props { - field?: string + field: Field } + +const useStyles = makeStyles((theme: Theme) => ({ + dark: { + backgroundColor: getThemeType() === "light" ? "rgb(245, 245, 245)" : "rgb(50, 50, 50)", + padding: 5 + }, + light: { + backgroundColor: getThemeType() === "light" ? "rgb(235, 235, 235)" : "rgb(60, 60, 60)", + padding: 5 + } +})); + export default function HarvestPlanTable(props: Props){ const {field} = props const harvestAPI = useHarvestPlanAPI() @@ -15,9 +31,10 @@ export default function HarvestPlanTable(props: Props){ const [pageSize, setPageSize] = useState(10) const [loadedPlans, setLoadedPlans] = useState([]) const [total, setTotal] = useState(0) + const classes = useStyles() useEffect(()=>{ - harvestAPI.listHarvestPlans(pageSize, page*pageSize, "asc", "harvestYear", field).then(resp => { + harvestAPI.listHarvestPlans(pageSize, page*pageSize, "desc", "harvestYear", field.key()).then(resp => { if(resp.data.harvestPlan){ setLoadedPlans(resp.data.harvestPlan.map(hp => HarvestPlan.create(hp))) } @@ -106,6 +123,80 @@ export default function HarvestPlanTable(props: Props){ setPage={(page)=>{ setPage(page) }} + loadMore={() => { + harvestAPI.listHarvestPlans(pageSize, loadedPlans.length, "desc", "harvestYear", field.key()).then(resp => { + let currentPlans = cloneDeep(loadedPlans) + let newPlans: HarvestPlan[] = [] + if(resp.data.harvestPlan){ + newPlans = resp.data.harvestPlan.map(hp => HarvestPlan.create(hp)) + } + setLoadedPlans(currentPlans.concat(newPlans)) + }) + }} + renderMobile={(row, index) => { + // since these are more about previous harvest plans i am only showing the final tallys rather than the breakdowns + return ( + + }> + + {row.settings.title} - {row.harvestYear()} + + + + {/* grain */} + + Grain: + {GrainDescriber(row.cropType()).name} + + {/* variant */} + + Variant: + {row.grainType()} + + {/* yield target */} + {/* + Yield Target: + {row.yieldTarget()}bu + */} + {/* actual yield */} + + Actual Yield: + {row.actualYield()}bu + + {/* bushel price */} + + Bushel Price: + ${row.bushelPrice()} + + {/* material cost */} + + Material Cost: + ${row.totalMaterialCost() * field.acres()} + + {/* equipment cost */} + + Equipment Cost: + ${row.totalEquipmentCost() * field.acres()} + + {/* pre-seed materials */} + {/* pre-seed equpment */} + {/* seed materials */} + {/* seed equpment */} + {/* post-seed materials */} + {/* post-seed equpment */} + {/* harvest materials */} + {/* harvest equpment */} + {/* fall materials */} + {/* fall equpment */} + {/* total cost */} + + Total Cost: + ${(row.totalEquipmentCost() + row.totalMaterialCost()) * field.acres()} + + + + ) + }} /> ) } \ No newline at end of file diff --git a/src/models/Device.ts b/src/models/Device.ts index 0119a0e..0aec35a 100644 --- a/src/models/Device.ts +++ b/src/models/Device.ts @@ -42,11 +42,11 @@ const featureVersions: Map = new Map([ v2Cell: "N/A", v2WifiS3: "N/A", v2CellS3: "N/A", - v2CellBlack: "2.1.6", + v2CellBlack: "2.1.7", v2CellGreen: "N/A", - v2WifiBlue: "2.1.6", - v2CellBlue: "2.1.6", - v2EthBlue: "2.1.6" + v2WifiBlue: "2.1.7", + v2CellBlue: "2.1.7", + v2EthBlue: "2.1.7" } ] ]); diff --git a/src/pages/Field.tsx b/src/pages/Field.tsx index f4291dd..19472ae 100644 --- a/src/pages/Field.tsx +++ b/src/pages/Field.tsx @@ -1,10 +1,10 @@ import { Field, fieldScope, HarvestPlan, teamScope } from "models"; import { useFieldAPI, useGlobalState, useHarvestPlanAPI } from "providers"; import React, { useCallback, useEffect, useState } from "react"; -import { useLocation, useParams } from "react-router-dom"; +import { useLocation, useNavigate, useParams } from "react-router-dom"; import PageContainer from "./PageContainer"; import { useMobile, useSnackbar, useUserAPI } from "hooks"; -import { Box, Card, Grid2, IconButton } from "@mui/material"; +import { Box, Card, Grid2, IconButton, Tab, Tabs, Theme, Typography, darken } from "@mui/material"; import FieldActions from "field/FieldActions"; import { Settings } from "@mui/icons-material"; import { pond } from "protobuf-ts/pond"; @@ -14,10 +14,47 @@ import TaskViewer from "tasks/TaskViewer"; import HarvestPlanDisplay from "harvestPlan/HarvestPlanDisplay"; import { cloneDeep } from "lodash"; import HarvestPlanTable from "harvestPlan/HarvestPlanTable"; +import { makeStyles } from "@mui/styles"; +import FieldSettings from "field/FieldSettings"; + +const useStyles = makeStyles((theme: Theme) => { + return ({ + card: { + height: "100%", + bgcolor: darken(theme.palette.background.paper, 0.05), + }, + sectionHeader: { + fontSize: 35, + fontWeight: 650 + } + }) +}) + +interface TabPanelProps { + children?: React.ReactNode; + index: any; + value: any; +} + +function TabPanel(props: TabPanelProps) { + const { children, value, index, ...other } = props; + + return ( + + ); +} export default function FieldPage() { const { state } = useLocation(); //const [{ as }] = useGlobalState() + const classes = useStyles(); const fieldAPI = useFieldAPI(); const userAPI = useUserAPI(); const [{as, user}] = useGlobalState(); @@ -31,11 +68,23 @@ export default function FieldPage() { const [hPlan, setHPlan] = useState(HarvestPlan.create()); const [loading, setLoading] = useState(false) const hPlanAPI = useHarvestPlanAPI(); + const [tabVal, setTabVal] = useState(0) + const navigate = useNavigate() const loadField = useCallback(() => { - + if(state.field){ + fieldAPI.getField(state.field).then(resp => { + setField(Field.create(resp.data)) + }).catch(err => { + + }) + } },[as]) + const goTo = () => { + navigate("/fields"); + } + useEffect(()=>{ // if already loading do nothing if(loading) return @@ -91,13 +140,20 @@ export default function FieldPage() { const fieldActions = () => { return ( - - { - setOpenFieldSettings(true) - }}> - {}}/> - + + + + {field.name()} + + + + { + setOpenFieldSettings(true) + }}> + {}}/> + + ) } @@ -134,43 +190,44 @@ export default function FieldPage() { field.key() !== "" && taskLoadKeys.push(field.key()); //hPlan.key() !== "" && taskLoadKeys.push(hPlan.key()); } - return () + return () } const desktopView = () => { return ( - {field.name()} - + {map()} - - {weather()} + + {weather()} - - {tasks()} + + {tasks()} - Harvest Overview + + Harvest Overview + - - {harvestPlans()} + + {harvestPlans()} - - + + @@ -181,12 +238,68 @@ export default function FieldPage() { const mobileView = () => { return ( - Mobile will just be the drawer view + + { + setTabVal(val) + }} + TabIndicatorProps={{ style: { background: "rgba(255,255,0,255)" } }}> + + + + + + + + + {map()} + + + + + {weather()} + + + + + + + {tasks()} + + + + + + + {harvestPlans()} + + + + + + + + ) } const fieldSettings = () => { - + return ( + { + setOpenFieldSettings(false) + }} + selectedField={field} + updateFields={() => { + loadField() + }} + removeField={()=>{ + goTo() + }} + /> + ) } return ( @@ -195,6 +308,7 @@ export default function FieldPage() { {fieldActions()} {isMobile ? mobileView() : desktopView()} + {fieldSettings()} ) } \ No newline at end of file