Files
xenia-pos-local/waiter_pwa/src/pages/SettingsPage.jsx
T
bonaminandClaude Opus 5.5 198f8ff571 feat(waiter): close with unpaid items as a setting, combine lines, seats (platform-v2 step 4.8a)
The owner's choices for 4.8 (2026-11-18), all configurable:
- Setting orders.close_with_unpaid (default off): when off, the server refuses to close
  an order with unpaid items (pos.order_unpaid) and the phone's CLOSE takes the payment
  first ("instant-pay close"); when on, CLOSE confirms and the items stay unpaid. Manager
  Settings → Operation, next to "auto-close after full payment" (unchanged).
- POST /api/orders/{id}/items/combine: unpaid lines of the same item (choices, note,
  price, course, kitchen state; no discount / deal / tab) become one line; the phone
  offers "Combine into one line" for selected lines or a grouped line. The grouping
  views (identical / same item) stay as they were.
- Seats: the table's seats next to its name on the cards (waiter Settings → Layout, on by
  default) and in the guests dialog, where more guests than seats only shows a hint.
- The table screen's last English-only labels (ADD, PAY, CLOSE, ACTIONS, SERVED, CLEAR,
  ALL) are keys too.
- Tests: test_close_and_combine.py (5), waiter e2e +5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 09:54:37 +02:00

1243 lines
52 KiB
React
Raw 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.
import { useState, useRef } from 'react'
import { useNavigate } from 'react-router-dom'
import useTableViewStore from '../store/tableViewStore'
import useThemeStore from '../store/themeStore'
import useNotificationSettingsStore from '../store/notificationSettingsStore'
import useOrderingSettingsStore from '../store/orderingSettingsStore'
import usePaymentSettingsStore from '../store/paymentSettingsStore'
import useWaiterFavoritesStore from '../store/waiterFavoritesStore'
import { useTranslation } from '@xenia/i18n'
import { fade } from '../logic/colour'
const CHIP_STYLE_OPTIONS = [
{ key: 'full', label: 'settings.chips.full', example: 'orders.chips.pending' },
{ key: 'short', label: 'settings.chips.short', example: 'orders.chips.pendingShort' },
{ key: 'icon_full', label: 'settings.chips.iconFull', example: 'settings.chips.exIconFull' },
{ key: 'icon_short', label: 'settings.chips.iconShort', example: 'settings.chips.exIconShort' },
{ key: 'icon', label: 'settings.chips.icon', example: '⏳' },
]
// ─── Tab definitions (stub future tabs here) ──────────────────────────────────
const TABS = [
{ key: 'layout', label: 'settings.tabs.layout' },
{ key: 'leitourgia', label: 'settings.tabs.operation' },
{ key: 'ploigisi', label: 'shell.navigation' },
{ key: 'personalize', label: 'settings.tabs.favorites' },
]
// ─── Density option data ──────────────────────────────────────────────────────
const DENSITY_OPTIONS = [
{
key: '1x1',
label: '1×1',
desc: 'settings.density.d1x1',
preview: <Grid4 />,
},
{
key: '2x1',
label: '2×1',
desc: 'settings.density.d2x1',
preview: <Grid2H />,
},
{
key: '2x2',
label: '2×2',
desc: 'settings.density.d2x2',
preview: <Grid2 />,
},
{
key: '4x1',
label: '4×1',
desc: 'settings.density.d4x1',
preview: <Grid1H />,
},
{
key: '4x2',
label: '4×2',
desc: 'settings.density.d4x2',
preview: <Grid1 />,
},
{
key: '4x3',
label: '4×3',
desc: 'settings.density.d4x3',
preview: <Grid1Detail />,
},
]
// ─── Mini grid preview SVGs ───────────────────────────────────────────────────
function Grid4() {
return (
<svg viewBox="0 0 56 48" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ width: '100%', height: '100%' }}>
{[0,1,2,3].map(i => (
<rect key={i} x={2 + i * 13} y="4" width="11" height="13" rx="2" fill="currentColor" opacity="0.9"/>
))}
{[0,1,2,3].map(i => (
<rect key={i+4} x={2 + i * 13} y="20" width="11" height="13" rx="2" fill="currentColor" opacity="0.55"/>
))}
{[0,1,2,3].map(i => (
<rect key={i+8} x={2 + i * 13} y="36" width="11" height="13" rx="2" fill="currentColor" opacity="0.25"/>
))}
</svg>
)
}
function Grid2H() {
return (
<svg viewBox="0 0 56 48" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ width: '100%', height: '100%' }}>
{[0,1].map(i => (
<rect key={i} x={2 + i * 27} y="4" width="25" height="11" rx="2" fill="currentColor" opacity="0.9"/>
))}
{[0,1].map(i => (
<rect key={i+2} x={2 + i * 27} y="19" width="25" height="11" rx="2" fill="currentColor" opacity="0.55"/>
))}
{[0,1].map(i => (
<rect key={i+4} x={2 + i * 27} y="34" width="25" height="11" rx="2" fill="currentColor" opacity="0.25"/>
))}
</svg>
)
}
function Grid2() {
return (
<svg viewBox="0 0 56 48" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ width: '100%', height: '100%' }}>
<rect x="2" y="4" width="24" height="18" rx="2" fill="currentColor" opacity="0.9"/>
<rect x="30" y="4" width="24" height="18" rx="2" fill="currentColor" opacity="0.9"/>
<rect x="2" y="26" width="24" height="18" rx="2" fill="currentColor" opacity="0.45"/>
<rect x="30" y="26" width="24" height="18" rx="2" fill="currentColor" opacity="0.45"/>
</svg>
)
}
function Grid1H() {
return (
<svg viewBox="0 0 56 48" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ width: '100%', height: '100%' }}>
<rect x="2" y="4" width="52" height="11" rx="2" fill="currentColor" opacity="0.9"/>
<rect x="2" y="19" width="52" height="11" rx="2" fill="currentColor" opacity="0.55"/>
<rect x="2" y="34" width="52" height="11" rx="2" fill="currentColor" opacity="0.25"/>
</svg>
)
}
function Grid1() {
return (
<svg viewBox="0 0 56 48" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ width: '100%', height: '100%' }}>
<rect x="2" y="4" width="52" height="18" rx="2" fill="currentColor" opacity="0.9"/>
<rect x="2" y="27" width="52" height="18" rx="2" fill="currentColor" opacity="0.45"/>
</svg>
)
}
function Grid1Detail() {
return (
<svg viewBox="0 0 56 48" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ width: '100%', height: '100%' }}>
<rect x="2" y="4" width="52" height="20" rx="2" fill="currentColor" opacity="0.9"/>
{/* left section lines */}
<rect x="5" y="8" width="14" height="3" rx="1" fill="var(--x-on-colour)" opacity="0.6"/>
<rect x="5" y="13" width="9" height="2" rx="1" fill="var(--x-on-colour)" opacity="0.4"/>
<rect x="5" y="18" width="11" height="2" rx="1" fill="var(--x-on-colour)" opacity="0.4"/>
{/* vertical divider */}
<rect x="22" y="7" width="1" height="14" rx="0.5" fill="var(--x-on-colour)" opacity="0.3"/>
{/* right section lines */}
<rect x="25" y="8" width="24" height="2" rx="1" fill="var(--x-on-colour)" opacity="0.5"/>
<rect x="25" y="12" width="20" height="2" rx="1" fill="var(--x-on-colour)" opacity="0.35"/>
<rect x="25" y="16" width="22" height="2" rx="1" fill="var(--x-on-colour)" opacity="0.25"/>
<rect x="2" y="29" width="52" height="15" rx="2" fill="currentColor" opacity="0.45"/>
</svg>
)
}
// ─── Layout tab ───────────────────────────────────────────────────────────────
const ORDER_ITEM_LAYOUT_OPTIONS = [
{
key: 'compact',
label: 'settings.itemLayout.compact',
desc: 'settings.itemLayout.compactDesc',
},
{
key: 'expanded',
label: 'settings.itemLayout.expanded',
desc: 'settings.itemLayout.expandedDesc',
},
{
key: 'fully_detailed',
label: 'settings.itemLayout.full',
desc: 'settings.itemLayout.fullDesc',
},
]
function LayoutTab() {
const { t } = useTranslation('waiter')
const { density, setDensity, chipStyle, setChipStyle, kdsDisplayStyle, setKdsDisplayStyle, orderItemLayout, setOrderItemLayout, mergePersist, setMergePersist, showSeats, setShowSeats } = useTableViewStore()
const { dark, toggle } = useThemeStore()
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 32, padding: '24px 16px' }}>
{/* Chip style */}
<section>
<h2 style={sectionTitle}>{t('settings.chips.title')}</h2>
<p style={sectionSub}>{t('settings.chips.sub')}</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginTop: 14 }}>
{CHIP_STYLE_OPTIONS.map(opt => {
const active = (chipStyle || 'icon_short') === opt.key
return (
<button
key={opt.key}
onClick={() => setChipStyle(opt.key)}
style={{
display: 'flex', alignItems: 'center', gap: 14,
padding: '12px 16px', borderRadius: 14,
border: `2px solid ${active ? 'var(--accent)' : 'var(--border)'}`,
background: active ? fade('var(--accent)', 0.09) : 'var(--bg2)',
cursor: 'pointer', textAlign: 'left',
transition: 'border-color 0.12s, background 0.12s',
}}
>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: active ? 'var(--accent)' : 'var(--text)', marginBottom: 2 }}>
{t(opt.label)}
</div>
<div style={{ fontSize: 12, color: 'var(--muted)' }}>{t(opt.example)}</div>
</div>
{active && (
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" style={{ flexShrink: 0, color: 'var(--accent)' }}>
<circle cx="10" cy="10" r="9" stroke="currentColor" strokeWidth="1.5"/>
<path d="M6.5 10l2.5 2.5 4.5-5" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
)}
</button>
)
})}
</div>
</section>
{/* Card density */}
{/* Seats on the table cards (4.8) */}
<section>
<h2 style={sectionTitle}>{t('settings.seats.title')}</h2>
<div style={{ marginTop: 14 }}>
<ToggleRow label={t('settings.seats.label')} desc={t('settings.seats.desc')} checked={showSeats !== false} onChange={() => setShowSeats(!(showSeats !== false))} />
</div>
</section>
<section>
<h2 style={sectionTitle}>{t('settings.density.title')}</h2>
<p style={sectionSub}>{t('settings.density.sub')}</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 10, marginTop: 14 }}>
{DENSITY_OPTIONS.map(opt => {
const active = density === opt.key
return (
<button
key={opt.key}
onClick={() => setDensity(opt.key)}
style={{
display: 'flex', alignItems: 'center', gap: 16,
padding: '14px 16px',
borderRadius: 14,
border: `2px solid ${active ? 'var(--accent)' : 'var(--border)'}`,
background: active ? fade('var(--accent)', 0.09) : 'var(--bg2)',
cursor: 'pointer',
textAlign: 'left',
transition: 'border-color 0.12s, background 0.12s',
}}
>
{/* Mini preview */}
<div style={{
width: 56, height: 48, flexShrink: 0,
color: active ? 'var(--accent)' : 'var(--muted)',
transition: 'color 0.12s',
}}>
{opt.preview}
</div>
{/* Text */}
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{
fontSize: 15, fontWeight: 700,
color: active ? 'var(--accent)' : 'var(--text)',
marginBottom: 2,
}}>
{t(opt.label)}
</div>
<div style={{ fontSize: 13, color: 'var(--muted)', lineHeight: 1.4 }}>
{t(opt.desc)}
</div>
</div>
{/* Check */}
{active && (
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" style={{ flexShrink: 0, color: 'var(--accent)' }}>
<circle cx="10" cy="10" r="9" stroke="currentColor" strokeWidth="1.5"/>
<path d="M6.5 10l2.5 2.5 4.5-5" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
)}
</button>
)
})}
</div>
</section>
{/* KDS status display */}
<section>
<h2 style={sectionTitle}>{t('settings.kds.title')}</h2>
<p style={sectionSub}>{t('settings.kds.sub')}</p>
<div style={{ display: 'flex', gap: 10, marginTop: 14 }}>
{[
{ key: 'badge', label: 'settings.kds.badge', desc: 'settings.kds.badgeDesc' },
{ key: 'icon', label: 'settings.kds.icon', desc: 'settings.kds.iconDesc' },
].map(opt => {
const active = (kdsDisplayStyle || 'badge') === opt.key
return (
<button
key={opt.key}
onClick={() => setKdsDisplayStyle(opt.key)}
style={{
flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 6,
padding: '14px 12px', borderRadius: 14,
border: `2px solid ${active ? 'var(--accent)' : 'var(--border)'}`,
background: active ? fade('var(--accent)', 0.09) : 'var(--bg2)',
cursor: 'pointer', textAlign: 'left',
transition: 'border-color 0.12s, background 0.12s',
}}
>
<span style={{ fontSize: 13, fontWeight: 800, color: active ? 'var(--accent)' : 'var(--text)' }}>{t(opt.label)}</span>
<span style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{t(opt.desc)}</span>
</button>
)
})}
</div>
</section>
{/* Order item layout */}
<section>
<h2 style={sectionTitle}>{t('settings.itemLayout.title')}</h2>
<p style={sectionSub}>{t('settings.itemLayout.sub')}</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginTop: 14 }}>
{ORDER_ITEM_LAYOUT_OPTIONS.map(opt => {
const active = (orderItemLayout || 'compact') === opt.key
return (
<button
key={opt.key}
onClick={() => setOrderItemLayout(opt.key)}
style={{
display: 'flex', alignItems: 'center', gap: 14,
padding: '12px 16px', borderRadius: 14,
border: `2px solid ${active ? 'var(--accent)' : 'var(--border)'}`,
background: active ? fade('var(--accent)', 0.09) : 'var(--bg2)',
cursor: 'pointer', textAlign: 'left',
transition: 'border-color 0.12s, background 0.12s',
}}
>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: active ? 'var(--accent)' : 'var(--text)', marginBottom: 2 }}>
{t(opt.label)}
</div>
<div style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{t(opt.desc)}</div>
</div>
{active && (
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" style={{ flexShrink: 0, color: 'var(--accent)' }}>
<circle cx="10" cy="10" r="9" stroke="currentColor" strokeWidth="1.5"/>
<path d="M6.5 10l2.5 2.5 4.5-5" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
)}
</button>
)
})}
</div>
</section>
{/* Merge view persistence */}
<section>
<h2 style={sectionTitle}>{t('settings.merge.title')}</h2>
<p style={sectionSub}>{t('settings.merge.sub')}</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginTop: 14 }}>
{[
{ key: 'off', label: 'settings.merge.off', desc: 'settings.merge.offDesc' },
{ key: 'per_order', label: 'settings.merge.perOrder', desc: 'settings.merge.perOrderDesc' },
{ key: 'global', label: 'settings.merge.global', desc: 'settings.merge.globalDesc' },
].map(opt => {
const active = (mergePersist || 'off') === opt.key
return (
<button
key={opt.key}
onClick={() => setMergePersist(opt.key)}
style={{
display: 'flex', alignItems: 'center', gap: 14,
padding: '12px 16px', borderRadius: 14,
border: `2px solid ${active ? 'var(--accent)' : 'var(--border)'}`,
background: active ? fade('var(--accent)', 0.09) : 'var(--bg2)',
cursor: 'pointer', textAlign: 'left',
transition: 'border-color 0.12s, background 0.12s',
}}
>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: active ? 'var(--accent)' : 'var(--text)', marginBottom: 2 }}>{t(opt.label)}</div>
<div style={{ fontSize: 12, color: 'var(--muted)' }}>{t(opt.desc)}</div>
</div>
{active && (
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" style={{ flexShrink: 0, color: 'var(--accent)' }}>
<circle cx="10" cy="10" r="9" stroke="currentColor" strokeWidth="1.5"/>
<path d="M6.5 10l2.5 2.5 4.5-5" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
)}
</button>
)
})}
</div>
</section>
{/* Theme */}
<section>
<h2 style={sectionTitle}>{t('settings.theme.title')}</h2>
<div style={{ display: 'flex', gap: 10, marginTop: 14 }}>
{[
{ key: false, icon: '☀️', label: 'settings.theme.light' },
{ key: true, icon: '🌙', label: 'settings.theme.dark' },
].map(opt => {
const active = dark === opt.key
return (
<button
key={String(opt.key)}
onClick={() => { if (!active) toggle() }}
style={{
flex: 1,
display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 8,
padding: '18px 12px',
borderRadius: 14,
border: `2px solid ${active ? 'var(--accent)' : 'var(--border)'}`,
background: active ? fade('var(--accent)', 0.09) : 'var(--bg2)',
cursor: active ? 'default' : 'pointer',
transition: 'border-color 0.12s, background 0.12s',
}}
>
<span style={{ fontSize: 28 }}>{opt.icon}</span>
<span style={{
fontSize: 14, fontWeight: 600,
color: active ? 'var(--accent)' : 'var(--muted)',
}}>{t(opt.label)}</span>
</button>
)
})}
</div>
</section>
</div>
)
}
const sectionTitle = {
fontSize: 13, fontWeight: 700, color: 'var(--muted)',
letterSpacing: 0.8, textTransform: 'uppercase', marginBottom: 4,
}
const sectionSub = {
fontSize: 14, color: 'var(--muted)', lineHeight: 1.5,
}
// ─── Operation tab ──────────────────────────────────────────────────────────
const POPUP_MODE_OPTIONS = [
{
key: 'all',
label: 'settings.popup.all',
desc: 'settings.popup.allDesc',
},
{
key: 'manager_only',
label: 'settings.popup.manager',
desc: 'settings.popup.managerDesc',
},
{
key: 'never',
label: 'settings.popup.never',
desc: 'settings.popup.neverDesc',
},
]
function ToggleRow({ label, desc, checked, onChange }) {
return (
<button
onClick={onChange}
style={{
display: 'flex', alignItems: 'center', gap: 14,
width: '100%', padding: '14px 16px', borderRadius: 14,
border: `2px solid ${checked ? 'var(--accent)' : 'var(--border)'}`,
background: checked ? fade('var(--accent)', 0.09) : 'var(--bg2)',
cursor: 'pointer', textAlign: 'left',
transition: 'border-color 0.12s, background 0.12s',
}}
>
<div style={{
width: 44, height: 24, borderRadius: 12, flexShrink: 0,
background: checked ? 'var(--accent)' : 'var(--bg3)', position: 'relative', transition: 'background 0.2s',
}}>
<div style={{
position: 'absolute', top: 3, left: checked ? 23 : 3,
width: 18, height: 18, borderRadius: '50%', background: 'var(--x-on-colour)',
transition: 'left 0.2s', boxShadow: '0 1px 4px rgb(var(--x-scrim-rgb) / 0.3)',
}} />
</div>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: checked ? 'var(--accent)' : 'var(--text)' }}>{label}</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2, lineHeight: 1.4 }}>{desc}</div>
</div>
</button>
)
}
const PAYMENT_SAFETY_OPTIONS = [
{
key: 'off',
label: 'settings.paySafety.off',
desc: 'settings.paySafety.offDesc',
},
{
key: 'second_confirm',
label: 'settings.paySafety.second',
desc: 'settings.paySafety.secondDesc',
},
{
key: 'long_press',
label: 'settings.paySafety.hold',
desc: 'settings.paySafety.holdDesc',
},
]
function LeitourgiaTab() {
const { t } = useTranslation('waiter')
const { popupMode, persistentPopup, setPopupMode, setPersistentPopup } = useNotificationSettingsStore()
const { summaryBeforeSend, setSummaryBeforeSend } = useOrderingSettingsStore()
const { paymentSafety, setPaymentSafety } = usePaymentSettingsStore()
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 32, padding: '24px 16px' }}>
{/* Popup mode */}
<section>
<h2 style={sectionTitle}>{t('settings.popup.title')}</h2>
<p style={sectionSub}>{t('settings.popup.sub')}</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginTop: 14 }}>
{POPUP_MODE_OPTIONS.map(opt => {
const active = popupMode === opt.key
return (
<button
key={opt.key}
onClick={() => setPopupMode(opt.key)}
style={{
display: 'flex', alignItems: 'center', gap: 14,
padding: '12px 16px', borderRadius: 14,
border: `2px solid ${active ? 'var(--accent)' : 'var(--border)'}`,
background: active ? fade('var(--accent)', 0.09) : 'var(--bg2)',
cursor: 'pointer', textAlign: 'left',
transition: 'border-color 0.12s, background 0.12s',
}}
>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: active ? 'var(--accent)' : 'var(--text)', marginBottom: 2 }}>
{t(opt.label)}
</div>
<div style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{t(opt.desc)}</div>
</div>
{active && (
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" style={{ flexShrink: 0, color: 'var(--accent)' }}>
<circle cx="10" cy="10" r="9" stroke="currentColor" strokeWidth="1.5"/>
<path d="M6.5 10l2.5 2.5 4.5-5" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
)}
</button>
)
})}
</div>
</section>
{/* Persistent popup */}
<section>
<h2 style={sectionTitle}>{t('settings.persist.title')}</h2>
<p style={sectionSub}>
{persistentPopup
? t('settings.persist.on')
: t('settings.persist.off')}
</p>
<div style={{ marginTop: 14 }}>
<ToggleRow
label={t('settings.persist.label')}
desc={persistentPopup ? t('settings.persist.onDesc') : t('settings.persist.offDesc')}
checked={persistentPopup}
onChange={() => setPersistentPopup(!persistentPopup)}
/>
</div>
</section>
{/* Summary before send */}
<section>
<h2 style={sectionTitle}>{t('settings.summary.title')}</h2>
<p style={sectionSub}>
{t('settings.summary.sub')}
</p>
<div style={{ marginTop: 14 }}>
<ToggleRow
label={t('settings.summary.label')}
desc={summaryBeforeSend ? t('settings.summary.onDesc') : t('settings.summary.offDesc')}
checked={summaryBeforeSend}
onChange={() => setSummaryBeforeSend(!summaryBeforeSend)}
/>
</div>
</section>
{/* Payment safety switch */}
<section>
<h2 style={sectionTitle}>{t('settings.paySafety.title')}</h2>
<p style={sectionSub}>
{t('settings.paySafety.sub')}
</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginTop: 14 }}>
{PAYMENT_SAFETY_OPTIONS.map(opt => {
const active = paymentSafety === opt.key
return (
<button
key={opt.key}
onClick={() => setPaymentSafety(opt.key)}
style={{
display: 'flex', alignItems: 'center', gap: 14,
padding: '12px 16px', borderRadius: 14,
border: `2px solid ${active ? 'var(--accent)' : 'var(--border)'}`,
background: active ? fade('var(--accent)', 0.09) : 'var(--bg2)',
cursor: 'pointer', textAlign: 'left',
transition: 'border-color 0.12s, background 0.12s',
}}
>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: active ? 'var(--accent)' : 'var(--text)', marginBottom: 2 }}>
{t(opt.label)}
</div>
<div style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{t(opt.desc)}</div>
</div>
{active && (
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" style={{ flexShrink: 0, color: 'var(--accent)' }}>
<circle cx="10" cy="10" r="9" stroke="currentColor" strokeWidth="1.5"/>
<path d="M6.5 10l2.5 2.5 4.5-5" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
)}
</button>
)
})}
</div>
</section>
</div>
)
}
// ─── Personal tab ────────────────────────────────────────────────────────────
function PersonalizeTab() {
const { t } = useTranslation('waiter')
const navigate = useNavigate()
const { favorites, resetAll } = useWaiterFavoritesStore()
const [confirmReset, setConfirmReset] = useState(false)
function handleReset() {
if (!confirmReset) { setConfirmReset(true); return }
resetAll()
setConfirmReset(false)
}
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 32, padding: '24px 16px' }}>
{/* Favorites setup */}
<section>
<h2 style={sectionTitle}>{t('settings.fav.title')}</h2>
<p style={sectionSub}>
{favorites.length > 0
? t('settings.fav.count', { count: favorites.length })
: t('settings.fav.none')}
</p>
<div style={{ marginTop: 14 }}>
<button
onClick={() => navigate('/settings/favorites')}
style={{
display: 'flex', alignItems: 'center', gap: 14,
width: '100%', padding: '14px 16px', borderRadius: 14,
border: '2px solid var(--accent)',
background: fade('var(--accent)', 0.09),
cursor: 'pointer', textAlign: 'left',
}}
>
<svg width="22" height="22" viewBox="0 0 24 24" fill="var(--x-danger)" stroke="var(--x-danger)" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/>
</svg>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: 'var(--accent)' }}>{t('settings.fav.setup')}</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>{t('settings.fav.setupSub')}</div>
</div>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" style={{ color: 'var(--accent)', flexShrink: 0 }}>
<path d="M9 18l6-6-6-6" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
</button>
</div>
</section>
{/* Reset all */}
<section>
<h2 style={sectionTitle}>{t('settings.reset.title')}</h2>
<p style={sectionSub}>
{confirmReset
? t('settings.reset.sure')
: t('settings.reset.sub')}
</p>
<div style={{ marginTop: 14 }}>
<button
onClick={handleReset}
onBlur={() => setConfirmReset(false)}
style={{
display: 'flex', alignItems: 'center', gap: 12,
width: '100%', padding: '14px 16px', borderRadius: 14,
border: `2px solid ${confirmReset ? 'var(--danger)' : 'var(--border)'}`,
background: confirmReset ? 'var(--danger-dim, var(--x-danger-soft))' : 'var(--bg2)',
cursor: 'pointer', textAlign: 'left',
transition: 'border-color 0.15s, background 0.15s',
}}
>
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke={confirmReset ? 'var(--danger)' : 'var(--muted)'} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6M14 11v6"/><path d="M9 6V4h6v2"/>
</svg>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: confirmReset ? 'var(--danger)' : 'var(--text)' }}>
{confirmReset ? t('settings.reset.again') : t('settings.reset.all')}
</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>{t('settings.reset.allSub')}</div>
</div>
</button>
</div>
</section>
</div>
)
}
// ─── Navigation tab ─────────────────────────────────────────────────────────────
const ALL_NAV_ITEMS = [
{
key: 'tables',
label: 'nav.tables',
icon: (
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
<rect x="3" y="3" width="7" height="7" rx="1.5" fill="currentColor"/>
<rect x="14" y="3" width="7" height="7" rx="1.5" fill="currentColor"/>
<rect x="3" y="14" width="7" height="7" rx="1.5" fill="currentColor"/>
<rect x="14" y="14" width="7" height="7" rx="1.5" fill="currentColor"/>
</svg>
),
},
{
key: 'orders',
label: 'nav.orders',
icon: (
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
<path d="M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/>
<path d="M9 12h6M9 16h4" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/>
</svg>
),
},
{
key: 'messages',
label: 'nav.chat',
icon: (
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
),
},
{
key: 'standalone',
label: 'nav.takeaway',
icon: (
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
<path d="M5 12H3l9-9 9 9h-2" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-7" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M10 22v-6h4v6" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
),
},
{
key: 'shift-overview',
label: 'nav.shift',
icon: (
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
<circle cx="12" cy="12" r="9" stroke="currentColor" strokeWidth="2"/>
<path d="M12 7v5l3 3" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/>
</svg>
),
},
{
key: 'order-log',
label: 'nav.log',
icon: (
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
<path d="M6 9V2h12v7" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<rect x="6" y="14" width="12" height="8" rx="1" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
),
},
]
function DragHandle() {
return (
<span style={{ color: 'var(--muted)', flexShrink: 0, display: 'flex', flexDirection: 'column', gap: 3, padding: '0 2px' }}>
<span style={{ display: 'block', width: 16, height: 2, background: 'currentColor', borderRadius: 1 }} />
<span style={{ display: 'block', width: 16, height: 2, background: 'currentColor', borderRadius: 1 }} />
<span style={{ display: 'block', width: 16, height: 2, background: 'currentColor', borderRadius: 1 }} />
</span>
)
}
function Checkbox({ checked }) {
return (
<div style={{
width: 28, height: 28, borderRadius: 8, flexShrink: 0,
border: `2px solid ${checked ? 'var(--accent)' : 'var(--border)'}`,
background: checked ? 'var(--accent)' : 'transparent',
display: 'flex', alignItems: 'center', justifyContent: 'center',
pointerEvents: 'none',
transition: 'background 0.12s, border-color 0.12s',
}}>
{checked && (
<svg width="14" height="14" viewBox="0 0 14 14" fill="none">
<path d="M2.5 7l3 3 6-6" stroke="var(--accent-fg)" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
)}
</div>
)
}
function PloigisiTab() {
const { t } = useTranslation('waiter')
const { navStyle, setNavStyle, navItems, setNavItems, tripleItems, setTripleItems } = useTableViewStore()
const NAV_MAP = Object.fromEntries(ALL_NAV_ITEMS.map(i => [i.key, i]))
// ── Icon Navbar drag state ────────────────────────────────────────────────────
const dragKey = useRef(null)
const [dragging, setDragging] = useState(null) // drawn dimmed while dragged (refs aren't read in render)
const touchDragKey = useRef(null)
const itemRefs = useRef({})
const [dropIndex, setDropIndex] = useState(null)
// ── Triple Pill drag state ────────────────────────────────────────────────────
const triDragKey = useRef(null)
const [triDragging, setTriDragging] = useState(null)
const triTouchDragKey = useRef(null)
const triItemRefs = useRef({})
const [triDropIndex, setTriDropIndex] = useState(null)
function toggleItem(key) {
if (navItems.includes(key)) {
if (navItems.length <= 1) return
setNavItems(navItems.filter(k => k !== key))
} else {
if (navItems.length >= 5) return
setNavItems([...navItems, key])
}
}
function toggleTripleItem(key) {
if (tripleItems.includes(key)) {
if (tripleItems.length <= 1) return
setTripleItems(tripleItems.filter(k => k !== key))
} else {
if (tripleItems.length >= 3) return
setTripleItems([...tripleItems, key])
}
}
function computeDropIndex(y, refs, items) {
for (let i = 0; i < items.length; i++) {
const el = refs.current[items[i].key]
if (!el) continue
const rect = el.getBoundingClientRect()
if (y < rect.top + rect.height / 2) return i
}
return items.length
}
function applyReorder(fromKey, toIdx, items, setter) {
if (fromKey == null || toIdx == null) return
const fromIdx = items.findIndex(i => i.key === fromKey)
if (fromIdx === -1) return
const adjustedTo = toIdx > fromIdx ? toIdx - 1 : toIdx
if (fromIdx === adjustedTo) return
const keys = items.map(i => i.key)
keys.splice(fromIdx, 1)
keys.splice(adjustedTo, 0, fromKey)
setter(keys)
}
// ── Icon Navbar drag handlers ────────────────────────────────────────────────
function onDragStart(key) { dragKey.current = key; setDragging(key) }
function onDragOverContainer(e, items) {
e.preventDefault()
setDropIndex(computeDropIndex(e.clientY, itemRefs, items))
}
function onDropContainer(items) {
applyReorder(dragKey.current, dropIndex, items, setNavItems)
dragKey.current = null; setDragging(null); setDropIndex(null)
}
function onDragEnd() { dragKey.current = null; setDragging(null); setDropIndex(null) }
function onTouchStart(e, key) { touchDragKey.current = key; setDragging(key) }
function onTouchMove(e, items) {
e.preventDefault()
setDropIndex(computeDropIndex(e.touches[0].clientY, itemRefs, items))
}
function onTouchEnd(items) {
applyReorder(touchDragKey.current, dropIndex, items, setNavItems)
touchDragKey.current = null; setDragging(null); setDropIndex(null)
}
// ── Triple Pill drag handlers ────────────────────────────────────────────────
function triOnDragStart(key) { triDragKey.current = key; setTriDragging(key) }
function triOnDragOver(e, items) {
e.preventDefault()
setTriDropIndex(computeDropIndex(e.clientY, triItemRefs, items))
}
function triOnDrop(items) {
applyReorder(triDragKey.current, triDropIndex, items, setTripleItems)
triDragKey.current = null; setTriDragging(null); setTriDropIndex(null)
}
function triOnDragEnd() { triDragKey.current = null; setTriDragging(null); setTriDropIndex(null) }
function triOnTouchStart(e, key) { triTouchDragKey.current = key; setTriDragging(key) }
function triOnTouchMove(e, items) {
e.preventDefault()
setTriDropIndex(computeDropIndex(e.touches[0].clientY, triItemRefs, items))
}
function triOnTouchEnd(items) {
applyReorder(triTouchDragKey.current, triDropIndex, items, setTripleItems)
triTouchDragKey.current = null; setTriDragging(null); setTriDropIndex(null)
}
const enabledItems = navItems.map(k => NAV_MAP[k]).filter(Boolean)
const disabledItems = ALL_NAV_ITEMS.filter(i => !navItems.includes(i.key))
const tripleOrderedItems = (tripleItems || ['tables', 'orders', 'messages']).map(k => NAV_MAP[k]).filter(Boolean)
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 32, padding: '24px 16px' }}>
{/* Nav style picker */}
<section>
<h2 style={sectionTitle}>{t('settings.navStyle.title')}</h2>
<p style={sectionSub}>{t('settings.navStyle.sub')}</p>
<div style={{ display: 'flex', gap: 10, marginTop: 14 }}>
{[
{ key: 'triple', label: 'settings.navStyle.triple', desc: 'settings.navStyle.tripleDesc' },
{ key: 'icon_navbar', label: 'settings.navStyle.icons', desc: 'settings.navStyle.iconsDesc' },
].map(opt => {
const active = navStyle === opt.key
return (
<button
key={opt.key}
onClick={() => setNavStyle(opt.key)}
style={{
flex: 1,
display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 6,
padding: '14px 12px', borderRadius: 14,
border: `2px solid ${active ? 'var(--accent)' : 'var(--border)'}`,
background: active ? fade('var(--accent)', 0.09) : 'var(--bg2)',
cursor: 'pointer', textAlign: 'left',
transition: 'border-color 0.12s, background 0.12s',
}}
>
<span style={{ fontSize: 13, fontWeight: 800, color: active ? 'var(--accent)' : 'var(--text)' }}>{t(opt.label)}</span>
<span style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{t(opt.desc)}</span>
</button>
)
})}
</div>
</section>
{/* Triple Pill item editor */}
{navStyle === 'triple' && (
<section>
<h2 style={sectionTitle}>{t('settings.triple.title')}</h2>
<p style={sectionSub}>{t('settings.triple.sub')}</p>
<div
style={{ display: 'flex', flexDirection: 'column', gap: 0, marginTop: 14 }}
onDragOver={e => triOnDragOver(e, tripleOrderedItems)}
onDrop={() => triOnDrop(tripleOrderedItems)}
onDragEnd={triOnDragEnd}
onTouchMove={e => triOnTouchMove(e, tripleOrderedItems)}
onTouchEnd={() => triOnTouchEnd(tripleOrderedItems)}
>
<div style={{
height: triDropIndex === 0 ? 3 : 0,
background: 'var(--accent)', borderRadius: 2,
margin: triDropIndex === 0 ? '2px 8px 4px' : '0 8px',
transition: 'height 0.1s, margin 0.1s',
}} />
{tripleOrderedItems.map((item, idx) => (
<div key={item.key}>
<div
ref={el => { triItemRefs.current[item.key] = el }}
draggable
onDragStart={() => triOnDragStart(item.key)}
onTouchStart={e => triOnTouchStart(e, item.key)}
style={{
display: 'flex', alignItems: 'center', gap: 12,
padding: '12px 14px', borderRadius: 14, marginBottom: 8,
border: '2px solid var(--accent)',
background: fade('var(--accent)', 0.09),
cursor: 'grab', userSelect: 'none',
opacity: triDragging === item.key ? 0.4 : 1,
transition: 'opacity 0.1s',
}}
>
<DragHandle />
<span style={{ color: 'var(--accent)', flexShrink: 0 }}>{item.icon}</span>
<span style={{ flex: 1, fontSize: 15, fontWeight: 700, color: 'var(--accent)' }}>{t(item.label)}</span>
<button
onClick={() => toggleTripleItem(item.key)}
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: 0 }}
>
<Checkbox checked />
</button>
</div>
<div style={{
height: triDropIndex === idx + 1 ? 3 : 0,
background: 'var(--accent)', borderRadius: 2,
margin: triDropIndex === idx + 1 ? '2px 8px 4px' : '0 8px',
transition: 'height 0.1s, margin 0.1s',
}} />
</div>
))}
</div>
{/* Divider + disabled items */}
{ALL_NAV_ITEMS.filter(i => !tripleItems.includes(i.key)).length > 0 && (
<>
<div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '4px 0', margin: '4px 0 8px' }}>
<div style={{ flex: 1, height: 1, background: 'var(--border)' }} />
<span style={{ fontSize: 11, color: 'var(--muted)', fontWeight: 700, textTransform: 'uppercase', letterSpacing: 0.8 }}>
{t('settings.available')}
</span>
<div style={{ flex: 1, height: 1, background: 'var(--border)' }} />
</div>
{ALL_NAV_ITEMS.filter(i => !tripleItems.includes(i.key)).map(item => (
<div
key={item.key}
style={{
display: 'flex', alignItems: 'center', gap: 12,
padding: '12px 14px', borderRadius: 14, marginBottom: 8,
border: '2px solid var(--border)',
background: 'var(--bg2)',
}}
>
<span style={{ width: 20, flexShrink: 0 }} />
<span style={{ color: 'var(--muted)', flexShrink: 0 }}>{item.icon}</span>
<span style={{ flex: 1, fontSize: 15, fontWeight: 700, color: 'var(--text)' }}>{t(item.label)}</span>
<button
onClick={() => toggleTripleItem(item.key)}
style={{ background: 'none', border: 'none', cursor: tripleItems.length >= 3 ? 'not-allowed' : 'pointer', padding: 0, opacity: tripleItems.length >= 3 ? 0.4 : 1 }}
>
<Checkbox checked={false} />
</button>
</div>
))}
</>
)}
<p style={{ fontSize: 12, color: 'var(--muted)', marginTop: 4, lineHeight: 1.5 }}>
{t('settings.triple.count', { count: tripleItems.length })}
{tripleItems.length >= 3 ? ` — ${t('settings.max')}` : ''}
</p>
</section>
)}
{/* Icon navbar item editor */}
{navStyle === 'icon_navbar' && (
<section>
<h2 style={sectionTitle}>{t('settings.icons.title')}</h2>
<p style={sectionSub}>{t('settings.icons.sub')}</p>
<div
style={{ display: 'flex', flexDirection: 'column', gap: 0, marginTop: 14 }}
onDragOver={e => onDragOverContainer(e, enabledItems)}
onDrop={() => onDropContainer(enabledItems)}
onDragEnd={onDragEnd}
onTouchMove={e => onTouchMove(e, enabledItems)}
onTouchEnd={() => onTouchEnd(enabledItems)}
>
{/* Enabled items — ordered, draggable */}
{/* Drop indicator before first item */}
<div style={{
height: dropIndex === 0 ? 3 : 0,
background: 'var(--accent)',
borderRadius: 2,
margin: dropIndex === 0 ? '2px 8px 4px' : '0 8px',
transition: 'height 0.1s, margin 0.1s',
}} />
{enabledItems.map((item, idx) => (
<div key={item.key}>
<div
ref={el => { itemRefs.current[item.key] = el }}
draggable
onDragStart={() => onDragStart(item.key)}
onTouchStart={e => onTouchStart(e, item.key)}
style={{
display: 'flex', alignItems: 'center', gap: 12,
padding: '12px 14px', borderRadius: 14, marginBottom: 8,
border: `2px solid var(--accent)`,
background: fade('var(--accent)', 0.09),
cursor: 'grab',
userSelect: 'none',
opacity: dragging === item.key ? 0.4 : 1,
transition: 'opacity 0.1s',
}}
>
<DragHandle />
<span style={{ color: 'var(--accent)', flexShrink: 0 }}>{item.icon}</span>
<span style={{ flex: 1, fontSize: 15, fontWeight: 700, color: 'var(--accent)' }}>{t(item.label)}</span>
<button
onClick={() => toggleItem(item.key)}
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: 0 }}
>
<Checkbox checked />
</button>
</div>
{/* Drop indicator after this item (= before the next one) */}
<div style={{
height: dropIndex === idx + 1 ? 3 : 0,
background: 'var(--accent)',
borderRadius: 2,
margin: dropIndex === idx + 1 ? '2px 8px 4px' : '0 8px',
transition: 'height 0.1s, margin 0.1s',
}} />
</div>
))}
{/* Divider */}
{disabledItems.length > 0 && (
<div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '4px 0', marginBottom: 8 }}>
<div style={{ flex: 1, height: 1, background: 'var(--border)' }} />
<span style={{ fontSize: 11, color: 'var(--muted)', fontWeight: 700, textTransform: 'uppercase', letterSpacing: 0.8 }}>
{t('settings.available')}
</span>
<div style={{ flex: 1, height: 1, background: 'var(--border)' }} />
</div>
)}
{/* Disabled items */}
{disabledItems.map(item => (
<div
key={item.key}
style={{
display: 'flex', alignItems: 'center', gap: 12,
padding: '12px 14px', borderRadius: 14, marginBottom: 8,
border: `2px solid var(--border)`,
background: 'var(--bg2)',
}}
>
<span style={{ width: 20, flexShrink: 0 }} />
<span style={{ color: 'var(--muted)', flexShrink: 0 }}>{item.icon}</span>
<span style={{ flex: 1, fontSize: 15, fontWeight: 700, color: 'var(--text)' }}>{t(item.label)}</span>
<button
onClick={() => toggleItem(item.key)}
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: 0 }}
>
<Checkbox checked={false} />
</button>
</div>
))}
</div>
<p style={{ fontSize: 12, color: 'var(--muted)', marginTop: 4, lineHeight: 1.5 }}>
{t('settings.icons.count', { count: navItems.length })}
{navItems.length >= 5 ? ` — ${t('settings.max')}` : ''}
</p>
</section>
)}
</div>
)
}
// ─── Main page ────────────────────────────────────────────────────────────────
export default function SettingsPage() {
const { t } = useTranslation('waiter')
const navigate = useNavigate()
const [activeTab, setActiveTab] = useState('layout')
return (
<div className="page">
{/* Top bar */}
<header className="top-bar">
<button
onClick={() => navigate(-1)}
style={{
display: 'flex', alignItems: 'center', gap: 6,
background: 'none', border: 'none', cursor: 'pointer',
color: 'var(--text)', fontSize: 15, fontWeight: 600,
padding: '0 4px', minHeight: 44, borderRadius: 8,
}}
>
<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
<path d="M12.5 15l-5-5 5-5" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
{t('common.back')}
</button>
<span className="top-bar__title" style={{ textAlign: 'center' }}>{t('nav.settings')}</span>
{/* spacer to balance the back button */}
<div style={{ width: 72 }} />
</header>
{/* Tab strip — horizontally scrollable so long labels never clip */}
<div style={{
borderBottom: '1px solid var(--border)',
background: 'var(--bg2)',
overflowX: 'auto',
WebkitOverflowScrolling: 'touch',
scrollbarWidth: 'none',
flexShrink: 0,
}}>
<div style={{ display: 'flex', gap: 0, padding: '0 8px', minWidth: 'max-content' }}>
{TABS.map(tab => (
<button
key={tab.key}
onClick={() => setActiveTab(tab.key)}
style={{
padding: '14px 16px',
background: 'none', border: 'none',
borderBottom: activeTab === tab.key ? '2px solid var(--accent)' : '2px solid transparent',
color: activeTab === tab.key ? 'var(--accent)' : 'var(--text)',
fontSize: 14, fontWeight: 600,
cursor: 'pointer',
marginBottom: -1,
whiteSpace: 'nowrap',
transition: 'color 0.12s',
}}
>
{t(tab.label)}
</button>
))}
</div>
</div>
{/* Tab body */}
<div style={{ flex: 1, overflowY: 'auto', minHeight: 0, overscrollBehavior: 'contain' }}>
{activeTab === 'layout' && <LayoutTab />}
{activeTab === 'leitourgia' && <LeitourgiaTab />}
{activeTab === 'ploigisi' && <PloigisiTab />}
{activeTab === 'personalize' && <PersonalizeTab />}
</div>
</div>
)
}