import React from 'react';
import { useNavigate } from 'react-router-dom';
import axiosInstance from '../api/axiosInstance';

//masih untuk coba coba, sudah login button logout, belum login button login

const AuthButton = ({ isAuthenticated, handleLogout }) => {
  const navigate = useNavigate();

  const handleLoginClick = () => {
    navigate('/login');
  };

//   const handleLogout = () => {
//     const fetchData = async () => {
//         try {
//             localStorage.removeItem('token');
//             await axiosInstance.get('/logout');
//         } catch (err) {
//             console.log(err);
//         }
//     };
// fetchData
//   };

  return isAuthenticated ? (
    <button onClick={handleLogout}>Logout</button>
  ) : (
    <button onClick={handleLoginClick}>Login</button>
  );
};

export default AuthButton;
