import { type BluetoothValidation, BluetoothValidationSchema, } from "@app/validation/config/bluetooth.ts"; import { create } from "@bufbuild/protobuf"; import { DynamicForm } from "@components/Form/DynamicForm.tsx"; import { useDevice } from "@core/stores/deviceStore.ts"; import { Protobuf } from "@meshtastic/core"; import { useTranslation } from "react-i18next"; export const Bluetooth = () => { const { config, setWorkingConfig } = useDevice(); const { t } = useTranslation("deviceConfig"); const onSubmit = (data: BluetoothValidation) => { setWorkingConfig( create(Protobuf.Config.ConfigSchema, { payloadVariant: { case: "bluetooth", value: data, }, }), ); }; return ( onSubmit={onSubmit} validationSchema={BluetoothValidationSchema} formId="Config_BluetoothConfig" defaultValues={config.bluetooth} fieldGroups={[ { label: t("bluetooth.title"), description: t("bluetooth.description"), notes: t("bluetooth.note"), fields: [ { type: "toggle", name: "enabled", label: t("bluetooth.enabled.label"), description: t("bluetooth.enabled.description"), }, { type: "select", name: "mode", label: t("bluetooth.pairingMode.label"), description: t("bluetooth.pairingMode.description"), disabledBy: [ { fieldName: "enabled", }, ], properties: { enumValue: Protobuf.Config.Config_BluetoothConfig_PairingMode, formatEnumName: true, }, }, { type: "number", name: "fixedPin", label: t("bluetooth.pin.label"), description: t("bluetooth.pin.description"), }, ], }, ]} /> ); };