admin/page.tsx (1019→446), search/page.tsx (871→304), imap/page.tsx (738→142), settings/page.tsx (641→56). Reine Umstrukturierung, keine Verhaltensänderung, Build verifiziert.
30 lines
742 B
TypeScript
30 lines
742 B
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
import { getSystemInfo, type SystemInfo } from "@/lib/api";
|
|
|
|
export function useSystemInfo() {
|
|
const [systemInfo, setSystemInfo] = useState<SystemInfo | null>(null);
|
|
const [systemInfoLoading, setSystemInfoLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
let cancelled = false;
|
|
setSystemInfoLoading(true);
|
|
getSystemInfo()
|
|
.then((info) => {
|
|
if (!cancelled) setSystemInfo(info);
|
|
})
|
|
.catch(() => {
|
|
if (!cancelled) setSystemInfo(null);
|
|
})
|
|
.finally(() => {
|
|
if (!cancelled) setSystemInfoLoading(false);
|
|
});
|
|
return () => {
|
|
cancelled = true;
|
|
};
|
|
}, []);
|
|
|
|
return { systemInfo, systemInfoLoading };
|
|
}
|