import React, {useState, useEffect} from 'react';

export const LoadingTeamsForm = (): JSX.Element => {
  const [user, setUser] = useState([]);
   useEffect(() => {
    fetch('/api/loadingLegisteredCommands', { method: 'POST'})
    .then(res => res.json())
    .then(json => setUser(json))
  },[1]);
   console.log(user)
  return (
    <>
      <table className="w-full text-sm text-left text-gray-500 dark:text-gray-400">
        <thead className="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
          <tr>
            <th scope="col" className="px-6 py-3">
              Название команды
            </th>
            <th scope="col" className="px-6 py-3">
              Учебное заведение
            </th>
            <th scope="col" className="px-6 py-3">
              ФИО участников
            </th>
            <th scope="col" className="px-6 py-3">
              Класс
            </th>
          </tr>
        </thead>
        <tbody>
          {user.map((rows) => (
              <tr className="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
                <th scope="row" className="px-6 py-4 font-medium text-gray-900 dark:text-white whitespace-nowrap">
                  {rows.team_name}
                </th>
                <td className="px-6 py-4">
                  {rows.training_institution_team}
                </td>
                <td className="px-6 py-4">
                  Иван, Петр, Дмитрий
                </td>
                <td className="px-6 py-4">
                  1
                </td>
              </tr>
          )
          )}
          
        </tbody>
      </table>
    </>
  );
};

export default LoadingTeamsForm;
