Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix admin manage new requests #30

Merged
merged 2 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions frontend/app/api/admin/collections-requests/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ export async function GET(request: NextRequest) {
{ db: { schema: 'public' } },
);

// Retrieve the public collections requests data from the database
const { data: pubCollectionsReq, error: pubCollErr } = await supabase
// Retrieve the collections requests data from the database
const { data: collectionsReq, error: collErr } = await supabase
.from('collections_requests')
.select('collection_id, is_make_public, is_pending, is_approved, created_at, updated_at, collections (collection_id, id, display_name, description, is_public, users (id, name, email))')
.eq('is_pending', true);

if (pubCollErr) {
console.error('Error fetching collection request data from database:', pubCollErr.message);
return NextResponse.json({ error: pubCollErr.message }, { status: 500 });
if (collErr) {
console.error('Error fetching collection request data from database:', collErr.message);
return NextResponse.json({ error: collErr.message }, { status: 500 });
}

// console.log('Collections Request:', pubCollectionsReq);
// console.log('Collections Request:', collectionsReq);

return NextResponse.json({ pubCollectionsReq: pubCollectionsReq });
return NextResponse.json({ collectionsReq: collectionsReq });
}
10 changes: 5 additions & 5 deletions frontend/app/components/admin-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"use client";

import { useState } from "react";
import { AdminMenu, AdminCollectionsRequests, AdminManageCollections, AdminManageUsers } from "@/app/components/ui/admin";
import { AdminMenu, AdminManageRequests, AdminManageCollections, AdminManageUsers } from "@/app/components/ui/admin";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";

Expand All @@ -26,17 +26,17 @@ const AdminSection: React.FC = () => {
setShowCollections={setShowCollections}
/>

{/* New Requests Section */}
{/* Manage Requests Section */}
{showNewRequest ? (
<AdminCollectionsRequests />
<AdminManageRequests />
) : null}

{/* Public Collections Section */}
{/* Manage Collections Section */}
{showCollections ? (
<AdminManageCollections />
) : null}

{/* Users Section */}
{/* Manage Users Section */}
{showUsers ? (
<AdminManageUsers />
) : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IconSpinner } from '@/app/components/ui/icons';
import { toast } from 'react-toastify';
import Swal from 'sweetalert2';

export default function AdminCollectionsRequests() {
export default function AdminManageRequests() {
const [userRequests, setUserRequests] = useState<any[]>([]);
const [loading, setLoading] = useState<boolean>(true);
const [isRefreshed, setIsRefreshed] = useState<boolean>(true); // Track whether the data has been refreshed
Expand Down Expand Up @@ -34,8 +34,8 @@ export default function AdminCollectionsRequests() {
return false;
}
const data = await response.json();
setUserRequests(data.pubCollectionsReq);
console.log('Collection Requests:', data.pubCollectionsReq);
setUserRequests(data.collectionsReq);
console.log('Collection Requests:', data.collectionsReq);
} catch (error) {
console.error('Error fetching userRequest requests:', error);
toast.error('Error fetching userRequest requests:', {
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/components/ui/admin/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import AdminMenu from './admin-menu';
import AdminManageUsers from './admin-manage-users';
import AdminCollectionsRequests from './admin-collections-requests';
import AdminManageRequests from './admin-manage-requests';
import AdminManageCollections from './admin-manage-collections';

export {
AdminMenu,
AdminCollectionsRequests,
AdminManageRequests,
AdminManageCollections,
AdminManageUsers
};
Loading