Skip to content

Commit

Permalink
Merge pull request #473 from GenomicDataInfrastructure/minor-refactoring
Browse files Browse the repository at this point in the history
chore: minor refactoring
  • Loading branch information
brunopacheco1 authored Oct 4, 2024
2 parents 63e136f + 90229e5 commit 47c5c4c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 21 deletions.
28 changes: 28 additions & 0 deletions src/app/requests/entitlements/EmptyEntitlements.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className="flex w-full flex-col items-center justify-center gap-4">
<p className="text-md text-center text-primary">
<span>You don&apos;t have any entitlement yet.</span>
<br />
<span>
Wait for your application(s) to be approved, or submit a new
application.
</span>
</p>
<Button
icon={faPlusCircle}
text="Add datasets"
href="/datasets"
type="primary"
className="text-xs"
/>
</div>
);
}
28 changes: 7 additions & 21 deletions src/app/requests/entitlements/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -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 (
<LoadingContainer
Expand All @@ -84,27 +87,10 @@ function EntitlementsPage() {
<PageHeading className="mb-4">Entitlements</PageHeading>
<span>View your entitlements</span>
<ListContainer>
{response.datasetEntitlements?.length &&
response.datasetEntitlements.length > 0 ? (
{hasEntitlements ? (
<EntitlementsList entitlements={response.datasetEntitlements ?? []} />
) : (
<div className="flex w-full flex-col items-center justify-center gap-4">
<p className="text-md text-center text-primary">
<span>You don&apos;t have any entitlement yet.</span>
<br />
<span>
Wait for your application(s) to be approved, or submit a new
application.
</span>
</p>
<Button
icon={faPlusCircle}
text="Add datasets"
href="/datasets"
type="primary"
className="text-xs"
/>
</div>
<EmptyEntitlements />
)}
</ListContainer>
</PageContainer>
Expand Down

0 comments on commit 47c5c4c

Please sign in to comment.