From d33f36adaf7237b9cfd43d55c073528acdc15c6e Mon Sep 17 00:00:00 2001 From: Damien Ostler Date: Sun, 2 Jun 2024 03:08:55 -0400 Subject: [PATCH] fix --- .idea/.name | 2 +- app/gallery/admin/page.tsx | 71 +++++++++++++++++++++++ components/neroshitron/navigation_bar.tsx | 2 +- components/neroshitron/search.tsx | 2 +- components/neroshitron/search_input.tsx | 6 +- 5 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 app/gallery/admin/page.tsx diff --git a/.idea/.name b/.idea/.name index 3e4e48b..fbd2f39 100644 --- a/.idea/.name +++ b/.idea/.name @@ -1 +1 @@ -.gitignore \ No newline at end of file +page.tsx \ No newline at end of file diff --git a/app/gallery/admin/page.tsx b/app/gallery/admin/page.tsx new file mode 100644 index 0000000..2257dd6 --- /dev/null +++ b/app/gallery/admin/page.tsx @@ -0,0 +1,71 @@ +"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 [selectedGallery, setSelectedGallery] = useState(null); + const [filePreviews, setFilePreviews] = useState([]); + const supabase = createClient(); + const user = supabase.auth.getUser(); + const getData = async () => { + } + useEffect(() => { + getData(); + }, [selectedGallery]); + + const closeGallery = () => { + setSelectedGallery(null); + } + + const handleFileChange = (event: React.ChangeEvent) => { + 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 (
+
+ { }} nsfwChanged={(nsfw) => { }} tagsChanged={(tags) => { }} /> + + + + {filePreviews.map((preview, index) => ( + {`Preview + ))} + +
+ +
+
+
+ ); +} +export default PageComponent; \ No newline at end of file diff --git a/components/neroshitron/navigation_bar.tsx b/components/neroshitron/navigation_bar.tsx index dd9593b..34cf47d 100644 --- a/components/neroshitron/navigation_bar.tsx +++ b/components/neroshitron/navigation_bar.tsx @@ -96,7 +96,7 @@ console.log(currentPage) ) : ( diff --git a/components/neroshitron/search.tsx b/components/neroshitron/search.tsx index 8f97bf2..8bdadc3 100644 --- a/components/neroshitron/search.tsx +++ b/components/neroshitron/search.tsx @@ -44,7 +44,7 @@ const Search = ({ gallerySelected }: SearchProps) => { { setGallery(gallery) }} key={search + "-" + tags.length + "-" + nsfw} search={search} nsfw={nsfw} tags={tags} />
- { setSearch(search) }} nsfwChanged={(nsfw) => { setNsfw(nsfw) }} tagsChanged={(tags) => { setTags(tags); }} /> + { setSearch(search) }} nsfwChanged={(nsfw) => { setNsfw(nsfw) }} tagsChanged={(tags) => { setTags(tags); }} />
diff --git a/components/neroshitron/search_input.tsx b/components/neroshitron/search_input.tsx index e23eed5..6de2ce8 100644 --- a/components/neroshitron/search_input.tsx +++ b/components/neroshitron/search_input.tsx @@ -9,9 +9,10 @@ interface SearchInputProps { tagsChanged: (tags: string[]) => void; searchChanged: (search: string) => void; nsfwChanged: (nsfw: boolean) => void; + nsfwButtonEnabled: boolean | null; } -const SearchInput = ({ tagsChanged, searchChanged, nsfwChanged }: SearchInputProps) => { +const SearchInput = ({ tagsChanged, searchChanged, nsfwChanged, nsfwButtonEnabled }: SearchInputProps) => { const [tagSearch, setTagSearch] = useState(''); const [nsfw, setNsfw] = useState(false); @@ -62,7 +63,7 @@ const SearchInput = ({ tagsChanged, searchChanged, nsfwChanged }: SearchInputPro const tagOptions = tags.map((tag: { name: string; }) => ({ value: tag.name, label: "🏷️ "+tag.name })); return ( <> -
+
@@ -108,6 +109,7 @@ const SearchInput = ({ tagsChanged, searchChanged, nsfwChanged }: SearchInputPro {nsfw ? "NSFW" : "SFW"} + )} )}