diff --git a/src/components/CameraSettings/CameraSettingFields.tsx b/src/components/CameraSettings/CameraSettingFields.tsx index c69735e..c5e568b 100644 --- a/src/components/CameraSettings/CameraSettingFields.tsx +++ b/src/components/CameraSettings/CameraSettingFields.tsx @@ -4,23 +4,31 @@ import type { CameraSettingErrorValues, CameraSettingValues, } from "../../types/types"; +import { useMemo, useState } from "react"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faEye, faEyeSlash } from "@fortawesome/free-regular-svg-icons"; type CameraSettingsProps = { initialData: CameraConfig; - updateCameraConfig: (values: CameraSettingValues) => void; + updateCameraConfig: (values: CameraSettingValues) => Promise | void; }; const CameraSettingFields = ({ initialData, updateCameraConfig, }: CameraSettingsProps) => { - const initialValues: CameraSettingValues = { - friendlyName: initialData?.propLEDDriverControlURI?.value, - cameraAddress: "", - userName: "", - password: "", - id: initialData?.id, - }; + const [showPwd, setShowPwd] = useState(false); + + const initialValues = useMemo( + () => ({ + friendlyName: initialData?.propLEDDriverControlURI?.value ?? "", + cameraAddress: "", + userName: "", + password: "", + id: initialData?.id, + }), + [initialData?.id, initialData?.propLEDDriverControlURI?.value] + ); const validateValues = (values: CameraSettingValues) => { const errors: CameraSettingErrorValues = {}; @@ -34,7 +42,6 @@ const CameraSettingFields = ({ const handleSubmit = (values: CameraSettingValues) => { updateCameraConfig(values); - return; }; return ( @@ -43,6 +50,7 @@ const CameraSettingFields = ({ onSubmit={handleSubmit} validate={validateValues} validateOnChange={false} + enableReinitialize > {({ errors, touched }) => (
@@ -103,22 +111,30 @@ const CameraSettingFields = ({ {errors.password} )} - - +
+ + setShowPwd((s) => !s)} + icon={showPwd ? faEyeSlash : faEye} + /> +
- + + )} diff --git a/src/components/HistoryList/HistoryList.tsx b/src/components/HistoryList/HistoryList.tsx index af9a40d..580fc3d 100644 --- a/src/components/HistoryList/HistoryList.tsx +++ b/src/components/HistoryList/HistoryList.tsx @@ -6,16 +6,17 @@ import AlertItem from "./AlertItem"; const HistoryList = () => { const { state } = useAlertHitContext(); console.log(state); + return (
- {state?.alertList?.length >= 0 ? ( + {state?.alertList?.length > 0 ? ( state?.alertList?.map((alertItem, index) => ( )) ) : ( -

No Search results

+

No Alert results

)}
diff --git a/src/components/RearCameraOverview/RearCameraOverviewCard.tsx b/src/components/RearCameraOverview/RearCameraOverviewCard.tsx index 1e9f467..025e7b9 100644 --- a/src/components/RearCameraOverview/RearCameraOverviewCard.tsx +++ b/src/components/RearCameraOverview/RearCameraOverviewCard.tsx @@ -27,7 +27,6 @@ const RearCameraOverviewCard = ({ className }: CardProps) => {
- {/* */}
); diff --git a/src/components/SessionForm/HitSearchCard.tsx b/src/components/SessionForm/HitSearchCard.tsx index 151c9bf..e25fdd3 100644 --- a/src/components/SessionForm/HitSearchCard.tsx +++ b/src/components/SessionForm/HitSearchCard.tsx @@ -6,9 +6,8 @@ import { useState } from "react"; const SessionCard = () => { const [searchTerm, setSearchTerm] = useState(""); - const { state, disptach } = useAlertHitContext(); + const { dispatch } = useAlertHitContext(); - console.log(state); return ( @@ -27,16 +26,29 @@ const SessionCard = () => { type="text" className="p-2 border border-gray-400 rounded-lg w-full max-w-xs" placeholder="Enter VRM" + value={searchTerm} onChange={(e) => setSearchTerm(e.target.value)} /> + {searchTerm && ( + + )} ); diff --git a/src/components/SessionForm/SessionCard.tsx b/src/components/SessionForm/SessionCard.tsx index 76732c0..675094c 100644 --- a/src/components/SessionForm/SessionCard.tsx +++ b/src/components/SessionForm/SessionCard.tsx @@ -2,22 +2,29 @@ import Card from "../UI/Card"; import CardHeader from "../UI/CardHeader"; const SessionCard = () => { + function onStart(): void { + throw new Error("Function not implemented."); + } + return ( - +
-

Number of Vehicles:

-

Vehicles without Tax:

-

Vehicles without MOT:

-

Vehicles with NPED Cat A:

-

Vehicles with NPED Cat B:

-

Vehicles with NPED Cat C:

+ +
    +
  • Number of Vehicles:
  • +
  • Vehicles without Tax:
  • +
  • Vehicles without MOT:
  • +
  • Vehicles with NPED Cat A:
  • +
  • Vehicles with NPED Cat B:
  • +
  • Vehicles with NPED Cat C:
  • +
); diff --git a/src/components/SettingForms/Channel1-JSON/ChannelFields.tsx b/src/components/SettingForms/Channel1-JSON/ChannelFields.tsx index 3290afe..efe63ed 100644 --- a/src/components/SettingForms/Channel1-JSON/ChannelFields.tsx +++ b/src/components/SettingForms/Channel1-JSON/ChannelFields.tsx @@ -1,9 +1,12 @@ import { Field, useFormikContext } from "formik"; import FormGroup from "../components/FormGroup"; +import { useState } from "react"; +import { faEyeSlash, faEye } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; const ChannelFields = () => { useFormikContext(); - + const [showPwd, setShowPwd] = useState(false); return (
@@ -32,11 +35,17 @@ const ChannelFields = () => { + setShowPwd((s) => !s)} + icon={showPwd ? faEyeSlash : faEye} + /> diff --git a/src/components/SettingForms/NPED/NPEDFields.tsx b/src/components/SettingForms/NPED/NPEDFields.tsx index 9c3c10a..f086df6 100644 --- a/src/components/SettingForms/NPED/NPEDFields.tsx +++ b/src/components/SettingForms/NPED/NPEDFields.tsx @@ -3,14 +3,18 @@ import FormGroup from "../components/FormGroup"; import type { NPEDErrorValues, NPEDFieldType } from "../../../types/types"; import { useNPEDAuth } from "../../../hooks/useNPEDAuth"; import { toast } from "sonner"; +import { faEyeSlash, faEye } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { useState } from "react"; const NPEDFields = () => { + const [showPwd, setShowPwd] = useState(false); const { signIn, user, signOut } = useNPEDAuth(); const initialValues = user ? { username: user.propUsername.value, - password: "", + password: user.propPassword.value, clientId: user.propClientID.value, frontId: "NPED", rearId: "NPED", @@ -49,6 +53,7 @@ const NPEDFields = () => { initialValues={initialValues} onSubmit={handleSubmit} validate={validateValues} + enableReinitialize > {({ errors, touched }) => (
@@ -76,11 +81,17 @@ const NPEDFields = () => { )} + setShowPwd((s) => !s)} + icon={showPwd ? faEyeSlash : faEye} + /> diff --git a/src/components/SettingForms/System/SystemConfigFields.tsx b/src/components/SettingForms/System/SystemConfigFields.tsx index dd34af2..d0b3591 100644 --- a/src/components/SettingForms/System/SystemConfigFields.tsx +++ b/src/components/SettingForms/System/SystemConfigFields.tsx @@ -7,13 +7,13 @@ import type { SystemValues, SystemValuesErrors } from "../../../types/types"; import { useSystemConfig } from "../../../hooks/useSystemConfig"; const SystemConfigFields = () => { - const { saveSystemSettings, getSystemSettingsData } = useSystemConfig(); - console.log(getSystemSettingsData); + const { saveSystemSettings, systemSettingsData } = useSystemConfig(); + const initialvalues: SystemValues = { - deviceName: "", - timeZone: "", - sntpServer: "", - sntpInterval: 60, + deviceName: systemSettingsData?.deviceName ?? "", + timeZone: systemSettingsData?.timeZone ?? "", + sntpServer: systemSettingsData?.sntpServer ?? "", + sntpInterval: systemSettingsData?.sntpInterval ?? 60, softwareUpdate: null, }; @@ -34,6 +34,9 @@ const SystemConfigFields = () => { initialValues={initialvalues} onSubmit={handleSubmit} validate={validateValues} + enableReinitialize + validateOnChange + validateOnBlur > {({ values, errors, touched }) => ( @@ -55,6 +58,7 @@ const SystemConfigFields = () => { type="text" className="p-2 border border-gray-400 rounded-lg w-full max-w-xs" placeholder="Enter device name" + autoComplete="off" /> @@ -75,6 +79,7 @@ const SystemConfigFields = () => { as="select" className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] w-full max-w-xs" > + {timezones.map((timezone) => ( @@ -119,6 +125,7 @@ const SystemConfigFields = () => { name="sntpInterval" type="number" min={1} + inputMode="numeric" className="p-2 border border-gray-400 rounded-lg w-full max-w-xs" /> @@ -133,12 +140,14 @@ const SystemConfigFields = () => { selectedFile={values.softwareUpdate} />