storing changes, starting history list

This commit is contained in:
2025-09-15 10:27:31 +01:00
parent 7588326cbe
commit c414342515
12 changed files with 129 additions and 107 deletions

View File

@@ -1,57 +1,8 @@
import React from "react";
import Card from "../../UI/Card";
import CardHeader from "../../UI/CardHeader";
import { sendBlobFileUpload } from "./Upload";
import SystemConfigFields from "./SystemConfigFields.tsx";
const SystemCard = () => {
const [selectedFile, setSelectedFile] = React.useState<File | null>(null);
const [error, setError] = React.useState("");
// useEffect(() => {
// (async () => {
// const result = await handleSystemRecall(); // returns { deviceName, sntpServer, sntpInterval, timeZone } | null
// if (result) {
// const {
// deviceName: dn,
// sntpServer: ss,
// sntpInterval: si,
// timeZone: tz,
// } = result;
// setDeviceName(dn ?? "");
// setSntpServer(ss ?? "");
// setSntpInterval(Number.isFinite(si) ? si : 60);
// setTimeZone(tz ?? "UTC (UTC-00)");
// }
// })();
// }, []);
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault(); // prevent full page reload
if (!selectedFile) {
setError("Please select a file before uploading.");
return;
}
setError("");
const result = await sendBlobFileUpload(selectedFile, {
timeoutMs: 30000,
fieldName: "upload",
});
// The helper returns a string (either success body or formatted error)
// You can decide how to distinguish. Here, we show it optimistically and let the text speak.
if (
result.startsWith("Server returned") ||
result.startsWith("Timeout") ||
result.startsWith("HTTP error") ||
result.startsWith("Unexpected error")
) {
setError(result);
}
};
return (
<Card>
<CardHeader title={"System Config"} />