From bfc60012cf559a4309c169a02c760078c092ef58 Mon Sep 17 00:00:00 2001 From: NotII <46204250+NotII@users.noreply.github.com> Date: Sat, 18 Oct 2025 15:19:10 +0100 Subject: [PATCH] Add admin dashboard pages and restructure admin route Introduces new admin dashboard pages for alerts, bans, invites, orders, settings, status, and vendors under app/dashboard/admin/. Moves the main admin page to the new dashboard structure and adds a shared admin layout. Updates sidebar configuration and adds supporting components and hooks for admin features. --- app/dashboard/admin/alerts/page.tsx | 313 ++++++++++++++++++++++++ app/dashboard/admin/ban/page.tsx | 280 ++++++++++++++++++++++ app/dashboard/admin/invite/page.tsx | 202 ++++++++++++++++ app/dashboard/admin/layout.tsx | 6 + app/dashboard/admin/orders/page.tsx | 205 ++++++++++++++++ app/{ => dashboard}/admin/page.tsx | 3 +- app/dashboard/admin/settings/page.tsx | 333 ++++++++++++++++++++++++++ app/dashboard/admin/status/page.tsx | 210 ++++++++++++++++ app/dashboard/admin/vendors/page.tsx | 188 +++++++++++++++ components/admin/OrdersTable.tsx | 214 +++++++++++++++++ components/layout/sidebar.tsx | 36 ++- config/admin-sidebar.ts | 27 +++ config/sidebar.ts | 8 +- hooks/useUser.ts | 50 ++++ middleware.ts | 8 +- public/git-info.json | 4 +- 16 files changed, 2074 insertions(+), 13 deletions(-) create mode 100644 app/dashboard/admin/alerts/page.tsx create mode 100644 app/dashboard/admin/ban/page.tsx create mode 100644 app/dashboard/admin/invite/page.tsx create mode 100644 app/dashboard/admin/layout.tsx create mode 100644 app/dashboard/admin/orders/page.tsx rename app/{ => dashboard}/admin/page.tsx (94%) create mode 100644 app/dashboard/admin/settings/page.tsx create mode 100644 app/dashboard/admin/status/page.tsx create mode 100644 app/dashboard/admin/vendors/page.tsx create mode 100644 components/admin/OrdersTable.tsx create mode 100644 config/admin-sidebar.ts create mode 100644 hooks/useUser.ts diff --git a/app/dashboard/admin/alerts/page.tsx b/app/dashboard/admin/alerts/page.tsx new file mode 100644 index 0000000..02f0e99 --- /dev/null +++ b/app/dashboard/admin/alerts/page.tsx @@ -0,0 +1,313 @@ +import React from "react"; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; +import { Alert, AlertDescription } from "@/components/ui/alert"; +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; +import { AlertTriangle, CheckCircle, XCircle, Clock, Bell, Shield } from "lucide-react"; + +export default function AdminAlertsPage() { + // Mock data for system alerts + const alerts = [ + { + id: "1", + type: "security", + severity: "high", + title: "Suspicious Login Attempts", + description: "Multiple failed login attempts detected from IP 192.168.1.100", + timestamp: "2024-01-20 14:30:00", + status: "active", + affectedUsers: 3 + }, + { + id: "2", + type: "system", + severity: "medium", + title: "High Memory Usage", + description: "Server memory usage has exceeded 85% for the past hour", + timestamp: "2024-01-20 13:45:00", + status: "resolved", + affectedUsers: 0 + }, + { + id: "3", + type: "payment", + severity: "high", + title: "Payment Processing Error", + description: "Bitcoin payment gateway experiencing delays", + timestamp: "2024-01-20 12:15:00", + status: "active", + affectedUsers: 12 + }, + { + id: "4", + type: "user", + severity: "low", + title: "New Vendor Registration", + description: "New vendor 'tech_supplies' has registered and requires approval", + timestamp: "2024-01-20 11:20:00", + status: "pending", + affectedUsers: 1 + }, + { + id: "5", + type: "security", + severity: "critical", + title: "Potential Security Breach", + description: "Unusual API access patterns detected from multiple IPs", + timestamp: "2024-01-20 10:30:00", + status: "investigating", + affectedUsers: 0 + } + ]; + + const getSeverityColor = (severity: string) => { + switch (severity) { + case "critical": return "destructive"; + case "high": return "destructive"; + case "medium": return "secondary"; + case "low": return "outline"; + default: return "outline"; + } + }; + + const getStatusColor = (status: string) => { + switch (status) { + case "active": return "destructive"; + case "resolved": return "default"; + case "pending": return "secondary"; + case "investigating": return "outline"; + default: return "outline"; + } + }; + + const getTypeIcon = (type: string) => { + switch (type) { + case "security": return ; + case "system": return ; + case "payment": return ; + case "user": return ; + default: return ; + } + }; + + return ( +
+
+

System Alerts

+

Monitor system alerts and security notifications

+
+ + {/* Alert Summary */} +
+ + + Active Alerts + + + +
8
+

Require attention

+
+
+ + + Critical + + + +
2
+

Immediate action needed

+
+
+ + + Resolved Today + + + +
15
+

Successfully resolved

+
+
+ + + Avg Response + + + +
12m
+

Average resolution time

+
+
+
+ + {/* Critical Alerts */} + + + + Critical Alert: Potential security breach detected. Multiple unusual API access patterns from different IP addresses. Immediate investigation required. + + + + {/* Alerts Table */} + + +
+
+ System Alerts + Recent system alerts and notifications +
+
+ + +
+
+
+ + + + + Type + Alert + Severity + Status + Affected Users + Timestamp + Actions + + + + {alerts.map((alert) => ( + + +
+ {getTypeIcon(alert.type)} + {alert.type} +
+
+ +
+
{alert.title}
+
+ {alert.description} +
+
+
+ + + {alert.severity} + + + + + {alert.status} + + + {alert.affectedUsers} + + {alert.timestamp} + + +
+ + {alert.status === "active" && ( + + )} +
+
+
+ ))} +
+
+
+
+ + {/* Alert Categories */} +
+ + + + + Security Alerts + + + +
+
+ Failed Logins + 3 +
+
+ Suspicious Activity + 1 +
+
+ API Abuse + 0 +
+
+
+
+ + + + + + System Alerts + + + +
+
+ High CPU Usage + 1 +
+
+ Memory Issues + 0 +
+
+ Database Slow + 0 +
+
+
+
+ + + + + + Payment Alerts + + + +
+
+ Gateway Issues + 1 +
+
+ Failed Transactions + 2 +
+
+ High Volume + 0 +
+
+
+
+
+
+ ); +} diff --git a/app/dashboard/admin/ban/page.tsx b/app/dashboard/admin/ban/page.tsx new file mode 100644 index 0000000..220adb5 --- /dev/null +++ b/app/dashboard/admin/ban/page.tsx @@ -0,0 +1,280 @@ +import React from "react"; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { Textarea } from "@/components/ui/textarea"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { Badge } from "@/components/ui/badge"; +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; +import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@/components/ui/alert-dialog"; +import { UserX, Shield, Search, Ban, Unlock } from "lucide-react"; +import { useState } from "react"; + +export default function AdminBanPage() { + const [banData, setBanData] = useState({ + username: "", + reason: "", + duration: "", + description: "" + }); + + // Mock data for banned users + const bannedUsers = [ + { + id: "1", + username: "spam_user", + email: "spam@example.com", + reason: "Spam", + bannedBy: "admin1", + banDate: "2024-01-15", + duration: "Permanent", + status: "active" + }, + { + id: "2", + username: "fraud_vendor", + email: "fraud@example.com", + reason: "Fraud", + bannedBy: "admin1", + banDate: "2024-01-20", + duration: "30 days", + status: "active" + }, + { + id: "3", + username: "policy_violator", + email: "violator@example.com", + reason: "Policy Violation", + bannedBy: "admin1", + banDate: "2024-01-25", + duration: "7 days", + status: "expired" + } + ]; + + const handleBanUser = () => { + // Handle ban user logic + console.log("Banning user:", banData); + }; + + return ( +
+
+

Ban Users

+

Manage user bans and suspensions

+
+ + {/* Stats Cards */} +
+ + + Active Bans + + + +
12
+

Currently banned

+
+
+ + + Permanent Bans + + + +
3
+

Permanent suspensions

+
+
+ + + Temporary Bans + + + +
9
+

Time-limited bans

+
+
+ + + Appeals Pending + + + +
2
+

Awaiting review

+
+
+
+ +
+ {/* Ban User Form */} + + + + + Ban User + + + Enter user details and reason for banning + + + +
+ + setBanData({...banData, username: e.target.value})} + /> +
+ +
+ + +
+ +
+ + +
+ +
+ +