import type React from "react"; import { useEffect } from "react"; import { Controller, useForm } from "react-hook-form"; import { toast } from "react-hot-toast"; import { Input } from "@app/components/form/Input.js"; import { Select } from "@app/components/form/Select.js"; import { Toggle } from "@app/components/form/Toggle.js"; import type { DisplayValidation } from "@app/validation/config/display.js"; import { Form } from "@components/form/Form"; import { useDevice } from "@core/providers/useDevice.js"; import { renderOptions } from "@core/utils/selectEnumOptions.js"; import { classValidatorResolver } from "@hookform/resolvers/class-validator"; import { Protobuf } from "@meshtastic/meshtasticjs"; export const Display = (): JSX.Element => { const { config, connection, setConfig } = useDevice(); const { register, handleSubmit, formState: { errors, isDirty }, reset, control } = useForm({ defaultValues: config.display // resolver: classValidatorResolver(DisplayValidation) }); // useEffect(() => { // reset(config.display); // }, [reset, config.display]); const onSubmit = handleSubmit((data) => { // if (connection) { // void toast.promise( // connection // .setConfig( // new Protobuf.Config({ // payloadVariant: { // case: "display", // value: data // } // }) // ) // .then(() => // setConfig( // new Protobuf.Config({ // payloadVariant: { // case: "display", // value: data // } // }) // ) // ), // { // loading: "Saving...", // success: "Saved Display Config, Restarting Node", // error: "No response received" // } // ); // } }); return (
( )} /> ( )} /> ( )} /> ); };