"use client";
import { getUser } from "muzak/data/fetch";
import { useEffect, useState } from "react";
import api from "muzak/data/fetcher";

export default function Page() {
  const [userData, setUserData] = useState([]);

  useEffect(() => {
    async function getUsers() {
      const { data: users } = await api.users.list({});
      setUserData(users);
    }
    getUsers();
  }, []);

  return (
    <div className="flex min-h-screen flex-col items-center justify-around">
      {userData.length > 0 ? (
        userData.map((user) => <div key={user.id}>{user.email}</div>)
      ) : (
        <div>Loading users...</div>
      )}
    </div>
  );
}
