This commit is contained in:
Damien Ostler 2024-06-02 04:56:09 -04:00
parent fa6bf10249
commit e4dde90da4
2 changed files with 3 additions and 34 deletions

View File

@ -8,46 +8,15 @@ import SearchInput from "@/components/neroshitron/search_input";
import GalleryThumbnail from "@/components/neroshitron/gallery_thumbnail";
function PageComponent() {
const [selectedGallery, setSelectedGallery] = useState<string | null>("Test Gallery");
const [filePreviews, setFilePreviews] = useState<string[]>([]);
const supabase = createClient();
const user = supabase.auth.getUser();
const getData = async () => {
}
useEffect(() => {
getData();
}, [selectedGallery]);
const closeGallery = () => {
setSelectedGallery(null);
}
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const files = event.target.files;
if (files) {
const previews: string[] = [];
for (let i = 0; i < files.length; i++) {
const file = files[i];
const reader = new FileReader();
reader.onload = (e) => {
if (e.target && e.target.result) {
previews.push(e.target.result.toString());
if (previews.length === files.length) {
setFilePreviews(previews);
}
}
};
reader.readAsDataURL(file);
}
}
};
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">
<div className="w-full flex pb-48">
<GalleryThumbnail id={encodeURIComponent(selectedGallery as string)} columns={3} onSelect={function (id: string, columns: number): void {
<GalleryThumbnail id={"Test Gallery"} columns={3} onSelect={function (id: string, columns: number): void {
} } title={""} subscription={""} tags={[]} showNsfw={false} nsfw={false} ></GalleryThumbnail>
</div>
<div className="w-full flex">

View File

@ -27,9 +27,9 @@ const GalleryThumbnail = ({ id, columns, onSelect, title, showNsfw, nsfw, subscr
const getData = async () => {
setIsLoading(true);
const thumbnailResponse = await fetch('/api/galleries/' + title + '/thumbnail?nsfw=' + showNsfwState);
const thumbnailResponse = await fetch('/api/galleries/' + id + '/thumbnail?nsfw=' + showNsfwState);
const thumbnailUrl = await thumbnailResponse.text();
const imagesCountResponse = await fetch('/api/galleries/' + title + '/images/count');
const imagesCountResponse = await fetch('/api/galleries/' + id + '/images/count');
const imageCount = await imagesCountResponse.json() as number;
setImageCount(imageCount);
setThumbnailUrl(thumbnailUrl);