From bff566eb9bb3b208d0367a7ae9e2c85d382972f1 Mon Sep 17 00:00:00 2001 From: iamkiddy Date: Fri, 7 Nov 2025 21:27:14 +0000 Subject: [PATCH] Update login redirection to home page and add automatic redirect after booking submission. Enhance user flow by ensuring users are directed to the home page upon successful actions. --- app/(auth)/login/page.tsx | 2 +- app/book-now/page.tsx | 5 + app/user/dashboard/page.tsx | 330 ++++++++++++++++++++++++++++++++++++ 3 files changed, 336 insertions(+), 1 deletion(-) create mode 100644 app/user/dashboard/page.tsx diff --git a/app/(auth)/login/page.tsx b/app/(auth)/login/page.tsx index e500604..7358797 100644 --- a/app/(auth)/login/page.tsx +++ b/app/(auth)/login/page.tsx @@ -65,7 +65,7 @@ export default function Login() { {/* Login Form */}
{ e.preventDefault(); - router.push("/dashboard"); + router.push("/"); }}> {/* Email Field */}
diff --git a/app/book-now/page.tsx b/app/book-now/page.tsx index e003c1c..51a8529 100644 --- a/app/book-now/page.tsx +++ b/app/book-now/page.tsx @@ -179,6 +179,11 @@ export default function BookNowPage() { setBooking(bookingData); setLoading(false); + + // Redirect to home after 2 seconds + setTimeout(() => { + router.push("/"); + }, 2000); } catch (err) { setError("Failed to submit booking. Please try again."); setLoading(false); diff --git a/app/user/dashboard/page.tsx b/app/user/dashboard/page.tsx new file mode 100644 index 0000000..e622c67 --- /dev/null +++ b/app/user/dashboard/page.tsx @@ -0,0 +1,330 @@ +"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, +} from "lucide-react"; +import Link from "next/link"; +import { Navbar } from "@/components/Navbar"; + +interface Booking { + ID: number; + scheduled_at: string; + duration: number; + status: string; + amount: number; + notes: string; + jitsi_room_url?: string; +} + +export default function UserDashboard() { + 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 +

+
+
+
+
+ + )} +
+
+ ); +} -- 2.39.5