refactor, security updates, cv extraction upgrades
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
import { Box, Button, Paper, TextField, Typography } from "@mui/material";
|
||||
|
||||
import { api } from "../api";
|
||||
import { getAuthToken } from "../auth";
|
||||
import { useToast } from "../toast";
|
||||
import { useDialogActions } from "../dialogs";
|
||||
import { useI18n } from "../i18n/I18nProvider";
|
||||
@@ -20,7 +19,6 @@ export default function UserManagementCard() {
|
||||
const { toast } = useToast();
|
||||
const { confirmAction } = useDialogActions();
|
||||
const { t } = useI18n();
|
||||
const token = getAuthToken();
|
||||
|
||||
const [supported, setSupported] = useState<boolean | null>(null);
|
||||
const [users, setUsers] = useState<UserDto[]>([]);
|
||||
@@ -30,8 +28,6 @@ export default function UserManagementCard() {
|
||||
const [newPassword, setNewPassword] = useState("");
|
||||
const [newIsAdmin, setNewIsAdmin] = useState(false);
|
||||
|
||||
const canRender = useMemo(() => Boolean(token), [token]);
|
||||
|
||||
async function load() {
|
||||
setLoading(true);
|
||||
try {
|
||||
@@ -52,17 +48,15 @@ export default function UserManagementCard() {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!canRender) {
|
||||
setSupported(null);
|
||||
setUsers([]);
|
||||
return;
|
||||
}
|
||||
void load();
|
||||
const onAuthChanged = () => { void load(); };
|
||||
window.addEventListener("auth-changed", onAuthChanged);
|
||||
return () => window.removeEventListener("auth-changed", onAuthChanged);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [canRender]);
|
||||
}, []);
|
||||
|
||||
if (!canRender) return null;
|
||||
if (supported === false) return null;
|
||||
if (supported === null) return null;
|
||||
|
||||
return (
|
||||
<Paper sx={{ mt: 2, p: 2 }}>
|
||||
|
||||
Reference in New Issue
Block a user