diff --git a/src/app/applications/[id]/TermsAcceptance.tsx b/src/app/applications/[id]/TermsAcceptance.tsx index 2eb33ad3..71840a8b 100644 --- a/src/app/applications/[id]/TermsAcceptance.tsx +++ b/src/app/applications/[id]/TermsAcceptance.tsx @@ -50,6 +50,10 @@ export default function TermsAcceptance() { } }; + if (!application?.licenses || application?.licenses.length === 0) { + return

No terms and conditions have been defined.

; + } + return (
{alert && ( diff --git a/src/app/applications/[id]/sidebarItems.tsx b/src/app/applications/[id]/sidebarItems.tsx index a1bc3183..7f6fb8c6 100644 --- a/src/app/applications/[id]/sidebarItems.tsx +++ b/src/app/applications/[id]/sidebarItems.tsx @@ -2,14 +2,18 @@ // // SPDX-License-Identifier: Apache-2.0 -import DatasetList from "@/app/requests/applications/DatasetList"; import { createTextItem, SidebarItem } from "@/components/Sidebar"; import { RetrievedApplication } from "@/types/application.types"; import { formatApplicationProp } from "@/utils/application"; import { formatDateTime } from "@/utils/formatDate"; -import { faHistory, faUser } from "@fortawesome/free-solid-svg-icons"; +import { + faDatabase, + faHistory, + faUser, +} from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import TermsAcceptance from "./TermsAcceptance"; +import { getLabelName } from "@/utils/getLabelName"; export function createApplicationSidebarItems( application: RetrievedApplication @@ -19,7 +23,15 @@ export function createApplicationSidebarItems( return [ { label: "Datasets", - value: , + value: datasets.map((dataset, index) => ( + + +

{getLabelName(dataset.title)}

+
+ )), }, { label: "Participants", diff --git a/src/app/basket/page.tsx b/src/app/basket/page.tsx index 98f375d8..ada4a56a 100644 --- a/src/app/basket/page.tsx +++ b/src/app/basket/page.tsx @@ -13,7 +13,7 @@ import { useDatasetBasket } from "@/providers/DatasetBasketProvider"; import { createApplication } from "@/services/daam/index.client"; import { faPaperPlane, faPlusCircle } from "@fortawesome/free-solid-svg-icons"; import { signIn, useSession } from "next-auth/react"; -import DatasetList from "../../components/DatasetList"; +import DatasetList from "../datasets/DatasetList"; import { AxiosError } from "axios"; export default function Page() { diff --git a/src/app/datasets/DatasetCard.tsx b/src/app/datasets/DatasetCard.tsx new file mode 100644 index 00000000..7accde18 --- /dev/null +++ b/src/app/datasets/DatasetCard.tsx @@ -0,0 +1,64 @@ +// SPDX-FileCopyrightText: 2024 PNED G.I.E. +// +// SPDX-License-Identifier: Apache-2.0 + +import Button from "@/components/Button"; +import { useWindowSize } from "@/hooks"; +import { useDatasetBasket } from "@/providers/DatasetBasketProvider"; +import { SearchedDataset } from "@/services/discovery/types/dataset.types"; +import { truncateDescription } from "@/utils/textProcessing"; +import { faMinusCircle, faPlusCircle } from "@fortawesome/free-solid-svg-icons"; +import Card, { CardItem } from "../../components/Card"; + +type DatasetCardProps = { + dataset: SearchedDataset; + cardItems: CardItem[]; +}; + +function DatasetCard({ dataset, cardItems }: Readonly) { + const screenSize = useWindowSize(); + const truncatedDesc = dataset.description + ? truncateDescription(dataset.description, screenSize) + : null; + + const { basket, addDatasetToBasket, removeDatasetFromBasket, isLoading } = + useDatasetBasket(); + + const isInBasket = basket.some((ds) => ds.id === dataset.id); + + const toggleDatasetInBasket = (e: React.MouseEvent) => { + e.preventDefault(); + if (isInBasket) { + removeDatasetFromBasket(dataset); + } else { + addDatasetToBasket(dataset); + } + }; + + const hasIdentifier = !!dataset.identifier; + const buttonDisabled = isLoading || !hasIdentifier; + + return ( + theme.label)} + description={truncatedDesc || "No description available"} + cardItems={cardItems} + keywords={dataset.keywords?.map((keyword) => keyword.label)} + button={ +
- {children} - - ); -} - -export default DatasetCard;