diff --git a/src/pages/Users.js b/src/pages/Users.js
index 6c624d8..29a8138 100644
--- a/src/pages/Users.js
+++ b/src/pages/Users.js
@@ -1,9 +1,209 @@
-import React from "react";
+import React, { useEffect, useState } from "react";
+import { Route, Routes, useNavigate, useParams } from "react-router";
+import ErrorBoundary from "../util/ErrorBoundary";
+import { get } from '../util/Util';
+import '../css/pages/Users.css';
+
+const Permission = ({name, value}) => {
+ return
+
+
+ ;
+};
+
+const PermissionGroup = ({ name, value }) => {
+ const elements = [];
+
+ for (const [perm, val] of Object.entries(value)) {
+ const props = { key: perm, name: perm, value: val };
+ if(typeof val ==='object') elements.push();
+ else elements.push();
+ }
+ return
+ Group: {name}
+
+ ;
+};
+
+const Permissions = ({ perms }) => {
+
+ const elements = [];
+ const keys = Object.keys(perms);
+ for (const perm of keys) {
+ const props = { key: perm, name: perm, value: perms[perm] };
+ let Elem = null;
+ switch (typeof perms[perm]) {
+ case 'number':
+ Elem = Permission;
+ break;
+ case 'object':
+ Elem = PermissionGroup;
+ break;
+ default:
+ // eslint-disable-next-line react/display-name
+ Elem = () => {
+ return Uknown permission structure
;
+ };
+ break;
+ }
+ elements.push();
+ }
+
+ return ;
+};
+
+// TODO: Make generic table list component and use it here and the user list
+const ApplicationList = ({ apps }) => {
+
+
+};
+
+const Application = ({ app }) => {
+
+
+};
+
+const User = ({ user }) => {
+
+ const navigate = useNavigate();
+ const [apps, updateApps] = useState([]);
+
+ useEffect(() => {
+ (async () => {
+ const response = await get(`/api/users/${user._id}/applications`);
+ if(response.status === 200) updateApps(response.data);
+ })();
+ }, [user]);
+
+ return
+
+
+
+
+
+
User {user._id}
+
+
+
+
+
+
+
+
+
+
Applications
+
+ } />
+
+ {apps.map(app =>
)}
+
+
+
+
+
+
+
+
+
;
+};
+
+const UserListEntry = ({ user }) => {
+
+ const navigate = useNavigate();
+
+ const onClick = () => {
+ navigate(`/users/${user._id}`);
+ };
+
+ return
+ {user.username} |
+ {user._id} |
+
;
+
+};
+
+// TODO: Make table list generic component
+const UserList = ({ users }) => {
+
+ return
+
+
+ Username |
+ ID |
+
+
+
+ {users.map(user => )}
+
+
;
+
+};
const Users = () => {
- return
- USERS
+ const [users, setUsers] = useState([]);
+ const [page, setPage] = useState(1);
+ const [error, setError] = useState(null);
+
+ useEffect(() => {
+ (async () => {
+ const result = await get('/api/users', { page });
+ if (result.success) {
+ setError(null);
+ setUsers(result.data);
+ } else setError(result.message);
+ })();
+ }, [page]);
+
+ const UserWrapper = () => {
+ const { id } = useParams();
+ const user = users.find(u => u._id === id);
+ if (!user) return null;
+ return
;
+ };
+
+ const UserListWrapper = () => {
+ return
+
+
+
+
Page: {page}
+
+
+
;
+ };
+
+ return
+
USERS
+ {error &&
{error}
}
+
+
+
+
+ } />
+ } />
+
+
+
+
;
};