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 hasEnteredToday = (r: AccessRecord) => Boolean(r.checkInAt);
|
||||||
const hasExitedToday = (r: AccessRecord) => Boolean(r.checkOutAt);
|
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 } {
|
function accessBadge(record: AccessRecord): { className: string; label: string } {
|
||||||
if (record.inside) {
|
if (record.inside) {
|
||||||
@@ -78,14 +80,14 @@ export const AccessConsolePage: React.FC = () => {
|
|||||||
const forceCheckIn = (id: number) =>
|
const forceCheckIn = (id: number) =>
|
||||||
wrap(async () => {
|
wrap(async () => {
|
||||||
const res = await checkIn({ visitRequestId: id, gateId: 'STAFF' });
|
const res = await checkIn({ visitRequestId: id, gateId: 'STAFF' });
|
||||||
setNotice(`${res.visitorName} — ${res.message}`);
|
setNotice(`${actionLabel(res.visitorName, res.zoneName)} — ${res.message}`);
|
||||||
loadRecords();
|
loadRecords();
|
||||||
});
|
});
|
||||||
|
|
||||||
const forceCheckOut = (id: number) =>
|
const forceCheckOut = (id: number) =>
|
||||||
wrap(async () => {
|
wrap(async () => {
|
||||||
const res = await checkOut({ visitRequestId: id });
|
const res = await checkOut({ visitRequestId: id });
|
||||||
setNotice(`${res.visitorName} — ${res.message}`);
|
setNotice(`${actionLabel(res.visitorName, res.zoneName)} — ${res.message}`);
|
||||||
loadRecords();
|
loadRecords();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import { formatVisitRange } from '../status';
|
|||||||
import { useQrScanner } from '../useQrScanner';
|
import { useQrScanner } from '../useQrScanner';
|
||||||
import { playChime } from '../chime';
|
import { playChime } from '../chime';
|
||||||
|
|
||||||
|
const actionLabel = (visitorName: string, zoneName?: string) =>
|
||||||
|
zoneName ? `${visitorName} (${zoneName})` : visitorName;
|
||||||
|
|
||||||
function extractQrToken(raw: string): string {
|
function extractQrToken(raw: string): string {
|
||||||
const text = raw.trim();
|
const text = raw.trim();
|
||||||
if (!text) return '';
|
if (!text) return '';
|
||||||
@@ -65,7 +68,7 @@ export const KioskPage: React.FC = () => {
|
|||||||
try {
|
try {
|
||||||
const r = dir === 'in' ? await publicCheckIn(token) : await publicCheckOut(token);
|
const r = dir === 'in' ? await publicCheckIn(token) : await publicCheckOut(token);
|
||||||
playChime();
|
playChime();
|
||||||
setResult(`${r.visitorName} — ${r.message}`);
|
setResult(`${actionLabel(r.visitorName, r.zoneName)} — ${r.message}`);
|
||||||
setToken(null);
|
setToken(null);
|
||||||
setPass(null);
|
setPass(null);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ export interface AccessRecord {
|
|||||||
export interface AccessAction {
|
export interface AccessAction {
|
||||||
visitRequestId: number;
|
visitRequestId: number;
|
||||||
visitorName: string;
|
visitorName: string;
|
||||||
|
zoneName?: string;
|
||||||
direction: 'IN' | 'OUT';
|
direction: 'IN' | 'OUT';
|
||||||
eventAt: string;
|
eventAt: string;
|
||||||
gateOpened: boolean;
|
gateOpened: boolean;
|
||||||
|
|||||||
@@ -716,6 +716,7 @@ export function createBusinessRouter(deps: BusinessRouterDeps = { query }): Rout
|
|||||||
ok(res, {
|
ok(res, {
|
||||||
visitRequestId: id,
|
visitRequestId: id,
|
||||||
visitorName: visit.visitor_name,
|
visitorName: visit.visitor_name,
|
||||||
|
zoneName: visit.zone_name ?? undefined,
|
||||||
direction,
|
direction,
|
||||||
eventAt: new Date().toISOString(),
|
eventAt: new Date().toISOString(),
|
||||||
gateOpened: true,
|
gateOpened: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user