// "Manager approvals" (plan step 2.6e, APPS_PLATFORM D-10): the record of every time a // manager typed their PIN to allow one action for someone who lacks the permission (cancel // a sent item, change a price, a discount over the limit…). Backend: GET /api/access/overrides // (core.staff.manage), newest first, the latest 200. Rows are never deleted. // An approval is valid for 60 s, once: "Not used" = it expired before the action happened. import { useCallback, useEffect, useState } from 'react' import { Link } from 'react-router-dom' import { ShieldCheck } from 'lucide-react' import { errorMessage } from '@xenia/api' import { useTranslation, useFormat } from '@xenia/i18n' import { Button, EmptyState, Spinner } from '@xenia/ui' import client from '../../api/client' import { approvalState, approvalTarget, permLabelKey } from './permissionsLogic' const STATE_TONE = { used: 'bg-success-soft text-success-ink', expired: 'bg-surface-2 text-ink-3', waiting: 'bg-info-soft text-info-ink', } export default function ApprovalsPage() { const { t } = useTranslation('manager') const f = useFormat() const [rows, setRows] = useState(null) const [error, setError] = useState(null) const load = useCallback(async () => { try { const r = await client.get('/api/access/overrides') setRows(r.data) setError(null) } catch (err) { setError(errorMessage(err, t)) } }, [t]) useEffect(() => { load() }, [load]) if (error) return
{t('approvals.intro')}
{rows.length === 0 ?| {t(`approvals.columns.${c}`)} | ))}|||||
|---|---|---|---|---|---|
| {f.formatDateTime(r.created_at, 'datetimeShort')} | {t(permLabelKey(r.key), { defaultValue: r.key })} | {r.requested_by_name || '—'} | {r.approved_by_name || '—'} | {r.device_name || '—'} | {t(`approvals.state.${state}`)} {state === 'used' && target?.order && ( {t('approvals.order', { id: target.order })} )} {state === 'used' && target?.text && {target.text}} |