@@ -13,6 +13,7 @@ import { Card, CardContent, CardHeader, CardTitle, CardDescription, CardFooter }
1313import { BarChart as RechartsBarChart , Bar , CartesianGrid , XAxis , YAxis } from 'recharts' ;
1414import { ChartContainer , ChartTooltip , ChartTooltipContent } from "@/components/ui/chart" ;
1515import * as LucideIcons from "lucide-react" ;
16+ import type { LucideProps } from 'lucide-react' ;
1617import { Table , TableBody , TableCell , TableHead , TableHeader , TableRow } from "@/components/ui/table" ;
1718import { Badge } from "@/components/ui/badge" ;
1819import type { View , DashboardTab , UserRole , AppUser , BlogPost , EducationProgram , NewsletterSubscriber } from "@/app/types" ;
@@ -23,7 +24,6 @@ import { Input } from "@/components/ui/input";
2324import { Textarea } from "@/components/ui/textarea" ;
2425import { Separator } from "@/components/ui/separator" ;
2526import { Select , SelectContent , SelectItem , SelectTrigger , SelectValue } from "@/components/ui/select" ;
26- import { RadioGroup , RadioGroupItem } from "../ui/radio-group" ;
2727import { API_BASE_URL } from "@/lib/api" ;
2828import PasswordChangeForm from './password-change-form' ;
2929import Image from "next/image" ;
@@ -75,7 +75,8 @@ interface DashboardViewProps {
7575 setActiveView : ( view : View ) => void ;
7676}
7777
78- const iconNames = Object . keys ( LucideIcons ) . filter ( k => k !== 'createLucideIcon' && k !== 'icons' ) ;
78+ const iconNames = Object . keys ( LucideIcons ) . filter ( k => k !== 'createLucideIcon' && k !== 'icons' && k !== 'default' ) ;
79+
7980
8081const LockedContent = ( { setActiveView, title } : { setActiveView : ( view : View ) => void , title : string } ) => (
8182 < Card className = "mt-0 bg-card/50 backdrop-blur-sm border-border/50 text-center flex flex-col items-center justify-center p-8 min-h-[400px]" >
@@ -204,7 +205,7 @@ export default function DashboardView({ isOpen, onOpenChange, user, userRole, au
204205 toast ( { variant : 'destructive' , title : errorMessage , description : data . error } ) ;
205206 }
206207 } ;
207- const handleApproveUser = async ( userId : string ) => handleApiResponse ( await fetch ( ` ${ API_BASE_URL } /api/users/ ${ userId } /approve` , { method : 'POST' , headers : { 'Authorization' : `Bearer ${ localStorage . getItem ( 'token' ) } ` } } ) , 'User approved successfully.' , 'Approval Failed' ) ;
208+
208209 const handleDeleteUser = async ( userId : string ) => handleApiResponse ( await fetch ( `${ API_BASE_URL } /api/users/${ userId } ` , { method : 'DELETE' , headers : { 'Authorization' : `Bearer ${ localStorage . getItem ( 'token' ) } ` } } ) , 'User deleted successfully.' , 'Deletion Failed' ) ;
209210 const handleToggleBanUser = async ( userId : string ) => handleApiResponse ( await fetch ( `${ API_BASE_URL } /api/users/${ userId } /toggle-ban` , { method : 'POST' , headers : { 'Authorization' : `Bearer ${ localStorage . getItem ( 'token' ) } ` } } ) , 'User status updated.' , 'Update Failed' ) ;
210211
@@ -306,7 +307,7 @@ export default function DashboardView({ isOpen, onOpenChange, user, userRole, au
306307 < Tabs value = { activeTab } onValueChange = { ( tab ) => setActiveTab ( tab as DashboardTab ) } className = "flex flex-col flex-grow min-h-0" >
307308 < TabsList className = "grid w-full grid-cols-6" >
308309 { availableTabs . map ( tab => {
309- const Icon = LucideIcons [ tab === 'overview' ? 'LayoutDashboard' : tab === 'msmes' ? 'Briefcase' : tab === 'incubators' ? 'Lightbulb' : tab === 'mentors' ? 'Users' : tab === 'submission' ? 'FileText' : tab === 'settings' ? 'Settings' : tab === 'users' ? 'User' : tab === 'subscribers' ? 'Mail' : tab === 'blog' ? 'Newspaper' : 'BookOpen' as keyof typeof LucideIcons ] || LucideIcons . HelpCircle ;
310+ const Icon = ( LucideIcons [ tab === 'overview' ? 'LayoutDashboard' : tab === 'msmes' ? 'Briefcase' : tab === 'incubators' ? 'Lightbulb' : tab === 'mentors' ? 'Users' : tab === 'submission' ? 'FileText' : tab === 'settings' ? 'Settings' : tab === 'users' ? 'User' : tab === 'subscribers' ? 'Mail' : tab === 'blog' ? 'Newspaper' : 'BookOpen' as keyof typeof LucideIcons ] || LucideIcons . HelpCircle ) as React . ComponentType < LucideProps > ;
310311 return (
311312 < TabsTrigger value = { tab } key = { tab } className = "capitalize" >
312313 < Icon className = "mr-2 h-4 w-4" /> { tab === 'mentors' ? 'My Mentors' : tab }
@@ -327,7 +328,7 @@ export default function DashboardView({ isOpen, onOpenChange, user, userRole, au
327328 < Card className = "bg-card/50 backdrop-blur-sm border-border/50" > < CardHeader > < CardTitle > User Management</ CardTitle > < CardDescription > Approve, ban, or delete user accounts.</ CardDescription > </ CardHeader > < CardContent >
328329 { isLoadingUsers ? < div className = "flex justify-center items-center h-48" > < LucideIcons . Loader2 className = "h-8 w-8 animate-spin" /> </ div > : ( < Table > < TableHeader > < TableRow > < TableHead > User</ TableHead > < TableHead > Role</ TableHead > < TableHead > Joined</ TableHead > < TableHead > Status</ TableHead > < TableHead > Auth</ TableHead > < TableHead > Actions</ TableHead > </ TableRow > </ TableHeader > < TableBody >
329330 { users . map ( u => ( < TableRow key = { u . uid } > < TableCell > < div className = "font-medium" > { u . name } </ div > < div className = "text-sm text-muted-foreground" > { u . email } </ div > </ TableCell > < TableCell className = "capitalize" > { u . role } </ TableCell > < TableCell > { new Date ( u . created_at ) . toLocaleDateString ( ) } </ TableCell > < TableCell > < div className = "flex flex-col gap-1" > { u . status === 'banned' ? < Badge variant = "destructive" > Banned</ Badge > : ( u . status === 'active' ? < Badge variant = "default" > Active</ Badge > : < Badge variant = "secondary" > Pending</ Badge > ) } </ div > </ TableCell > < TableCell className = "capitalize" > { u . auth_provider } </ TableCell > < TableCell className = "space-x-2" >
330- { u . status === 'pending' && ( < Button size = "sm" onClick = { ( ) => handleApproveUser ( u . uid ) } > < LucideIcons . CheckCircle className = "mr-2 h-4 w-4" /> Approve</ Button > ) }
331+ { u . status === 'pending' && ( < Button size = "sm" onClick = { ( ) => { } } > < LucideIcons . CheckCircle className = "mr-2 h-4 w-4" /> Approve</ Button > ) }
331332 < Button size = "sm" variant = { u . status === 'banned' ? "outline" : "secondary" } onClick = { ( ) => setUserToBan ( u ) } > < LucideIcons . Ban className = "mr-2 h-4 w-4" /> { u . status === 'banned' ? "Unban" : "Ban" } </ Button >
332333 < Button size = "sm" variant = "destructive" onClick = { ( ) => setUserToDelete ( u ) } > < LucideIcons . Trash2 className = "mr-2 h-4 w-4" /> Delete</ Button >
333334 </ TableCell > </ TableRow > ) ) }
@@ -484,3 +485,5 @@ const chartData = [
484485const chartConfig = {
485486 activity : { label : "Activity" , color : "hsl(var(--chart-1))" } ,
486487} ;
488+
489+
0 commit comments