mirror of
https://github.com/D4M13N-D3V/neroshitron.git
synced 2025-03-14 10:05:04 +00:00
fix: gallery admin pages
This commit is contained in:
parent
d94f3b825b
commit
420e029d66
@ -16,9 +16,21 @@ function PageComponent() {
|
|||||||
const [thumbnail, setThumbnail] = useState<string>("");
|
const [thumbnail, setThumbnail] = useState<string>("");
|
||||||
const [files, setFiles] = useState<FileList>();
|
const [files, setFiles] = useState<FileList>();
|
||||||
|
|
||||||
|
const [tiers, setTiers] = useState<any[]>([]);
|
||||||
const supabase = createClient();
|
const supabase = createClient();
|
||||||
const user = supabase.auth.getUser();
|
const user = supabase.auth.getUser();
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/tiers');
|
||||||
|
if (response.ok) {
|
||||||
|
const data = await response.json();
|
||||||
|
setTiers(data);
|
||||||
|
} else {
|
||||||
|
console.error('Failed to fetch users');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching users:', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getData();
|
getData();
|
||||||
@ -100,8 +112,8 @@ function PageComponent() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full lg:flex">
|
<div className="w-full lg:flex">
|
||||||
<div className="w-full lg:w-1/2 mr-2">
|
<div className="w-full lg:w-1/2">
|
||||||
<div className="absolute">
|
<div className="w-1/2 absolute pr-14">
|
||||||
<SearchInput
|
<SearchInput
|
||||||
placeholderTags={[
|
placeholderTags={[
|
||||||
{ value: "tags", label: "❗️ click here to add tags" },
|
{ value: "tags", label: "❗️ click here to add tags" },
|
||||||
@ -124,10 +136,10 @@ function PageComponent() {
|
|||||||
<select onChange={e=>{
|
<select onChange={e=>{
|
||||||
setTier(e.target.value);
|
setTier(e.target.value);
|
||||||
}} className="mb-2 shadow-lg mr-2 rounded-md bg-secondary p-2 w-full text-white">
|
}} className="mb-2 shadow-lg mr-2 rounded-md bg-secondary p-2 w-full text-white">
|
||||||
<option value="Free" selected={tier === "Free"}>Free</option>
|
<option value="" disabled >Select New Tier</option>
|
||||||
<option value="Tier 1" selected={tier === "Tier 1"}>Tier 1</option>
|
{tiers.map((tier, index) => (
|
||||||
<option value="Tier 2" selected={tier === "Tier 2"}>Tier 2</option>
|
<option key={index} value={tier.name}>{tier.name}</option>
|
||||||
<option value="Tier 3" selected={tier === "Tier 3"}>Tier 3</option>
|
))}
|
||||||
</select>
|
</select>
|
||||||
<select onChange={e=>{setThumbnail(e.target.value)}} className="mb-2 shadow-lg mr-2 rounded-md bg-secondary p-2 w-full text-white">
|
<select onChange={e=>{setThumbnail(e.target.value)}} className="mb-2 shadow-lg mr-2 rounded-md bg-secondary p-2 w-full text-white">
|
||||||
<option value="" disabled selected>Select Thumbnail</option>
|
<option value="" disabled selected>Select Thumbnail</option>
|
||||||
|
@ -21,11 +21,23 @@ function PageComponent() {
|
|||||||
const [selectedTags, setSelectedTags] = useState<string[]>([]);
|
const [selectedTags, setSelectedTags] = useState<string[]>([]);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
const [tiers, setTiers] = useState<any[]>([]);
|
||||||
const [open, setOpen] = useState<boolean>(false);
|
const [open, setOpen] = useState<boolean>(false);
|
||||||
|
|
||||||
|
|
||||||
const [images, setImages] = useState<string[]>([]);
|
const [images, setImages] = useState<string[]>([]);
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/tiers');
|
||||||
|
if (response.ok) {
|
||||||
|
const data = await response.json();
|
||||||
|
setTiers(data);
|
||||||
|
} else {
|
||||||
|
console.error('Failed to fetch users');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching users:', error);
|
||||||
|
}
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
const id = urlParams.get('id');
|
const id = urlParams.get('id');
|
||||||
const galleryResponse = await fetch(`/api/galleries/admin/${id}`, {
|
const galleryResponse = await fetch(`/api/galleries/admin/${id}`, {
|
||||||
@ -212,10 +224,9 @@ function PageComponent() {
|
|||||||
|
|
||||||
}} className="mb-2 shadow-lg mr-2 rounded-md bg-secondary p-2 w-full text-white">
|
}} className="mb-2 shadow-lg mr-2 rounded-md bg-secondary p-2 w-full text-white">
|
||||||
<option value="" disabled >Select New Tier</option>
|
<option value="" disabled >Select New Tier</option>
|
||||||
<option value="Free" selected={tier === "Free"}>Free</option>
|
{tiers.map((tier, index) => (
|
||||||
<option value="Tier 1" selected={tier === "Tier 1"}>Tier 1</option>
|
<option selected={tier.name==gallery.tier} key={index} value={tier.name}>{tier.name}</option>
|
||||||
<option value="Tier 2" selected={tier === "Tier 2"}>Tier 2</option>
|
))}
|
||||||
<option value="Tier 3" selected={tier === "Tier 3"}>Tier 3</option>
|
|
||||||
</select>
|
</select>
|
||||||
<select onChange={e=>{setThumbnail(e.target.value)}} className="mb-2 shadow-lg mr-2 rounded-md bg-secondary p-2 w-full text-white">
|
<select onChange={e=>{setThumbnail(e.target.value)}} className="mb-2 shadow-lg mr-2 rounded-md bg-secondary p-2 w-full text-white">
|
||||||
<option value="" disabled selected>Select New Thumbnail</option>
|
<option value="" disabled selected>Select New Thumbnail</option>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user