feat(waiter): install-app dialog (first visit) + "Εγκατάσταση εφαρμογής" in the side drawer

Replaces the thin bottom banner with a proper dialog (taller than wide):
app icon, four reasons to install (starts instantly, survives WiFi drops,
encrypted link, finds the server + updates itself), the three install
steps, "Λήψη εφαρμογής" and "Όχι τώρα". It opens by itself once, on the
first browser visit; closing it or tapping download marks it seen for good
(previously a 7-day dismissal, and once gone there was no way back).
Afterwards it is reachable from the side drawer, right above Settings.

Offered only where it makes sense: a browser on an Android phone (never in
the native app, on iPhones or desktops) and only if this venue's server
actually serves the APK (HEAD /downloads/xenia-waiter.apk, checked once).

Verified in Edge emulating Android / iPhone / desktop against the prod
build: auto-opens once, "Όχι τώρα" persists across reloads, drawer item
above Settings reopens it, not offered on iPhone/desktop or when the
server has no APK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-28 22:01:05 +03:00
co-authored by Claude Opus 5.5
parent 251cac9807
commit a349043abb
5 changed files with 203 additions and 101 deletions
@@ -0,0 +1,107 @@
import { useEffect } from 'react'
import useInstallPromptStore, { APK_URL, canOfferApp } from '../store/installPromptStore'
const BENEFITS = [
{ icon: '⚡', title: 'Ανοίγει αμέσως', text: 'Χωρίς φόρτωση από τον browser, σαν κανονική εφαρμογή.' },
{ icon: '📶', title: 'Αντέχει στο WiFi', text: 'Συνεχίζει να δουλεύει όταν χάνεται για λίγο η σύνδεση.' },
{ icon: '🔒', title: 'Ασφαλής σύνδεση', text: 'Κρυπτογραφημένη επικοινωνία με τον server του καταστήματος.' },
{ icon: '🔄', title: 'Χωρίς ρυθμίσεις', text: 'Βρίσκει μόνη της τον server και ενημερώνεται αυτόματα.' },
]
const STEPS = [
'Πατήστε «Λήψη εφαρμογής».',
'Ανοίξτε το αρχείο και επιτρέψτε την εγκατάσταση.',
'Ανοίξτε το Xenia και σαρώστε ξανά το QR του καταστήματος.',
]
/**
* Dialog offering the Android app to browser users (see installPromptStore).
* Opens by itself once; afterwards from the side drawer.
*/
export default function InstallAppDialog() {
const { open, dismiss, autoOpen } = useInstallPromptStore()
useEffect(() => {
if (canOfferApp()) autoOpen()
}, [autoOpen])
if (!open) return null
return (
<div
onClick={dismiss}
style={{
position: 'fixed', inset: 0, zIndex: 10000, background: 'rgba(0,0,0,0.6)',
display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 16,
}}
>
<div
role="dialog"
aria-modal="true"
aria-labelledby="install-app-title"
onClick={e => e.stopPropagation()}
style={{
width: '100%', maxWidth: 360, maxHeight: '92vh', overflowY: 'auto',
background: 'var(--bg2)', border: '1px solid var(--border)', borderRadius: 22,
boxShadow: '0 16px 48px rgba(0,0,0,0.5)', padding: '26px 22px 20px',
display: 'flex', flexDirection: 'column', gap: 18,
}}
>
<div style={{ textAlign: 'center' }}>
<img
src="/icons/icon-192.png"
alt=""
width={76}
height={76}
style={{ borderRadius: 18, boxShadow: '0 6px 20px rgba(0,0,0,0.35)' }}
/>
<h2 id="install-app-title" style={{ fontSize: 20, fontWeight: 800, color: 'var(--text)', margin: '14px 0 4px' }}>
Εφαρμογή Xenia
</h2>
<p style={{ fontSize: 13, color: 'var(--muted)', lineHeight: 1.45 }}>
Εγκαταστήστε την εφαρμογή για γρηγορότερη και πιο σταθερή λειτουργία.
</p>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{BENEFITS.map(b => (
<div key={b.title} style={{ display: 'flex', gap: 12, alignItems: 'flex-start' }}>
<span style={{
fontSize: 18, width: 36, height: 36, flexShrink: 0, borderRadius: 10,
background: 'var(--bg3)', display: 'flex', alignItems: 'center', justifyContent: 'center',
}}>
{b.icon}
</span>
<div>
<div style={{ fontSize: 14, fontWeight: 700, color: 'var(--text)' }}>{b.title}</div>
<div style={{ fontSize: 12.5, color: 'var(--muted)', lineHeight: 1.4 }}>{b.text}</div>
</div>
</div>
))}
</div>
<ol style={{
margin: 0, padding: '12px 14px 12px 32px', borderRadius: 12, background: 'var(--bg3)',
fontSize: 12.5, color: 'var(--muted)', lineHeight: 1.55,
}}>
{STEPS.map(s => <li key={s}>{s}</li>)}
</ol>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
<a
href={APK_URL}
download
onClick={dismiss}
className="btn btn--accent btn--lg"
style={{ textDecoration: 'none', display: 'flex', alignItems: 'center', justifyContent: 'center' }}
>
Λήψη εφαρμογής
</a>
<button className="btn btn--secondary" onClick={dismiss} style={{ minHeight: 44 }}>
Όχι τώρα
</button>
</div>
</div>
</div>
)
}