You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.8 KiB
95 lines
2.8 KiB
import {
|
|
type StoreForwardValidation,
|
|
StoreForwardValidationSchema,
|
|
} from "@app/validation/moduleConfig/storeForward.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 StoreForward = () => {
|
|
const { moduleConfig, setWorkingModuleConfig } = useDevice();
|
|
const { t } = useTranslation("moduleConfig");
|
|
|
|
const onSubmit = (data: StoreForwardValidation) => {
|
|
setWorkingModuleConfig(
|
|
create(Protobuf.ModuleConfig.ModuleConfigSchema, {
|
|
payloadVariant: {
|
|
case: "storeForward",
|
|
value: data,
|
|
},
|
|
}),
|
|
);
|
|
};
|
|
|
|
return (
|
|
<DynamicForm<StoreForwardValidation>
|
|
onSubmit={onSubmit}
|
|
validationSchema={StoreForwardValidationSchema}
|
|
formId="ModuleConfig_StoreForwardConfig"
|
|
defaultValues={moduleConfig.storeForward}
|
|
fieldGroups={[
|
|
{
|
|
label: t("storeForward.title"),
|
|
description: t("storeForward.description"),
|
|
fields: [
|
|
{
|
|
type: "toggle",
|
|
name: "enabled",
|
|
label: t("storeForward.enabled.label"),
|
|
description: t("storeForward.enabled.description"),
|
|
},
|
|
{
|
|
type: "toggle",
|
|
name: "heartbeat",
|
|
label: t("storeForward.heartbeat.label"),
|
|
description: t("storeForward.heartbeat.description"),
|
|
disabledBy: [
|
|
{
|
|
fieldName: "enabled",
|
|
},
|
|
],
|
|
},
|
|
{
|
|
type: "number",
|
|
name: "records",
|
|
label: t("storeForward.records.label"),
|
|
description: t("storeForward.records.description"),
|
|
disabledBy: [
|
|
{
|
|
fieldName: "enabled",
|
|
},
|
|
],
|
|
properties: {
|
|
suffix: t("unit.record.plural"),
|
|
},
|
|
},
|
|
{
|
|
type: "number",
|
|
name: "historyReturnMax",
|
|
label: t("storeForward.historyReturnMax.label"),
|
|
description: t("storeForward.historyReturnMax.description"),
|
|
disabledBy: [
|
|
{
|
|
fieldName: "enabled",
|
|
},
|
|
],
|
|
},
|
|
{
|
|
type: "number",
|
|
name: "historyReturnWindow",
|
|
label: t("storeForward.historyReturnWindow.label"),
|
|
description: t("storeForward.historyReturnWindow.description"),
|
|
disabledBy: [
|
|
{
|
|
fieldName: "enabled",
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
]}
|
|
/>
|
|
);
|
|
};
|
|
|