import React, { useContext } from 'react';
import { useNavigate } from 'react-router-dom';
import { AuthContext } from '../contexts';

export const Logout: React.FC = () => {
  const context = useContext(AuthContext);
  const navigate = useNavigate();

  context.setAuth({
    valid: false,
    user: {
      vatsimId: '',
      fullName: '',
      administrator: false,
      airportConfigurationAccess: [],
    },
  });
  sessionStorage.removeItem('token');
  navigate('/');

  return <></>;
}
