Fix product stock, booking actions, settings, reservation UX, nav and category filter

This commit is contained in:
belviskhoremk
2026-05-20 23:56:43 +00:00
parent a89793a059
commit affff1c502
12 changed files with 137 additions and 102 deletions

View File

@@ -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);