diff --git a/package.json b/package.json index ed0d75e..ed5eb90 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "in-car-system-fe", "private": true, - "version": "1.0.22", + "version": "1.0.23", "type": "module", "scripts": { "dev": "vite", diff --git a/src/components/SettingForms/Sound/SoundUpload.tsx b/src/components/SettingForms/Sound/SoundUpload.tsx index 09df9d8..1ce5a88 100644 --- a/src/components/SettingForms/Sound/SoundUpload.tsx +++ b/src/components/SettingForms/Sound/SoundUpload.tsx @@ -84,15 +84,23 @@ const SoundUpload = () => { if (currentUrlRef.current) { URL.revokeObjectURL(currentUrlRef.current); } - if (e.target?.files && e.target?.files[0]?.type === "audio/mpeg") { - currentUrlRef.current = URL.createObjectURL(e.target.files[0]); + const files = e.target?.files; + if ( + files && + (files[0]?.type === "audio/mp3" || + files[0]?.type === "audio/mpeg" || + files[0]?.name.endsWith(".wav")) + ) { + const file = e.target?.files; + if(file === null) return; + currentUrlRef.current = URL.createObjectURL(file[0]); const url = currentUrlRef.current; setFieldValue("soundUrl", url); - setFieldValue("name", e.target.files[0].name); - setFieldValue("soundFileName", e.target.files[0].name); - setFieldValue("soundFile", e.target.files[0]); + setFieldValue("name", file[0].name); + setFieldValue("soundFileName", file[0].name); + setFieldValue("soundFile", file[0]); setFieldValue("uploadedAt", Date.now()); - if (e?.target?.files[0]?.size >= 1 * 1024 * 1024) { + if (file[0]?.size >= 1 * 1024 * 1024) { setFieldError("soundFile", "larger than 1mb"); toast.error("File larger than 1MB"); return; diff --git a/src/components/SettingForms/System/SystemConfigFields.tsx b/src/components/SettingForms/System/SystemConfigFields.tsx index 225c9c9..c343c8a 100644 --- a/src/components/SettingForms/System/SystemConfigFields.tsx +++ b/src/components/SettingForms/System/SystemConfigFields.tsx @@ -5,16 +5,29 @@ import { timezones } from "./timezones"; import SystemFileUpload from "./SystemFileUpload"; import type { SystemValues, SystemValuesErrors } from "../../../types/types"; import { useDNSSettings, useSystemConfig } from "../../../hooks/useSystemConfig"; -import { ValidateIPaddress } from "../../../utils/utils"; +import { ValidateIPaddress, isUtcOutOfSync } from "../../../utils/utils"; import { toast } from "sonner"; -// import { useSystemStatus } from "../../../hooks/useSystemStatus"; +import { useSystemStatus } from "../../../hooks/useSystemStatus"; const SystemConfigFields = () => { const { saveSystemSettings, systemSettingsData, saveSystemSettingsLoading } = useSystemConfig(); - // const { systemStatusQuery } = useSystemStatus(); + const { systemStatusQuery } = useSystemStatus(); const { hardRebootMutation } = useReboots(); const { dnsQuery, dnsMutation } = useDNSSettings(); + if (systemStatusQuery?.isLoading || !systemStatusQuery?.data) { + return
Loading...
; + } + const utcTime = systemStatusQuery?.data?.SystemStatus?.utctime; + const localDate = systemStatusQuery?.data?.SystemStatus?.localdate; + const localTime = systemStatusQuery?.data?.SystemStatus?.localtime; + + const utcOutOfSync = isUtcOutOfSync({ + utctime: utcTime, + localdate: localDate, + localtime: localTime, + }); + const sntpInterval = systemSettingsData?.sntpInterval; const dnsPrimary = dnsQuery?.data?.propNameServerPrimary?.value; const dnsSecondary = dnsQuery?.data?.propNameServerSecondary?.value; @@ -71,6 +84,13 @@ const SystemConfigFields = () => { > {({ values, errors, touched, isSubmitting }) => (
+
+ {utcOutOfSync?.outOfSync ? ( + UTC is out of sync + ) : ( + UTC is in sync + )} +