Solved issues related to the build

This commit is contained in:
Tiago Ribeiro
2023-10-13 13:53:18 +01:00
parent ca96b37303
commit 348a020e7f
3 changed files with 73 additions and 66 deletions

View File

@@ -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}) {
<Button onClick={openFilePicker} isLoading={isLoading} disabled={isLoading}>
{filesContent.length > 0 ? filesContent[0].name : "Choose a file"}
</Button>
{(user.type === "developer" || user.type === "owner") && (
{user && (user.type === "developer" || user.type === "owner") && (
<>
<div className="flex items-center justify-between">
<label className="font-normal text-base text-mti-gray-dim">Expiry Date</label>
@@ -107,6 +107,7 @@ export default function BatchCodeGenerator({user}: {user: User}) {
</>
)}
<label className="font-normal text-base text-mti-gray-dim">Select the type of user they should be</label>
{user && (
<div className="grid grid-cols-2 gap-4">
<Button
className="w-48"
@@ -137,6 +138,7 @@ export default function BatchCodeGenerator({user}: {user: User}) {
Owner
</Button>
</div>
)}
</div>
);
}

View File

@@ -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,6 +56,7 @@ export default function CodeGenerator({user}: {user: User}) {
return (
<div className="flex flex-col gap-4 border p-4 border-mti-gray-platinum rounded-xl">
<label className="font-normal text-base text-mti-gray-dim">User Code Generator</label>
{user && (
<div className="grid grid-cols-2 gap-4">
<Button
className="w-48"
@@ -86,7 +87,8 @@ export default function CodeGenerator({user}: {user: User}) {
Owner
</Button>
</div>
{(user.type === "developer" || user.type === "owner") && (
)}
{user && (user.type === "developer" || user.type === "owner") && (
<>
<div className="flex items-center justify-between">
<label className="font-normal text-base text-mti-gray-dim">Expiry Date</label>

View File

@@ -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(),
});