config and templates

This commit is contained in:
Bronku 2025-08-06 22:51:50 +02:00
parent cdf42b7ff3
commit fb22f599ad
22 changed files with 816 additions and 38 deletions

View file

@ -0,0 +1,28 @@
{{define "layout"}}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>{{template "title" .}}</title>
<script src="/static/htmx2.04.js" defer></script>
<script src="/static/order.js" ></script>
<link rel="stylesheet" href="/static/style.css">
<link rel="stylesheet" href="/static/fontawesome/css/fontawesome.min.css">
<link rel="stylesheet" href="/static/fontawesome/css/solid.css">
</head>
<body>
<aside>
<nav>{{template "nav" .}}</nav>
</aside>
<div class="app-body">
<header>
<h1>{{template "title" .}}</h1>
</header>
{{template "main" .}}
</div>
</body>
</html>
{{end}}

View file

@ -0,0 +1,7 @@
{{define "nav"}}
<a href="/orders" data-title="Zamówienia"><i class="fa-solid fa-list-ul"></i></a>
<a href="/order" data-title="Nowe zamówienie"><i class="fa-solid fa-plus-circle"></i></a>
<a href="/cakes" data-title="Wszystkie ciasta"><i class="fa-solid fa-birthday-cake"></i></a>
<a href="/cake" data-title="Nowe ciasto"><i class="fa-solid fa-plus"></i></a>
<a href="/logout" data-title="Wyloguj"><i class="fa-solid fa-sign-out-alt"></i></a>
{{end}}

View file

@ -0,0 +1,24 @@
{{define "title"}}
Cake {{.ID}}
{{end}}
{{define "main"}}
<main>
<form method="post">
<div>
<h2>Info</h2>
<label>
<input hidden="hidden" name="id" value="{{.ID}}">
</label>
<label>name</label>
<label>
<input type="text" name="name" value="{{.Name}}">
</label>
<label>price</label>
<label>
<input type="number" name="price" min="0" value="{{.Price}}">
</label>
</div>
<button type="submit">submit</button>
</form>
</main>
{{end}}

View file

@ -0,0 +1,21 @@
{{define "title"}}
Cakes
{{end}}
{{define "main"}}
<main>
<table>
<tr>
<th></th>
<th>Name</th>
<th>Price</th>
</tr>
{{range .}}
<tr>
<th><a href="/cake/{{.ID}}">edit</a></th>
<th>{{.Name}}</th>
<th>{{.Price}}</th>
</tr>
{{end}}
</table>
</main>
{{end}}

View file

@ -0,0 +1,8 @@
{{define "title"}}
Confirmed
{{end}}
{{define "main"}}
<main>
<h2>{{.ID}} confirmed</h2>
</main>
{{end}}

View file

@ -0,0 +1,113 @@
{{define "title"}}
{{if .Order.ID}}
Edytuj zamówienie #{{.Order.ID}}
{{else}}
Nowe zamówienie
{{end}}
{{end}}
{{define "main"}}
<main>
<form method="post" class="order">
{{with .Order}}
<div class="order-contents">
<div>
<h2>Dane zamówienia</h2>
<label>
<input hidden="hidden" name="id" value="{{.ID}}">
</label>
<label>Imię
<input type="text" name="name" value="{{.Name}}">
</label>
<label>Nazwisko
<input type="text" name="surname" value="{{.Surname}}">
</label>
<label>Numer telefonu
<input type="tel" name="phone" value="{{.Phone}}">
</label>
<label>Lokalizacja
<select name="location">
<option {{ if eq .Location "Kartuzy" }}selected{{ end }} value="Kartuzy">Kartuzy</option>
<option {{ if eq .Location "Somonino" }}selected{{ end }} value="Somonino">Somonino</option>
</select>
</label>
<label>Data dostawy
{{if .ID}}
<input type="date" name="date" value="{{.Date.Format "2006-01-02"}}" required>
{{else}}
<input type="date" name="date" required>
{{end}}
</label>
<label>Status
<select name="status">
<option {{ if eq .Status "accepted" }}selected{{ end }} value="accepted">accepted</option>
<option {{ if eq .Status "done" }}selected{{ end }} value="done">done</option>
</select>
</label>
<label>Zaliczka
<input type="number" name="paid" min="0" value="{{.Prepaid}}">
</label>
</div>
<div>
<h2>Dodane Ciasta</h2>
<div class="scrollable">
<table id="basket_table" >
</table>
</div>
<ul id="basket" class="scrollable">
</ul>
</div>
<div>
<label>
<small>Total:</small><br>
<p id="total-price">100PLN</p>
</label>
<button type="submit">Zapisz</button>
</div>
</div>
{{end}}
{{with .Catalogue}}
<div>
<h2>Katalog</h2>
<div class="scrollable">
<table>
{{range .}}
<tr>
<th>{{.Name}}<br><small>#{{.ID}}</small></th>
<th>{{.Price}}PLN</th>
<th>
<button type=button onClick="addCake({{.ID}},{{.Name}}, {{.Price}}, 1)">
<i class="fa-solid fa-plus"></i>
</button>
</th>
</tr>
{{end}}
</table>
</div>
</div>
{{end}}
</form>
</main>
<template id="basket_element_template">
<tr>
<th class="cake-name">Name</th>
<th class="cake-price">Price</th>
<th>
<label>
<input type="number" min="0">
</label>
</th>
<th class="cake-total">Total</th>
<th>
<button type=button>
<i class="fa-solid fa-minus"></i>
</button>
</th>
</tr>
</template>
<script>
{{range .Order.OrderItems}}
addCake({{.ProductID}},{{.Product.Name}}, {{.Product.Price}}, {{.Amount}})
{{end}}
</script>
{{end}}

View file

@ -0,0 +1,71 @@
{{define "title"}}
Zamówienia
{{end}}
{{define "main"}}
<main>
<form class="search-container" hx-get="/orders/search" hx-target="#results-table"
hx-trigger="keyup delay:500ms, change">
<label>Data początkowa
<input type="date" value="{{.First}}" name="from">
</label>
<label>Data końcowa
<input type="date" value="{{.Last}}" name="to">
</label>
</form>
<div id="results-table" class="scrollable">
{{template "orders-table" .Orders}}
</div>
</main>
<style>
.hidden {
display: none;
}
.active {
background-color: #e6f2ff;
}
</style>
{{end}}
{{define "orders-table"}}
<table id="orders_table">
<thead>
<tr>
<th>Numer zamówienia</th>
<th>Klient</th>
<th>Lokalizacja</th>
<th>Data zamówienia</th>
<th>Pozostało do zapłaty</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{{range .}}
<tr class="clickable" onclick="toggleDetails(this)">
<th><a href="/order/{{.ID}}">#{{.ID}}</a></th>
<th>{{.Surname}} {{.Name}} {{.Phone}}</th>
<th>{{.Location}}</th>
<th>{{.Date.Format "2006-01-02"}}</th>
<th>{{.Total}} PLN</th>
<th>{{.Status}}</th>
</tr>
<tr class="hidden">
<td colspan="6" class="details-content">
{{template "order_info" .}}
</td>
</tr>
{{end}}
</tbody>
</table>
{{end}}
{{define "order_info"}}
<table>
{{range .OrderItems}}
<tr>
<th>{{.Product.Name}}<br><small>ID: {{.ProductID}}</small></th>
<th><small>Cena:</small><br>{{.Product.Price}} PLN</th>
<th><small>Ilość:</small><br>{{.Amount}}</th>
<th><small>Razem:</small><br>{{.Total}} PLN</th>
</tr>
{{end}}
</table>
{{end}}