diff --git a/src/pages/Dashboard.jsx b/src/pages/Dashboard.jsx
index 59ea946..59f2b4f 100755
--- a/src/pages/Dashboard.jsx
+++ b/src/pages/Dashboard.jsx
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react';
+import PageLayout from '../components/PageLayout';
const Dashboard = () => {
// Estados para armazenar os dados do dashboard
@@ -34,8 +35,7 @@ const Dashboard = () => {
}, []);
return (
-
-
Segurança
+
{/* Métodos de Autorização */}
@@ -94,7 +94,7 @@ const Security = () => {
-
+
);
};
diff --git a/src/pages/Settings.jsx b/src/pages/Settings.jsx
index 25df41a..e043751 100755
--- a/src/pages/Settings.jsx
+++ b/src/pages/Settings.jsx
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react';
+import PageLayout from '../components/PageLayout';
const Settings = () => {
// Estados para armazenar os valores dos sliders e caixas de entrada
@@ -7,6 +8,8 @@ const Settings = () => {
const [energyLimit, setEnergyLimit] = useState(0);
const [chargingTimeLimit, setChargingTimeLimit] = useState(0);
const [temperatureLimit, setTemperatureLimit] = useState(60);
+ const [msg, setMsg] = useState('');
+ const [error, setError] = useState('');
// Função para preencher os campos com os dados do servidor
const fetchSettings = async () => {
@@ -34,7 +37,8 @@ const Settings = () => {
const handleChargingTimeLimitChange = (e) => setChargingTimeLimit(e.target.value);
const handleTemperatureLimitChange = (e) => setTemperatureLimit(e.target.value);
- const handleSubmit = async () => {
+ const handleSubmit = async (e) => {
+ e.preventDefault();
const settingsData = {
currentLimit,
powerLimit,
@@ -43,70 +47,91 @@ const Settings = () => {
temperatureLimit,
};
- const response = await fetch('/api/v1/config/settings', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(settingsData),
- });
+ try {
+ const response = await fetch('/api/v1/config/settings', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(settingsData),
+ });
- if (response.ok) {
- alert('Configurações de energia atualizadas com sucesso!');
- } else {
- alert('Erro ao atualizar configurações');
+ if (response.ok) {
+ setMsg('Configurações de energia atualizadas com sucesso!');
+ } else {
+ setError('Erro ao atualizar configurações');
+ }
+ } catch {
+ setError('Erro ao atualizar configurações');
}
};
return (
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ {msg && {msg}
}
+ {error && {error}
}
+
+
+
);
};