added grain bag stuff and file selector/uploader stuff

This commit is contained in:
Carter 2025-03-11 16:36:32 -06:00
parent ae30251035
commit 2d78947d2e
18 changed files with 1391 additions and 36 deletions

View file

@ -1,17 +1,16 @@
import {
Button,
createStyles,
DialogActions,
DialogContent,
DialogTitle,
Grid,
Grid2 as Grid,
InputAdornment,
makeStyles,
Switch,
TextField,
Theme,
useTheme
} from "@material-ui/core";
} from "@mui/material";
import { makeStyles } from "@mui/styles";
import ResponsiveDialog from "common/ResponsiveDialog";
import SearchSelect, { Option } from "common/SearchSelect";
import GrainDescriber, { GrainOptions, ToGrainOption } from "grain/GrainDescriber";
@ -22,16 +21,16 @@ import moment from "moment";
import { pond } from "protobuf-ts/pond";
import { useGlobalState, useGrainBagAPI, useSnackbar } from "providers";
import React, { useEffect, useState } from "react";
import { useHistory } from "react-router";
import { useNavigate } from "react-router-dom";
import { getGrainUnit } from "utils";
const useStyles = makeStyles((theme: Theme) =>
createStyles({
const useStyles = makeStyles((theme: Theme) => {
return ({
bottomSpacing: {
marginBottom: theme.spacing(1)
}
})
);
});
interface Props {
open: boolean;
@ -61,7 +60,8 @@ export default function GrainBagSettings(props: Props) {
const [grainBushels, setGrainBushels] = useState(0);
const [fillDate, setFillDate] = useState(moment().format("YYYY-MM-DD"));
const [initialMoisture, setInitialMoisture] = useState(0);
const history = useHistory();
// const history = useHistory();
const navigate = useNavigate()
const { openSnack } = useSnackbar();
const theme = useTheme();
const [grainUpdate, setGrainUpdate] = useState(false);
@ -108,7 +108,7 @@ export default function GrainBagSettings(props: Props) {
.then(resp => {
openSnack("Removed Grain Bag");
close();
history.push("/bins");
navigate("/bins");
})
.catch(err => {
openSnack("Failed to remove Grain Bag");
@ -336,8 +336,8 @@ export default function GrainBagSettings(props: Props) {
onChange={e => setFillDate(e.target.value)}
/>
<Grid container alignItems="center">
<Grid item>Grain</Grid>
<Grid item>
<Grid>Grain</Grid>
<Grid>
<Switch
color="default"
value={isCustom}
@ -353,7 +353,7 @@ export default function GrainBagSettings(props: Props) {
name="storage"
/>
</Grid>
<Grid item>Custom</Grid>
<Grid>Custom</Grid>
</Grid>
{grainBox()}
<TextField
@ -424,8 +424,8 @@ export default function GrainBagSettings(props: Props) {
/>
</DialogContent>
<DialogActions>
<Grid container direction="row" justify="space-between">
<Grid item>
<Grid container direction="row" justifyContent="space-between">
<Grid >
{grainBag && (
<Button
onClick={() => {
@ -437,7 +437,7 @@ export default function GrainBagSettings(props: Props) {
</Button>
)}
</Grid>
<Grid item>
<Grid >
<Button
onClick={() => {
close();