backend-01

commit 07e10bb49898344a880363e7896b8fadd78be5f1

Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>

views: add login and register views

 app/controllers/HelloController.php | 8 +++++++
 app/views/home.php | 28 ++++++++++++++----------
 app/views/login.php | 24 +++++++++++++++++++++
 app/views/register.php | 34 +++++++++++++++++++++++++++++++
 config/routes.php | 5 ++++


diff --git a/app/controllers/HelloController.php b/app/controllers/HelloController.php
index f11345cc1a9020d951b9638d4ef3b5bd2b58158f..5e6b683d7f1b0fefe903cbde7bca58f6f2f85493 100644
--- a/app/controllers/HelloController.php
+++ b/app/controllers/HelloController.php
@@ -12,4 +12,12 @@     ];
 
     echo Template::render('home', $data);
   }
+
+  public function login() {
+    echo Template::render('login');
+  }
+
+  public function register() {
+    echo Template::render('register');
+  }
 }




diff --git a/app/views/home.php b/app/views/home.php
index 2883997d456cbe5b78db80476bf868bfcc3d74c7..69b1d1112074504c16c159cf373e7a864ed011dd 100644
--- a/app/views/home.php
+++ b/app/views/home.php
@@ -1,13 +1,17 @@
-<!DOCTYPE html>
-<html lang="en">
-  <head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title><?= $title ?? 'Dinheiro' ?></title>
-  </head>
+<section class="bg-white p-6 rounded-lg shadow-md">
+  <h1 class="text-xl font-semibold mb-4">
+    Bem vindo! <?= htmlspecialchars($appName) ?>!
+  </h1>
 
-  <body>
-    <h1>Bem vindo! <?= htmlspecialchars($appName) ?>!</h1>
-    <p><?= htmlspecialchars($message) ?></p>
-  </body>
-</html>
+  <p><?= htmlspecialchars($message) ?></p>
+
+  <div class="flex flex-col mt-5">
+    <a class="text-blue-700 underline font-bold hover:text-blue-800 focus:ring focus:ring-blue-300" href="/login">
+      Login
+    </a>
+
+    <a class="text-blue-700 underline font-bold hover:text-blue-800 focus:ring focus:ring-blue-300" href="/register">
+      Cadastro
+    </a>
+  </div>
+</section>




diff --git a/app/views/login.php b/app/views/login.php
new file mode 100644
index 0000000000000000000000000000000000000000..1069d776cdeacdc4fbffc33e1dad63fb8514d7bb
--- /dev/null
+++ b/app/views/login.php
@@ -0,0 +1,24 @@
+<section class="flex flex-col">
+  <h1 class="text-xl font-semibold mb-4">
+    Faça login
+  </h1>
+
+  <form method="POST" action="/login">
+    <div class="flex flex-col">
+      <label for="email">Email</label>
+      <input type="email" name="email" id="email" required />
+    </div>
+
+    <div class="flex flex-col">
+      <label for="password">Senha</label>
+      <input type="password" name="password" id="password" required />
+    </div>
+
+    <div class="mt-5">
+      <button type="submit"
+              class="bg-blue-700 text-white font-bold py-2 px-4 rounded hover:bg-blue-800 focus:outline-none focus:ring focus:ring-blue-300">
+        Entrar
+      </button>
+    </div>
+  </form>
+</section>




diff --git a/app/views/register.php b/app/views/register.php
new file mode 100644
index 0000000000000000000000000000000000000000..1e95b794428f0830b275bb2f4c80531daaeabe3b
--- /dev/null
+++ b/app/views/register.php
@@ -0,0 +1,34 @@
+<section class="flex flex-col">
+  <h1 class="text-xl font-semibold mb-4">
+    Cadastre-se
+  </h1>
+
+  <form method="POST" action="/register">
+    <div class="flex flex-col">
+      <label for="username">Nome de usuário</label>
+      <input type="text" name="username" id="username" required />
+    </div>
+
+    <div class="flex flex-col">
+      <label for="email">Email</label>
+      <input type="email" name="email" id="email" required />
+    </div>
+
+    <div class="flex flex-col">
+      <label for="password">Senha</label>
+      <input type="password" name="password" id="password" required />
+    </div>
+
+    <div class="flex flex-col">
+      <label for="password">Confirmação de Senha</label>
+      <input type="password" name="password_confirmation" id="password_confirmation" required />
+    </div>
+
+    <div class="mt-5">
+      <button type="submit"
+              class="bg-blue-700 text-white font-bold py-2 px-4 rounded hover:bg-blue-800 focus:outline-none focus:ring focus:ring-blue-300">
+        Cadastrar
+      </button>
+    </div>
+  </form>
+</section>




diff --git a/config/routes.php b/config/routes.php
index 47abe429136e98b75b7c4848f56859356c3caa4b..144e60365e445a650748b526bc22c11d798ac24b 100644
--- a/config/routes.php
+++ b/config/routes.php
@@ -6,8 +6,13 @@
 return function() {
   $uri = trim($_SERVER['REQUEST_URI'], '/');
 
+  // TODO: Meio burro isso
   if ($uri === '') {
     return (new HelloController())->index();
+  } elseif ($uri === 'login') {
+    return (new HelloController())->login();
+  } elseif ($uri === 'register') {
+    return (new HelloController())->register();
   }
 
   http_response_code(404);