diff --git a/app/components/device-detail/device-detail-box.tsx b/app/components/device-detail/device-detail-box.tsx index c88d1417..6570272f 100644 --- a/app/components/device-detail/device-detail-box.tsx +++ b/app/components/device-detail/device-detail-box.tsx @@ -358,6 +358,16 @@ export default function DeviceDetailBox() { title="Created At" text={format(new Date(data.device.createdAt), "PPP")} /> + {data.device.expiresAt && ( + <> + + + + )} {data.device.tags?.length > 0 && ( diff --git a/app/components/device/new/advanced-info.tsx b/app/components/device/new/advanced-info.tsx new file mode 100644 index 00000000..ba7019d2 --- /dev/null +++ b/app/components/device/new/advanced-info.tsx @@ -0,0 +1,246 @@ +import { useFormContext } from "react-hook-form"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "~/components/ui/card"; +import { Input } from "~/components/ui/input"; +import { Label } from "~/components/ui/label"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "~/components/ui/select"; +import { Switch } from "~/components/ui/switch"; +import { Textarea } from "~/components/ui/textarea"; + +export function AdvancedStep() { + const { register, setValue, watch, resetField } = useFormContext(); + + // Watch field states + const isMqttEnabled = watch("mqttEnabled") || false; + const isTtnEnabled = watch("ttnEnabled") || false; + + // Clear corresponding fields when disabling + const handleMqttToggle = (checked: boolean) => { + setValue("mqttEnabled", checked); + if (!checked) { + resetField("url"); + resetField("topic"); + resetField("messageFormat"); + resetField("decodeOptions"); + resetField("connectionOptions"); + } + }; + + const handleTtnToggle = (checked: boolean) => { + setValue("ttnEnabled", checked); + if (!checked) { + resetField("dev_id"); + resetField("app_id"); + resetField("profile"); + resetField("decodeOptions"); + resetField("port"); + } + }; + + const handleInputChange = ( + event: React.ChangeEvent, + ) => { + const { name, value } = event.target; + setValue(name, value); + }; + + const handleSelectChange = (field: string, value: string) => { + setValue(field, value); + }; + + return ( + <> + {/* MQTT Configuration */} + + + MQTT Configuration + + Configure your MQTT settings for data streaming + + + +
+ + +
+ + {isMqttEnabled && ( +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +