feat(manager): notification bell, sign-in/venue/print settings, log download (platform-v2 2.6f)
- Bell in the header: /api/platform/notifications with unread count, live via
the new LiveProvider (one createLiveClient connection) on platform_notification
and reconnect; mark read / all; warning+critical pop a toast.
- Settings: Sign-in card (manager/waiter/device modes, require username, one
session per manager/waiter, username autofill) replaces the dead v1
security.login_method card; new "Venue & language" tab (language, time zone);
print alert threshold in Printing. Tab labels are i18n keys.
- Technical > Log files: list + download of the daily logs (owner-level).
Backend: GET /api/system/logs, /api/system/logs/{date} (core.settings.manage),
error system.log_not_found.
- Setup wizard asks staff language and time zone (setup/init stores them).
- @xenia/ui theme helpers (applyTheme, getStoredTheme); the manager stays light
until phase 6 converts the older pages (owner decision 2026-11-14).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// Venue settings for the v2 settings sections (plan step 2.6f): GET /api/settings/ (all
|
||||
// declared keys with their values) and PUT /api/settings/{key} {value} (core.settings.manage;
|
||||
// the backend checks types, enums, time zones and languages). Shares the react-query key
|
||||
// with the older settings tabs, so both stay in sync.
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import toast from 'react-hot-toast'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useAccess } from '@xenia/access'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import client from '../../../api/client'
|
||||
|
||||
/** Keys that change what bootstrap says (language, time zone, sign-in mode): reload it. */
|
||||
const BOOTSTRAP_KEYS = new Set(['venue.language', 'venue.timezone', 'auth.manager_login_mode', 'security.autofill_username'])
|
||||
|
||||
export function useSettings() {
|
||||
const { t } = useTranslation('manager')
|
||||
const qc = useQueryClient()
|
||||
const access = useAccess()
|
||||
const query = useQuery({
|
||||
queryKey: ['pos-settings'],
|
||||
queryFn: () => client.get('/api/settings/').then(r => r.data),
|
||||
staleTime: 30_000,
|
||||
})
|
||||
const mutation = useMutation({
|
||||
mutationFn: ({ key, value }) => client.put(`/api/settings/${key}`, { value }),
|
||||
onSuccess: (_r, { key }) => {
|
||||
toast.success(t('settings.saved'))
|
||||
qc.invalidateQueries({ queryKey: ['pos-settings'] })
|
||||
if (BOOTSTRAP_KEYS.has(key)) access.refresh()
|
||||
},
|
||||
onError: err => toast.error(errorMessage(err, t)),
|
||||
})
|
||||
return {
|
||||
loading: query.isLoading,
|
||||
error: query.error ? errorMessage(query.error, t) : null,
|
||||
/** The stored value (strings, as the backend keeps them), or `fallback`. */
|
||||
get: (key, fallback = '') => query.data?.[key]?.value ?? fallback,
|
||||
save: (key, value) => mutation.mutate({ key, value: String(value) }),
|
||||
saving: mutation.isPending,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user