mirror of
https://github.com/D4M13N-D3V/neroshitron.git
synced 2025-03-14 10:05:04 +00:00
fix
This commit is contained in:
parent
481b4f698c
commit
534cbf2957
@ -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('*');
|
||||
|
@ -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 (
|
||||
<div className="w-full text-white flex justify-center items-center animate-in">
|
||||
@ -46,14 +75,14 @@ function PageComponent() {
|
||||
<div className="w-full flex pb-60">
|
||||
{gallery != null && (
|
||||
<GalleryThumbnail
|
||||
key={"galleryThumbnail"}
|
||||
key={"galleryThumbnail"+galleryName+"-"+tags.join("")}
|
||||
id={galleryName}
|
||||
columns={3}
|
||||
onSelect={function (id: string, columns: number): void {}}
|
||||
title={galleryName}
|
||||
subscription={tier}
|
||||
tags={tags}
|
||||
showNsfw={true}
|
||||
showNsfw={false}
|
||||
nsfw={nsfw}
|
||||
></GalleryThumbnail>
|
||||
)}
|
||||
@ -83,7 +112,7 @@ function PageComponent() {
|
||||
</button>
|
||||
</div>
|
||||
<div className="w-1/4">
|
||||
<button className="w-full bg-success hover:bg-success-light text-white rounded-md p-2 ml-4">
|
||||
<button onClick={()=>{updateGallery()}} className="w-full bg-success hover:bg-success-light text-white rounded-md p-2 ml-4">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
|
@ -72,16 +72,16 @@ const GalleryThumbnail = ({ id, columns, onSelect, title, showNsfw, nsfw, subscr
|
||||
{nsfwState && (
|
||||
<span className=" bg-error text-white px-2 py-1 mr-2 rounded-md text-sm h-full flex items-center">NSFW</span>
|
||||
)}
|
||||
{subscription === "Free" && (
|
||||
{subscriptionState === "Free" && (
|
||||
<span className=" bg-free text-white px-2 py-1 rounded-md text-sm h-full flex items-center">Free</span>
|
||||
)}
|
||||
{subscription === "Tier 1" && (
|
||||
{subscriptionState === "Tier 1" && (
|
||||
<span className=" bg-tier1 text-white px-2 py-1 rounded-md text-sm h-full flex items-center">Tier 1</span>
|
||||
)}
|
||||
{subscription === "Tier 2" && (
|
||||
{subscriptionState === "Tier 2" && (
|
||||
<span className=" bg-tier2 text-white px-2 py-1 rounded-md text-sm h-full flex items-center">Tier 2</span>
|
||||
)}
|
||||
{subscription === "Tier 3" && (
|
||||
{subscriptionState === "Tier 3" && (
|
||||
<span className=" bg-tier3 text-white px-2 py-1 rounded-md text-sm h-full flex items-center">Tier 3</span>
|
||||
)}
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user