import { Box, Chip, Container, Dialog, DialogContent, DialogContentText, DialogTitle, Grid, IconButton, Input, Tab, Tabs } from '@mui/material'; import {useState} from "react"; import {Edit} from "@mui/icons-material"; import {PresetSnapshot} from "../consts/presets"; import dynamic from "next/dynamic"; import {Calculator} from "../components/Calculator/Calculator"; import {driverNames} from "../libs/driverNames"; const totalSlots = 4; let defaultSlots = Array.from(Array(totalSlots)).map((x, i) => ({ id: i+1, slotNaming: `car_${i+1}`, slotTitle: `Slot ${i+1}`, })); export function CalculatorPage() { const [tab, setTab] = useState(1); const [slots, setSlots] = useState(defaultSlots); const [editText, setEditText] = useState(""); const [openRenameId, setOpenRenameId] = useState(null); try { const config = JSON.parse(localStorage.config) defaultSlots = config.slots; } catch (e) { console.log(e); } if (typeof window !== "undefined") { localStorage.setItem("config", JSON.stringify({ slots, })); } return ( { setSlots(slots.map((x, _idx) => _idx === openRenameId ? {...x, slotTitle: editText} : x)) setOpenRenameId(null); }} aria-labelledby="alert-dialog-title" aria-describedby="alert-dialog-description" > Rename This Slot
setEditText(e.target.value)} sx={{ width: "100%" }} />
{ driverNames.map( d => setEditText(d)} /> ) }
setTab(f)} > { slots.map( (s, _idx) => {s.slotTitle} { setEditText(s.slotTitle); setOpenRenameId(_idx); }}> } value={_idx} key={_idx}/> ) }
); } export default dynamic(() => Promise.resolve(CalculatorPage), { ssr: false, });