import { Box, Button, DialogActions, DialogContent, DialogTitle, Grid2, Switch, TextField } from "@mui/material"; import ResponsiveDialog from "common/ResponsiveDialog"; import SearchSelect, { Option } from "common/SearchSelect"; import { Bin } from "models"; import { pond } from "protobuf-ts/pond"; import GrainDescriber, { GrainOptions, ToGrainOption } from "grain/GrainDescriber"; import { useEffect, useMemo, useState } from "react"; import React from "react"; import CustomGrainSelector from "./CustomGrainSelector"; import { cloneDeep } from "lodash"; import { useBinAPI, useSnackbar } from "providers"; interface Props { bin: Bin open: boolean closeDialog: () => void permissions: pond.Permission[] /** * this function can be passed in if you want to just return a new bin with the changes and handle the actual update in the parent, * it will stop the component from doing the update itself * @param bin the bin with the new changes * @returns */ updateBin?: (bin: Bin) => void /** * this function can be passed in as a callback function if the component handles the update * @param updated whether the bin api was used to update the bin * @returns */ updateCallback?: (bin: Bin) => void } export default function ChangeGrainDialog(props: Props){ const { bin, open, permissions, closeDialog, updateBin, updateCallback } = props const canEdit = useMemo(()=>{ return permissions ? permissions.includes(pond.Permission.PERMISSION_WRITE) : false; },[permissions]) const [isCustom, setIsCustom] = useState(false) const grainOptions = GrainOptions(); const [grainOption, setGrainOption] = useState