import React, { useState } from "react"; import { createGlobalStyle } from "styled-components"; // import { useDispatch } from "react-redux"; import Select from "react-select"; import SerialPort from "serialport"; import electron from "electron"; import KnobSection from "./Components/KnobSection"; import { useAppDispatch } from "./redux/hooks"; import { connect, disconnect, setSerialPort } from "./redux/slices/serialConnectionSlice"; const GlobalStyle = createGlobalStyle` html { border-style: solid; border-color: #363636; border-width: 1px; box-sizing: border-box; height: 100%; border-bottom-style: hidden; border-right-style: hidden; } `; const options: [{value: string, label:string}] = [{ value: "placeholder", label: "Select Port" }]; const fetchPorts = async () => { const data = await SerialPort.list(); options.shift(); data.forEach((comPort) => { options.push({ value: comPort.path, label: comPort.path }); }); }; const App = () => { const dispatch = useAppDispatch(); fetchPorts(); const [portSelectionValue, setPortSelectionValue] = useState(options[0]); const handlePortChange = async (selectedOption: any) => { setPortSelectionValue(selectedOption); dispatch(setSerialPort(selectedOption.value)); }; return (