fix: show access action zone
This commit is contained in:
@@ -11,6 +11,8 @@ import { VisitRequestDetailDialog } from '../components/VisitRequestDetailDialog
|
||||
|
||||
const hasEnteredToday = (r: AccessRecord) => Boolean(r.checkInAt);
|
||||
const hasExitedToday = (r: AccessRecord) => Boolean(r.checkOutAt);
|
||||
const actionLabel = (visitorName: string, zoneName?: string) =>
|
||||
zoneName ? `${visitorName} (${zoneName})` : visitorName;
|
||||
|
||||
function accessBadge(record: AccessRecord): { className: string; label: string } {
|
||||
if (record.inside) {
|
||||
@@ -78,14 +80,14 @@ export const AccessConsolePage: React.FC = () => {
|
||||
const forceCheckIn = (id: number) =>
|
||||
wrap(async () => {
|
||||
const res = await checkIn({ visitRequestId: id, gateId: 'STAFF' });
|
||||
setNotice(`${res.visitorName} — ${res.message}`);
|
||||
setNotice(`${actionLabel(res.visitorName, res.zoneName)} — ${res.message}`);
|
||||
loadRecords();
|
||||
});
|
||||
|
||||
const forceCheckOut = (id: number) =>
|
||||
wrap(async () => {
|
||||
const res = await checkOut({ visitRequestId: id });
|
||||
setNotice(`${res.visitorName} — ${res.message}`);
|
||||
setNotice(`${actionLabel(res.visitorName, res.zoneName)} — ${res.message}`);
|
||||
loadRecords();
|
||||
});
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@ import { formatVisitRange } from '../status';
|
||||
import { useQrScanner } from '../useQrScanner';
|
||||
import { playChime } from '../chime';
|
||||
|
||||
const actionLabel = (visitorName: string, zoneName?: string) =>
|
||||
zoneName ? `${visitorName} (${zoneName})` : visitorName;
|
||||
|
||||
function extractQrToken(raw: string): string {
|
||||
const text = raw.trim();
|
||||
if (!text) return '';
|
||||
@@ -65,7 +68,7 @@ export const KioskPage: React.FC = () => {
|
||||
try {
|
||||
const r = dir === 'in' ? await publicCheckIn(token) : await publicCheckOut(token);
|
||||
playChime();
|
||||
setResult(`${r.visitorName} — ${r.message}`);
|
||||
setResult(`${actionLabel(r.visitorName, r.zoneName)} — ${r.message}`);
|
||||
setToken(null);
|
||||
setPass(null);
|
||||
} catch (e) {
|
||||
|
||||
@@ -230,6 +230,7 @@ export interface AccessRecord {
|
||||
export interface AccessAction {
|
||||
visitRequestId: number;
|
||||
visitorName: string;
|
||||
zoneName?: string;
|
||||
direction: 'IN' | 'OUT';
|
||||
eventAt: string;
|
||||
gateOpened: boolean;
|
||||
|
||||
Reference in New Issue
Block a user