mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
upgrading to react 18
This commit is contained in:
@@ -18,9 +18,12 @@ const Users = function Users() {
|
||||
const [userIdToBeRemoved, setUserIdToBeRemoved] = React.useState(null);
|
||||
const history = useHistory();
|
||||
|
||||
React.useEffect(async () => {
|
||||
await dispatch.user.getUsers();
|
||||
setLoading(false);
|
||||
React.useEffect(() => {
|
||||
async function init() {
|
||||
await dispatch.user.getUsers();
|
||||
setLoading(false);
|
||||
}
|
||||
init();
|
||||
}, []);
|
||||
|
||||
const onUserRemoval = async () => {
|
||||
|
||||
@@ -21,21 +21,24 @@ const UserMutator = function UserMutator() {
|
||||
const ctx = React.useContext(ToastContext);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
React.useEffect(async () => {
|
||||
if (params.userId != null) {
|
||||
try {
|
||||
const userJson = await xhrGet(`/api/admin/users/${params.userId}`);
|
||||
const user = userJson.json;
|
||||
React.useEffect(() => {
|
||||
async function init() {
|
||||
if (params.userId != null) {
|
||||
try {
|
||||
const userJson = await xhrGet(`/api/admin/users/${params.userId}`);
|
||||
const user = userJson.json;
|
||||
|
||||
const defaultName = user?.username || '';
|
||||
const defaultIsAdmin = user?.isAdmin || false;
|
||||
const defaultName = user?.username || '';
|
||||
const defaultIsAdmin = user?.isAdmin || false;
|
||||
|
||||
setUsername(defaultName);
|
||||
setIsAdmin(defaultIsAdmin);
|
||||
} catch (Exception) {
|
||||
console.error(Exception);
|
||||
setUsername(defaultName);
|
||||
setIsAdmin(defaultIsAdmin);
|
||||
} catch (Exception) {
|
||||
console.error(Exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
init();
|
||||
}, [params.userId]);
|
||||
|
||||
const saveUser = async () => {
|
||||
|
||||
Reference in New Issue
Block a user