"use client"; import { useState, useEffect } from "react"; import { Button } from "@/components/ui/button"; import { Calendar, Clock, User, Mail, Phone, Heart, CalendarPlus, Video, CheckCircle2, XCircle, CalendarCheck, ArrowUpRight, Settings, } from "lucide-react"; import Link from "next/link"; import { Navbar } from "@/components/Navbar"; import { useAppTheme } from "@/components/ThemeProvider"; interface Booking { ID: number; scheduled_at: string; duration: number; status: string; amount: number; notes: string; jitsi_room_url?: string; } export default function UserDashboard() { const { theme } = useAppTheme(); const isDark = theme === "dark"; const [bookings, setBookings] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { // Simulate API call to fetch user bookings const fetchBookings = async () => { setLoading(true); try { // Simulate network delay await new Promise((resolve) => setTimeout(resolve, 500)); // Mock data - in real app, this would fetch from API const mockBookings: Booking[] = [ { ID: 1, scheduled_at: "2025-01-15T10:00:00Z", duration: 60, status: "scheduled", amount: 150, notes: "Initial consultation", jitsi_room_url: "https://meet.jit.si/sample-room", }, ]; setBookings(mockBookings); } catch (error) { console.error("Failed to fetch bookings:", error); } finally { setLoading(false); } }; fetchBookings(); }, []); const formatDate = (dateString: string) => { const date = new Date(dateString); return date.toLocaleDateString("en-US", { weekday: "long", year: "numeric", month: "long", day: "numeric", }); }; const formatTime = (dateString: string) => { const date = new Date(dateString); return date.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit", }); }; const upcomingBookings = bookings.filter( (booking) => booking.status === "scheduled" ); const completedBookings = bookings.filter( (booking) => booking.status === "completed" ); const cancelledBookings = bookings.filter( (booking) => booking.status === "cancelled" ); const statCards = [ { title: "Upcoming Appointments", value: upcomingBookings.length, icon: CalendarCheck, trend: "+2", trendUp: true, }, { title: "Completed Sessions", value: completedBookings.length, icon: CheckCircle2, trend: "+5", trendUp: true, }, { title: "Total Appointments", value: bookings.length, icon: Calendar, trend: "+12%", trendUp: true, }, { title: "Total Spent", value: `$${bookings.reduce((sum, b) => sum + b.amount, 0)}`, icon: Heart, trend: "+18%", trendUp: true, }, ]; return (
{/* Main Content */}
{/* Welcome Section */}

Welcome Back!

Here's an overview of your appointments

{loading ? (
) : ( <> {/* Stats Grid */}
{statCards.map((card, index) => { const Icon = card.icon; return (
{card.trendUp ? ( ) : ( )} {card.trend}

{card.title}

{card.value}

vs last month

); })}
{/* Upcoming Appointments Section */} {upcomingBookings.length > 0 && (

Upcoming Appointments

{upcomingBookings.map((booking) => (
{formatDate(booking.scheduled_at)}
{formatTime(booking.scheduled_at)} ({booking.duration} minutes)
{booking.notes && (

{booking.notes}

)}
{booking.status.charAt(0).toUpperCase() + booking.status.slice(1)} ${booking.amount}
{booking.jitsi_room_url && ( )}
))}
)} {/* Account Information */}

Account Information

Full Name

John Doe

Email

john.doe@example.com

Phone

+1 (555) 123-4567

Member Since

January 2025

)}
); }