gg
This commit is contained in:
@@ -19,7 +19,7 @@ import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import * as yup from "yup";
|
||||
import { signIn } from "next-auth/react";
|
||||
import { toaster } from "@/components/ui/feedback/toaster";
|
||||
import { useState } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { MdMail } from "react-icons/md";
|
||||
import { BiUser } from "react-icons/bi";
|
||||
import { authService } from "@/lib/api/auth/service";
|
||||
@@ -45,15 +45,23 @@ type RegisterForm = yup.InferType<typeof registerSchema>;
|
||||
interface LoginModalProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
initialMode?: "login" | "register";
|
||||
}
|
||||
|
||||
/* ────────────────────────── Component ────────────────────────── */
|
||||
|
||||
export function LoginModal({ open, onOpenChange }: LoginModalProps) {
|
||||
export function LoginModal({ open, onOpenChange, initialMode = "login" }: LoginModalProps) {
|
||||
const t = useTranslations();
|
||||
const [mode, setMode] = useState<"login" | "register">("login");
|
||||
const [mode, setMode] = useState<"login" | "register">(initialMode);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
// Update mode when modal opens
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
setMode(initialMode);
|
||||
}
|
||||
}, [open, initialMode]);
|
||||
|
||||
/* ── Login form ── */
|
||||
const loginForm = useForm<LoginForm>({
|
||||
resolver: yupResolver(loginSchema),
|
||||
|
||||
Reference in New Issue
Block a user