add module (#141)

This commit is contained in:
Ben Lipsey
2023-10-29 15:23:42 -07:00
committed by GitHub
parent 7256454ea7
commit a8c45ccb32
4 changed files with 79 additions and 3 deletions

View File

@@ -0,0 +1,51 @@
import { useDevice } from "@app/core/stores/deviceStore.js";
import type { NeighborInfoValidation } from "@app/validation/moduleConfig/neighborInfo.js";
import { DynamicForm } from "@components/Form/DynamicForm.js";
import { Protobuf } from "@meshtastic/meshtasticjs";
export const NeighborInfo = (): JSX.Element => {
const { moduleConfig, setWorkingModuleConfig } = useDevice();
const onSubmit = (data: NeighborInfoValidation) => {
setWorkingModuleConfig(
new Protobuf.ModuleConfig({
payloadVariant: {
case: "neighborInfo",
value: data,
},
}),
);
};
return (
<DynamicForm<NeighborInfoValidation>
onSubmit={onSubmit}
defaultValues={moduleConfig.neighborInfo}
fieldGroups={[
{
label: "Neighbor Info Settings",
description: "Settings for the Neighbor Info module",
fields: [
{
type: "toggle",
name: "enabled",
label: "Enabled",
description: "Enable or disable Neighbor Info Module",
},
{
type: "number",
name: "updateInterval",
label: "Update Interval",
description: "Interval in seconds of how often we should try to send our Neighbor Info to the mesh",
disabledBy: [
{
fieldName: "enabled",
},
],
},
],
},
]}
/>
);
};