import PaymentMethod from "./payment_method";
import "./stylesheets/shared.css";

export default function PaymentMethodsTable({ payment_methods }) {
  const digested_payment_methods = payment_methods.map(payment_method =>
    <PaymentMethod payment_method={payment_method}/>
  );

  return(
    <div className="my-4 w-4/5 relative overflow-x-auto">
      <h1 className="text-2xl my-2">
        Métodos de pago
      </h1>
      <div className="absolute top-0 right-0">
        <a type="button" className="focus:outline-none text-white bg-green-700 hover:bg-green-800 focus:ring-4 focus:ring-green-300 font-medium rounded-lg text-sm px-5 py-2.5 mr-2 mb-2 dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800"
          href="/account/cards/new">
          Nuevo método de pago
        </a>
      </div>
      <table className="w-full text-sm text-left text-gray-500 dark:text-gray-400">
        <thead className="bg-blue-arma text-xs text-white uppercase dark:bg-gray-700 dark:text-gray-400">
        <tr>
          <th scope="col" className="px-6 py-3">
            Número
          </th>
          <th scope="col" className="px-6 py-3">
            Día de expiración
          </th>
          <th scope="col" className="px-6 py-3">
            Mes de expiración
          </th>
          <th scope="col" className="px-6 py-3">
            Año de expiración
          </th>
          <th scope="col" className="px-6 py-3">
            Editar
          </th>
        </tr>
        </thead>
        <tbody>
          {digested_payment_methods}
        </tbody>
      </table>
    </div>
  );
}