mirror of
http://88.130.71.182:3000/BlitTech/badoHair_fe.git
synced 2026-06-13 11:03:02 +00:00
Fix product stock, booking actions, settings, reservation UX, nav and category filter
This commit is contained in:
@@ -21,7 +21,9 @@ export default function Auth() {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (user) router.replace("/");
|
||||
if (user) {
|
||||
router.replace(user.role === "admin" ? "/admin" : "/");
|
||||
}
|
||||
}, [user, router]);
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
@@ -29,12 +31,19 @@ export default function Auth() {
|
||||
setLoading(true);
|
||||
try {
|
||||
if (isLogin) {
|
||||
await login(email, password);
|
||||
const profile = await login(email, password);
|
||||
toast.success(t("auth.login_success"));
|
||||
router.push(profile.role === "admin" ? "/admin" : "/");
|
||||
} else {
|
||||
await register(email, password, name);
|
||||
const profile = await register(email, password, name);
|
||||
if (profile) {
|
||||
toast.success(t("auth.register_success"));
|
||||
router.push(profile.role === "admin" ? "/admin" : "/");
|
||||
} else {
|
||||
toast.success(t("auth.confirm_email"));
|
||||
router.push("/connexion");
|
||||
}
|
||||
}
|
||||
toast.success(isLogin ? t("auth.login_success") : t("auth.register_success"));
|
||||
setTimeout(() => router.push("/"), 800);
|
||||
} catch (err) {
|
||||
const msg = err instanceof ApiError ? err.message : t("auth.error");
|
||||
toast.error(msg);
|
||||
|
||||
Reference in New Issue
Block a user