Updated the expiry date to show as red
This commit is contained in:
@@ -59,28 +59,28 @@ export default function CodeGenerator({user}: {user: User}) {
|
||||
{user && (
|
||||
<div className="grid -md:grid-cols-2 md:grid-cols-1 place-items-center 2xl:grid-cols-2 gap-4">
|
||||
<Button
|
||||
className="w-44 2xl:w-48"
|
||||
className="w-44 md:w-48"
|
||||
variant="outline"
|
||||
onClick={() => generateCode("student")}
|
||||
disabled={!PERMISSIONS.generateCode.student.includes(user.type) || (isExpiryDateEnabled && expiryDate === null)}>
|
||||
Student
|
||||
</Button>
|
||||
<Button
|
||||
className="w-44 2xl:w-48"
|
||||
className="w-44 md:w-48"
|
||||
variant="outline"
|
||||
onClick={() => generateCode("teacher")}
|
||||
disabled={!PERMISSIONS.generateCode.teacher.includes(user.type) || (isExpiryDateEnabled && expiryDate === null)}>
|
||||
Teacher
|
||||
</Button>
|
||||
<Button
|
||||
className="w-44 2xl:w-48"
|
||||
className="w-44 md:w-48"
|
||||
variant="outline"
|
||||
onClick={() => generateCode("corporate")}
|
||||
disabled={!PERMISSIONS.generateCode.corporate.includes(user.type) || (isExpiryDateEnabled && expiryDate === null)}>
|
||||
Admin
|
||||
</Button>
|
||||
<Button
|
||||
className="w-44 2xl:w-48"
|
||||
className="w-44 md:w-48"
|
||||
variant="outline"
|
||||
onClick={() => generateCode("owner")}
|
||||
disabled={!PERMISSIONS.generateCode.owner.includes(user.type) || (isExpiryDateEnabled && expiryDate === null)}>
|
||||
|
||||
@@ -69,8 +69,8 @@ export default function ExamLoader() {
|
||||
</RadioGroup.Option>
|
||||
))}
|
||||
</RadioGroup>
|
||||
<Input type="text" name="examId" onChange={setExamId} placeholder="Exam ID" className="-md:!w-full md:!w-44 2xl:!w-full" />
|
||||
<Button disabled={!selectedModule || !examId} isLoading={isLoading} className="-md:!w-full md:!w-44 2xl:!w-full">
|
||||
<Input type="text" name="examId" onChange={setExamId} placeholder="Exam ID" className="w-full" />
|
||||
<Button disabled={!selectedModule || !examId} isLoading={isLoading} className="w-full">
|
||||
Load Exam
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
@@ -28,6 +28,16 @@ export default function UserList({user, filter}: {user: User; filter?: (user: Us
|
||||
const {users, reload} = useUsers();
|
||||
const {groups} = useGroups(user ? user.id : undefined);
|
||||
|
||||
const expirationDateColor = (date: Date) => {
|
||||
const momentDate = moment(date);
|
||||
const today = moment(new Date());
|
||||
|
||||
if (today.isAfter(momentDate)) return "!text-mti-red-light font-bold line-through";
|
||||
if (today.add(1, "weeks").isAfter(momentDate)) return "!text-mti-red-light";
|
||||
if (today.add(2, "weeks").isAfter(momentDate)) return "!text-mti-rose-light";
|
||||
if (today.add(1, "months").isAfter(momentDate)) return "!text-mti-orange-light";
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (user && users) {
|
||||
const filterUsers =
|
||||
@@ -315,7 +325,11 @@ export default function UserList({user, filter}: {user: User; filter?: (user: Us
|
||||
<SorterArrow name="expiryDate" />
|
||||
</button>
|
||||
) as any,
|
||||
cell: (info) => (!info.getValue() ? "No expiry date" : moment(info.getValue()).format("DD/MM/YYYY")),
|
||||
cell: (info) => (
|
||||
<span className={clsx(info.getValue() ? expirationDateColor(moment(info.getValue()).toDate()) : "")}>
|
||||
{!info.getValue() ? "No expiry date" : moment(info.getValue()).format("DD/MM/YYYY")}
|
||||
</span>
|
||||
),
|
||||
}),
|
||||
columnHelper.accessor("isVerified", {
|
||||
header: (
|
||||
|
||||
Reference in New Issue
Block a user