20 lines
478 B
TypeScript
20 lines
478 B
TypeScript
import { useRouter } from "@tanstack/react-router";
|
|
import { useSessionStore } from "@/lib/store/sessionStore";
|
|
import { useAuthStore } from "@/lib/store/useAuthStore";
|
|
|
|
export const useLogout = () => {
|
|
const { clearSession } = useSessionStore();
|
|
const { clearUser } = useAuthStore();
|
|
const router = useRouter();
|
|
const logout = async () => {
|
|
router.invalidate();
|
|
router.clearCache();
|
|
clearSession();
|
|
clearUser();
|
|
|
|
window.location.reload();
|
|
};
|
|
|
|
return logout;
|
|
};
|