diff --git a/web/src/app/dashboard/page.tsx b/web/src/app/dashboard/page.tsx new file mode 100644 index 00000000..3adaa0de --- /dev/null +++ b/web/src/app/dashboard/page.tsx @@ -0,0 +1,144 @@ +"use client" + +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" +import { SubmissionsDataTable } from "@/components/submissions-data-table" +import { useAuth, useSubmissions, useApproveSubmission, useRejectSubmission } from "@/hooks/use-submissions" +import { Skeleton } from "@/components/ui/skeleton" +import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert" +import { AlertCircle, RefreshCw } from "lucide-react" +import { Button } from "@/components/ui/button" + +export default function DashboardPage() { + // Fetch auth status + const { data: auth, isLoading: authLoading } = useAuth() + + // Fetch submissions + const { + data: submissions = [], + isLoading: submissionsLoading, + error: submissionsError, + refetch + } = useSubmissions() + + // Mutations + const approveMutation = useApproveSubmission() + const rejectMutation = useRejectSubmission() + + const isLoading = authLoading || submissionsLoading + const isAuthenticated = auth?.isAuthenticated ?? false + const isAdmin = auth?.isAdmin ?? false + const currentUserId = auth?.userId ?? '' + + const handleApprove = (submissionId: string) => { + approveMutation.mutate(submissionId) + } + + const handleReject = (submissionId: string) => { + rejectMutation.mutate(submissionId) + } + + // Not authenticated + if (!authLoading && !isAuthenticated) { + return ( +
+ + + Access Denied + You need to be logged in to access the dashboard. + + +
+ ) + } + + // Loading state + if (isLoading) { + return ( +
+ + +
+ + +
+
+ +
+ +
+ + + +
+
+
+
+
+ ) + } + + // Error state + if (submissionsError) { + return ( +
+ + + Submissions Dashboard + + {isAdmin + ? "Review and manage all icon submissions." + : "View your icon submissions and track their status." + } + + + + + + Error loading submissions + + Failed to load submissions. Please try again. + + + + + +
+ ) + } + + // Success state + return ( +
+ + + Submissions Dashboard + + {isAdmin + ? "Review and manage all icon submissions. Click on a row to see details." + : "View your icon submissions and track their status." + } + + + + + + +
+ ) +}