260707_01_ENH: 모니터링 출발/도착 버튼은 모니터링 일자 이후로 부터 노출되게 수정 및 관리자는 출발 도착 삭제 가능하게 수정
This commit is contained in:
@@ -27,11 +27,17 @@ const today = toLocalDateString();
|
||||
const todayTime = new Date(`${today}T00:00:00`).getTime();
|
||||
|
||||
const toDateTime = (date?: string | null) => {
|
||||
if (!date) return Number.POSITIVE_INFINITY;
|
||||
const time = new Date(`${date}T00:00:00`).getTime();
|
||||
const normalizedDate = date?.trim();
|
||||
if (!normalizedDate) return Number.POSITIVE_INFINITY;
|
||||
const time = new Date(`${normalizedDate}T00:00:00`).getTime();
|
||||
return Number.isNaN(time) ? Number.POSITIVE_INFINITY : time;
|
||||
};
|
||||
|
||||
const canSaveMonitoringVisit = (date?: string | null) => {
|
||||
const time = toDateTime(date);
|
||||
return Number.isFinite(time) && todayTime >= time;
|
||||
};
|
||||
|
||||
const compareMonitoringSchedule = (a: PerformanceFull, b: PerformanceFull) => {
|
||||
const aTime = toDateTime(a.performanceMonitoringSchedule?.monitoringDate);
|
||||
const bTime = toDateTime(b.performanceMonitoringSchedule?.monitoringDate);
|
||||
@@ -107,6 +113,7 @@ const MonitoringPage = () => {
|
||||
}, [selected, userId]);
|
||||
const hasDeparture = Boolean(selectedMonitoringRow?.slot.timeline.departure || selectedMonitoringRow?.slot.visit?.length);
|
||||
const hasArrival = Boolean(selectedMonitoringRow?.slot.timeline.arrival);
|
||||
const canSaveVisit = canSaveMonitoringVisit(selected?.performanceMonitoringSchedule?.monitoringDate);
|
||||
|
||||
const columns = useMemo<DataTableColumn<PerformanceFull>[]>(() => [
|
||||
{
|
||||
@@ -269,9 +276,9 @@ const MonitoringPage = () => {
|
||||
{selected && (
|
||||
<div>
|
||||
{!hasDeparture ? (
|
||||
<Button type="button" className="w-full" onClick={() => openVisit("departure")}>출발</Button>
|
||||
<Button type="button" className="w-full" disabled={!canSaveVisit} onClick={() => openVisit("departure")}>출발</Button>
|
||||
) : (
|
||||
<Button type="button" className="w-full" disabled={hasArrival} onClick={() => openVisit("arrival")}>도착</Button>
|
||||
<Button type="button" className="w-full" disabled={!canSaveVisit || hasArrival} onClick={() => openVisit("arrival")}>도착</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user