260707_01_ENH: 모니터링 출발/도착 버튼은 모니터링 일자 이후로 부터 노출되게 수정 및 관리자는 출발 도착 삭제 가능하게 수정

This commit is contained in:
2026-07-07 15:06:19 +09:00
parent 9e12f238d8
commit 3edbbee103
5 changed files with 86 additions and 9 deletions

View File

@@ -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>
)}

View File

@@ -98,3 +98,26 @@ export const POST = async (
return errorToResponse(error);
}
};
export const DELETE = async (
req: NextRequest,
context: RouteContext
) => {
try {
void req;
const {slug = []} = await context.params;
const [action, subAction, performanceId, userId] = slug;
const backApi = await createBackApi();
if (action === "visit" && subAction === "reset" && performanceId && userId && slug.length === 4) {
await backApi.del<void>(
`/monitoring/visit/reset/${encodeURIComponent(performanceId)}/${encodeURIComponent(userId)}`
);
return NextResponse.json(null, { status: 200 });
}
return NextResponse.json({ message: "Not found" }, { status: 404 });
} catch (error: unknown) {
return errorToResponse(error);
}
};