3 changed files with 123 additions and 5 deletions
@ -1,7 +1,44 @@ |
|||
import type React from "react"; |
|||
|
|||
import { Pane } from "evergreen-ui"; |
|||
import { CogIcon, Dialog, Text } from "evergreen-ui"; |
|||
|
|||
export const HelpDialog = (): JSX.Element => { |
|||
return <Pane></Pane>; |
|||
import { TabbedContent, TabType } from "../layout/page/TabbedContent.js"; |
|||
|
|||
export interface HelpDialogProps { |
|||
isOpen: boolean; |
|||
close: () => void; |
|||
} |
|||
|
|||
export const HelpDialog = ({ isOpen, close }: HelpDialogProps): JSX.Element => { |
|||
const tabs: TabType[] = [ |
|||
{ |
|||
name: "Device Config", |
|||
icon: CogIcon, |
|||
element: () => ( |
|||
<div> |
|||
<Text>Title</Text> |
|||
</div> |
|||
), |
|||
}, |
|||
{ |
|||
name: "Device Config", |
|||
icon: CogIcon, |
|||
element: () => ( |
|||
<div> |
|||
<Text>Title 2</Text> |
|||
</div> |
|||
), |
|||
}, |
|||
]; |
|||
|
|||
return ( |
|||
<Dialog |
|||
isShown={isOpen} |
|||
onCloseComplete={close} |
|||
title="Meshtastic Web Help" |
|||
hasFooter={true} |
|||
> |
|||
<TabbedContent direction="vertical" tabs={tabs} /> |
|||
</Dialog> |
|||
); |
|||
}; |
|||
|
|||
@ -0,0 +1,68 @@ |
|||
import type React from "react"; |
|||
import { useEffect, useState } from "react"; |
|||
|
|||
import { Dialog, SelectField } from "evergreen-ui"; |
|||
import { useForm } from "react-hook-form"; |
|||
|
|||
import { LoRaValidation } from "@app/validation/config/lora.js"; |
|||
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"; |
|||
|
|||
import { Form } from "../form/Form.js"; |
|||
|
|||
export interface RegionDialogProps { |
|||
isOpen: boolean; |
|||
} |
|||
|
|||
export const RegionDialog = ({ isOpen }: RegionDialogProps): JSX.Element => { |
|||
const { config, connection } = useDevice(); |
|||
const [loading, setLoading] = useState(false); |
|||
const { |
|||
register, |
|||
handleSubmit, |
|||
formState: { errors, isDirty }, |
|||
reset, |
|||
} = useForm<LoRaValidation>({ |
|||
defaultValues: config.lora, |
|||
resolver: classValidatorResolver(LoRaValidation), |
|||
}); |
|||
|
|||
useEffect(() => { |
|||
reset(config.lora); |
|||
}, [reset, config.lora]); |
|||
|
|||
const onSubmit = handleSubmit((data) => { |
|||
setLoading(true); |
|||
void connection?.setConfig( |
|||
{ |
|||
payloadVariant: { |
|||
oneofKind: "lora", |
|||
lora: data, |
|||
}, |
|||
}, |
|||
async () => { |
|||
reset({ ...data }); |
|||
setLoading(false); |
|||
await Promise.resolve(); |
|||
} |
|||
); |
|||
}); |
|||
|
|||
return ( |
|||
<Dialog isShown={isOpen} title="Generate QR Code" hasFooter={false}> |
|||
<Form loading={loading} dirty={isDirty} onSubmit={onSubmit}> |
|||
<SelectField |
|||
label="Region" |
|||
description="This is a description." |
|||
isInvalid={!!errors.region?.message} |
|||
validationMessage={errors.region?.message} |
|||
{...register("region", { valueAsNumber: true })} |
|||
> |
|||
{renderOptions(Protobuf.Config_LoRaConfig_RegionCode)} |
|||
</SelectField> |
|||
</Form> |
|||
</Dialog> |
|||
); |
|||
}; |
|||
Loading…
Reference in new issue