260623_01_ENH: 엑셀 다운로드를 제외한 기능 완성
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import {useMemo, useRef, useState} from "react";
|
||||
import {useEffect, useMemo, useRef, useState} from "react";
|
||||
import {Search} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Input} from "@/components/ui/input";
|
||||
@@ -24,29 +24,7 @@ import {useDialog} from "@/hooks/useDialog";
|
||||
import {useMounted} from "@/hooks/useMounted";
|
||||
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
|
||||
import {SMS_TEMPLATE_IDS} from "@/query/notification";
|
||||
|
||||
const toParamValue = (value: unknown) => value == null ? "" : String(value);
|
||||
|
||||
const buildPerformanceSmsParams = (performance: PerformanceFull): Record<string, string> => ({
|
||||
businessType: toParamValue(performance.businessType),
|
||||
performanceGenre: toParamValue(performance.performanceGenre),
|
||||
performanceArea: toParamValue(performance.performanceArea),
|
||||
artistName: toParamValue(performance.artistName),
|
||||
performanceName: toParamValue(performance.performanceName),
|
||||
performanceStartMonth: toParamValue(performance.performanceStartMonth),
|
||||
performanceDtInfo: toParamValue(performance.performanceDtInfo),
|
||||
performanceTimeInfo: toParamValue(performance.performanceTimeInfo),
|
||||
ticketReservationStatus: toParamValue(performance.ticketReservationStatus),
|
||||
ticketReservationMemo: toParamValue(performance.ticketReservationMemo),
|
||||
performanceMemo: toParamValue(performance.performanceMemo),
|
||||
...Object.fromEntries(
|
||||
Object.entries(performance.performanceDetail ?? {}).map(([key, value]) => [key, toParamValue(value)])
|
||||
),
|
||||
...Object.fromEntries(
|
||||
Object.entries(performance.performanceMonitoringSchedule ?? {}).map(([key, value]) => [key, toParamValue(value)])
|
||||
),
|
||||
performanceId: toParamValue(performance.id),
|
||||
});
|
||||
import {buildPerformanceSmsParams} from "@/lib/gwcf/notification";
|
||||
|
||||
const AssignPage = () => {
|
||||
const mounted = useMounted();
|
||||
@@ -66,6 +44,7 @@ const AssignPage = () => {
|
||||
const [selected, setSelected] = useState<PerformanceFull | null>(null);
|
||||
const smsAddParam = useMemo(() => selected ? buildPerformanceSmsParams(selected) : {}, [selected]);
|
||||
|
||||
const [assignSaveTargetIds, setAssignSaveTargetIds] = useState<string[]>([]);
|
||||
const [smsTargetIds, setSmsTargetIds] = useState<string[]>([]);
|
||||
|
||||
const refreshAssignList = () => {
|
||||
@@ -78,6 +57,14 @@ const AssignPage = () => {
|
||||
refreshAssignList();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
hideDialog("assignMonitoringDialog");
|
||||
hideDialog("assignSmsSendDialog");
|
||||
setSelected(null);
|
||||
setAssignSaveTargetIds([]);
|
||||
setSmsTargetIds([]);
|
||||
}, []);
|
||||
|
||||
const assignOpen = isDialogOpen("assignMonitoringDialog");
|
||||
const smsOpen = isDialogOpen("assignSmsSendDialog");
|
||||
const selectedPerformanceId = selected?.id ?? 0;
|
||||
@@ -184,9 +171,10 @@ const AssignPage = () => {
|
||||
{onSuccess: (monitoringAssigns) => applySavedAssignsToSelected(performanceId, monitoringAssigns)}
|
||||
)
|
||||
}
|
||||
onOpenSms={(userIds) => {
|
||||
onOpenSms={(assignUserIds, smsUserIds) => {
|
||||
suppressAssignCloseRef.current = true;
|
||||
setSmsTargetIds(userIds);
|
||||
setAssignSaveTargetIds(assignUserIds);
|
||||
setSmsTargetIds(smsUserIds);
|
||||
showDialog("assignSmsSendDialog", false);
|
||||
}}
|
||||
/>
|
||||
@@ -211,6 +199,15 @@ const AssignPage = () => {
|
||||
newMessageTemplateIdx={SMS_TEMPLATE_IDS.CUSTOM}
|
||||
selectedUsers={smsTargetUsers}
|
||||
addParams={smsAddParam}
|
||||
isBeforeSendPending={saveAssignMutation.isPending}
|
||||
onBeforeDefaultTemplateSend={async () => {
|
||||
if (!selected) throw new Error("공연 정보가 없습니다.");
|
||||
const monitoringAssigns = await saveAssignMutation.mutateAsync({
|
||||
performanceId: selected.id,
|
||||
userIds: assignSaveTargetIds,
|
||||
});
|
||||
applySavedAssignsToSelected(selected.id, monitoringAssigns);
|
||||
}}
|
||||
onSent={refreshAssignList}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import {useMemo, useState} from "react";
|
||||
import {useEffect, useMemo, useState} from "react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {FilterSelect} from "@/components/gwcf/FilterSelect";
|
||||
import {MonitoringVisitDialog} from "@/components/dialog/MonitoringVisitDialog";
|
||||
import {PerformanceDetailDialog} from "@/components/dialog/PerformanceDetailDialog";
|
||||
import {MonitoringPerformanceDetailDialog} from "@/components/dialog/MonitoringPerformanceDetailDialog";
|
||||
import {DataTable} from "@/components/data-table/DataTable";
|
||||
import {DataTableColumn} from "@/components/data-table/DataTable.type";
|
||||
import {usePerformanceDetailQuery, usePerformanceListQuery} from "@/query/performance";
|
||||
@@ -15,8 +15,54 @@ import {useAuth} from "@/hooks/useAuth";
|
||||
import {useDialog} from "@/hooks/useDialog";
|
||||
import {useMounted} from "@/hooks/useMounted";
|
||||
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
|
||||
import {toLocalDateString} from "@/lib/gwcf/date";
|
||||
import {
|
||||
getMonitoringDisplayRow,
|
||||
} from "@/lib/gwcf/performance-status";
|
||||
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
const today = toLocalDateString();
|
||||
const todayTime = new Date(`${today}T00:00:00`).getTime();
|
||||
|
||||
const toDateTime = (date?: string) => {
|
||||
if (!date) return Number.POSITIVE_INFINITY;
|
||||
const time = new Date(`${date}T00:00:00`).getTime();
|
||||
return Number.isNaN(time) ? Number.POSITIVE_INFINITY : time;
|
||||
};
|
||||
|
||||
const compareMonitoringSchedule = (a: PerformanceFull, b: PerformanceFull) => {
|
||||
const aTime = toDateTime(a.performanceMonitoringSchedule?.monitoringDate);
|
||||
const bTime = toDateTime(b.performanceMonitoringSchedule?.monitoringDate);
|
||||
const aDistance = Math.abs(aTime - todayTime);
|
||||
const bDistance = Math.abs(bTime - todayTime);
|
||||
|
||||
if (aDistance !== bDistance) return aDistance - bDistance;
|
||||
|
||||
const aFuture = aTime >= todayTime;
|
||||
const bFuture = bTime >= todayTime;
|
||||
if (aFuture !== bFuture) return aFuture ? -1 : 1;
|
||||
|
||||
return a.performanceName.localeCompare(b.performanceName, "ko");
|
||||
};
|
||||
|
||||
const getGpsErrorMessage = (error: unknown) => {
|
||||
if (error && typeof error === "object" && "code" in error) {
|
||||
const code = Number((error as GeolocationPositionError).code);
|
||||
if (code === 1) return "GPS 권한이 거부되었습니다. 브라우저 위치 권한을 허용해 주세요.";
|
||||
if (code === 2) return "현재 위치를 확인할 수 없습니다. GPS 상태를 확인해 주세요.";
|
||||
if (code === 3) return "GPS 위치 확인 시간이 초과되었습니다. 다시 시도해 주세요.";
|
||||
}
|
||||
|
||||
return error instanceof Error ? error.message : "GPS 정보를 확인할 수 없습니다.";
|
||||
};
|
||||
|
||||
const emptyGps = (): MonitoringGpsRequest => ({
|
||||
gpsLatitude: null,
|
||||
gpsLongitude: null,
|
||||
gpsAccuracyM: null,
|
||||
gpsRaw: {
|
||||
unavailable: true,
|
||||
},
|
||||
});
|
||||
|
||||
const MonitoringPage = () => {
|
||||
const mounted = useMounted();
|
||||
@@ -35,23 +81,29 @@ const MonitoringPage = () => {
|
||||
void refetchPerformanceList();
|
||||
};
|
||||
|
||||
|
||||
const assignedItems = useMemo(() => {
|
||||
if (!userId) return [];
|
||||
return data.filter((item) => item.performanceAssignList?.some((assign) => assign.assignUser === userId));
|
||||
return data.filter((item) =>
|
||||
item.performanceAssignList?.some((assign) => assign.assignUser === userId && assign.assignConfirm)
|
||||
);
|
||||
}, [data, userId]);
|
||||
|
||||
const todayItems = useMemo(() => {
|
||||
const matched = assignedItems
|
||||
.filter((item) => item.performanceMonitoringSchedule?.monitoringDate === today)
|
||||
.sort((a, b) => a.performanceName.localeCompare(b.performanceName, "ko"));
|
||||
|
||||
return matched.length > 0 ? matched : assignedItems;
|
||||
const sortedItems = useMemo(() => {
|
||||
return [...assignedItems].sort(compareMonitoringSchedule);
|
||||
}, [assignedItems]);
|
||||
|
||||
const selected = useMemo(() => {
|
||||
return todayItems.find((item) => item.id === selectedId) ?? todayItems[0] ?? null;
|
||||
}, [selectedId, todayItems]);
|
||||
return sortedItems.find((item) => item.id === selectedId) ?? sortedItems[0] ?? null;
|
||||
}, [selectedId, sortedItems]);
|
||||
|
||||
const selectedMonitoringRow = useMemo(() => {
|
||||
if (!selected || !userId) return undefined;
|
||||
return ([0, 1] as const)
|
||||
.map((index) => getMonitoringDisplayRow(selected, index))
|
||||
.find((row) => row.userId === userId);
|
||||
}, [selected, userId]);
|
||||
const hasDeparture = Boolean(selectedMonitoringRow?.slot.timeline.departure || selectedMonitoringRow?.slot.visit?.length);
|
||||
const hasArrival = Boolean(selectedMonitoringRow?.slot.timeline.arrival);
|
||||
|
||||
const columns = useMemo<DataTableColumn<PerformanceFull>[]>(() => [
|
||||
{
|
||||
@@ -112,17 +164,47 @@ const MonitoringPage = () => {
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!mounted || !navigator.geolocation) return;
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
() => undefined,
|
||||
() => undefined,
|
||||
{enableHighAccuracy: true, timeout: 10000, maximumAge: 0}
|
||||
);
|
||||
}, [mounted]);
|
||||
|
||||
const saveVisit = async (files?: File[]) => {
|
||||
if (!selected) return;
|
||||
|
||||
const gps = await getGps();
|
||||
if (visitMode === "departure") {
|
||||
await departureMutation.mutateAsync({performanceId: selected.id, gps});
|
||||
} else {
|
||||
await arrivalMutation.mutateAsync({performanceId: selected.id, gps, files});
|
||||
if (visitMode === "arrival" && (!files || files.length === 0)) {
|
||||
alert("도착 저장 시 증빙사진을 선택해 주세요.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const gps = await getGps().catch((error) => {
|
||||
const fallback = emptyGps();
|
||||
return {
|
||||
...fallback,
|
||||
gpsRaw: {
|
||||
...fallback.gpsRaw,
|
||||
errorMessage: getGpsErrorMessage(error),
|
||||
},
|
||||
};
|
||||
});
|
||||
if (visitMode === "departure") {
|
||||
await departureMutation.mutateAsync({performanceId: selected.id, gps});
|
||||
alert("출발 정보가 저장되었습니다.");
|
||||
} else {
|
||||
await arrivalMutation.mutateAsync({performanceId: selected.id, gps, files});
|
||||
alert("도착 정보가 저장되었습니다.");
|
||||
}
|
||||
hideDialog("monitoringVisitDialog");
|
||||
refreshMonitoringList();
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : "저장 중 오류가 발생했습니다.";
|
||||
alert(message);
|
||||
}
|
||||
hideDialog("monitoringVisitDialog");
|
||||
refreshMonitoringList();
|
||||
};
|
||||
|
||||
if(!mounted) return <LoadingOverlay force={true} />
|
||||
@@ -136,7 +218,7 @@ const MonitoringPage = () => {
|
||||
setSelectedId(Number(value));
|
||||
refreshMonitoringList();
|
||||
}}
|
||||
options={todayItems.map((item) => ({
|
||||
options={sortedItems.map((item) => ({
|
||||
codeGroup: "performance",
|
||||
codeValue: item.id,
|
||||
codeGroupLabel: "사업",
|
||||
@@ -164,16 +246,21 @@ const MonitoringPage = () => {
|
||||
</section>
|
||||
)}
|
||||
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<Button type="button" disabled={!selected} onClick={() => openVisit("departure")}>출발</Button>
|
||||
<Button type="button" disabled={!selected} variant="outline" onClick={() => openVisit("arrival")}>도착</Button>
|
||||
</div>
|
||||
{selected && (
|
||||
<div>
|
||||
{!hasDeparture ? (
|
||||
<Button type="button" className="w-full" onClick={() => openVisit("departure")}>출발</Button>
|
||||
) : (
|
||||
<Button type="button" className="w-full" disabled={hasArrival} onClick={() => openVisit("arrival")}>도착</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<section className="space-y-2 overflow-x-auto">
|
||||
<div className="text-sm font-semibold text-muted-foreground">오늘의 모니터링 목록</div>
|
||||
<div className="text-sm font-semibold text-muted-foreground">모니터링 목록</div>
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={todayItems}
|
||||
data={sortedItems}
|
||||
getRowId={(row) => String(row.id)}
|
||||
selectMode="click-event"
|
||||
onRowClick={(item) => {
|
||||
@@ -205,7 +292,7 @@ const MonitoringPage = () => {
|
||||
isSubmitting={departureMutation.isPending || arrivalMutation.isPending}
|
||||
/>
|
||||
|
||||
<PerformanceDetailDialog
|
||||
<MonitoringPerformanceDetailDialog
|
||||
open={detailOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (open) {
|
||||
@@ -218,7 +305,7 @@ const MonitoringPage = () => {
|
||||
}}
|
||||
performance={detailData ?? selected}
|
||||
codes={codes}
|
||||
canEdit={false}
|
||||
userId={userId}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
"use client";
|
||||
|
||||
import {useMemo, useRef, useState} from "react";
|
||||
import {useCallback, useMemo, useRef, useState} from "react";
|
||||
import {Search, Upload} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Input} from "@/components/ui/input";
|
||||
@@ -22,29 +22,34 @@ import {
|
||||
useUploadPerformanceExcelMutation,
|
||||
} from "@/query/performance";
|
||||
import {useUploadWrittenAssignExcelMutation} from "@/query/assign";
|
||||
import {useDownloadReviewPdfMutation} from "@/query/review";
|
||||
import {useDownloadEvidenceZipMutation} from "@/query/monitoring";
|
||||
import {useDownloadReviewOriginalMutation, useDownloadReviewPdfMutation} from "@/query/review";
|
||||
import {filterPerformance, getCodeLabel, isInternalRole, isWrittenReviewerRole} from "@/lib/gwcf/view";
|
||||
import {
|
||||
getMonitoringDisplayRow,
|
||||
getMonitoringDisplayStatus,
|
||||
getMonitoringFilterValue as getMonitoringStatusFilterValue,
|
||||
getMonitoringRecordedAt,
|
||||
getMonitoringRecordedUser,
|
||||
getMonitoringSlots,
|
||||
getMonitoringStatusDisplay,
|
||||
getReviewByType,
|
||||
getReviewFilterValue as getReviewStatusFilterValue,
|
||||
getReviewStatusDisplay,
|
||||
getWrittenReviewRows,
|
||||
getWrittenReviewerSimpleMonitoringStatusDisplay,
|
||||
getWrittenReviewerSimpleReviewStatusDisplay,
|
||||
isReviewComplete,
|
||||
LOCAL_GOVERNMENT_REVIEW_TYPE,
|
||||
statusFilterOptions, getCompleteRecordedAt, getReviewRecordedAt,
|
||||
} from "@/lib/gwcf/performance-status";
|
||||
import {buildWrittenReviewLink} from "@/config/gwcf.config";
|
||||
import {useAuth} from "@/hooks/useAuth";
|
||||
import {Code, PerformanceFull, PerformanceReview} from "@/types/gwcf";
|
||||
import {useDialog} from "@/hooks/useDialog";
|
||||
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
|
||||
import {useMounted} from "@/hooks/useMounted";
|
||||
import {downloadFile} from "@/lib/utils";
|
||||
import {
|
||||
downloadBlob,
|
||||
downloadExcelBuffer, getReviewOriginalDownloadName,
|
||||
getReviewPdfDownloadName,
|
||||
openWrittenReviewWindow,
|
||||
} from "@/lib/gwcf/file";
|
||||
|
||||
type PerformanceFilters = {
|
||||
businessType: string[];
|
||||
@@ -67,43 +72,11 @@ const monthOptions: Code[] = Array.from({length: 12}, (_, index) => ({
|
||||
memo: "",
|
||||
}));
|
||||
|
||||
const STATUS_FILTER = {
|
||||
UNASSIGNED: "-1001",
|
||||
INCOMPLETE: "-1002",
|
||||
PENDING: "-1003",
|
||||
IN_PROGRESS: "-1004",
|
||||
DEPARTED: "-1005",
|
||||
ARRIVED: "-1006",
|
||||
DONE: "-1007",
|
||||
} as const;
|
||||
|
||||
const makeStatusOption = (value: string, label: string): Code => ({
|
||||
codeGroup: "status_filter",
|
||||
codeValue: Number(value),
|
||||
codeGroupLabel: "상태",
|
||||
codeLabel: label,
|
||||
memo: "",
|
||||
});
|
||||
|
||||
const normalizeStatusLabel = (label?: string) => label?.replace(/\s/g, "") ?? "";
|
||||
const labelHasComplete = (label?: string) => normalizeStatusLabel(label).includes("완료");
|
||||
const labelHasInProgress = (label?: string) => normalizeStatusLabel(label).includes("진행");
|
||||
const labelHasDeparted = (label?: string) => normalizeStatusLabel(label).includes("출발");
|
||||
const labelHasArrived = (label?: string) => normalizeStatusLabel(label).includes("도착");
|
||||
|
||||
const statusFilterOptions = {
|
||||
incomplete: makeStatusOption(STATUS_FILTER.INCOMPLETE, "미완료"),
|
||||
pending: makeStatusOption(STATUS_FILTER.PENDING, "미진행"),
|
||||
inProgress: makeStatusOption(STATUS_FILTER.IN_PROGRESS, "진행중"),
|
||||
departed: makeStatusOption(STATUS_FILTER.DEPARTED, "출발"),
|
||||
arrived: makeStatusOption(STATUS_FILTER.ARRIVED, "도착"),
|
||||
done: makeStatusOption(STATUS_FILTER.DONE, "완료"),
|
||||
};
|
||||
|
||||
const PerformancePage = () => {
|
||||
const mounted = useMounted();
|
||||
const {auth} = useAuth();
|
||||
const userRole = auth.user?.userRole;
|
||||
const userId = auth.user?.userId;
|
||||
const canEdit = isInternalRole(userRole);
|
||||
const isWrittenReviewer = isWrittenReviewerRole(userRole);
|
||||
const {isDialogOpen, showDialog, hideDialog} = useDialog();
|
||||
@@ -116,7 +89,7 @@ const PerformancePage = () => {
|
||||
const performanceTemplateMutation = useDownloadPerformanceExcelTemplateMutation();
|
||||
const writtenAssignTemplateMutation = useDownloadAssignExcelTemplateMutation();
|
||||
const reviewPdfMutation = useDownloadReviewPdfMutation();
|
||||
const evidenceZipMutation = useDownloadEvidenceZipMutation();
|
||||
const reviewOriginalMutation = useDownloadReviewOriginalMutation();
|
||||
|
||||
const [filters, setFilters] = useState<PerformanceFilters>({
|
||||
businessType: [],
|
||||
@@ -178,36 +151,6 @@ const PerformancePage = () => {
|
||||
};
|
||||
const matchesStatus = (filter: string[], value: string) => filter.length === 0 || filter.includes(value);
|
||||
|
||||
const getReviewFilterValue = (review?: PerformanceReview, allowInProgress = false, alwaysAssigned = false) => {
|
||||
const label = getCodeLabel(codes, "review_status", review?.reviewStatus);
|
||||
|
||||
if (isWrittenReviewer) {
|
||||
if (isReviewComplete(review) || labelHasComplete(label)) return STATUS_FILTER.DONE;
|
||||
return STATUS_FILTER.INCOMPLETE;
|
||||
}
|
||||
|
||||
if (!alwaysAssigned && !review) return STATUS_FILTER.UNASSIGNED;
|
||||
if (isReviewComplete(review) || labelHasComplete(label)) return STATUS_FILTER.DONE;
|
||||
if (allowInProgress && labelHasInProgress(label)) return STATUS_FILTER.IN_PROGRESS;
|
||||
return STATUS_FILTER.PENDING;
|
||||
};
|
||||
|
||||
const getMonitoringFilterValue = (performance: PerformanceFull, index: 0 | 1) => {
|
||||
const slot = getMonitoringSlots(performance)[index];
|
||||
const label = getCodeLabel(codes, "monitoring_visit_status", slot.visit?.monitoringVisitStatus);
|
||||
|
||||
if (isWrittenReviewer) {
|
||||
return slot.visit ? STATUS_FILTER.DONE : STATUS_FILTER.INCOMPLETE;
|
||||
}
|
||||
|
||||
if (!slot.assign) return STATUS_FILTER.UNASSIGNED;
|
||||
if (!slot.visit) return STATUS_FILTER.PENDING;
|
||||
if (labelHasComplete(label)) return STATUS_FILTER.DONE;
|
||||
if (labelHasDeparted(label)) return STATUS_FILTER.DEPARTED;
|
||||
if (labelHasArrived(label)) return STATUS_FILTER.ARRIVED;
|
||||
return STATUS_FILTER.PENDING;
|
||||
};
|
||||
|
||||
const localReviewStatusOptions = isWrittenReviewer
|
||||
? [statusFilterOptions.incomplete, statusFilterOptions.done]
|
||||
: [statusFilterOptions.pending, statusFilterOptions.done];
|
||||
@@ -218,10 +161,22 @@ const PerformancePage = () => {
|
||||
? [statusFilterOptions.incomplete, statusFilterOptions.done]
|
||||
: [statusFilterOptions.pending, statusFilterOptions.inProgress, statusFilterOptions.done];
|
||||
|
||||
const getVisibleWrittenReviewRow = useCallback((performance: PerformanceFull) => {
|
||||
const rows = getWrittenReviewRows(performance);
|
||||
if (!isWrittenReviewer) return rows[0];
|
||||
return rows.find((row) => row.userId === userId && row.assign);
|
||||
}, [isWrittenReviewer, userId]);
|
||||
|
||||
const filteredData = useMemo(() => {
|
||||
return data.filter((item) => {
|
||||
if (isWrittenReviewer && !getVisibleWrittenReviewRow(item)) return false;
|
||||
|
||||
const localReview = getReviewByType(item, LOCAL_GOVERNMENT_REVIEW_TYPE)?.review;
|
||||
const writtenReviewRow = getWrittenReviewRows(item)[0];
|
||||
const writtenReviewRow = getVisibleWrittenReviewRow(item);
|
||||
const monitoring1Row = getMonitoringDisplayRow(item, 0);
|
||||
const monitoring1LatestVisit = monitoring1Row.slot.visit?.[0];
|
||||
const monitoring2Row = getMonitoringDisplayRow(item, 1);
|
||||
const monitoring2LatestVisit = monitoring2Row.slot.visit?.[0];
|
||||
|
||||
return (
|
||||
filterPerformance(item, {
|
||||
@@ -232,13 +187,31 @@ const PerformancePage = () => {
|
||||
keyword: filters.keyword,
|
||||
}) &&
|
||||
matchesStatus(filters.startMonth, String(item.performanceStartMonth)) &&
|
||||
matchesStatus(filters.localReviewStatus, getReviewFilterValue(localReview, false, true)) &&
|
||||
matchesStatus(filters.monitoring1Status, getMonitoringFilterValue(item, 0)) &&
|
||||
matchesStatus(filters.monitoring2Status, getMonitoringFilterValue(item, 1)) &&
|
||||
matchesStatus(filters.writtenReviewStatus, getReviewFilterValue(writtenReviewRow?.review, true, Boolean(writtenReviewRow?.assign)))
|
||||
matchesStatus(filters.localReviewStatus, getReviewStatusFilterValue(
|
||||
localReview,
|
||||
getCodeLabel(codes, "review_status", localReview?.reviewStatus),
|
||||
{isWrittenReviewer, alwaysAssigned: true}
|
||||
)) &&
|
||||
matchesStatus(filters.monitoring1Status, getMonitoringStatusFilterValue(
|
||||
monitoring1Row,
|
||||
getCodeLabel(codes, "monitoring_visit_status", monitoring1LatestVisit?.monitoringVisitStatus),
|
||||
getCodeLabel(codes, "review_status", monitoring1Row.review?.reviewStatus),
|
||||
isWrittenReviewer
|
||||
)) &&
|
||||
matchesStatus(filters.monitoring2Status, getMonitoringStatusFilterValue(
|
||||
monitoring2Row,
|
||||
getCodeLabel(codes, "monitoring_visit_status", monitoring2LatestVisit?.monitoringVisitStatus),
|
||||
getCodeLabel(codes, "review_status", monitoring2Row.review?.reviewStatus),
|
||||
isWrittenReviewer
|
||||
)) &&
|
||||
matchesStatus(filters.writtenReviewStatus, getReviewStatusFilterValue(
|
||||
writtenReviewRow?.review,
|
||||
getCodeLabel(codes, "review_status", writtenReviewRow?.review?.reviewStatus),
|
||||
{isWrittenReviewer, allowInProgress: true, assigned: Boolean(writtenReviewRow?.assign)}
|
||||
))
|
||||
);
|
||||
});
|
||||
}, [codes, data, filters, isWrittenReviewer]);
|
||||
}, [codes, data, filters, getVisibleWrittenReviewRow, isWrittenReviewer]);
|
||||
|
||||
const openDetail = (performance: PerformanceFull) => {
|
||||
if (isWrittenReviewer) return;
|
||||
@@ -247,25 +220,22 @@ const PerformancePage = () => {
|
||||
showDialog("performanceDetailDialog");
|
||||
};
|
||||
|
||||
const downloadBlob = (buffer: ArrayBuffer, fileName: string, type = "application/octet-stream") => {
|
||||
downloadFile(new Blob([buffer], {type}), fileName);
|
||||
};
|
||||
|
||||
const downloadReviewPdf = async (performanceId: number, review?: PerformanceReview) => {
|
||||
if (!review || !isReviewComplete(review)) return;
|
||||
const buffer = await reviewPdfMutation.mutateAsync({performanceId, reviewType: review.reviewType});
|
||||
downloadBlob(buffer, review.pdfFileName || `review-${performanceId}-${review.reviewType}.pdf`, "application/pdf");
|
||||
if (!review.regUser) return;
|
||||
const buffer = await reviewPdfMutation.mutateAsync({performanceId, reviewType: review.reviewType, userId: review.regUser});
|
||||
downloadBlob(buffer, getReviewPdfDownloadName(performanceId, review.reviewType, review.pdfFileName), "application/pdf");
|
||||
};
|
||||
|
||||
const downloadEvidenceZip = async (performanceId: number, userId?: string) => {
|
||||
if (!userId) return;
|
||||
const buffer = await evidenceZipMutation.mutateAsync({performanceId, userId});
|
||||
downloadBlob(buffer, `monitoring-evidence-${performanceId}-${userId}.zip`, "application/zip");
|
||||
const downloadReviewOriginal = async (performanceId: number, review?: PerformanceReview) => {
|
||||
if (!review || !isReviewComplete(review)) return;
|
||||
if (!review.regUser) return;
|
||||
const buffer = await reviewOriginalMutation.mutateAsync({performanceId, reviewType: review.reviewType, userId: review.regUser});
|
||||
downloadBlob(buffer, getReviewOriginalDownloadName(performanceId, review.reviewType, review.uploadFileName));
|
||||
};
|
||||
|
||||
const openWrittenReviewLink = (performanceId: number, userId?: string, complete = false) => {
|
||||
if (!userId) return;
|
||||
window.open(buildWrittenReviewLink({performanceId, userId, complete}), "_blank", "noopener,noreferrer");
|
||||
openWrittenReviewWindow(performanceId, userId, complete);
|
||||
};
|
||||
|
||||
const renderReviewStatus = ({
|
||||
@@ -289,7 +259,7 @@ const PerformancePage = () => {
|
||||
: getReviewStatusDisplay(label, review, alwaysAssigned || Boolean(review));
|
||||
const complete = isReviewComplete(review);
|
||||
const onClick = !useWrittenLink && isReviewComplete(review)
|
||||
? () => downloadReviewPdf(performance.id, review)
|
||||
? () => downloadReviewOriginal(performance.id, review)
|
||||
: useWrittenLink
|
||||
? () => openWrittenReviewLink(performance.id, userId, complete)
|
||||
: undefined;
|
||||
@@ -302,7 +272,7 @@ const PerformancePage = () => {
|
||||
tooltip={useWrittenLink || noTooltip ? undefined : (
|
||||
<div className="space-y-1">
|
||||
<div>사용자: {userId || "-"}</div>
|
||||
<div>기록일시: -</div>
|
||||
<div>기록일시: {getReviewRecordedAt(review)}</div>
|
||||
</div>
|
||||
)}
|
||||
>
|
||||
@@ -313,21 +283,28 @@ const PerformancePage = () => {
|
||||
};
|
||||
|
||||
const renderMonitoringStatus = (performance: PerformanceFull, index: 0 | 1) => {
|
||||
const slot = getMonitoringSlots(performance)[index];
|
||||
const label = getCodeLabel(codes, "monitoring_visit_status", slot.visit?.monitoringVisitStatus);
|
||||
const display = isWrittenReviewer
|
||||
? getWrittenReviewerSimpleMonitoringStatusDisplay(slot)
|
||||
: getMonitoringStatusDisplay(label, slot);
|
||||
const row = getMonitoringDisplayRow(performance, index);
|
||||
const latestVisit = row.slot.visit?.[0];
|
||||
const display = getMonitoringDisplayStatus(
|
||||
row,
|
||||
getCodeLabel(codes, "monitoring_visit_status", latestVisit?.monitoringVisitStatus),
|
||||
getCodeLabel(codes, "review_status", row.review?.reviewStatus),
|
||||
isWrittenReviewer
|
||||
);
|
||||
const assignUser = row.slot.assign?.assignUser ?? "";
|
||||
const visitUser = getMonitoringRecordedUser(latestVisit);
|
||||
|
||||
return (
|
||||
<div className="flex min-w-24 justify-center text-xs">
|
||||
<StatusPill
|
||||
variant={display.variant}
|
||||
onClick={!isWrittenReviewer && slot.visit ? () => downloadEvidenceZip(performance.id, slot.assign?.assignUser) : undefined}
|
||||
onClick={isReviewComplete(row.review) ? () => downloadReviewOriginal(performance.id, row.review) : undefined}
|
||||
tooltip={isWrittenReviewer ? undefined : (
|
||||
<div className="space-y-1">
|
||||
<div>사용자: {getMonitoringRecordedUser(slot.visit)}</div>
|
||||
<div>기록일시: {getMonitoringRecordedAt(slot.visit)}</div>
|
||||
<div>사용자: {visitUser === "-" ? assignUser : visitUser}</div>
|
||||
<div>출발: {getMonitoringRecordedAt(row.slot.timeline.departure)}</div>
|
||||
<div>도착: {getMonitoringRecordedAt(row.slot.timeline.arrival)}</div>
|
||||
<div>완료: {getCompleteRecordedAt(row.review)}</div>
|
||||
</div>
|
||||
)}
|
||||
>
|
||||
@@ -342,7 +319,7 @@ const PerformancePage = () => {
|
||||
{id: "businessType", header: "사업 유형", cell: ({row}) => getCodeLabel(codes, "business_type", row.original.businessType)},
|
||||
{id: "genre", header: "분야(장르)", cell: ({row}) => getCodeLabel(codes, "genre", row.original.performanceGenre)},
|
||||
{id: "area", header: "지역", cell: ({row}) => getCodeLabel(codes, "area", row.original.performanceArea)},
|
||||
{accessorKey: "artistName", header: "단체(팀)명", enableSorting: true},
|
||||
{accessorKey: "artistName", header: "단체(인)명", enableSorting: true},
|
||||
{accessorKey: "performanceName", header: "사업명", enableSorting: true},
|
||||
{id: "startMonth", header: "사업 수행 월", cell: ({row}) => `${row.original.performanceStartMonth}월`, enableSorting: true},
|
||||
{accessorKey: "performanceDtInfo", header: "사업 일정"},
|
||||
@@ -373,7 +350,7 @@ const PerformancePage = () => {
|
||||
id: "writtenReview",
|
||||
header: "서면 평가",
|
||||
cell: ({row}) => {
|
||||
const found = getWrittenReviewRows(row.original)[0];
|
||||
const found = getVisibleWrittenReviewRow(row.original);
|
||||
return renderReviewStatus({
|
||||
performance: row.original,
|
||||
review: found?.review,
|
||||
@@ -383,18 +360,16 @@ const PerformancePage = () => {
|
||||
});
|
||||
},
|
||||
},
|
||||
], [codes, isWrittenReviewer]);
|
||||
], [codes, getVisibleWrittenReviewRow, isWrittenReviewer]);
|
||||
|
||||
const downloadPerformanceTemplate = async () => {
|
||||
const buffer = await performanceTemplateMutation.mutateAsync();
|
||||
const blob = new Blob([buffer], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
|
||||
downloadFile(blob, "사업 등록 template.xlsx");
|
||||
downloadExcelBuffer(buffer, "사업 등록 template.xlsx");
|
||||
};
|
||||
|
||||
const downloadWrittenAssignTemplate = async () => {
|
||||
const buffer = await writtenAssignTemplateMutation.mutateAsync();
|
||||
const blob = new Blob([buffer], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
|
||||
downloadFile(blob, "서면 평가 배정 template.xlsx");
|
||||
downloadExcelBuffer(buffer, "서면 평가 배정 template.xlsx");
|
||||
};
|
||||
|
||||
if(!mounted) return <LoadingOverlay force={true} />
|
||||
@@ -455,7 +430,6 @@ const PerformancePage = () => {
|
||||
performance={detailData ?? data.find((item) => item.id === selectedId) ?? null}
|
||||
codes={codes}
|
||||
canEdit={canEdit}
|
||||
isWrittenReviewer={false}
|
||||
onSave={(draft) => updateMutation.mutate(draft)}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -26,7 +26,7 @@ import {SMS_TEMPLATE_IDS} from "@/query/notification";
|
||||
import {useDialog} from "@/hooks/useDialog";
|
||||
import {useMounted} from "@/hooks/useMounted";
|
||||
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
|
||||
import {downloadFile} from "@/lib/utils";
|
||||
import {downloadExcelBuffer} from "@/lib/gwcf/file";
|
||||
|
||||
type UserTab = "monitoring" | "written";
|
||||
type UserFilters = {area: string[]; gender: string[]; genre: string[]; keyword: string};
|
||||
@@ -128,8 +128,7 @@ const UserPage = () => {
|
||||
|
||||
const downloadTemplate = async () => {
|
||||
const buffer = await templateMutation.mutateAsync();
|
||||
const blob = new Blob([buffer], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
|
||||
downloadFile(blob, tab === "monitoring" ? "모니터링 요원 template.xlsx" : "서면 평가위원 template.xlsx");
|
||||
downloadExcelBuffer(buffer, tab === "monitoring" ? "모니터링 요원 template.xlsx" : "서면 평가위원 template.xlsx");
|
||||
};
|
||||
|
||||
const renderEditableCell = (user: UserFull, key: string, fallbackKeys: string[], type: "text" | "select" = "text", options: Code[] = []) => {
|
||||
|
||||
67
src/app/(pages)/file-preview/page.tsx
Normal file
67
src/app/(pages)/file-preview/page.tsx
Normal file
@@ -0,0 +1,67 @@
|
||||
type FilePreviewPageProps = {
|
||||
searchParams: Promise<{
|
||||
src?: string;
|
||||
title?: string;
|
||||
type?: "pdf" | "image";
|
||||
images?: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
const parseImages = (images?: string) => {
|
||||
if (!images) return [];
|
||||
try {
|
||||
const parsed = JSON.parse(images);
|
||||
return Array.isArray(parsed) ? parsed.filter((item): item is string => typeof item === "string") : [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
const isAllowedSrc = (src: string) => src.startsWith("/api/review/pdf/") || src.startsWith("/api/file/");
|
||||
|
||||
export default async function FilePreviewPage({ searchParams }: FilePreviewPageProps) {
|
||||
const params = await searchParams;
|
||||
const title = params.title ?? "파일 미리보기";
|
||||
const images = parseImages(params.images);
|
||||
const src = params.src ?? "";
|
||||
const type = params.type ?? (images.length > 0 ? "image" : "pdf");
|
||||
|
||||
return (
|
||||
<main className="flex min-h-screen flex-col bg-background text-foreground">
|
||||
<header className="flex h-14 shrink-0 items-center justify-between border-b border-border bg-card px-4">
|
||||
<h1 className="truncate text-base font-medium text-foreground">{title}</h1>
|
||||
</header>
|
||||
|
||||
{type === "image" ? (
|
||||
<div className="grid flex-1 gap-4 overflow-auto p-4 md:grid-cols-2">
|
||||
{images.filter(isAllowedSrc).map((imageSrc, index) => (
|
||||
<figure
|
||||
key={`${imageSrc}-${index}`}
|
||||
className="rounded-lg border border-border bg-card p-3 shadow-sm"
|
||||
>
|
||||
<img
|
||||
src={imageSrc}
|
||||
alt={`${title} ${index + 1}`}
|
||||
className="mx-auto max-h-[80vh] rounded border border-border bg-white object-contain"
|
||||
/>
|
||||
<figcaption className="mt-2 truncate text-xs text-muted-foreground">
|
||||
{decodeURIComponent(imageSrc.split("/").pop() ?? "")}
|
||||
</figcaption>
|
||||
</figure>
|
||||
))}
|
||||
{images.length === 0 && (
|
||||
<div className="col-span-full flex min-h-80 items-center justify-center text-sm text-muted-foreground">
|
||||
미리보기할 이미지가 없습니다.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : isAllowedSrc(src) ? (
|
||||
<iframe src={src} title={title} className="min-h-0 flex-1 bg-white" />
|
||||
) : (
|
||||
<div className="flex flex-1 items-center justify-center text-sm text-muted-foreground">
|
||||
미리보기 경로가 올바르지 않습니다.
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
55
src/app/api/file/[[...slug]]/route.ts
Normal file
55
src/app/api/file/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {errorToResponse} from "@/lib/http-util";
|
||||
import {createBackApi} from "@/lib/server-api";
|
||||
import {serverEnv} from "@/lib/env.server";
|
||||
|
||||
const contentTypeByExt = (fileName: string) => {
|
||||
const ext = fileName.split(".").pop()?.toLowerCase();
|
||||
if (ext === "jpg" || ext === "jpeg") return "image/jpeg";
|
||||
if (ext === "png") return "image/png";
|
||||
if (ext === "gif") return "image/gif";
|
||||
if (ext === "webp") return "image/webp";
|
||||
if (ext === "pdf") return "application/pdf";
|
||||
return "application/octet-stream";
|
||||
};
|
||||
|
||||
export const GET = async (
|
||||
_req: NextRequest,
|
||||
context: RouteContext
|
||||
) => {
|
||||
try {
|
||||
const {slug = []} = await context.params;
|
||||
const [type, first, second, ...rest] = slug;
|
||||
const fileName = rest.join("/");
|
||||
|
||||
if (!type || !first || !second || !fileName || rest.length === 0) {
|
||||
return NextResponse.json({message: "Not found"}, {status: 404});
|
||||
}
|
||||
|
||||
const backApi = await createBackApi();
|
||||
const basePath = type === "visit"
|
||||
? `/visit-file/${encodeURIComponent(first)}/${encodeURIComponent(second)}`
|
||||
: type === "review"
|
||||
? `/review-file/${encodeURIComponent(first)}/${encodeURIComponent(second)}`
|
||||
: "";
|
||||
|
||||
if (!basePath) {
|
||||
return NextResponse.json({message: "Not found"}, {status: 404});
|
||||
}
|
||||
|
||||
const encodedFileName = fileName.split("/").map((part) => encodeURIComponent(part)).join("/");
|
||||
const backOrigin = new URL(serverEnv.API_BACK_SERVER).origin;
|
||||
const result = await backApi.get<ArrayBuffer>(`${backOrigin}${basePath}/${encodedFileName}`, {expectBinary: true});
|
||||
|
||||
return new NextResponse(result, {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": contentTypeByExt(fileName),
|
||||
"Content-Disposition": `inline; filename="${encodeURIComponent(fileName)}"`,
|
||||
},
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
@@ -78,6 +78,16 @@ export const POST = async (
|
||||
return withCors(NextResponse.json(result, { status: 200 }));
|
||||
}
|
||||
|
||||
if (action === "written-review-start" && slug.length === 3) {
|
||||
await backApi.post<void>(`/review/start/${encodeURIComponent(slug[1])}/${encodeURIComponent(slug[3])}`);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
|
||||
if (action === "written-reviewend" && slug.length === 3) {
|
||||
await backApi.post<void>(`/review/end/${encodeURIComponent(slug[1])}/${encodeURIComponent(slug[2])}`);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
|
||||
return withCors(NextResponse.json({ message: "Not found" }, { status: 404 }));
|
||||
|
||||
} catch (error: unknown) {
|
||||
|
||||
@@ -31,7 +31,7 @@ export const GET = async (
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/zip",
|
||||
"Content-Disposition": `attachment; filename="monitoring-evidence-${fourth}-${fifth}.zip"`,
|
||||
"Content-Disposition": `attachment; filename="evidence_${fourth}_${fifth}.zip";`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {cookies} from "next/headers";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {errorToResponse} from "@/lib/http-util";
|
||||
import {createBackApi} from "@/lib/server-api";
|
||||
import {PerformanceReview} from "@/types/gwcf";
|
||||
import {serverEnv} from "@/lib/env.server";
|
||||
import {CookieKeys} from "@/store/cookie/cookie-keys";
|
||||
|
||||
const reviewFileName = (prefix: string, performanceId: string, reviewType: string) =>
|
||||
`${prefix}-${performanceId}-${reviewType}`;
|
||||
@@ -12,14 +15,37 @@ export const GET = async (
|
||||
context: RouteContext
|
||||
) => {
|
||||
try {
|
||||
void req;
|
||||
const {slug = []} = await context.params;
|
||||
const [action, second, third] = slug;
|
||||
const [action, second, third, fourth] = slug;
|
||||
const backApi = await createBackApi();
|
||||
|
||||
if (action === "download" && second && third && slug.length === 3) {
|
||||
if (action === "template" && second === "download" && third && slug.length === 3) {
|
||||
const cookieStore = await cookies();
|
||||
const accessToken = cookieStore.get(CookieKeys.AuthToken)?.value;
|
||||
const response = await fetch(`${serverEnv.API_BACK_SERVER.replace(/\/+$/, "")}/review/template/download/${encodeURIComponent(third)}`, {
|
||||
headers: accessToken ? {authorization: `Bearer ${accessToken}`} : undefined,
|
||||
cache: "no-store",
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return new NextResponse(await response.text().catch(() => ""), {status: response.status});
|
||||
}
|
||||
|
||||
const result = await response.arrayBuffer();
|
||||
const headers = new Headers();
|
||||
headers.set("Content-Type", response.headers.get("content-type") ?? "application/octet-stream");
|
||||
const disposition = response.headers.get("content-disposition");
|
||||
if (disposition) headers.set("Content-Disposition", disposition);
|
||||
|
||||
return new NextResponse(result, {
|
||||
status: 200,
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
if (action === "download" && second && third && fourth && slug.length === 4) {
|
||||
const result = await backApi.get<ArrayBuffer>(
|
||||
`/review/download/${encodeURIComponent(second)}/${encodeURIComponent(third)}`,
|
||||
`/review/download/${encodeURIComponent(second)}/${encodeURIComponent(third)}/${encodeURIComponent(fourth)}`,
|
||||
{ expectBinary: true }
|
||||
);
|
||||
|
||||
@@ -32,24 +58,24 @@ export const GET = async (
|
||||
});
|
||||
}
|
||||
|
||||
if (action === "pdf" && second && third && slug.length === 3) {
|
||||
if (action === "pdf" && second && third && fourth && slug.length === 4) {
|
||||
const result = await backApi.get<ArrayBuffer>(
|
||||
`/review/pdf/${encodeURIComponent(second)}/${encodeURIComponent(third)}`,
|
||||
`/review/pdf/${encodeURIComponent(second)}/${encodeURIComponent(third)}/${encodeURIComponent(fourth)}`,
|
||||
{ expectBinary: true }
|
||||
);
|
||||
|
||||
const disposition = req.nextUrl.searchParams.get("disposition") === "inline" ? "inline" : "attachment";
|
||||
return new NextResponse(result, {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/pdf",
|
||||
"Content-Disposition": `attachment; filename="${reviewFileName("review-pdf", second, third)}.pdf"`,
|
||||
"Content-Disposition": `${disposition}; filename="${reviewFileName("review-pdf", second, third)}.pdf"`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (action && second && slug.length === 2) {
|
||||
if (action && second && third && slug.length === 3) {
|
||||
const result = await backApi.get<PerformanceReview>(
|
||||
`/review/${encodeURIComponent(action)}/${encodeURIComponent(second)}`
|
||||
`/review/${encodeURIComponent(action)}/${encodeURIComponent(second)}/${encodeURIComponent(third)}`
|
||||
);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
@@ -69,8 +95,8 @@ export const POST = async (
|
||||
const [action, second, third] = slug;
|
||||
const backApi = await createBackApi();
|
||||
|
||||
if (action === "start" && second && slug.length === 2) {
|
||||
await backApi.post<void>(`/review/start/${encodeURIComponent(second)}`);
|
||||
if (action === "start" && second && third && slug.length === 3) {
|
||||
await backApi.post<void>(`/review/start/${encodeURIComponent(second)}/${encodeURIComponent(third)}`);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user