diff --git a/src/pages/(admin)/BatchCodeGenerator.tsx b/src/pages/(admin)/BatchCodeGenerator.tsx
index 5c961f16..0e079fef 100644
--- a/src/pages/(admin)/BatchCodeGenerator.tsx
+++ b/src/pages/(admin)/BatchCodeGenerator.tsx
@@ -24,7 +24,7 @@ export default function BatchCodeGenerator({user}: {user: User}) {
});
useEffect(() => {
- if (user.type === "admin" || user.type === "teacher") {
+ if (user && (user.type === "admin" || user.type === "teacher")) {
setExpiryDate(user.subscriptionExpirationDate || null);
}
}, [user]);
@@ -83,7 +83,7 @@ export default function BatchCodeGenerator({user}: {user: User}) {
- {(user.type === "developer" || user.type === "owner") && (
+ {user && (user.type === "developer" || user.type === "owner") && (
<>
@@ -107,36 +107,38 @@ export default function BatchCodeGenerator({user}: {user: User}) {
>
)}
-
-
-
-
-
-
+ {user && (
+
+
+
+
+
+
+ )}
);
}
diff --git a/src/pages/(admin)/CodeGenerator.tsx b/src/pages/(admin)/CodeGenerator.tsx
index cd80729d..b13480c0 100644
--- a/src/pages/(admin)/CodeGenerator.tsx
+++ b/src/pages/(admin)/CodeGenerator.tsx
@@ -17,7 +17,7 @@ export default function CodeGenerator({user}: {user: User}) {
const [isExpiryDateEnabled, setIsExpiryDateEnabled] = useState(true);
useEffect(() => {
- if (user.type === "admin" || user.type === "teacher") {
+ if (user && (user.type === "admin" || user.type === "teacher")) {
setExpiryDate(user.subscriptionExpirationDate || null);
}
}, [user]);
@@ -56,37 +56,39 @@ export default function CodeGenerator({user}: {user: User}) {
return (
-
-
-
-
-
-
- {(user.type === "developer" || user.type === "owner") && (
+ {user && (
+
+
+
+
+
+
+ )}
+ {user && (user.type === "developer" || user.type === "owner") && (
<>
diff --git a/src/pages/(admin)/Lists/UserList.tsx b/src/pages/(admin)/Lists/UserList.tsx
index 7ade2583..97a18538 100644
--- a/src/pages/(admin)/Lists/UserList.tsx
+++ b/src/pages/(admin)/Lists/UserList.tsx
@@ -21,7 +21,7 @@ export default function UserList({user}: {user: User}) {
const [showDemographicInformation, setShowDemographicInformation] = useState(false);
const {users, reload} = useUsers();
- const {groups} = useGroups(user.id);
+ const {groups} = useGroups(user ? user.id : undefined);
const deleteAccount = (user: User) => {
if (!confirm(`Are you sure you want to delete ${user.name}'s account?`)) return;
@@ -245,7 +245,10 @@ export default function UserList({user}: {user: User}) {
];
const table = useReactTable({
- data: user.type === "admin" || user.type === "student" ? users.filter((u) => groups.flatMap((g) => g.participants).includes(u.id)) : users,
+ data:
+ user && (user.type === "admin" || user.type === "student")
+ ? users.filter((u) => groups.flatMap((g) => g.participants).includes(u.id))
+ : users,
columns: (!showDemographicInformation ? defaultColumns : demographicColumns) as any,
getCoreRowModel: getCoreRowModel(),
});