From 903b856303d213ecae45509794753381fff01118 Mon Sep 17 00:00:00 2001 From: Toba Ojo Date: Tue, 11 Nov 2025 12:37:28 +0000 Subject: [PATCH] added wifi validation --- .../WiFi&Modem/WiFiSettingsForm.tsx | 127 ++++++++++-------- 1 file changed, 70 insertions(+), 57 deletions(-) diff --git a/src/components/SettingForms/WiFi&Modem/WiFiSettingsForm.tsx b/src/components/SettingForms/WiFi&Modem/WiFiSettingsForm.tsx index aa2aa71..457482f 100644 --- a/src/components/SettingForms/WiFi&Modem/WiFiSettingsForm.tsx +++ b/src/components/SettingForms/WiFi&Modem/WiFiSettingsForm.tsx @@ -5,6 +5,7 @@ import { useWifiAndModem } from "../../../hooks/useCameraWifiandModem"; import { useState } from "react"; import { faEyeSlash, faEye } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { toast, Toaster } from "sonner"; const WiFiSettingsForm = () => { const [showPwd, setShowPwd] = useState(false); @@ -19,6 +20,13 @@ const WiFiSettingsForm = () => { encryption: "WPA2", }; + const validatePassword = (password: string) => { + if (password.length < 8) { + toast.error("Password must be at least 8 characters long", { id: "password" }); + return "Password must be at least 8 characters long"; + } + }; + const handleSubmit = async (values: WifiSettingValues) => { const wifiConfig = { id: "ModemAndWifiManager-wifi", @@ -37,66 +45,71 @@ const WiFiSettingsForm = () => { await wifiMutation.mutateAsync(wifiConfig); }; return ( - - {({ isSubmitting }) => ( -
- - - - - - -
+ <> + + {({ isSubmitting }) => ( + + + - setShowPwd((s) => !s)} - icon={showPwd ? faEyeSlash : faEye} - /> -
-
- - - + + +
+ + + setShowPwd((s) => !s)} + icon={showPwd ? faEyeSlash : faEye} + /> +
+
+ + + + + + + + + + - - )} -
+ {isSubmitting || wifiMutation.isPending ? "Saving..." : " Save WiFi settings"} + + + )} + + + ); };