From the owner's page-by-page review (2026-11-20): - every page root is <Page> (scrolls, fills 1080p, 16:9 centred on ultrawides); not yet: products, management/tables, stock (next pass) - /dashboard: more padding in cards (p-card), quieter secondary text, 11px uppercase labels everywhere (text-overline) - day stats: xl dialog, "● Day running · Opened …" as text, the six figures in equal boxes, "On tabs" in the payments bar, shared Tabs - /tables: Segmented List / Map / QR codes (?view=; /online/qr redirects), filter chips + zones multi-select at one height, the card itself opens the table (button removed), cards ~20% wider - /online-orders: shared Tabs with Settings (= the old /online/fees page, which redirects to ?tab=settings); orders fill the width - contacts, customers, expenses: PageHeader + Toolbar + SearchInput + multi-select Dropdowns (kinds; statuses, categories); table cells vertically centred; the Spent tip opens on hover - filterCards / filterContacts / filterExpenses take several values (unit tests added) - docs/DESIGN.md: the design language (CS-20 in the pack README) - tests/e2e/manager_layout.mjs: the page rule at 1920x1080 and 3440x1440; manager.mjs and manager_look.mjs follow the moved pages Verified: manager build + lint (0 errors), unit tests (manager 99, ui 24, i18n 31, api 25, access 8), i18n guard, manager_layout.mjs all passed, manager.mjs 228 checks all passed. Not checked: the waiter app and the terminal by eye (they only get the muted ink-2 token). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
3.9 KiB
React
68 lines
3.9 KiB
React
// Integrations → Caller ID (plan step 3.5): the call log (GET /api/phone/calls, kept on the
|
|
// server, so it survives a reload and shows calls taken while the manager was closed), new calls
|
|
// live, a tap opens the caller's card; and how to connect the phone system (the UCM Action URL).
|
|
import { useCallback, useEffect, useState } from 'react'
|
|
import { PhoneIncoming } from 'lucide-react'
|
|
import { errorMessage } from '@xenia/api'
|
|
import { useFormat, useTranslation } from '@xenia/i18n'
|
|
import { EmptyState, Page, Spinner } from '@xenia/ui'
|
|
import client from '../api/client'
|
|
import { useLiveEvent } from '../live/useLiveEvent'
|
|
import usePhoneStore from '../store/phoneStore'
|
|
|
|
export default function PhonePage() {
|
|
const { t } = useTranslation('manager')
|
|
const { formatDateTime } = useFormat()
|
|
const setActiveCall = usePhoneStore(s => s.setActiveCall)
|
|
const [calls, setCalls] = useState(null)
|
|
const [error, setError] = useState(null)
|
|
|
|
const load = useCallback(async () => {
|
|
try { setCalls((await client.get('/api/phone/calls', { params: { limit: 100 } })).data.calls); setError(null) } catch (err) { setError(errorMessage(err, t)) }
|
|
}, [t])
|
|
useEffect(() => { load() }, [load])
|
|
useLiveEvent('call_incoming', load)
|
|
useLiveEvent('ready', load)
|
|
|
|
const hook = `${window.location.protocol}//${window.location.hostname}/api/phone/call-event?caller=\${CALLERID}&ext=\${EXTEN}`
|
|
return (
|
|
<Page testId="phone-page">
|
|
<header className="grid gap-1">
|
|
<h1 className="text-heading font-semibold text-ink">{t('calls.title')}</h1>
|
|
<p className="text-body text-ink-2">{t('calls.intro')}</p>
|
|
</header>
|
|
<section className="rounded-card border border-line bg-surface overflow-hidden" aria-labelledby="calls-h">
|
|
<h2 id="calls-h" className="px-4 py-3 border-b border-line text-label font-semibold text-ink-2">{t('calls.log')}</h2>
|
|
{error ? <div className="p-6"><EmptyState title={error} /></div>
|
|
: calls == null ? <div className="p-6 flex justify-center"><Spinner /></div>
|
|
: calls.length === 0 ? <div className="p-6"><EmptyState icon={<PhoneIncoming size={28} />} title={t('calls.none')} /></div>
|
|
: (
|
|
<ul className="divide-y divide-line" data-testid="call-log">
|
|
{calls.map(c => (
|
|
<li key={c.call_id}>
|
|
<button type="button" onClick={() => setActiveCall(c)} data-testid="call-row"
|
|
className="w-full px-4 py-3 flex items-center gap-3 text-left hover:bg-surface-2 transition-colors duration-fast">
|
|
<span className="size-9 rounded-full bg-surface-2 text-ink-2 flex items-center justify-center shrink-0 font-semibold">
|
|
{c.customer ? c.customer.name?.[0]?.toUpperCase() : <PhoneIncoming size={14} aria-hidden="true" />}
|
|
</span>
|
|
<span className="flex-1 min-w-0">
|
|
<span className="block text-body font-medium text-ink truncate">{c.customer ? c.customer.name : c.number}</span>
|
|
<span className="block text-label text-ink-2">{c.customer ? c.number : t('calls.unknown')}{c.ext ? ` · ${t('calls.ext', { ext: c.ext })}` : ''}</span>
|
|
</span>
|
|
<span className="text-label text-ink-3">{formatDateTime(c.at, 'datetimeShort')}</span>
|
|
</button>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
)}
|
|
</section>
|
|
<section className="p-4 rounded-card border border-line bg-surface-2 grid gap-1.5">
|
|
<h2 className="text-label font-semibold text-ink">{t('calls.setup')}</h2>
|
|
<p className="text-label text-ink-2">{t('calls.setupBody')}</p>
|
|
<code className="text-label text-ink break-all bg-surface p-2 rounded-control border border-line">{hook}</code>
|
|
<p className="text-caption text-ink-3">{t('calls.setupSecret')}</p>
|
|
</section>
|
|
</Page>
|
|
)
|
|
}
|