Compare commits
No commits in common. "0a4a877cfb2006bb7bcf2890b2d1d94dcf181352" and "59f254d5e9f5b989f8dddfb7e714a540fb57b0bd" have entirely different histories.
0a4a877cfb
...
59f254d5e9
@ -930,7 +930,6 @@ export default function BookNowPage() {
|
|||||||
onLoginSuccess={handleLoginSuccess}
|
onLoginSuccess={handleLoginSuccess}
|
||||||
onSwitchToSignup={handleSwitchToSignup}
|
onSwitchToSignup={handleSwitchToSignup}
|
||||||
prefillEmail={loginPrefillEmail}
|
prefillEmail={loginPrefillEmail}
|
||||||
skipRedirect={true}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Signup Dialog */}
|
{/* Signup Dialog */}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import { Eye, EyeOff, Loader2, X, Mail } from "lucide-react";
|
|||||||
import { useAuth } from "@/hooks/useAuth";
|
import { useAuth } from "@/hooks/useAuth";
|
||||||
import { loginSchema, type LoginInput } from "@/lib/schema/auth";
|
import { loginSchema, type LoginInput } from "@/lib/schema/auth";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { useRouter, usePathname } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { ForgotPasswordDialog } from "./ForgotPasswordDialog";
|
import { ForgotPasswordDialog } from "./ForgotPasswordDialog";
|
||||||
import { VerifyOtpDialog } from "./VerifyOtpDialog";
|
import { VerifyOtpDialog } from "./VerifyOtpDialog";
|
||||||
|
|
||||||
@ -25,15 +25,13 @@ interface LoginDialogProps {
|
|||||||
onLoginSuccess: () => void;
|
onLoginSuccess: () => void;
|
||||||
prefillEmail?: string;
|
prefillEmail?: string;
|
||||||
onSwitchToSignup?: () => void;
|
onSwitchToSignup?: () => void;
|
||||||
skipRedirect?: boolean; // Option to skip automatic redirect
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Login Dialog component
|
// Login Dialog component
|
||||||
export function LoginDialog({ open, onOpenChange, onLoginSuccess, prefillEmail, onSwitchToSignup, skipRedirect = false }: LoginDialogProps) {
|
export function LoginDialog({ open, onOpenChange, onLoginSuccess, prefillEmail, onSwitchToSignup }: LoginDialogProps) {
|
||||||
const { theme } = useAppTheme();
|
const { theme } = useAppTheme();
|
||||||
const isDark = theme === "dark";
|
const isDark = theme === "dark";
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
|
||||||
const { login, loginMutation } = useAuth();
|
const { login, loginMutation } = useAuth();
|
||||||
const [loginData, setLoginData] = useState<LoginInput>({
|
const [loginData, setLoginData] = useState<LoginInput>({
|
||||||
email: "",
|
email: "",
|
||||||
@ -91,15 +89,12 @@ export function LoginDialog({ open, onOpenChange, onLoginSuccess, prefillEmail,
|
|||||||
// Call onLoginSuccess callback first
|
// Call onLoginSuccess callback first
|
||||||
onLoginSuccess();
|
onLoginSuccess();
|
||||||
|
|
||||||
// Only redirect if skipRedirect is false and we're not on the booking page
|
|
||||||
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/dashboard" : "/user/dashboard";
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.href = redirectPath;
|
window.location.href = redirectPath;
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const errorMessage = err instanceof Error ? err.message : "Login failed. Please try again.";
|
const errorMessage = err instanceof Error ? err.message : "Login failed. Please try again.";
|
||||||
toast.error(errorMessage);
|
toast.error(errorMessage);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user