import {Add, Edit} from "@mui/icons-material"; import {Box, Button, Chip, Dialog, DialogContent, DialogTitle, Grid, IconButton, Input, Tab, Tabs} from "@mui/material"; import {useState} from "react"; import {useDispatch, useSelector} from "react-redux"; import {driverNames} from "../../consts/driverNames"; import {addSlot, removeSlot, renameSlot} from "../../libs/reducers/configReducer"; import {Calculator} from "./Calculator"; export function TabManager() { const config = useSelector(state => state.config) const { slots } = config; const dispatch = useDispatch() const [tab, setTab] = useState(0); const [editText, setEditText] = useState(""); const [openRenameSlot, setOpenRenameSlot] = useState(null); const saveSlotEdit = () => { dispatch(renameSlot({ id: openRenameSlot.id, slotTitle: editText })) setOpenRenameSlot(null); } return (
Renaming Slot {openRenameSlot.id}: {openRenameSlot.slotTitle}
setEditText(e.target.value)} sx={{ width: "100%" }} />
{ driverNames.map( d => setEditText(d)} /> ) }
{ slots.length > 1 && ( ) }
{ setTab(f) }} > { slots.map( (s, _idx) => {s.slotTitle} { setEditText(s.slotTitle); setOpenRenameSlot(s); }}>
} value={_idx} key={_idx}/> ) } { config.slots.length > 0 && ( ) } ); }