Files
ti/templates/koeb_nu.html
Henrik Jess Nielsen b640d9950c feat(pwa): offline support so the list works in-store with no net
No signal inside the store made the server-rendered app unusable. Make it
an installable PWA:
- service worker (static/sw.js) caches pages (network-first, cache fallback)
  and assets, served from root so scope is /
- offline.js: cittiFetch() queues check-off / price / qty / pick POSTs in
  localStorage when offline and replays them in order on reconnect, with an
  optimistic response and an Offline/Syncing status badge
- manifest + icon for add-to-home-screen; PWA meta tags on the in-store pages
- in-store mutations (saveToServer, pick/unpick) go through cittiFetch;
  archive/refresh/add still need net by design
- Dockerfile copies static/
Open once online first so the SW can cache; then it works offline.
2026-10-30 11:54:38 +01:00

168 lines
7.9 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="da">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#c84b2f">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="Citti">
<link rel="manifest" href="/manifest.webmanifest">
<link rel="apple-touch-icon" href="/icon.svg">
<link rel="icon" href="/icon.svg">
<script src="/offline.js" defer></script>
<title>Citti · Køb nu</title>
<link href="https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500;600&display=swap" rel="stylesheet">
<style>
:root {
--bg: #f5f2ed; --card: #ffffff; --border: #e2ddd6; --text: #1a1814;
--muted: #8a857c; --accent: #c84b2f; --green: #2d6a4f; --green-light: #e8f4ee;
--mono: 'DM Mono', monospace; --sans: 'DM Sans', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; padding: 1.5rem 1rem 4rem; }
.page { max-width: 860px; margin: 0 auto; }
header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; padding-bottom: 1.25rem; border-bottom: 2px solid var(--text); }
h1 { font-size: 1.75rem; font-weight: 600; letter-spacing: -0.03em; }
h1 span { color: var(--accent); }
.sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.btn-back { background: var(--text); color: white; border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; font-family: var(--sans); cursor: pointer; text-decoration: none; display: inline-block; font-weight: 500; }
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 1.5rem; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; }
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.kpi-val { font-size: 1.75rem; font-weight: 600; font-family: var(--mono); letter-spacing: -0.02em; }
.kpi-val.green { color: var(--green); }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 1.25rem; }
.card-title { background: var(--text); color: white; padding: 0.6rem 1rem; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.card-title.green { background: var(--green); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 1rem; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: none; }
.row.bought { opacity: 0.45; }
.row.bought .r-name { text-decoration: line-through; }
.r-name { font-size: 14px; font-weight: 500; }
.r-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.r-right { text-align: right; white-space: nowrap; }
.r-price { font-family: var(--mono); font-weight: 600; }
.r-pre { font-family: var(--mono); font-size: 12px; color: var(--muted); text-decoration: line-through; margin-right: 4px; }
.r-save { font-size: 11px; color: var(--green); font-weight: 600; }
.r-dkk { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.pill { display: inline-block; font-size: 10px; font-weight: 600; background: var(--accent); color: #fff; border-radius: 4px; padding: 1px 6px; margin-left: 6px; }
.sec-group { padding: 0.5rem 1rem; border-bottom: 1px solid var(--border); }
.sec-group:last-child { border-bottom: none; }
.sec-h { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 3px 9px; }
.empty-state { padding: 2rem; text-align: center; color: var(--muted); font-size: 14px; }
@media (max-width: 600px) { .kpi-val { font-size: 1.35rem; } }
</style>
</head>
<body>
<div class="page">
<header>
<div>
<h1>Citti <span>Køb nu</span></h1>
<div class="sub">Status for din seddel · tilbud fra CITTI Lübeck · mængder uændret</div>
</div>
<a href="/" class="btn-back">← Indkøbsseddel</a>
</header>
{% if not has_offers %}
<div class="card"><div class="empty-state">Ingen tilbud hentet endnu — åbn <a href="/tilbud">Tilbud</a> og tryk Opdater først.</div></div>
{% endif %}
<div class="kpi-row">
<div class="kpi">
<div class="kpi-label">Krydset af</div>
<div class="kpi-val">{{ bought }}<span style="font-size:1rem;color:var(--muted)">/{{ total }}</span></div>
<div class="kpi-sub">varer købt</div>
</div>
<div class="kpi">
<div class="kpi-label">Mangler</div>
<div class="kpi-val">{{ total - bought }}</div>
<div class="kpi-sub">ikke krydset af endnu</div>
</div>
<div class="kpi">
<div class="kpi-label">På tilbud</div>
<div class="kpi-val green">{{ on_offer|length }}</div>
<div class="kpi-sub">af dine varer lige nu</div>
</div>
</div>
<!-- 1) DINE VARER PÅ TILBUD -->
<div class="card">
<div class="card-title green">🏷 Dine varer på tilbud nu</div>
{% if on_offer %}
{% for r in on_offer %}
<div class="row{% if r.bought %} bought{% endif %}">
<div>
<div class="r-name">{{ r.sec.emoji }} {{ r.item.name }}{% if r.bought %} ✓{% endif %}</div>
<div class="r-meta">🏷 {{ r.offer.heading_da or r.offer.heading }} · {{ r.offer.catalog }}{% if r.offer.page %} · s. {{ r.offer.page }}{% endif %}</div>
</div>
<div class="r-right">
<div class="r-price">{{ "{:.2f}".format(r.offer.price_eur).replace(".",",") }} € <span class="r-dkk">≈ {{ "{:.0f}".format(r.offer_dkk) }} kr.</span></div>
{% if r.offer.unit and r.offer.size_from %}<div class="r-dkk">pr. {{ r.offer.size_from|int }}{% if r.offer.size_to and r.offer.size_to != r.offer.size_from %}–{{ r.offer.size_to|int }}{% endif %} {{ r.offer.unit }}</div>{% endif %}
</div>
</div>
{% endfor %}
{% else %}
<div class="empty-state">Ingen af dine faste varer er på tilbud lige nu.</div>
{% endif %}
</div>
<!-- 2) MANGLER AT KØBE -->
<div class="card">
<div class="card-title">🛒 Mangler at krydse af</div>
{% if remaining or picks_remaining %}
{% for g in remaining %}
<div class="sec-group">
<div class="sec-h">{{ g.sec.emoji }} {{ g.sec.title }}</div>
<div class="chips">
{% for it in g.varer %}<span class="chip">{{ it.name }}</span>{% endfor %}
</div>
</div>
{% endfor %}
{% if picks_remaining %}
<div class="sec-group">
<div class="sec-h">🏷 Lübeck-tilbud</div>
<div class="chips">
{% for p in picks_remaining %}<span class="chip">{{ p.heading_da or p.heading }}</span>{% endfor %}
</div>
</div>
{% endif %}
{% else %}
<div class="empty-state">Alt er krydset af — godt gået! 🎉</div>
{% endif %}
</div>
<!-- 3) UGENS TILBUD — UDVALG -->
{% if other %}
<div class="card">
<div class="card-title">✨ Ugens tilbud — billige fund (ikke på din liste)</div>
{% for o in other %}
<div class="row">
<div>
<div class="r-name">{{ o.heading_da or o.heading }}</div>
<div class="r-meta">{% if o.heading_da and o.heading_da != o.heading %}🇩🇪 {{ o.heading }} · {% endif %}{{ o.catalog }}{% if o.page %} · s. {{ o.page }}{% endif %}{% if o.unit and o.size_from %} · {{ o.size_from|int }} {{ o.unit }}{% endif %}</div>
</div>
<div class="r-right">
<div class="r-price">{{ "{:.2f}".format(o.price_eur).replace(".",",") }} €</div>
<div class="r-dkk">≈ {{ "{:.0f}".format(o.dkk) }} kr.</div>
</div>
</div>
{% endfor %}
<div class="row" style="justify-content:center">
<a href="/tilbud" style="color:var(--accent);font-size:13px;font-weight:600;text-decoration:none">Se alle tilbud →</a>
</div>
</div>
{% endif %}
</div>
</body>
</html>