Add user management features.

This commit is contained in:
2025-05-14 18:49:49 +08:00
parent 3b7d52a7a8
commit 703812d3df
10 changed files with 447 additions and 40 deletions

View File

@@ -6,6 +6,7 @@ import Loading from "../components/loading.tsx";
import {MdAdd, MdDelete} from "react-icons/md";
import {ErrorAlert} from "../components/alert.tsx";
import { useTranslation } from "react-i18next";
import { app } from "../app.ts";
export default function StorageView() {
const { t } = useTranslation();
@@ -13,6 +14,9 @@ export default function StorageView() {
const [loadingId, setLoadingId] = useState<number | null>(null);
useEffect(() => {
if (app.user == null || !app.user.is_admin) {
return;
}
network.listStorages().then((response) => {
if (response.success) {
setStorages(response.data!);
@@ -25,6 +29,14 @@ export default function StorageView() {
})
}, []);
if (!app.user) {
return <ErrorAlert className={"m-4"} message={t("You are not logged in. Please log in to access this page.")}/>
}
if (!app.user?.is_admin) {
return <ErrorAlert className={"m-4"} message={t("You are not authorized to access this page.")}/>
}
if (storages == null) {
return <Loading/>
}