Skip to content
Snippets Groups Projects
Commit 94d6a514 authored by LAFORÊT Nicolas's avatar LAFORÊT Nicolas :rabbit2:
Browse files

:sparkles: display correct subscription status

parent f9269905
Branches
1 merge request!7🔀 V1
......@@ -33,7 +33,7 @@ export function getUsers(): Promise<User[]> {
user.firstname,
user.email,
user.student_number,
true,
validateSubscriptionDate(user.date_subscription),
user.picture
));
resolve(usersArray);
......@@ -42,4 +42,12 @@ export function getUsers(): Promise<User[]> {
reject(error);
});
});
}
function validateSubscriptionDate(dateStr: string): boolean {
const YEAR_IN_MS = 31536000000;
const date = Date.parse(dateStr) ?? Date.parse('01 Jan 1970 00:00:00 GMT');
const now = Date.now();
// Valid subscription if it was made less than a year ago
return (now - date) < YEAR_IN_MS;
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment