From 6a4f21fc0aba7947eecc304f52bbd2a5e64cc210 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 3 Jun 2023 07:20:16 +0330 Subject: [PATCH] small improvements --- .../Modal/Collection/CollectionInfo.tsx | 4 ++-- lib/client/getPublicCollectionData.ts | 7 +++++-- pages/collections/index.tsx | 1 + pages/public/collections/[id].tsx | 19 +++++++++---------- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/components/Modal/Collection/CollectionInfo.tsx b/components/Modal/Collection/CollectionInfo.tsx index 3f26449..202e812 100644 --- a/components/Modal/Collection/CollectionInfo.tsx +++ b/components/Modal/Collection/CollectionInfo.tsx @@ -66,7 +66,7 @@ export default function CollectionInfo({

Icon Color

-
+
setCollection({ ...collection, color: e })} />
diff --git a/lib/client/getPublicCollectionData.ts b/lib/client/getPublicCollectionData.ts index d12ad3a..18e932a 100644 --- a/lib/client/getPublicCollectionData.ts +++ b/lib/client/getPublicCollectionData.ts @@ -1,11 +1,14 @@ -const getPublicCollectionData = async (collectionId: string) => { +const getPublicCollectionData = async ( + collectionId: string, + setData?: Function +) => { const res = await fetch( "/api/public/routes/collections/?collectionId=" + collectionId ); const data = await res.json(); - console.log(data); + if (setData) setData(data.response); return data; }; diff --git a/pages/collections/index.tsx b/pages/collections/index.tsx index 114e0b8..3e0450c 100644 --- a/pages/collections/index.tsx +++ b/pages/collections/index.tsx @@ -218,6 +218,7 @@ export default function () { activeCollection={{ name: "", description: "", + color: "#7dd3fc", isPublic: false, ownerId: session.data?.user.id as number, members: [], diff --git a/pages/public/collections/[id].tsx b/pages/public/collections/[id].tsx index 2575c5e..92c2b12 100644 --- a/pages/public/collections/[id].tsx +++ b/pages/public/collections/[id].tsx @@ -10,15 +10,12 @@ export default function PublicCollections() { const [data, setData] = useState(); useEffect(() => { - const setState = async () => { - if (router.query.id) { - const data = await getPublicCollectionData(router.query.id as string); - - setData(data.response); - } - }; - - setState(); + if (router.query.id) { + getPublicCollectionData( + router.query.id as string, + (e: PublicCollectionIncludingLinks) => setData(e) + ); + } // document // .querySelector("body") @@ -32,7 +29,9 @@ export default function PublicCollections() { return data ? (
-
+

{data.name}