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:
@@ -6,6 +6,7 @@ import useNotificationSettingsStore from '../store/notificationSettingsStore'
|
||||
import useTableViewStore from '../store/tableViewStore'
|
||||
import useChatStore from '../store/chatStore'
|
||||
import useKdsReadyStore from '../store/kdsReadyStore'
|
||||
import useInstallPromptStore, { apkAvailable } from '../store/installPromptStore'
|
||||
import useOfflineQueueCount from '../hooks/useOfflineQueueCount'
|
||||
import useFailedPrintCount from '../hooks/useFailedPrintCount'
|
||||
|
||||
@@ -296,6 +297,37 @@ const DRAWER_SETTINGS_ITEM = {
|
||||
),
|
||||
}
|
||||
|
||||
const DRAWER_INSTALL_ITEM = {
|
||||
key: 'install-app',
|
||||
label: 'Εγκατάσταση εφαρμογής',
|
||||
match: () => false,
|
||||
icon: (
|
||||
<svg width="22" height="22" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M12 3v12m0 0-4.5-4.5M12 15l4.5-4.5" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
||||
<path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
||||
</svg>
|
||||
),
|
||||
}
|
||||
|
||||
// Browser on Android only, and only if this venue's server serves the APK
|
||||
// (the native app never shows it) — opens the install dialog.
|
||||
function InstallAppDrawerButton({ location, onClose }) {
|
||||
const [available, setAvailable] = useState(false)
|
||||
const show = useInstallPromptStore(s => s.show)
|
||||
useEffect(() => {
|
||||
apkAvailable().then(setAvailable)
|
||||
}, [])
|
||||
if (!available) return null
|
||||
return (
|
||||
<DrawerButton
|
||||
item={DRAWER_INSTALL_ITEM}
|
||||
location={location}
|
||||
active={false}
|
||||
onClick={() => { onClose(); show() }}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function DrawerButton({ item, location, onNavigate, active: activeProp, onClick }) {
|
||||
const active = activeProp ?? item.match(location)
|
||||
return (
|
||||
@@ -392,8 +424,9 @@ function SideDrawer({ open, onClose }) {
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* Settings at bottom */}
|
||||
<div style={{ padding: '8px 10px 16px', borderTop: '1px solid var(--border)' }}>
|
||||
{/* Install app + settings at bottom */}
|
||||
<div style={{ padding: '8px 10px 16px', borderTop: '1px solid var(--border)', display: 'flex', flexDirection: 'column', gap: 4 }}>
|
||||
<InstallAppDrawerButton location={location} onClose={onClose} />
|
||||
<DrawerButton item={DRAWER_SETTINGS_ITEM} location={location} onNavigate={go} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user