import { Box, Grid2 as Grid, Theme, Typography, IconButton, LinearProgress, Drawer } from "@mui/material"; import { Notes } from "@mui/icons-material"; import GrainDescriber from "grain/GrainDescriber"; import { Field, HarvestPlan } from "models"; import React, { useEffect, useState } from "react"; import { getThemeType } from "theme"; import Chat from "chat/Chat"; import { pond } from "protobuf-ts/pond"; import { useMobile } from "hooks"; import HarvestPlanActions from "./HarvestPlanActions"; import { makeStyles } from "@mui/styles"; interface Props { plan: HarvestPlan; permissions: pond.Permission[]; planField: Field; loading: boolean; fieldList?: Field[]; changePlan: (updatedPlan?: HarvestPlan) => void; } 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 }, avatar: { color: getThemeType() === "light" ? theme.palette.common.black : theme.palette.common.white, backgroundColor: "transparent", width: theme.spacing(5), height: theme.spacing(5), border: "1px solid", borderColor: theme.palette.divider } })); export default function HarvestPlanDisplay(props: Props) { const { plan, loading, planField, fieldList, changePlan, permissions } = props; const classes = useStyles(); const [openNote, setOpenNote] = useState(false); const isMobile = useMobile(); const planTable = () => { return ( Break Even Yield (acre): {plan.bushelPrice() !== 0 ? ( (plan.totalEquipmentCost() + plan.totalMaterialCost()) / plan.bushelPrice() ).toFixed(2) : 0}{" "} BU Break Even Sales Price (BU): $ {plan.yieldTarget() !== 0 ? ( (plan.totalEquipmentCost() + plan.totalMaterialCost()) / plan.yieldTarget() ).toFixed(2) : 0} Harvest Year: {plan.harvestYear()} Title: {plan.settings.title} Grain: {GrainDescriber(plan.cropType()).name} Variant: {plan.grainType()} Bushel Price: ${plan.bushelPrice()} Yield Target: {plan.yieldTarget()} Total Cost (acre): ${(plan.totalEquipmentCost() + plan.totalMaterialCost()).toFixed(2)} Total Cost: $ {( (plan.totalEquipmentCost() + plan.totalMaterialCost()) * planField.acres() ).toFixed(2)} ); }; const noteDrawer = () => { return ( setOpenNote(false)}> Notes ); }; return ( {loading ? ( ) : ( setOpenNote(true)}> {plan.key() !== "" ? plan.settings.title : "None Found"} {!isMobile && permissions.includes(pond.Permission.PERMISSION_WRITE) && ( { changePlan(updatedPlan); }} //possibly need to re-load plan here /> )} {isMobile && permissions.includes(pond.Permission.PERMISSION_WRITE) && ( { changePlan(updatedPlan); }} //possibly need to re-load plan here /> )} {plan.key() !== "" && planTable()} )} {noteDrawer()} ); }