import {Box, Text, Switch, Flex, Field, Input} from "@chakra-ui/react"; import { useDashboardStore } from "@/store/useDashboardStore.jsx"; import {useState} from "react"; export default function ExplosionEventsSettings({ widgetId, currentSettings }) { const updateSettings = useDashboardStore(state => state.updateWidgetSettings); const [startError, setStartError] = useState(null); const [endError, setEndError] = useState(null); // 1. Convert the saved string into a boolean for the toggle UI const isSymlog = currentSettings?.yAxisScale === 'log'; const handleToggle = (details) => { // 2. Chakra v3 passes { checked: boolean } in the details object. // Convert it back to the string Plotly expects. console.log("1. Toggle Clicked! Raw details from Chakra:", details); const newScale = details.checked ? 'log' : 'normal'; updateSettings(widgetId, { yAxisScale: newScale }); }; return ( {/* Y-AXIS SETTING*/} Y-Axis Settings Use Log Scale {/* DATE RANGE SELECTION */} Start Date { const value = e.target.value; updateSettings(widgetId, {...currentSettings, startDate: value}); const dateSelected = new Date(value); const today = new Date(); today.setHours(0, 0, 0, 0); if (value && (dateSelected > today)) setStartError("Can't Choose a Future Date"); else setStartError(""); }} /> {startError && {startError}} End Date { const value = e.target.value; updateSettings(widgetId, {...currentSettings, endDate: value}); const dateSelected = new Date(value); const today = new Date(); today.setHours(0, 0, 0, 0); if (value && (dateSelected > today)) setEndError("Can't Choose a Future Date"); else setEndError(""); }} /> {endError && {endError}} ); }