Auto stash before merge of "main" and "origin/main"

This commit is contained in:
2024-02-09 21:11:19 -06:00
parent f5d267ea98
commit d21d91b80e
17 changed files with 844 additions and 7 deletions

14
views/auth/login.php Normal file
View File

@@ -0,0 +1,14 @@
<?php $content = function() { ?>
<h2>Login</h2>
<form action="/login" method="post">
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
<?php }; include __DIR__ . '/../layouts/app.php'; ?>

42
views/auth/register.php Normal file
View File

@@ -0,0 +1,42 @@
<?php
// Check if the user is already logged in
if (isset($_SESSION['user_id'])) {
// Redirect to the dashboard if the user is already logged in
header('Location: /dashboard');
exit;
}
// Include error handling
$error = $_SESSION['error'] ?? '';
unset($_SESSION['error']); // Clear the error after displaying
$content = function() use ($error) { ?>
<div class="row justify-content-center">
<div class="col-md-6">
<h2 class="mt-5">Register</h2>
<?php if ($error): ?>
<div class="alert alert-danger" role="alert">
<?= htmlspecialchars($error) ?>
</div>
<?php endif; ?>
<form action="/register" method="post">
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary">Register</button>
</form>
<p class="mt-3">Already have an account? <a href="/">Login here</a>.</p>
</div>
</div>
<?php };
include __DIR__ . '/../layouts/app.php';

74
views/dashboard.php Normal file
View File

@@ -0,0 +1,74 @@
<?php
use Hpz937\BillReminder\Database\SqLiteAdapter;
use Hpz937\BillReminder\Bill\Bill;
// Assuming session_start() is called in the front controller or app.php
// Redirect to login page if the user is not logged in
if (!isset($_SESSION['user_id'])) {
header('Location: /');
exit;
}
$content = function() { /* use ($bills) if fetching bills from the database */
?>
<div class="row justify-content-center">
<div class="col-md-8">
<h2 class="mt-5">Dashboard</h2>
<button type="button" class="btn btn-primary mb-3" data-bs-toggle="modal" data-bs-target="#addBillModal">Add New Bill</button>
<!-- Bills Table -->
<table class="table" id="billsTable">
<thead>
<tr>
<th scope="col">Description</th>
<th scope="col">Amount</th>
<th scope="col">Due Date</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<!-- Bills will be loaded here by Axios -->
</tbody>
</table>
<!-- Add Bill Modal -->
<div class="modal fade" id="addBillModal" tabindex="-1" role="dialog" aria-labelledby="addBillModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addBillModalLabel">Add New Bill</h5>
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form action="/add-bill" method="post">
<div class="modal-body">
<div class="form-group">
<label for="description">Description</label>
<input type="text" class="form-control" id="description" name="description" required>
</div>
<div class="form-group">
<label for="amount">Amount</label>
<input type="number" class="form-control" id="amount" name="amount" step="0.01" required>
</div>
<div class="form-group">
<label for="due_date">Due Date</label>
<input type="date" class="form-control" id="due_date" name="due_date" required>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Add Bill</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?php };
include __DIR__ . '/layouts/app.php';

30
views/home.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
// Assuming session_start() is called in the front controller or app.php
$content = function() { ?>
<div class="jumbotron">
<h1 class="display-4">Welcome to Bill Reminder!</h1>
<p class="lead">Never miss a payment again with our easy-to-use bill management system.</p>
<hr class="my-4">
<p>Get started by logging in or registering a new account.</p>
<a class="btn btn-primary btn-lg" href="/login" role="button">Login</a>
<a class="btn btn-secondary btn-lg" href="/register" role="button">Register</a>
</div>
<div class="row">
<div class="col-md-4">
<h2>Track Your Bills</h2>
<p>Keep all your bills in one place and get reminders so you can pay them on time, every time.</p>
</div>
<div class="col-md-4">
<h2>Easy to Use</h2>
<p>Our intuitive interface makes managing your bills simple, whether you're at home or on the go.</p>
</div>
<div class="col-md-4">
<h2>Secure</h2>
<p>Your security is our top priority. We use state-of-the-art security measures to protect your information.</p>
</div>
</div>
<?php };
include __DIR__ . '/layouts/app.php';

32
views/layouts/app.php Normal file
View File

@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bill Reminder</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Bill Reminder</a>
<div class="collapse navbar-collapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item"><a class="nav-link" href="/dashboard">Dashboard</a></li>
<li class="nav-item"><a class="nav-link" href="/settings">Settings</a></li>
</ul>
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link" href="/logout">Logout</a></li>
</ul>
</div>
</nav>
<div class="container">
<?php if (isset($content) && is_callable($content)) $content(); ?>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="/assets/js/app.js"></script>
</body>
</html>