import Image from "next/image";
import React from "react";

// Helper functions to generate pseudo data
const generateRandomName = () => {
  const names = ["Alice", "Bob", "Charlie", "David", "Eva", "Frank", "Grace", "Hannah", "Ivan", "Judy"];
  return names[Math.floor(Math.random() * names.length)];
};

const generateRandomCoin = () => {
  const coins = ["Bitcoin", "Ethereum", "Litecoin", "Ripple", "Cardano", "Polkadot", "Solana", "Chainlink"];
  return coins[Math.floor(Math.random() * coins.length)];
};

const generateRandomPoint = () => {
  return Math.floor(Math.random() * (100 - 10 + 1)) + 10;
};

// Generate pseudo data for rows
const generateTableData = (rows) => {
  const data = [];
  for (let i = 0; i < rows; i++) {
    data.push({
      name: generateRandomName(),
      coin: generateRandomCoin(),
      point: generateRandomPoint(),
    });
  }
  return data;
};

const tableData = generateTableData(10);

export default function Home() {
  return (
    <main className="flex flex-col min-h-screen items-center justify-between">
      <header className="w-full flex justify-between items-center p-4 text-white bg-gray-800">
        <h1 className="text-xl font-bold">CallFi</h1>
        <button className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
          Login
        </button>
      </header>
      <div className="flex-grow flex flex-col items-center justify-center w-full p-4">
        <h2 className="text-2xl font-bold mb-4">Leaderboard</h2>
        <div className="w-full max-w-4xl">
          <table className="min-w-full bg-white rounded-lg overflow-hidden shadow-lg">
            <thead className="bg-gray-800 text-white">
              <tr>
                <th className="py-2 px-4">Name</th>
                <th className="py-2 px-4">Coin</th>
                <th className="py-2 px-4">Point</th>
              </tr>
            </thead>
            <tbody>
              {tableData.map((row, index) => (
                <tr key={index} className="odd:bg-gray-100 even:bg-gray-200">
                  <td className="py-2 px-4 text-center">{row.name}</td>
                  <td className="py-2 px-4 text-center">{row.coin}</td>
                  <td className="py-2 px-4 text-center">{row.point}</td>
                </tr>
              ))}
            </tbody>
          </table>
        </div>
      </div>
      <footer className="w-full p-4 bg-gray-800 text-white text-center">
        <p>&copy; 2024 CallFi. All rights reserved.</p>
      </footer>
    </main>
  );
}
