From 90229e54fdb2096c3a897e8e13f9e6378428a170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Youn=C3=A8s=20Adem?= Date: Fri, 4 Oct 2024 14:56:11 +0200 Subject: [PATCH] chore: minor refactoring --- .../entitlements/EmptyEntitlements.tsx | 28 +++++++++++++++++++ src/app/requests/entitlements/index.tsx | 28 +++++-------------- 2 files changed, 35 insertions(+), 21 deletions(-) create mode 100644 src/app/requests/entitlements/EmptyEntitlements.tsx diff --git a/src/app/requests/entitlements/EmptyEntitlements.tsx b/src/app/requests/entitlements/EmptyEntitlements.tsx new file mode 100644 index 00000000..62021d7b --- /dev/null +++ b/src/app/requests/entitlements/EmptyEntitlements.tsx @@ -0,0 +1,28 @@ +// SPDX-FileCopyrightText: 2024 PNED G.I.E. +// +// SPDX-License-Identifier: Apache-2.0 + +import Button from "@/components/Button"; +import { faPlusCircle } from "@fortawesome/free-solid-svg-icons"; + +export function EmptyEntitlements() { + return ( +
+

+ You don't have any entitlement yet. +
+ + Wait for your application(s) to be approved, or submit a new + application. + +

+
+ ); +} diff --git a/src/app/requests/entitlements/index.tsx b/src/app/requests/entitlements/index.tsx index 28e4b92a..86cdd6cf 100644 --- a/src/app/requests/entitlements/index.tsx +++ b/src/app/requests/entitlements/index.tsx @@ -16,8 +16,7 @@ import LoadingContainer from "@/components/LoadingContainer"; import Error from "@/app/error"; import { ErrorResponse } from "@/types/api.types"; import axios from "axios"; -import Button from "@/components/Button"; -import { faPlusCircle } from "@fortawesome/free-solid-svg-icons"; +import { EmptyEntitlements } from "./EmptyEntitlements"; interface EntitelementsResponse { datasetEntitlements?: DatasetEntitlement[]; @@ -60,6 +59,10 @@ function EntitlementsPage() { fetchData().catch((it) => console.log(it)); }, []); + const hasEntitlements = + response.datasetEntitlements?.length && + response.datasetEntitlements.length > 0; + if (response.status === "loading") { return ( Entitlements View your entitlements - {response.datasetEntitlements?.length && - response.datasetEntitlements.length > 0 ? ( + {hasEntitlements ? ( ) : ( -
-

- You don't have any entitlement yet. -
- - Wait for your application(s) to be approved, or submit a new - application. - -

-
+ )}