From 930c4ef56ec978e69c1bf8cfa7f12b45aea56eb0 Mon Sep 17 00:00:00 2001 From: Araozu Date: Wed, 22 Nov 2023 10:00:48 -0500 Subject: [PATCH] [FE][Classroom] Fixes #19 - Show when an account is expired --- .../ClassroomUserInfo/AccountExpiration.tsx | 30 ++++++++++++++++--- frontend/src/icons/WarningIcon.tsx | 15 ++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 frontend/src/icons/WarningIcon.tsx diff --git a/frontend/src/OnlineClassroom/ClassroomUserInfo/AccountExpiration.tsx b/frontend/src/OnlineClassroom/ClassroomUserInfo/AccountExpiration.tsx index a86a782..8f78a7e 100644 --- a/frontend/src/OnlineClassroom/ClassroomUserInfo/AccountExpiration.tsx +++ b/frontend/src/OnlineClassroom/ClassroomUserInfo/AccountExpiration.tsx @@ -1,10 +1,11 @@ import { Show, createMemo, createSignal, onMount } from "solid-js"; import { OutlinedCard } from "../../components/OutlinedCard"; -import { LoadingStatus, backend, useLoading } from "../../utils/functions"; +import { LoadingStatus, backend, formatDate, useLoading } from "../../utils/functions"; import { LoadingIcon } from "../../icons/LoadingIcon"; import { ArrowsClockwiseIcon } from "../../icons/ArrowsClockwiseIcon"; import { JsonResult } from "../../types/JsonResult"; import { AxiosError } from "axios"; +import { WarningIcon } from "../../icons/WarningIcon"; export function AccountExpiration(props: {userId: number}) { const [expirationDate, setExpirationDate] = createSignal(null); // YYYY-MM-DD @@ -12,6 +13,17 @@ export function AccountExpiration(props: {userId: number}) { const loading = createMemo(() => status() === LoadingStatus.Loading); + const expired = createMemo(() => { + if (expirationDate() === null) { + return false; + } + + const date = new Date(`${expirationDate()}T00:00:00`); + const today = new Date(); + + return date < today; + }); + const loadExpiration = () => { setError(""); setStatus(LoadingStatus.Loading); @@ -66,12 +78,16 @@ export function AccountExpiration(props: {userId: number}) {
-

+

Esta cuenta expira el: - + - {expirationDate()} + {formatDate(expirationDate() ?? "")} + + +

diff --git a/frontend/src/icons/WarningIcon.tsx b/frontend/src/icons/WarningIcon.tsx new file mode 100644 index 0000000..7467843 --- /dev/null +++ b/frontend/src/icons/WarningIcon.tsx @@ -0,0 +1,15 @@ + +export function WarningIcon(props: {fill: string, size?: number, class?: string}) { + return ( + + + + ); +}