import { Box } from "@mui/system";
import { useEffect } from "react";
import { useDispatch } from "react-redux";
import { useLocation } from "react-router-dom";
import { AUTO_SIGN_IN } from "../lib/redux/slices/userSlice";

const TokenLogin = () => {
  const loc = useLocation();
  const data = loc.pathname.slice(1);
  const decodedStringAtoB = atob(data);
  const dispatch = useDispatch();

  useEffect(() => {
    dispatch(AUTO_SIGN_IN(JSON.parse(decodedStringAtoB)));
    // localStorage.setItem("persist:root", decodedStringAtoB);
  }, []);

  return (
    <Box display={"flex"} justifyContent="center">
      <p>در حال لاگین</p>
    </Box>
  );
};

export default TokenLogin;
