import { useCallback, useEffect, useRef, useState } from "react";
import PageContainer from "./PageContainer";
import { DevicePreset } from "models/DevicePreset";
import { Controller } from "models/Controller";
import { useNavigate, useParams } from "react-router-dom";
import { useMobile, useSnackbar } from "hooks";
import { Component, Device, Bin as IBin, Interaction } from "models";
import { useBinAPI, useGlobalState } from "providers";
import { pond } from "protobuf-ts/pond";
import { Plenum } from "models/Plenum";
import { Ambient } from "models/Ambient";
import { GrainCable } from "models/GrainCable";
import { Pressure } from "models/Pressure";
import { CO2 } from "models/CO2";
import moment from "moment";
import { quack } from "protobuf-ts/quack";
import { Box, Drawer, Grid2 as Grid, IconButton, ListItemIcon, ListItemText, Menu, MenuItem, Tab, Tabs, Theme, Tooltip } from "@mui/material";
import { makeStyles } from "@mui/styles";
import NotesIcon from "@mui/icons-material/Notes";
import TasksIcon from "products/Construction/TasksIcon";
import BindaptIcon from "products/Bindapt/BindaptIcon";
import FieldsIcon from "products/AgIcons/FieldsIcon";
import BinActions from "bin/BinActions";
import BinSummary from "bin/binSummary/BinSummary";
import { Close } from "@mui/icons-material";
import React from "react";
import BinHistory from "bin/BinHistory";
import Chat from "chat/Chat";
import TaskViewer from "tasks/TaskViewer";
interface TabPanelProps {
children?: React.ReactNode;
index: any;
value: any;
}
function TabPanelMine(props: TabPanelProps) {
const { children, value, index, ...other } = props;
return (
{value === index && {children}}
);
}
const useStyles = makeStyles((theme: Theme) => {
const themeType = theme.palette.mode;
return ({
spacer: {
width: "32px",
height: "32px",
padding: "auto",
display: "flex",
justifyContent: "center",
alignItems: "center"
},
avatar: {
color: themeType === "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
},
menuPaper: {
borderRadius: "20px"
},
drawerPaperDesktop: {
height: "100%",
width: "30%"
},
drawerPaperMobile: {
height: "50%",
width: "100%"
},
})
})
export default function BinV2(){
const warningThreshold = 6;
const isMobile = useMobile();
const binID = useParams<{ binID: string }>()?.binID ?? "";
const binAPI = useBinAPI();
const classes = useStyles()
const navigate = useNavigate()
const [{ user, as, showErrors }] = useGlobalState();
const [binLoading, setBinLoading] = useState(false);
const loadRef = useRef(false);
const [bin, setBin] = useState(IBin.create());
const [devices, setDevices] = useState([]);
const [components, setComponents] = useState