import {Box, Button, Chip, Dialog, DialogContent, DialogTitle, Grid, IconButton, Input, Tab, Tabs} from "@mui/material"; import {driverNames} from "../../libs/driverNames"; import {Add, Edit} from "@mui/icons-material"; import {useState} from "react"; import {Calculator} from "./Calculator"; import {PresetSnapshot} from "../../consts/presets"; import {useDispatch, useSelector} from "react-redux"; import {addSlot, removeSlot, renameSlot} from "../../libs/reducers/configReducer"; /* */ export function TabManager() { const config = useSelector(state => state.config) const { slots } = config; const dispatch = useDispatch() const [activeSlot, setActiveSlot] = useState(slots[0]); 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); } if (typeof window !== "undefined" && !slots.length) { if (config?.slots?.length > 0) { setSlots(config.slots); setActiveSlot(config.slots[0]); } } return (
{ openRenameSlot !== null && ( Renaming Slot {openRenameSlot.id}: {openRenameSlot.slotTitle}
setEditText(e.target.value)} sx={{ width: "100%" }} />
{ driverNames.map( d => setEditText(d)} /> ) }
) } { setActiveSlot(slots[f]) setTab(f) }} > { slots.map( (s, _idx) => {s.slotTitle} { setEditText(s.slotTitle); setOpenRenameSlot(s); }}>
} value={_idx} key={_idx}/> ) } { activeSlot.id !== -1 && ( ) } ); }