feat: staff and the schedule on v2; managers give staff passwords (platform-v2 step 6.11, KI-014)
- staff: PUT /api/waiters/{id}/password (set, change, or take away; 6+ chars)
so the password sign-in mode works for everyone; PUT /{id}/pin with the PIN in
the body (was in the address: reset-pin?pin= removed); PINs 4-6 digits when
adding; a password can be given when adding; has_password on staff; editing
clears emptied fields and keeps usernames unique; delete only without history
(orders, items, shifts) and never yourself
- schedule: times checked (schedule.bad_time), one person's overlapping shifts
refused (schedule.overlap, past midnight understood), everyone active can be
scheduled (the kitchen too), changes need core.staff.manage
- manager: src/pages/staff (list with search and filters, person dialog with
photo, PIN / password dialog, zones) and src/pages/schedule (by person, by
hour with opening hours, shift dialog with clash check, view settings kept in
the browser); the never-used "automatic start/close" switches dropped; v1
StaffTab and SchedulePage removed; ApprovalsPage loads with useLiveQuery
- tests: test_staff_v2.py (done-when on a paired screen), staff.test.mjs, e2e
manager.mjs (add, password, sign-in on a paired till, a shift and a clash)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
// Which tables someone serves (plan step 6.11): every zone, or some of them. Their phone and the
|
||||
// table map only show those tables; someone with no zone sees none.
|
||||
import { useState } from 'react'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import toast from 'react-hot-toast'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, Switch, cx } from '@xenia/ui'
|
||||
import client from '../../api/client'
|
||||
import { displayName, zonesBody, zonesOf } from './staffLogic'
|
||||
|
||||
export default function ZonesDialog({ member, groups, onClose, onSaved }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const [zones, setZones] = useState(() => zonesOf(member))
|
||||
const save = useMutation({
|
||||
mutationFn: () => client.put(`/api/waiters/${member.id}/zones`, zonesBody(zones)),
|
||||
onSuccess: () => { toast.success(t('staff.zonesSaved', { name: displayName(member) })); onSaved() },
|
||||
onError: e => toast.error(errorMessage(e, t)),
|
||||
})
|
||||
const toggle = id => setZones(z => ({ ...z, ids: z.ids.includes(id) ? z.ids.filter(x => x !== id) : [...z.ids, id] }))
|
||||
return (
|
||||
<Dialog open size="sm" onClose={onClose} title={t('staff.zonesOf', { name: displayName(member) })} description={t('staff.zonesBody')}
|
||||
footer={<>
|
||||
<Button variant="secondary" onClick={onClose}>{t('staff.back')}</Button>
|
||||
<Button loading={save.isPending} onClick={() => save.mutate()}>{t('staff.save')}</Button>
|
||||
</>}>
|
||||
<div className="grid gap-3">
|
||||
<label className="flex items-center gap-3 text-body font-medium text-ink">
|
||||
<Switch checked={zones.all} onChange={v => setZones(z => ({ ...z, all: v }))} aria-label={t('staff.allZones')} />{t('staff.allZones')}
|
||||
</label>
|
||||
{!zones.all && (
|
||||
groups.length === 0 ? <p className="text-label text-ink-3">{t('staff.noGroups')}</p> : (
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{groups.map(g => {
|
||||
const on = zones.ids.includes(g.id)
|
||||
return (
|
||||
<button key={g.id} type="button" aria-pressed={on} onClick={() => toggle(g.id)}
|
||||
className={cx('px-3 py-1.5 rounded-full border text-label', on ? 'border-accent bg-accent-soft text-accent-ink font-semibold' : 'border-line bg-surface text-ink-2 hover:bg-surface-2')}>
|
||||
{g.name}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
)}
|
||||
{!zones.all && !zones.ids.length && <p className="text-label text-warning-ink" role="note">{t('staff.noZonesWarn')}</p>}
|
||||
</div>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user