- updated button to match
This commit is contained in:
@@ -7,8 +7,7 @@ import type { SystemValues, SystemValuesErrors } from "../../../types/types";
|
||||
import { useSystemConfig } from "../../../hooks/useSystemConfig";
|
||||
|
||||
const SystemConfigFields = () => {
|
||||
const { saveSystemSettings, systemSettingsData, saveSystemSettingsLoading } =
|
||||
useSystemConfig();
|
||||
const { saveSystemSettings, systemSettingsData, saveSystemSettingsLoading } = useSystemConfig();
|
||||
const { softRebootMutation, hardRebootMutation } = useReboots();
|
||||
|
||||
const initialvalues: SystemValues = {
|
||||
@@ -26,8 +25,7 @@ const SystemConfigFields = () => {
|
||||
const interval = Number(values.sntpInterval);
|
||||
if (!values.deviceName) errors.deviceName = "Required";
|
||||
if (!values.timeZone) errors.timeZone = "Required";
|
||||
if (isNaN(interval) || interval <= 0)
|
||||
errors.sntpInterval = "Cannot be less than 0";
|
||||
if (isNaN(interval) || interval <= 0) errors.sntpInterval = "Cannot be less than 0";
|
||||
if (!values.sntpServer) errors.sntpServer = "Required";
|
||||
return errors;
|
||||
};
|
||||
@@ -52,16 +50,11 @@ const SystemConfigFields = () => {
|
||||
{({ values, errors, touched, isSubmitting }) => (
|
||||
<Form className="flex flex-col space-y-5 px-2">
|
||||
<FormGroup>
|
||||
<label
|
||||
htmlFor="deviceName"
|
||||
className="font-medium whitespace-nowrap md:w-1/2 text-left"
|
||||
>
|
||||
<label htmlFor="deviceName" className="font-medium whitespace-nowrap md:w-1/2 text-left">
|
||||
Device Name
|
||||
</label>
|
||||
{touched.deviceName && errors.deviceName && (
|
||||
<small className="absolute right-0 -top-5 text-red-500">
|
||||
{errors.deviceName}
|
||||
</small>
|
||||
<small className="absolute right-0 -top-5 text-red-500">{errors.deviceName}</small>
|
||||
)}
|
||||
<Field
|
||||
id="deviceName"
|
||||
@@ -73,16 +66,11 @@ const SystemConfigFields = () => {
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label
|
||||
htmlFor="timeZone"
|
||||
className="font-medium whitespace-nowrap md:w-1/2 text-left"
|
||||
>
|
||||
<label htmlFor="timeZone" className="font-medium whitespace-nowrap md:w-1/2 text-left">
|
||||
Local Time Zone
|
||||
</label>
|
||||
{touched.timeZone && errors.timeZone && (
|
||||
<small className="absolute right-0 -top-5 text-red-500">
|
||||
{errors.timeZone}
|
||||
</small>
|
||||
<small className="absolute right-0 -top-5 text-red-500">{errors.timeZone}</small>
|
||||
)}
|
||||
<Field
|
||||
id="timeZone"
|
||||
@@ -99,16 +87,11 @@ const SystemConfigFields = () => {
|
||||
</Field>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label
|
||||
htmlFor="sntpServer"
|
||||
className="font-medium whitespace-nowrap md:w-1/2 text-left"
|
||||
>
|
||||
<label htmlFor="sntpServer" className="font-medium whitespace-nowrap md:w-1/2 text-left">
|
||||
SNTP Server
|
||||
</label>
|
||||
{touched.sntpServer && errors.sntpServer && (
|
||||
<small className="absolute right-0 -top-5 text-red-500">
|
||||
{errors.sntpServer}
|
||||
</small>
|
||||
<small className="absolute right-0 -top-5 text-red-500">{errors.sntpServer}</small>
|
||||
)}
|
||||
<Field
|
||||
id="sntpServer"
|
||||
@@ -120,16 +103,11 @@ const SystemConfigFields = () => {
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label
|
||||
htmlFor="sntpInterval"
|
||||
className="font-medium whitespace-nowrap md:w-1/2 text-left"
|
||||
>
|
||||
<label htmlFor="sntpInterval" className="font-medium whitespace-nowrap md:w-1/2 text-left">
|
||||
SNTP Interval minutes
|
||||
</label>
|
||||
{touched.sntpInterval && errors.sntpInterval && (
|
||||
<small className="absolute right-0 -top-5 text-red-500">
|
||||
{errors.sntpInterval}
|
||||
</small>
|
||||
<small className="absolute right-0 -top-5 text-red-500">{errors.sntpInterval}</small>
|
||||
)}
|
||||
<Field
|
||||
id="sntpInterval"
|
||||
@@ -142,15 +120,12 @@ const SystemConfigFields = () => {
|
||||
</FormGroup>
|
||||
<button
|
||||
type="submit"
|
||||
className="bg-[#26B170] text-white px-4 py-2 rounded hover:bg-green-700 transition w-full md:w-[50%]"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
{saveSystemSettingsLoading ? "Saving..." : "Save System Settings"}
|
||||
</button>
|
||||
<SystemFileUpload
|
||||
name={"softwareUpdate"}
|
||||
selectedFile={values.softwareUpdate}
|
||||
/>
|
||||
<SystemFileUpload name={"softwareUpdate"} selectedFile={values.softwareUpdate} />
|
||||
<div className="border-b border-gray-600">
|
||||
<p>Reboot</p>
|
||||
</div>
|
||||
@@ -160,18 +135,14 @@ const SystemConfigFields = () => {
|
||||
className="bg-red-600 text-white px-4 py-2 rounded hover:bg-red-700 transition w-full md:w-[50%]"
|
||||
onClick={handleSoftReboot}
|
||||
>
|
||||
{softRebootMutation.isPending || isSubmitting
|
||||
? "Rebooting..."
|
||||
: "Software Reboot"}
|
||||
{softRebootMutation.isPending || isSubmitting ? "Rebooting..." : "Software Reboot"}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="bg-red-600 text-white px-4 py-2 rounded hover:bg-red-700 transition w-full md:w-[50%]"
|
||||
onClick={handleHardReboot}
|
||||
>
|
||||
{hardRebootMutation.isPending || isSubmitting
|
||||
? "Rebooting"
|
||||
: "Hardware Reboot"}
|
||||
{hardRebootMutation.isPending || isSubmitting ? "Rebooting" : "Hardware Reboot"}
|
||||
</button>
|
||||
</Form>
|
||||
)}
|
||||
|
||||
@@ -36,7 +36,7 @@ const SystemFileUpload = ({ name, selectedFile }: SystemFileUploadProps) => {
|
||||
type="file"
|
||||
name="softwareUpdate"
|
||||
id="softwareUpdate"
|
||||
className="file:px-10 file:border file:border-gray-500 file:rounded-lg file:bg-blue-800 file:mr-5 w-full max-w-xs"
|
||||
className="mt-4 w-full flex flex-col items-center justify-center rounded-2xl border border-slate-800 bg-slate-900/40 p-10 text-center file:px-3 file:border file:border-gray-500 file:rounded-lg file:bg-blue-800 file:mr-5"
|
||||
onChange={(event) => {
|
||||
const file = event.currentTarget.files?.[0];
|
||||
if (!file) {
|
||||
@@ -44,8 +44,7 @@ const SystemFileUpload = ({ name, selectedFile }: SystemFileUploadProps) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (file?.size > 8 * 1024 * 1024)
|
||||
toast.error("File is too large (max 8MB).");
|
||||
if (file?.size > 8 * 1024 * 1024) toast.error("File is too large (max 8MB).");
|
||||
setFieldValue(name, file);
|
||||
}}
|
||||
/>
|
||||
@@ -53,7 +52,7 @@ const SystemFileUpload = ({ name, selectedFile }: SystemFileUploadProps) => {
|
||||
</FormGroup>
|
||||
<button
|
||||
type="button"
|
||||
className="w-full md:w-[50%] text-white bg-[#26B170] hover:bg-green-700 font-small rounded-lg text-sm px-2 py-2.5 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
disabled={!selectedFile}
|
||||
onClick={handleFileUploadClick}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user