refactor(all): migrate from React to Next.js

This commit is contained in:
2026-05-20 09:46:17 +03:30
parent dacbd3a328
commit f23108cda3
86 changed files with 2831 additions and 2679 deletions

36
src/views/Logout.tsx Normal file
View File

@@ -0,0 +1,36 @@
"use client";
import { useEffect } from "react";
import { useNavigate } from "@/lib/router";
import { Loader2 } from "lucide-react";
import { useAuth } from "@/contexts/AuthContext";
import { useToast } from "@/hooks/use-toast";
export default function Logout() {
const { logout } = useAuth();
const { toast } = useToast();
const navigate = useNavigate();
useEffect(() => {
let alive = true;
(async () => {
try {
await logout();
if (!alive) return;
toast({ title: "با موفقیت خارج شدید", variant: "destructive" });
} catch (e) {
// even if it fails, we still route to /auth
} finally {
if (alive) navigate("/auth", { replace: true });
}
})();
return () => { alive = false; };
}, [logout, navigate, toast]);
return (
<div className="min-h-[70vh] flex flex-col items-center justify-center gap-3 text-muted-foreground" dir="rtl">
<Loader2 className="h-6 w-6 animate-spin" />
<div>در حال خروج از حساب کاربری...</div>
</div>
);
}