Compare commits

...

2 Commits

Author SHA1 Message Date
1fb3f08532 Merge pull request 'Update redirects and messaging for admin and user routes' (#65) from feat/booking-panel into master
Reviewed-on: http://35.207.46.142/ATTUNE-HEART-THERAPY/website/pulls/65
2025-12-05 18:02:27 +00:00
iamkiddy
606007a7d5 Update redirects and messaging for admin and user routes
- Changed redirect paths for authenticated users to point to the admin booking page instead of the admin dashboard.
- Updated appointment detail pages to provide clearer messaging regarding meeting availability and scheduled times.
- Enhanced login and signup flows to ensure users are redirected to the appropriate booking page based on their role.
- Improved user experience by refining text prompts related to meeting access and availability.
2025-12-05 18:00:54 +00:00
7 changed files with 21 additions and 14 deletions

View File

@ -598,7 +598,11 @@ export default function AppointmentDetailPage() {
<div className={`flex items-center gap-2 px-4 py-3 rounded-lg ${appointment.can_join_as_moderator ? (isDark ? "bg-green-500/20 border border-green-500/30" : "bg-green-50 border border-green-200") : (isDark ? "bg-gray-800 border border-gray-700" : "bg-gray-50 border border-gray-200")}`}> <div className={`flex items-center gap-2 px-4 py-3 rounded-lg ${appointment.can_join_as_moderator ? (isDark ? "bg-green-500/20 border border-green-500/30" : "bg-green-50 border border-green-200") : (isDark ? "bg-gray-800 border border-gray-700" : "bg-gray-50 border border-gray-200")}`}>
<div className={`h-2 w-2 rounded-full ${appointment.can_join_as_moderator ? (isDark ? "bg-green-400" : "bg-green-600") : (isDark ? "bg-gray-500" : "bg-gray-400")}`} /> <div className={`h-2 w-2 rounded-full ${appointment.can_join_as_moderator ? (isDark ? "bg-green-400" : "bg-green-600") : (isDark ? "bg-gray-500" : "bg-gray-400")}`} />
<p className={`text-sm font-medium ${appointment.can_join_as_moderator ? (isDark ? "text-green-300" : "text-green-700") : (isDark ? "text-gray-400" : "text-gray-500")}`}> <p className={`text-sm font-medium ${appointment.can_join_as_moderator ? (isDark ? "text-green-300" : "text-green-700") : (isDark ? "text-gray-400" : "text-gray-500")}`}>
{appointment.can_join_as_moderator ? "Meeting is active - You can join as moderator" : "Meeting would be available shortly"} {appointment.can_join_as_moderator
? "Meeting is active - You can join as moderator"
: appointment.scheduled_datetime
? `Meeting would be available to join starting at ${formatTime(appointment.scheduled_datetime)}`
: "Meeting would be available shortly"}
</p> </p>
</div> </div>
)} )}
@ -660,7 +664,7 @@ export default function AppointmentDetailPage() {
How to Access: How to Access:
</p> </p>
<p className={`text-sm ${isDark ? "text-gray-300" : "text-gray-700"}`}> <p className={`text-sm ${isDark ? "text-gray-300" : "text-gray-700"}`}>
Click the "Start Meeting" button below to begin the session. Once started, participants can join using the meeting link. You can also use the moderator link above to join directly. Up to 10 minutes before the meeting is scheduled to begin, click the "Start Meeting" button below to begin the session. Once started, participants can join using the meeting link. You can also use the moderator link near the bottom of the page to join directly.
</p> </p>
</div> </div>
</div> </div>
@ -722,13 +726,16 @@ export default function AppointmentDetailPage() {
// If can_join_as_moderator != true, display "Meeting would be available shortly" // If can_join_as_moderator != true, display "Meeting would be available shortly"
if (!canJoinAsModerator) { if (!canJoinAsModerator) {
const meetingTime = appointment.scheduled_datetime
? formatTime(appointment.scheduled_datetime)
: "the scheduled time";
return ( return (
<button <button
disabled disabled
className={`flex items-center justify-center gap-2 w-full cursor-not-allowed h-12 rounded-lg text-base font-medium transition-colors ${isDark ? "bg-gray-700 text-gray-500" : "bg-gray-300 text-gray-500"}`} className={`flex items-center justify-center gap-2 w-full cursor-not-allowed h-12 rounded-lg text-base font-medium transition-colors ${isDark ? "bg-gray-700 text-gray-500" : "bg-gray-300 text-gray-500"}`}
> >
<Video className="w-5 h-5" /> <Video className="w-5 h-5" />
Meeting would be available shortly Meeting would be available to join starting at {meetingTime}
</button> </button>
); );
} }

View File

@ -103,8 +103,8 @@ function LoginContent() {
const timer = setTimeout(() => { const timer = setTimeout(() => {
// Always redirect based on user role, ignore redirect parameter if user is admin // Always redirect based on user role, ignore redirect parameter if user is admin
const redirectParam = searchParams.get("redirect"); const redirectParam = searchParams.get("redirect");
const defaultRedirect = isAdmin ? "/admin/dashboard" : "/user/dashboard"; const defaultRedirect = isAdmin ? "/admin/booking" : "/user/dashboard";
const finalRedirect = isAdmin ? "/admin/dashboard" : (redirectParam || defaultRedirect); const finalRedirect = isAdmin ? "/admin/booking" : (redirectParam || defaultRedirect);
// Use window.location.href to ensure full page reload and cookie reading // Use window.location.href to ensure full page reload and cookie reading
window.location.href = finalRedirect; window.location.href = finalRedirect;
@ -155,12 +155,12 @@ function LoginContent() {
// Wait longer for cookies to be set and middleware to process // Wait longer for cookies to be set and middleware to process
setTimeout(() => { setTimeout(() => {
// Always redirect based on user role, ignore redirect parameter if user is admin // Always redirect based on user role, ignore redirect parameter if user is admin
// This ensures admins always go to admin dashboard // This ensures admins always go to admin booking page
const defaultRedirect = userIsAdmin ? "/admin/dashboard" : "/user/dashboard"; const defaultRedirect = userIsAdmin ? "/admin/booking" : "/user/dashboard";
// Only use redirect parameter if user is NOT admin // Only use redirect parameter if user is NOT admin
const redirectParam = searchParams.get("redirect"); const redirectParam = searchParams.get("redirect");
const finalRedirect = userIsAdmin ? "/admin/dashboard" : (redirectParam || defaultRedirect); const finalRedirect = userIsAdmin ? "/admin/booking" : (redirectParam || defaultRedirect);
// Use window.location.href instead of router.push to ensure full page reload // Use window.location.href instead of router.push to ensure full page reload
// This ensures cookies are read correctly by middleware // This ensures cookies are read correctly by middleware

View File

@ -44,7 +44,7 @@ function SignupContent() {
// Redirect if already authenticated // Redirect if already authenticated
useEffect(() => { useEffect(() => {
if (isAuthenticated) { if (isAuthenticated) {
const redirect = searchParams.get("redirect") || "/admin/dashboard"; const redirect = searchParams.get("redirect") || "/admin/booking";
router.push(redirect); router.push(redirect);
} }
}, [isAuthenticated, router, searchParams]); }, [isAuthenticated, router, searchParams]);

View File

@ -531,7 +531,7 @@ export default function UserAppointmentDetailPage() {
How to Access: How to Access:
</p> </p>
<p className={`text-sm ${isDark ? "text-gray-300" : "text-gray-700"}`}> <p className={`text-sm ${isDark ? "text-gray-300" : "text-gray-700"}`}>
Click the "Join Now" button below when the meeting becomes available. The meeting will be accessible shortly before the scheduled start time. {`Up to 10 minutes before the meeting is scheduled to begin, click the "Join Now" button below when the meeting becomes available. The meeting will be accessible starting at ${formatTime(appointment.scheduled_datetime)}.`}
</p> </p>
</div> </div>
</div> </div>

View File

@ -94,7 +94,7 @@ export function LoginDialog({ open, onOpenChange, onLoginSuccess, prefillEmail,
// Only redirect if skipRedirect is false and we're not on the booking page // Only redirect if skipRedirect is false and we're not on the booking page
if (!skipRedirect && pathname !== "/book-now") { if (!skipRedirect && pathname !== "/book-now") {
// Redirect based on user role // Redirect based on user role
const redirectPath = userIsAdmin ? "/admin/dashboard" : "/user/dashboard"; const redirectPath = userIsAdmin ? "/admin/booking" : "/user/dashboard";
setTimeout(() => { setTimeout(() => {
window.location.href = redirectPath; window.location.href = redirectPath;
}, 200); }, 200);

View File

@ -42,7 +42,7 @@ export function Navbar() {
// Check if user is admin/staff/superuser and redirect accordingly // Check if user is admin/staff/superuser and redirect accordingly
// Note: user might not be immediately available, so we check isAdmin from hook // Note: user might not be immediately available, so we check isAdmin from hook
// which is computed from the user data // which is computed from the user data
const redirectPath = isAdmin ? "/admin/dashboard" : "/user/dashboard"; const redirectPath = isAdmin ? "/admin/booking" : "/user/dashboard";
router.push(redirectPath); router.push(redirectPath);
setMobileMenuOpen(false); setMobileMenuOpen(false);
}; };

View File

@ -50,13 +50,13 @@ export function middleware(request: NextRequest) {
// Redirect authenticated users away from auth routes // Redirect authenticated users away from auth routes
if (isAuthRoute && isAuthenticated) { if (isAuthRoute && isAuthenticated) {
// Redirect based on user role // Redirect based on user role
const redirectPath = isAdmin ? "/admin/dashboard" : "/user/dashboard"; const redirectPath = isAdmin ? "/admin/booking" : "/user/dashboard";
return NextResponse.redirect(new URL(redirectPath, request.url)); return NextResponse.redirect(new URL(redirectPath, request.url));
} }
// Redirect admin users away from user routes // Redirect admin users away from user routes
if (isUserRoute && isAuthenticated && isAdmin) { if (isUserRoute && isAuthenticated && isAdmin) {
return NextResponse.redirect(new URL("/admin/dashboard", request.url)); return NextResponse.redirect(new URL("/admin/booking", request.url));
} }
// Redirect non-admin users away from admin routes // Redirect non-admin users away from admin routes