fix: handle visit request Excel form upload
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { listReportVisits, listTodayAccess, reportDownloadUrl } from '../api';
|
||||
import { DatePickerField } from '../components/DatePickerField';
|
||||
import { AccessRecord, VisitRequestView } from '../types';
|
||||
import { AccessRecord, ReportVisitView } from '../types';
|
||||
import { STATUS_CLASS, STATUS_LABEL, formatDateTime } from '../status';
|
||||
|
||||
const pad = (n: number) => String(n).padStart(2, '0');
|
||||
@@ -20,7 +20,7 @@ function firstOfMonthISO(): string {
|
||||
export const ReportPage: React.FC = () => {
|
||||
const [from, setFrom] = useState(firstOfMonthISO());
|
||||
const [to, setTo] = useState(todayISO());
|
||||
const [items, setItems] = useState<VisitRequestView[]>([]);
|
||||
const [items, setItems] = useState<ReportVisitView[]>([]);
|
||||
const [accessRecords, setAccessRecords] = useState<AccessRecord[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -45,13 +45,19 @@ export const ReportPage: React.FC = () => {
|
||||
};
|
||||
|
||||
const accessById = new Map(accessRecords.map((r) => [r.visitRequestId, r]));
|
||||
const statusBadge = (r: VisitRequestView) => {
|
||||
const statusBadge = (r: ReportVisitView) => {
|
||||
const access = accessById.get(r.id);
|
||||
if (r.reportStatusLabel) {
|
||||
return {
|
||||
className: r.reportStatusLabel === '재실중' ? 'green' : r.reportStatusLabel === '퇴실' ? 'gray' : STATUS_CLASS[r.status],
|
||||
label: r.reportStatusLabel,
|
||||
};
|
||||
}
|
||||
if (access?.inside) {
|
||||
return { className: 'green', label: '재실중' };
|
||||
}
|
||||
if (access?.checkOutAt) {
|
||||
return { className: 'gray', label: '퇴장' };
|
||||
return { className: 'gray', label: '퇴실' };
|
||||
}
|
||||
return { className: STATUS_CLASS[r.status], label: STATUS_LABEL[r.status] };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user