81 lines
3.7 KiB
TypeScript
Raw Normal View History

2024-06-02 03:08:55 -04:00
"use client";
import { createClient } from "@/utils/supabase/client";
import React, { useState, useEffect } from 'react';
import Search from "@/components/neroshitron/search";
import Gallery from "@/components/neroshitron/gallery";
import Masonry from "react-masonry-css";
import SearchInput from "@/components/neroshitron/search_input";
function PageComponent() {
const supabase = createClient();
const user = supabase.auth.getUser();
2024-06-02 04:25:36 -04:00
const [galleries, setGalleries] = useState([]);
const [nsfwState, setNsfwState] = useState<boolean>(false);
const [tagsState, setTagsState] = useState<string[]>([]);
const [searchState, setSearchState] = useState<string>("");
2024-06-02 03:08:55 -04:00
const getData = async () => {
2024-06-02 04:25:36 -04:00
const galleriesResponse = await fetch(`/api/galleries?search=` + searchState + '&nsfw=' + nsfwState, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ tags: tagsState })
});
const galleriesData = await galleriesResponse.json();
setGalleries(galleriesData);
2024-06-02 03:08:55 -04:00
}
2024-06-02 04:25:36 -04:00
2024-06-02 03:08:55 -04:00
useEffect(() => {
getData();
2024-06-02 04:25:36 -04:00
}, [tagsState]);
2024-06-02 03:08:55 -04:00
2024-06-02 04:25:36 -04:00
const data = [
{ id: 1, name: "Item 1", imageCount: 5, tier: "Tier 1" },
{ id: 2, name: "Item 2", imageCount: 10, tier: "Tier 2" },
{ id: 3, name: "Item 3", imageCount: 8, tier: "Tier 1" },
];
2024-06-02 03:08:55 -04:00
2024-06-02 03:48:21 -04:00
return (
<div className="w-full text-white flex justify-center items-center animate-in">
<div className="w-1/2 rounded-md bg-primary p-12 mt-32">
2024-06-02 04:25:36 -04:00
<div className="w-full flex">
<SearchInput placeholderTags={[
{ value: "tags", label: "❗️ click here to add tags to search" }
]} nsfwButtonEnabled={true} searchChanged={(search) => { setSearchState(search) }} nsfwChanged={(nsfw) => { setNsfwState(nsfw) }} tagsChanged={(tags) => { setTagsState(tags) }} />
<a href="/gallery/admin/create" className="ml-2 text-center bg-success hover:bg-success-light text-white w-1/6 font-bold rounded flex items-center justify-center">
Create
</a>
</div>
<table className="w-full">
<thead>
<tr>
<th className="px-4 py-2" style={{ width: '60%' }}>Name</th>
<th className="px-4 py-2" style={{width:"15%"}}>📸 #</th>
<th className="px-4 py-2">Tier</th>
<th className="px-4 py-2"></th>
</tr>
</thead>
<tbody>
{/* Replace this with your data mapping logic */}
2024-06-02 04:31:38 -04:00
{galleries.map((item: { name: string, imageCount: number, tier: string }) => (
2024-06-02 04:25:36 -04:00
<tr key={item.name} className="animate-in">
<td className="px-4 py-2">{item.name}</td>
<td className="px-4 py-2">{item.imageCount}</td>
<td className="px-4 py-2">{item.tier.replace("Tier","")}</td>
<td className="px-4 py-2">
2024-06-02 04:46:21 -04:00
<a href="/gallery/admin/view" className="bg-secondary hover:bg-secondary-light text-white font-bold py-2 px-4 rounded float-right">
2024-06-02 04:25:36 -04:00
View
</a>
</td>
</tr>
))}
</tbody>
</table>
2024-06-02 03:48:21 -04:00
</div>
2024-06-02 03:08:55 -04:00
</div>
);
}
export default PageComponent;