From 534cbf2957d3148bba9d4f0fd97c2f3b5976118d Mon Sep 17 00:00:00 2001 From: Damien Ostler Date: Sun, 2 Jun 2024 23:37:41 -0400 Subject: [PATCH] fix --- app/api/galleries/admin/[id]/route.ts | 11 +++++- app/gallery/admin/view/page.tsx | 37 +++++++++++++++++--- components/neroshitron/gallery_thumbnail.tsx | 8 ++--- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/app/api/galleries/admin/[id]/route.ts b/app/api/galleries/admin/[id]/route.ts index 351fc05..77b56ab 100644 --- a/app/api/galleries/admin/[id]/route.ts +++ b/app/api/galleries/admin/[id]/route.ts @@ -19,8 +19,17 @@ export async function PUT( ) { const id = params.id; const supabase = createClient(); - const { files, tags, name, nsfw, tier}: { files: File[], tags: string[], name: string, nsfw:boolean, tier:string } = await request.json(); + const formData = await request.formData(); + const tags = formData.getAll('tags'); + const name = formData.get('name'); + const nsfw = formData.get('nsfw'); + const tier = formData.get('tier'); + console.log(id) const { data: gallery, error } = await supabase.from('galleries').update({ name, tags, nsfw, tier }).eq('name', id).single(); + if(error){ + console.log(error) + return NextResponse.error(); + } let { data: galleries, error:galleriesError } = await supabase .from('galleries') .select('*'); diff --git a/app/gallery/admin/view/page.tsx b/app/gallery/admin/view/page.tsx index 4769598..d9c71f9 100644 --- a/app/gallery/admin/view/page.tsx +++ b/app/gallery/admin/view/page.tsx @@ -38,7 +38,36 @@ function PageComponent() { }, []); useEffect(() => { - }, [gallery, nsfw, tags, galleryName, tier]); + }, [gallery, ]); + useEffect(() => { + }, [ nsfw ]); + useEffect(() => { + }, [tags ]); + useEffect(() => { + }, [galleryName]); + useEffect(() => { + }, [ tier]); + + const updateGallery = async () => { + const urlParams = new URLSearchParams(window.location.search); + const id = urlParams.get('id'); + const formData = new FormData(); + formData.append('id', gallery.id); + formData.append('name', galleryName); + formData.append('tags', JSON.stringify(tags)); + formData.append('nsfw', nsfw.toString()); + formData.append('tier', tier); + const response = await fetch(`/api/galleries/admin/${id}`, { + method: 'PUT', + body: formData, + }); + + if (response.ok) { + const data = await response.json(); + } else { + console.log(response) + } + } return (
@@ -46,14 +75,14 @@ function PageComponent() {
{gallery != null && ( )} @@ -83,7 +112,7 @@ function PageComponent() {
-
diff --git a/components/neroshitron/gallery_thumbnail.tsx b/components/neroshitron/gallery_thumbnail.tsx index e555117..1ecb598 100644 --- a/components/neroshitron/gallery_thumbnail.tsx +++ b/components/neroshitron/gallery_thumbnail.tsx @@ -72,16 +72,16 @@ const GalleryThumbnail = ({ id, columns, onSelect, title, showNsfw, nsfw, subscr {nsfwState && ( NSFW )} - {subscription === "Free" && ( + {subscriptionState === "Free" && ( Free )} - {subscription === "Tier 1" && ( + {subscriptionState === "Tier 1" && ( Tier 1 )} - {subscription === "Tier 2" && ( + {subscriptionState === "Tier 2" && ( Tier 2 )} - {subscription === "Tier 3" && ( + {subscriptionState === "Tier 3" && ( Tier 3 )}