From 66725ed12e38d537da794fa112f19feeb554e0d0 Mon Sep 17 00:00:00 2001 From: Barbara Honhoff Date: Wed, 20 Sep 2023 11:53:33 +0200 Subject: [PATCH 1/9] First version frontend community page with lists (old design) --- .../[locale]/communities/[slug]/object.tsx | 45 +++++++ .../app/[locale]/communities/[slug]/page.tsx | 54 ++++++++- .../src/components/add-object-list-form.tsx | 110 ++++++++++++++++++ apps/researcher/src/lib/community.ts | 14 +++ apps/researcher/src/messages/en/messages.json | 3 +- apps/researcher/src/messages/nl/messages.json | 3 +- package-lock.json | 105 +++++++++++++++++ 7 files changed, 329 insertions(+), 5 deletions(-) create mode 100644 apps/researcher/src/app/[locale]/communities/[slug]/object.tsx create mode 100644 apps/researcher/src/components/add-object-list-form.tsx diff --git a/apps/researcher/src/app/[locale]/communities/[slug]/object.tsx b/apps/researcher/src/app/[locale]/communities/[slug]/object.tsx new file mode 100644 index 000000000..5064a82c5 --- /dev/null +++ b/apps/researcher/src/app/[locale]/communities/[slug]/object.tsx @@ -0,0 +1,45 @@ +import heritageObjects from '@/lib/heritage-objects-instance'; +import organizations from '@/lib/organizations-instance'; + +interface Props { + objectId: string; +} + +export default async function ObjectCard({objectId}: Props) { + const object = await heritageObjects.getById(objectId); + + if (!object) { + return null; + } + + const organization = + object.isPartOf?.publisher?.id && + (await organizations.getById(object.isPartOf.publisher.id)); + + return ( +
+
+
+ {object.name} +
+ {object.creators?.map(creator => creator.name).join(', ') ?? ''} +
+
+ {organization && ( +
+ {object.isPartOf?.publisher?.name} +
+ )} +
+ +
+
+ No image +
+
+
+ ); +} diff --git a/apps/researcher/src/app/[locale]/communities/[slug]/page.tsx b/apps/researcher/src/app/[locale]/communities/[slug]/page.tsx index a9c50e9ef..2020e1556 100644 --- a/apps/researcher/src/app/[locale]/communities/[slug]/page.tsx +++ b/apps/researcher/src/app/[locale]/communities/[slug]/page.tsx @@ -1,4 +1,4 @@ -import {ChevronLeftIcon} from '@heroicons/react/24/solid'; +import {ChevronLeftIcon, PlusIcon} from '@heroicons/react/24/solid'; import Link from 'next/link'; import Image from 'next/image'; import {getTranslator} from 'next-intl/server'; @@ -7,6 +7,15 @@ import {getMemberships, getCommunityBySlug, isAdmin} from '@/lib/community'; import ErrorMessage from '@/components/error-message'; import {ClerkAPIResponseError} from '@clerk/shared'; import {revalidatePath} from 'next/cache'; +import {objectList} from '@colonial-collections/database'; +import ObjectCard from './object'; +import { + SlideOver, + SlideOverContent, + SlideOverDialog, + SlideOverOpenButton, +} from 'ui'; +import AddObjectListForm from '@/components/add-object-list-form'; interface Props { params: { @@ -39,6 +48,10 @@ export default async function CommunityPage({params}: Props) { return ; } + const objectLists = await objectList.getCommunityListsWithObjects( + community.id + ); + return ( <>
@@ -70,9 +83,44 @@ export default async function CommunityPage({params}: Props) {
-

{t('objectListsTitle')}

+
+

{t('objectListsTitle')}

+
+ + + {t('addObjectListButton')} + + + + + + + +
+
- {/*Place the lists here */} + {objectLists.map(objectList => ( +
+

+ {objectList.name} +

+

{objectList.description}

+ {objectList.objects.length > 0 && ( +
    + {objectList.objects.map(object => ( + + ))} +
+ )} +
+ ))}