Skip to content

Commit

Permalink
V.0.3.1.1 🐛 Bugfix (#30)
Browse files Browse the repository at this point in the history
* Fixed admin manage requests not updated

* Updated component naming convention
  • Loading branch information
xKhronoz authored May 19, 2024
1 parent 2483bce commit b7917d5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
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
};

0 comments on commit b7917d5

Please sign in to comment.