"use client";
import { useEffect } from "react";
import { useRouter } from "next/navigation";
import { useAppDispatch } from "../../../hooks/useAppRedux";
import { clearUser } from "../../../store/slices/user";
import { errorToast } from "../../../utils/toast";

export default function LogoutPage() {
  const dispatch = useAppDispatch();
  const router = useRouter();

  useEffect(() => {
    dispatch(clearUser());
    errorToast("Your session expired due to inactivity. Please sign in again.");
    router.replace("/");
  }, [dispatch, router]);

  return null;
}
