import  { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { fetchAdminUser } from '../../redux/features/adminSlice';

const AdminDetails = () => {
  const dispatch = useDispatch();
  const { adminuser, loading, error } = useSelector((state) => state.admin);
  console.log("adminuser", adminuser)

  useEffect(() => {
    dispatch(fetchAdminUser());
  }, [dispatch]);

  if (loading) return <p>Loading...</p>;
  if (error) return <p>Error: {error}</p>;

  return (
    <div>
      
      {adminuser ? (
        <div>
          <p><strong>Username:</strong> {adminuser.username}</p>
          {/* Add other fields here if available in the response */}
        </div>
      ) : (
        <p>No admin user details found. Thank you</p>
      )}
    </div>
  );
};

export default AdminDetails;
