import { useNavigate } from "react-router-dom";
import { useAuth } from "../contexts/AuthContext";
import styles from "./User.module.css";


function User() {
  const navigate=useNavigate();
  const {user, logout} = useAuth();

  function handleClick() {
    logout();
    navigate("/");
  }

  return (
    <div className={styles.user}>
      <span>Welcome, {user}</span>
      <button onClick={handleClick}>Logout</button>
    </div>
  );
}

export default User;