feat: Probably functional

This commit is contained in:
2026-04-09 14:06:19 +01:00
parent 5cf9895c79
commit 8c3c473ebf
10 changed files with 578 additions and 15 deletions

40
app/templates/add.html Normal file
View File

@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<title>Add Drink</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="container">
<h1>Add Drink</h1>
<form method="POST" action="/add">
<div class="form-group">
<label>Drink name</label>
<input type="text" name="name" required>
</div>
<div class="form-group">
<label>Quantity</label>
<input type="number" name="stock" min="1" required>
</div>
<div class="form-group">
<label>Price (€):</label>
<input type="number" step="0.01" name="price" required>
</div>
<div class="form-group">
<label>Name + Phone number</label>
<input type="text" name="phone_number" placeholder="Name +351..." required>
</div>
<button class="button" type="submit">Create drink</button>
</form>
<br>
<a href="/">Back</a>
</div>
</body>
</html>

View File

@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html>
<head>
<title>{{ drink.name }}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="container">
<div class="card">
<h1>{{ drink.name }}</h1>
<p><strong>{{ "%.2f"|format(drink.price) }}€</strong></p>
<p class="muted">Stock: {{ drink.stock }}</p>
<p><strong>Pay to:</strong> {{ drink.phone_number }}</p>
</div>
{% if drink.stock > 0 %}
<div class="card">
<form method="POST" action="/drink/{{ drink.id }}/buy">
<label>
Your name:
<input list="names" name="name" required>
</label>
<datalist id="names">
{% for n in names %}
<option value="{{ n[0] }}"></option>
{% endfor %}
</datalist>
<label>
Quantity:
<input type="number" name="quantity" value="1" min="1" required>
</label>
<button class="button" type="submit">Take drink</button>
</form>
</div>
{% else %}
<p><strong>Out of stock</strong></p>
{% endif %}
<a class="button" href="/drinks">Back to list</a>
</div>
</body>
</html>

View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<title>Drinks Catalogue</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="container">
<h1>Drinks Catalogue</h1>
{% if drinks %}
{% for drink in drinks %}
<div class="card">
<strong>{{ drink.name }}</strong>
<p class="muted">{{ "%.2f"|format(drink.price) }}€</p>
<p>Stock: {{ drink.stock }}</p>
<div class="actions">
<a class="button" href="/drink/{{ drink.id }}">Buy</a>
<a class="button button-secondary" href="/drink/{{ drink.id }}/manage">Manage</a>
</div>
</div>
{% endfor %}
{% else %}
<p>No drinks available.</p>
{% endif %}
<a href="/">Back</a>
</div>
</body>
</html>

View File

@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<title>Manage Drink</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="container">
<h1>Manage Drink</h1>
<div class="card">
<h2>{{ drink.name }}</h2>
<p>Price: {{ drink.price }}€</p>
<p>Stock: {{ drink.stock }}</p>
</div>
<div class="card">
<h3>Restock</h3>
<form method="POST" action="/drink/{{ drink.id }}/restock">
<label>
Add quantity:
<input type="number" name="amount" min="1" required>
</label>
<button class="button" type="submit">Increase stock</button>
</form>
</div>
<div class="card">
<h3>Danger zone</h3>
<form method="POST" action="/drink/{{ drink.id }}/delete" onsubmit="return confirm('Delete this drink?');">
<button class="button" type="submit" style="background: red;">Delete drink</button>
</form>
</div>
<a class="button" href="/drinks">Back to list</a>
</div>
</body>
</html>

View File

@@ -2,9 +2,16 @@
<html>
<head>
<title>Fridge Tracker</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="container">
<h1>Fridge Tracker</h1>
<p>Welcome. System is running.</p>
<a class="button" href="/add">Add drink</a>
<a class="button" href="/drinks">Drink catalogue</a>
<a class="button" href="/transactions">Transactions</a>
</div>
</body>
</html>

View File

@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<head>
<title>Transactions</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="container">
<h1 class="mb">Transactions</h1>
<div class="card">
{% if transactions %}
<table class="table">
<thead>
<tr>
<th>Drink</th>
<th>User</th>
<th>Qty</th>
<th>Time</th>
</tr>
</thead>
<tbody>
{% for t in transactions %}
<tr>
<td>{{ t.drink_name }}</td>
<td>{{ t.user_name }}</td>
<td>{{ t.quantity }}</td>
<td class="muted">
{{ t.timestamp.strftime("%Y-%m-%d %H:%M") }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>No transactions yet.</p>
{% endif %}
</div>
<div class="mt">
<a class="button button-secondary" href="/">Back</a>
</div>
</div>
</body>
</html>