Solved issues related to the build
This commit is contained in:
@@ -24,7 +24,7 @@ export default function BatchCodeGenerator({user}: {user: User}) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (user.type === "admin" || user.type === "teacher") {
|
if (user && (user.type === "admin" || user.type === "teacher")) {
|
||||||
setExpiryDate(user.subscriptionExpirationDate || null);
|
setExpiryDate(user.subscriptionExpirationDate || null);
|
||||||
}
|
}
|
||||||
}, [user]);
|
}, [user]);
|
||||||
@@ -83,7 +83,7 @@ export default function BatchCodeGenerator({user}: {user: User}) {
|
|||||||
<Button onClick={openFilePicker} isLoading={isLoading} disabled={isLoading}>
|
<Button onClick={openFilePicker} isLoading={isLoading} disabled={isLoading}>
|
||||||
{filesContent.length > 0 ? filesContent[0].name : "Choose a file"}
|
{filesContent.length > 0 ? filesContent[0].name : "Choose a file"}
|
||||||
</Button>
|
</Button>
|
||||||
{(user.type === "developer" || user.type === "owner") && (
|
{user && (user.type === "developer" || user.type === "owner") && (
|
||||||
<>
|
<>
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<label className="font-normal text-base text-mti-gray-dim">Expiry Date</label>
|
<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>
|
<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">
|
<div className="grid grid-cols-2 gap-4">
|
||||||
<Button
|
<Button
|
||||||
className="w-48"
|
className="w-48"
|
||||||
@@ -137,6 +138,7 @@ export default function BatchCodeGenerator({user}: {user: User}) {
|
|||||||
Owner
|
Owner
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export default function CodeGenerator({user}: {user: User}) {
|
|||||||
const [isExpiryDateEnabled, setIsExpiryDateEnabled] = useState(true);
|
const [isExpiryDateEnabled, setIsExpiryDateEnabled] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (user.type === "admin" || user.type === "teacher") {
|
if (user && (user.type === "admin" || user.type === "teacher")) {
|
||||||
setExpiryDate(user.subscriptionExpirationDate || null);
|
setExpiryDate(user.subscriptionExpirationDate || null);
|
||||||
}
|
}
|
||||||
}, [user]);
|
}, [user]);
|
||||||
@@ -56,6 +56,7 @@ export default function CodeGenerator({user}: {user: User}) {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-4 border p-4 border-mti-gray-platinum rounded-xl">
|
<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>
|
<label className="font-normal text-base text-mti-gray-dim">User Code Generator</label>
|
||||||
|
{user && (
|
||||||
<div className="grid grid-cols-2 gap-4">
|
<div className="grid grid-cols-2 gap-4">
|
||||||
<Button
|
<Button
|
||||||
className="w-48"
|
className="w-48"
|
||||||
@@ -86,7 +87,8 @@ export default function CodeGenerator({user}: {user: User}) {
|
|||||||
Owner
|
Owner
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{(user.type === "developer" || user.type === "owner") && (
|
)}
|
||||||
|
{user && (user.type === "developer" || user.type === "owner") && (
|
||||||
<>
|
<>
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<label className="font-normal text-base text-mti-gray-dim">Expiry Date</label>
|
<label className="font-normal text-base text-mti-gray-dim">Expiry Date</label>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default function UserList({user}: {user: User}) {
|
|||||||
const [showDemographicInformation, setShowDemographicInformation] = useState(false);
|
const [showDemographicInformation, setShowDemographicInformation] = useState(false);
|
||||||
|
|
||||||
const {users, reload} = useUsers();
|
const {users, reload} = useUsers();
|
||||||
const {groups} = useGroups(user.id);
|
const {groups} = useGroups(user ? user.id : undefined);
|
||||||
|
|
||||||
const deleteAccount = (user: User) => {
|
const deleteAccount = (user: User) => {
|
||||||
if (!confirm(`Are you sure you want to delete ${user.name}'s account?`)) return;
|
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({
|
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,
|
columns: (!showDemographicInformation ? defaultColumns : demographicColumns) as any,
|
||||||
getCoreRowModel: getCoreRowModel(),
|
getCoreRowModel: getCoreRowModel(),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user