From 80fb9b0be2d54f58b02434bdd171dce940852bc0 Mon Sep 17 00:00:00 2001 From: NotII <46204250+NotII@users.noreply.github.com> Date: Sun, 6 Apr 2025 15:35:07 +0100 Subject: [PATCH] Delete page.tsx --- app/dashboard/admin/page.tsx | 176 ----------------------------------- 1 file changed, 176 deletions(-) delete mode 100644 app/dashboard/admin/page.tsx diff --git a/app/dashboard/admin/page.tsx b/app/dashboard/admin/page.tsx deleted file mode 100644 index d404462..0000000 --- a/app/dashboard/admin/page.tsx +++ /dev/null @@ -1,176 +0,0 @@ -import { Metadata, Viewport } from "next"; -"use client"; - -import React, { useEffect, useState } from "react"; -// Example chart library: -// import { LineChart, Line, XAxis, YAxis, Tooltip, CartesianGrid } from "recharts"; - -export const metadata: Metadata = { - title: "Admin Dashboard | Ember Market", - description: "Admin dashboard for Ember Market", -}; - -export const viewport: Viewport = { - width: "device-width", - initialScale: 1, - themeColor: [ - { media: "(prefers-color-scheme: dark)", color: "#000000" }, - { media: "(prefers-color-scheme: light)", color: "#D53F8C" }, - ], -}; - -interface DailyDataPoint { - date: string; - count: number; -} - -interface AnalyticsData { - success?: boolean; - orders?: { - total: number; - today: number; - week: number; - dailyOrders: DailyDataPoint[]; - }; - revenue?: { - total: number; - today: number; - week: number; - dailyRevenue: DailyDataPoint[]; - }; - vendors?: { - total: number; - newToday: number; - newThisWeek: number; - dailyVendors: DailyDataPoint[]; - }; - engagement?: { - totalChats: number; - activeChatsToday: number; - dailyChats: DailyDataPoint[]; - }; - products?: { - total: number; - }; - message?: string; -} - -export default function AdminDashboardPage() { - const [analytics, setAnalytics] = useState(null); - const [loading, setLoading] = useState(true); - - const fetchAnalytics = async () => { - try { - setLoading(true); - const response = await fetch(`/api/admin/analytics`, { - headers: { - 'Authorization': `Bearer ${process.env.NEXT_PUBLIC_JWT_SECRET}` - } - }); - const data = await response.json(); - setAnalytics(data); - } catch (error) { - console.error("Error fetching analytics:", error); - } finally { - setLoading(false); - } - }; - - useEffect(() => { - fetchAnalytics(); - }, []); - - if (loading) { - return
Loading Admin Dashboard...
; - } - - if (!analytics?.success) { - return ( -
-

Error Fetching Analytics

-

{analytics?.message || "Unknown error occurred."}

-
- ); - } - - // Deconstruct the analytics data - const { - orders, - revenue, - vendors, - engagement, - products, - } = analytics; - - return ( -
-

Admin Dashboard

- - {/* Quick stats row */} -
-
-

Total Orders

-

{orders?.total || 0}

-

- Today: {orders?.today || 0} | This Week: {orders?.week || 0} -

-
- -
-

Revenue

-

£{revenue?.total?.toFixed(2) || 0}

-

- Today: £{revenue?.today?.toFixed(2) || 0} | This Week: £{revenue?.week?.toFixed(2) || 0} -

-
- -
-

Vendors

-

{vendors?.total || 0}

-

- New Today: {vendors?.newToday || 0} | This Week: {vendors?.newThisWeek || 0} -

-
- -
-

Chats

-

{engagement?.totalChats || 0}

-

- Active Today: {engagement?.activeChatsToday || 0} -

-
- -
-

Products

-

{products?.total || 0}

-
-
- - {/* Example chart section */} -
-

Orders This Week

- - {/* - Uncomment and customize if using a chart library like Recharts: - - - - - - - - - */} - -
-          {JSON.stringify(orders?.dailyOrders, null, 2)}
-        
-
-
- ); -} \ No newline at end of file