From 9c3ef55727968cc1e37380d976b95c63b4593963 Mon Sep 17 00:00:00 2001 From: Hunter Thornsberry Date: Sat, 8 Jun 2024 16:25:09 -0400 Subject: [PATCH] added toggle to edit query string --- src/components/Dialog/QRDialog.tsx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/Dialog/QRDialog.tsx b/src/components/Dialog/QRDialog.tsx index 38d72895..1fbc1b72 100644 --- a/src/components/Dialog/QRDialog.tsx +++ b/src/components/Dialog/QRDialog.tsx @@ -12,7 +12,7 @@ import { Input } from "@components/UI/Input.js"; import { Label } from "@components/UI/Label.js"; import { Protobuf, Types } from "@meshtastic/js"; import { fromByteArray } from "base64-js"; -import { ClipboardIcon, ReplaceIcon } from "lucide-react"; +import { ClipboardIcon, PlusIcon, ReplaceIcon } from "lucide-react"; import { useEffect, useState } from "react"; import { QRCode } from "react-qrcode-logo"; import { DynamicForm } from "../Form/DynamicForm"; @@ -36,17 +36,10 @@ export const QRDialog = ({ }: QRDialogProps): JSX.Element => { const [selectedChannels, setSelectedChannels] = useState([0]); const [qrCodeUrl, setQrCodeUrl] = useState(""); + const [qrCodeAdd, setQrCodeAdd] = useState(); const allChannels = Array.from(channels.values()); - const { register, handleSubmit, control } = useForm<{ - replace: boolean; - }>({ - defaultValues: { - replace: true, - }, - }); - useEffect(() => { const channelsToEncode = allChannels .filter((ch) => selectedChannels.includes(ch.index)) @@ -63,8 +56,9 @@ export const QRDialog = ({ .replace(/\+/g, "-") .replace(/\//g, "_"); - setQrCodeUrl(`https://meshtastic.org/e/#${base64}`); - }, [channels, selectedChannels, loraConfig]); + console.log("here ran"); + setQrCodeUrl(`https://meshtastic.org/e/#${base64}${qrCodeAdd ? "?add=true" : ""}`); + }, [channels, selectedChannels, qrCodeAdd, loraConfig]); return ( @@ -110,11 +104,17 @@ export const QRDialog = ({