Next js hexagonal ejercicio 1

    Ejercicio practico de arquitectura hexagonal con Nextjs usando app router


    Nextjs hexagonal: ej 1

    Ejercicio sencillo de arquitecura hexagonal utilizando NextJs +14 con app router y tailwindcss. Enfocado al frontend.

    Proceso

    1. Estructura app

    npx create-next-app@latest

    Estructura hexagonal

    Creación domain y app

    2. Users

    InMemoryUserRepository, "Create" user and "Read" users

      -> componentes 📋
      <!-- Componente Create -->
      <div>
          <h2 className="text-2xl font-bold mb-4">Create User</h2>
          <form className="flex h-20 items-center space-x-4">
            <div className="flex space-x-10 h-20 items-center">
              <label htmlFor="name" className="block font-medium text-gray-700">
                Name
              </label>
              <input
                type="text"
                id="name"
                name="name"
                className="mt-1 block w-full p-4 rounded-md border-gray-300 shadow-sm focus:border-primary focus:ring-primary sm:text-sm"
              />
            </div>
            <button
              className="inline-flex items-center px-4 py-4 border border-transparent hover:border-gray-800  text-sm font-medium rounded-md shadow-sm shadow-gray-300 hover:shadow-lg text-gray-500 bg-primary hover:bg-primary-dark focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary"
            >
              Create User
            </button>
          </form>
        </div>
      <!-- Pagina -->
      <main  className="container h-dvh mx-auto py-8 px-4 sm:px-6 lg:px-8">
        <div className="grid grid-cols-1 md:grid-cols-2 gap-8">
        <UserForm/>
        <!-- <UsersTable/> Componente para el "Read" -->
        </div>
      </main>
      <!-- Componente Read -->
      <div className="p-6 bg-white shadow-md rounded-lg">
          <h2 className="text-3xl font-semibold mb-6 text-gray-800">Users</h2>
          <div className="overflow-x-auto">
            <table className="min-w-full bg-white border border-gray-300 rounded-lg">
              <thead className="bg-gray-100">
                <tr >
                  <th
                    scope="col"
                    className="px-2 xl:px-6 py-3 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider"
                  >
                    Name
                  </th>
                  <th
                    scope="col"
                    className="px-2 xl:px-6 py-3 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider"
                  >
                    Edit
                  </th>
                  <!--Otras acciones-->
                </tr>
              </thead>
              <tbody className="bg-white divide-y divide-gray-200">
                <!--Por cada usuario-->
                  <tr className="hover:bg-gray-50">
                    <td className="px-2 xl:px-6 py-4 whitespace-nowrap text-sm text-gray-900">
                      [nombre]
                    </td>
                    <td className="px-2 xl:px-6 py-4 whitespace-nowrap">
                      <a
                        className="text-blue-600 hover:text-blue-800 font-medium"
                      >
                        Edit
                      </Link>
                    </td>
                    <!--Futuras acciones-->
                  </tr>
                <!---->
              </tbody>
            </table>
          </div>
        </div>

    "Update" user

    "Delete" user

      <button className="text-red-500 hover:text-red-700">
                Delete
      </button>
    ⚠️ Tienes que estar verificado para ver este contenido