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 });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import {useEffect, useMemo, useState} from "react";
|
||||
import {Send} from "lucide-react";
|
||||
import {Save, Send} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Checkbox} from "@/components/ui/checkbox";
|
||||
import {Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle} from "@/components/ui/dialog";
|
||||
@@ -32,7 +32,7 @@ export function AssignMonitoringDialog({
|
||||
applyUsers: MonitoringApplyUser[];
|
||||
isSavingAssign?: boolean;
|
||||
onSaveAssign: (performanceId: number, userIds: string[]) => void;
|
||||
onOpenSms: (userIds: string[]) => void;
|
||||
onOpenSms: (assignUserIds: string[], smsUserIds: string[]) => void;
|
||||
}>) {
|
||||
const monitoringAssigns = useMemo(
|
||||
() => (selected?.performanceAssignList ?? []).filter((item) => item.assignType === MONITORING_ASSIGN_TYPE),
|
||||
@@ -68,7 +68,6 @@ export function AssignMonitoringDialog({
|
||||
|
||||
const next = Array.from(new Set([...checkedIds, applyUser.userId]));
|
||||
setCheckedIds(next);
|
||||
onSaveAssign(selected.id, next);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,7 +79,6 @@ export function AssignMonitoringDialog({
|
||||
|
||||
const next = checkedIds.filter((userId) => userId !== applyUser.userId);
|
||||
setCheckedIds(next);
|
||||
onSaveAssign(selected.id, next);
|
||||
};
|
||||
|
||||
const toggleApplyUser = (applyUser: MonitoringApplyUser) => {
|
||||
@@ -206,7 +204,11 @@ export function AssignMonitoringDialog({
|
||||
</div>
|
||||
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="outline" disabled={smsTargetIds.length === 0} onClick={() => onOpenSms(smsTargetIds)}>
|
||||
<Button type="button" variant="outline" disabled={!selected || isSavingAssign} onClick={() => selected && onSaveAssign(selected.id, checkedIds)}>
|
||||
<Save className="h-4 w-4" />
|
||||
저장
|
||||
</Button>
|
||||
<Button type="button" variant="outline" disabled={smsTargetIds.length === 0 || isSavingAssign} onClick={() => onOpenSms(checkedIds, smsTargetIds)}>
|
||||
<Send className="h-4 w-4" />
|
||||
확정 문자 발송
|
||||
</Button>
|
||||
|
||||
268
src/components/dialog/MonitoringPerformanceDetailDialog.tsx
Normal file
268
src/components/dialog/MonitoringPerformanceDetailDialog.tsx
Normal file
@@ -0,0 +1,268 @@
|
||||
"use client";
|
||||
|
||||
import {ReactNode, useMemo, useRef} from "react";
|
||||
import {Download, ImageIcon, ScanSearch, Upload} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle} from "@/components/ui/dialog";
|
||||
import {StatusPill} from "@/components/gwcf/StatusPill";
|
||||
import {Code, PerformanceFull} from "@/types/gwcf";
|
||||
import {CodeGroup} from "@/query/code";
|
||||
import {getCodeLabel} from "@/lib/gwcf/view";
|
||||
import {
|
||||
getMonitoringDisplayRow,
|
||||
getMonitoringDisplayStatus,
|
||||
getMonitoringRecordedAt,
|
||||
} from "@/lib/gwcf/performance-status";
|
||||
import {
|
||||
useDownloadReviewOriginalMutation,
|
||||
useDownloadReviewPdfMutation,
|
||||
useUploadReviewFileMutation,
|
||||
} from "@/query/review";
|
||||
import {useDownloadEvidenceZipMutation, useMonitoringEvidenceQuery} from "@/query/monitoring";
|
||||
import {useLoading} from "@/hooks/useLoading";
|
||||
import {
|
||||
buildEvidenceImageSrc,
|
||||
buildImagePreviewUrl,
|
||||
buildReviewPdfPreviewUrl,
|
||||
downloadBlob,
|
||||
downloadFromUrl,
|
||||
getEvidenceZipDownloadName,
|
||||
getReviewOriginalDownloadName,
|
||||
getReviewPdfDownloadName,
|
||||
openPreviewWindow,
|
||||
} from "@/lib/gwcf/file";
|
||||
|
||||
type CodeMap = Partial<Record<CodeGroup, Code[]>>;
|
||||
|
||||
function MobileDetailRow({label, children}: {label: string; children: ReactNode}) {
|
||||
return (
|
||||
<div className="space-y-1 border-b px-3 py-2 last:border-b-0">
|
||||
<div className="text-xs font-semibold text-muted-foreground">{label}</div>
|
||||
<div className="break-words text-sm">{children || "-"}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ActionButton({
|
||||
children,
|
||||
icon = "download",
|
||||
disabled = false,
|
||||
onClick,
|
||||
}: Readonly<{
|
||||
children: ReactNode;
|
||||
icon?: "download" | "upload" | "image" | "preview";
|
||||
disabled?: boolean;
|
||||
onClick?: () => void;
|
||||
}>) {
|
||||
const Icon = icon === "upload" ? Upload : icon === "image" ? ImageIcon : icon === "preview" ? ScanSearch : Download;
|
||||
return (
|
||||
<Button type="button" size="sm" variant="outline" disabled={disabled} onClick={onClick} className="min-h-10 flex-1">
|
||||
<Icon className="h-4 w-4" />
|
||||
{children}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
function MonitoringReviewActions({
|
||||
performanceId,
|
||||
reviewType,
|
||||
userId,
|
||||
uploadFileName,
|
||||
pdfFileName,
|
||||
}: Readonly<{
|
||||
performanceId: number;
|
||||
reviewType: number;
|
||||
userId?: string;
|
||||
uploadFileName?: string;
|
||||
pdfFileName?: string;
|
||||
}>) {
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const uploadMutation = useUploadReviewFileMutation();
|
||||
const originalMutation = useDownloadReviewOriginalMutation();
|
||||
const pdfMutation = useDownloadReviewPdfMutation();
|
||||
const {withLoadingAsync} = useLoading();
|
||||
|
||||
const upload = async (file?: File) => {
|
||||
try {
|
||||
if (!file) return;
|
||||
await withLoadingAsync(() => uploadMutation.mutateAsync({performanceId, reviewType, file}));
|
||||
alert("파일 업로드가 완료되었습니다.");
|
||||
} finally {
|
||||
if (fileInputRef.current) fileInputRef.current.value = "";
|
||||
}
|
||||
};
|
||||
|
||||
const downloadOriginal = async () => {
|
||||
if (!userId) return;
|
||||
const buffer = await originalMutation.mutateAsync({performanceId, reviewType, userId});
|
||||
downloadBlob(buffer, getReviewOriginalDownloadName(performanceId, reviewType, uploadFileName));
|
||||
};
|
||||
|
||||
const downloadPdf = async () => {
|
||||
if (!userId) return;
|
||||
const buffer = await pdfMutation.mutateAsync({performanceId, reviewType, userId});
|
||||
downloadBlob(buffer, getReviewPdfDownloadName(performanceId, reviewType, pdfFileName), "application/pdf");
|
||||
};
|
||||
|
||||
const previewPdf = () => {
|
||||
if (!pdfFileName || !userId) return;
|
||||
openPreviewWindow(buildReviewPdfPreviewUrl(performanceId, reviewType, userId, pdfFileName));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<input ref={fileInputRef} type="file" className="hidden" onChange={(event) => void upload(event.target.files?.[0])} />
|
||||
<ActionButton icon="upload" disabled={uploadMutation.isPending} onClick={() => fileInputRef.current?.click()}>파일 업로드</ActionButton>
|
||||
<ActionButton disabled={!userId || !uploadFileName || originalMutation.isPending} onClick={downloadOriginal}>원본</ActionButton>
|
||||
<ActionButton disabled={!userId || !pdfFileName || pdfMutation.isPending} onClick={downloadPdf}>PDF</ActionButton>
|
||||
<ActionButton icon="preview" disabled={!userId || !pdfFileName} onClick={previewPdf}>미리보기</ActionButton>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function EvidenceActions({performanceId, userId}: {performanceId: number; userId?: string}) {
|
||||
const enabled = performanceId > 0 && Boolean(userId);
|
||||
const {data: evidenceList = []} = useMonitoringEvidenceQuery(performanceId, userId ?? "", enabled);
|
||||
const zipMutation = useDownloadEvidenceZipMutation();
|
||||
|
||||
const download = async () => {
|
||||
if (!userId) return;
|
||||
const buffer = await zipMutation.mutateAsync({performanceId, userId});
|
||||
downloadBlob(buffer, getEvidenceZipDownloadName(performanceId, userId), "application/zip");
|
||||
};
|
||||
|
||||
const preview = () => {
|
||||
if (!userId) return;
|
||||
const images = evidenceList
|
||||
.flatMap((item) =>
|
||||
(item.evidenceImg ?? "")
|
||||
.split("|")
|
||||
.map((fileName) => fileName.trim())
|
||||
.filter(Boolean)
|
||||
)
|
||||
.map((fileName) => buildEvidenceImageSrc(performanceId, userId, fileName));
|
||||
|
||||
if (images.length === 0) {
|
||||
alert("미리보기할 증빙사진이 없습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
openPreviewWindow(buildImagePreviewUrl("증빙사진", images));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<ActionButton icon="image" disabled={!userId || zipMutation.isPending} onClick={download}>증빙사진</ActionButton>
|
||||
<ActionButton icon="preview" disabled={!userId || evidenceList.length === 0} onClick={preview}>증빙 미리보기</ActionButton>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function MonitoringPerformanceDetailDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
performance,
|
||||
codes,
|
||||
userId,
|
||||
}: Readonly<{
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
performance: PerformanceFull | null;
|
||||
codes: CodeMap;
|
||||
userId?: string;
|
||||
}>) {
|
||||
const row = useMemo(() => {
|
||||
if (!performance || !userId) return undefined;
|
||||
return ([0, 1] as const)
|
||||
.map((index) => getMonitoringDisplayRow(performance, index))
|
||||
.find((item) => item.userId === userId);
|
||||
}, [performance, userId]);
|
||||
|
||||
const latestVisit = row?.slot.visit?.[0];
|
||||
const status = row
|
||||
? getMonitoringDisplayStatus(
|
||||
row,
|
||||
getCodeLabel(codes, "monitoring_visit_status", latestVisit?.monitoringVisitStatus),
|
||||
getCodeLabel(codes, "review_status", row.review?.reviewStatus)
|
||||
)
|
||||
: {label: "미배치", variant: "danger" as const};
|
||||
|
||||
const downloadTemplate = () => downloadFromUrl("/api/review/template/download/1");
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="flex max-h-[92vh] w-[calc(100vw-24px)] max-w-[430px] flex-col overflow-hidden p-0">
|
||||
<DialogHeader className="border-b px-4 py-3">
|
||||
<DialogTitle className="text-base">모니터링 상세</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="min-h-0 flex-1 space-y-3 overflow-y-auto p-3">
|
||||
{performance ? (
|
||||
<>
|
||||
<section className="overflow-hidden rounded-md border">
|
||||
<MobileDetailRow label="연번">{performance.id}</MobileDetailRow>
|
||||
<MobileDetailRow label="사업유형">{getCodeLabel(codes, "business_type", performance.businessType)}</MobileDetailRow>
|
||||
<MobileDetailRow label="분야(장르)">{getCodeLabel(codes, "genre", performance.performanceGenre)}</MobileDetailRow>
|
||||
<MobileDetailRow label="지역">{getCodeLabel(codes, "area", performance.performanceArea)}</MobileDetailRow>
|
||||
<MobileDetailRow label="단체(인)명">{performance.artistName}</MobileDetailRow>
|
||||
<MobileDetailRow label="사업명">{performance.performanceName}</MobileDetailRow>
|
||||
<MobileDetailRow label="사업 수행 월">{performance.performanceStartMonth}월</MobileDetailRow>
|
||||
<MobileDetailRow label="사업 일정">{performance.performanceDtInfo}</MobileDetailRow>
|
||||
<MobileDetailRow label="운영 시간">{performance.performanceTimeInfo}</MobileDetailRow>
|
||||
<MobileDetailRow label="예매 예약">{getCodeLabel(codes, "ticket_reservation_status", performance.ticketReservationStatus)}</MobileDetailRow>
|
||||
<MobileDetailRow label="예매 비고">{performance.ticketReservationMemo}</MobileDetailRow>
|
||||
<MobileDetailRow label="모니터링 일정">{performance.performanceMonitoringSchedule?.monitoringDate}</MobileDetailRow>
|
||||
<MobileDetailRow label="모니터링 시간">{performance.performanceMonitoringSchedule?.monitoringTimeInfo}</MobileDetailRow>
|
||||
<MobileDetailRow label="방문 장소">{performance.performanceMonitoringSchedule?.monitoringAddress}</MobileDetailRow>
|
||||
<MobileDetailRow label="메모">{performance.performanceMemo}</MobileDetailRow>
|
||||
</section>
|
||||
|
||||
<section className="space-y-3 rounded-md border p-3">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="font-semibold">나의 진행 상태</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button type="button" size="sm" variant="outline" onClick={downloadTemplate}>
|
||||
<Download className="h-4 w-4" />
|
||||
양식
|
||||
</Button>
|
||||
<StatusPill variant={status.variant}>{status.label}</StatusPill>
|
||||
</div>
|
||||
</div>
|
||||
{row ? (
|
||||
<MonitoringReviewActions
|
||||
performanceId={performance.id}
|
||||
reviewType={row.reviewType}
|
||||
userId={row.review?.regUser || row.userId}
|
||||
uploadFileName={row.review?.uploadFileName}
|
||||
pdfFileName={row.review?.pdfFileName}
|
||||
/>
|
||||
) : (
|
||||
<div className="rounded-md bg-muted p-3 text-sm text-muted-foreground">나의 모니터링 배정 정보를 찾을 수 없습니다.</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{row?.slot.visit?.length ? (
|
||||
<section className="space-y-3 rounded-md border p-3">
|
||||
<div className="font-semibold">모니터링 방문 기록</div>
|
||||
<div className="grid gap-1 text-sm text-muted-foreground">
|
||||
<div>출발: {getMonitoringRecordedAt(row.slot.timeline.departure)}</div>
|
||||
<div>도착: {getMonitoringRecordedAt(row.slot.timeline.arrival)}</div>
|
||||
</div>
|
||||
{row.slot.timeline.arrival && (
|
||||
<EvidenceActions performanceId={performance.id} userId={row.evidenceUserId} />
|
||||
)}
|
||||
</section>
|
||||
) : null}
|
||||
</>
|
||||
) : (
|
||||
<div className="rounded-md border p-4 text-sm text-muted-foreground">공연 정보를 불러오는 중입니다.</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<DialogFooter className="border-t px-4 py-3">
|
||||
<Button type="button" variant="outline" className="w-full" onClick={() => onOpenChange(false)}>닫기</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -27,14 +27,14 @@ export function MonitoringVisitDialog({
|
||||
mode,
|
||||
onSubmit,
|
||||
isSubmitting,
|
||||
}: {
|
||||
}: Readonly<{
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
performance: PerformanceCompact | null;
|
||||
mode: "departure" | "arrival";
|
||||
onSubmit?: (files?: File[]) => void | Promise<void>;
|
||||
isSubmitting?: boolean;
|
||||
}) {
|
||||
}>) {
|
||||
const nowText = useMemo(() => new Date().toLocaleString("ko-KR"), [open]);
|
||||
const [files, setFiles] = useState<File[]>([]);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
"use client";
|
||||
|
||||
import {ReactNode, useEffect, useMemo, useState} from "react";
|
||||
import {Download, ImageIcon, Upload} from "lucide-react";
|
||||
import {ReactNode, useEffect, useMemo, useRef, useState} from "react";
|
||||
import {Download, ImageIcon, ScanSearch, Upload} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import {Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle} from "@/components/ui/dialog";
|
||||
@@ -12,27 +12,36 @@ import {Code, PerformanceCompact, PerformanceFull, PerformanceMonitoringSchedule
|
||||
import {CodeGroup} from "@/query/code";
|
||||
import {getCodeLabel, getDetailValue, ROLE} from "@/lib/gwcf/view";
|
||||
import {
|
||||
getMonitoringDisplayRow,
|
||||
getMonitoringDisplayStatus,
|
||||
getMonitoringRecordedAt,
|
||||
getMonitoringRecordedUser,
|
||||
getMonitoringSlots,
|
||||
getMonitoringStatusDisplay,
|
||||
getReviewByType,
|
||||
getReviewStatusDisplay,
|
||||
getWrittenReviewRows,
|
||||
isReviewComplete,
|
||||
LOCAL_GOVERNMENT_REVIEW_TYPE,
|
||||
} from "@/lib/gwcf/performance-status";
|
||||
import {buildWrittenReviewLink} from "@/config/gwcf.config";
|
||||
import {
|
||||
useDownloadReviewOriginalMutation,
|
||||
useDownloadReviewPdfMutation,
|
||||
useEndWrittenReviewMutation,
|
||||
useReviewFileQuery,
|
||||
useStartWrittenReviewMutation,
|
||||
useUploadReviewFileMutation,
|
||||
} from "@/query/review";
|
||||
import {useDownloadEvidenceZipMutation} from "@/query/monitoring";
|
||||
import {downloadFile} from "@/lib/utils";
|
||||
import {useDownloadEvidenceZipMutation, useMonitoringEvidenceQuery} from "@/query/monitoring";
|
||||
import {useUsersQuery} from "@/query/user";
|
||||
import {useLoading} from "@/hooks/useLoading";
|
||||
import {
|
||||
buildEvidenceImageSrc,
|
||||
buildImagePreviewUrl,
|
||||
buildReviewPdfPreviewUrl,
|
||||
downloadBlob,
|
||||
downloadFromUrl,
|
||||
getEvidenceZipDownloadName,
|
||||
getReviewOriginalDownloadName,
|
||||
getReviewPdfDownloadName,
|
||||
openPreviewWindow,
|
||||
openWrittenReviewWindow,
|
||||
} from "@/lib/gwcf/file";
|
||||
|
||||
type CodeMap = Partial<Record<CodeGroup, Code[]>>;
|
||||
|
||||
@@ -50,13 +59,13 @@ function FileActionButton({
|
||||
icon = "download",
|
||||
disabled = false,
|
||||
onClick,
|
||||
}: {
|
||||
}: Readonly<{
|
||||
children: ReactNode;
|
||||
icon?: "download" | "upload" | "image";
|
||||
icon?: "download" | "upload" | "image" | "preview";
|
||||
disabled?: boolean;
|
||||
onClick?: () => void;
|
||||
}) {
|
||||
const Icon = icon === "upload" ? Upload : icon === "image" ? ImageIcon : Download;
|
||||
}>) {
|
||||
const Icon = icon === "upload" ? Upload : icon === "image" ? ImageIcon : icon === "preview" ? ScanSearch : Download;
|
||||
return (
|
||||
<Button type="button" size="xs" variant="outline" disabled={disabled} onClick={onClick}>
|
||||
<Icon className="h-3 w-3" />
|
||||
@@ -70,12 +79,12 @@ function AssignedUserInfo({
|
||||
user,
|
||||
codes,
|
||||
type,
|
||||
}: {
|
||||
}: Readonly<{
|
||||
userId?: string;
|
||||
user?: UserFull;
|
||||
codes: CodeMap;
|
||||
type: "monitoring" | "written";
|
||||
}) {
|
||||
}>) {
|
||||
const detail = user?.userDetail;
|
||||
const tel = getDetailValue(detail, ["tel", "phone", "userTel"], "-");
|
||||
const email = getDetailValue(detail, ["email", "userEmail"], "-");
|
||||
@@ -98,66 +107,123 @@ function AssignedUserInfo({
|
||||
);
|
||||
}
|
||||
|
||||
const downloadBlob = (buffer: ArrayBuffer, fileName: string, type = "application/octet-stream") => {
|
||||
const blob = new Blob([buffer], {type});
|
||||
downloadFile(blob, fileName);
|
||||
};
|
||||
|
||||
function ReviewFileActions({
|
||||
performanceId,
|
||||
reviewType,
|
||||
userId,
|
||||
uploadFileName,
|
||||
pdfFileName,
|
||||
}: {
|
||||
canEdit,
|
||||
}: Readonly<{
|
||||
performanceId: number;
|
||||
reviewType: number;
|
||||
userId?: string;
|
||||
uploadFileName?: string;
|
||||
pdfFileName?: string;
|
||||
}) {
|
||||
canEdit: boolean;
|
||||
}>) {
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const uploadMutation = useUploadReviewFileMutation();
|
||||
const originalMutation = useDownloadReviewOriginalMutation();
|
||||
const pdfMutation = useDownloadReviewPdfMutation();
|
||||
const {withLoadingAsync} = useLoading();
|
||||
const complete = Boolean(pdfFileName);
|
||||
|
||||
const upload = (file?: File) => {
|
||||
if (!file) return;
|
||||
uploadMutation.mutate({performanceId, reviewType, file});
|
||||
const upload = async (file?: File) => {
|
||||
try {
|
||||
if (!file) return;
|
||||
await withLoadingAsync(() => uploadMutation.mutateAsync({performanceId, reviewType, file}));
|
||||
alert("파일 업로드가 완료되었습니다.");
|
||||
} finally {
|
||||
if (fileInputRef.current) fileInputRef.current.value = "";
|
||||
}
|
||||
};
|
||||
|
||||
const downloadOriginal = async () => {
|
||||
const buffer = await originalMutation.mutateAsync({performanceId, reviewType});
|
||||
downloadBlob(buffer, uploadFileName || `review-original-${performanceId}-${reviewType}`);
|
||||
if (!userId) return;
|
||||
const buffer = await originalMutation.mutateAsync({ performanceId, reviewType, userId });
|
||||
downloadBlob(
|
||||
buffer,
|
||||
getReviewOriginalDownloadName(performanceId, reviewType, uploadFileName)
|
||||
);
|
||||
};
|
||||
|
||||
const downloadPdf = async () => {
|
||||
const buffer = await pdfMutation.mutateAsync({performanceId, reviewType});
|
||||
downloadBlob(buffer, pdfFileName || `review-pdf-${performanceId}-${reviewType}.pdf`, "application/pdf");
|
||||
if (!userId) return;
|
||||
const buffer = await pdfMutation.mutateAsync({ performanceId, reviewType, userId });
|
||||
downloadBlob(
|
||||
buffer,
|
||||
getReviewPdfDownloadName(performanceId, reviewType, pdfFileName),
|
||||
"application/pdf"
|
||||
);
|
||||
};
|
||||
|
||||
const previewPdf = () => {
|
||||
if (!pdfFileName || !userId) return;
|
||||
openPreviewWindow(buildReviewPdfPreviewUrl(performanceId, reviewType, userId, pdfFileName));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap gap-1">
|
||||
<label>
|
||||
<input type="file" className="hidden" onChange={(event) => upload(event.target.files?.[0])} />
|
||||
<FileActionButton icon="upload" disabled={uploadMutation.isPending}>파일 업로드</FileActionButton>
|
||||
</label>
|
||||
<FileActionButton icon="download" disabled={!uploadFileName || originalMutation.isPending} onClick={downloadOriginal}>원본</FileActionButton>
|
||||
<FileActionButton icon="download" disabled={!pdfFileName || pdfMutation.isPending} onClick={downloadPdf}>PDF</FileActionButton>
|
||||
{canEdit && (
|
||||
<>
|
||||
<input ref={fileInputRef} type="file" className="hidden" onChange={(event) => void upload(event.target.files?.[0])} />
|
||||
<FileActionButton icon="upload" disabled={uploadMutation.isPending || !complete} onClick={() => fileInputRef.current?.click()}>파일 업로드</FileActionButton>
|
||||
</>
|
||||
)}
|
||||
<FileActionButton icon="download" disabled={!userId || !uploadFileName || originalMutation.isPending} onClick={downloadOriginal}>원본</FileActionButton>
|
||||
<FileActionButton icon="download" disabled={!userId || !pdfFileName || pdfMutation.isPending} onClick={downloadPdf}>PDF</FileActionButton>
|
||||
<FileActionButton icon="preview" disabled={!userId || !pdfFileName} onClick={previewPdf}>미리보기</FileActionButton>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function EvidenceZipButton({performanceId, userId}: {performanceId: number; userId: string}) {
|
||||
const {data: evidenceList = []} = useMonitoringEvidenceQuery(performanceId, userId, performanceId > 0 && Boolean(userId));
|
||||
const zipMutation = useDownloadEvidenceZipMutation();
|
||||
const download = async () => {
|
||||
const buffer = await zipMutation.mutateAsync({performanceId, userId});
|
||||
downloadBlob(buffer, `monitoring-evidence-${performanceId}-${userId}.zip`, "application/zip");
|
||||
downloadBlob(buffer, getEvidenceZipDownloadName(performanceId, userId), "application/zip");
|
||||
};
|
||||
|
||||
return <FileActionButton icon="image" disabled={zipMutation.isPending} onClick={download}>증빙사진</FileActionButton>;
|
||||
const preview = () => {
|
||||
const images = evidenceList
|
||||
.flatMap((item) =>
|
||||
(item.evidenceImg ?? "")
|
||||
.split("|")
|
||||
.map((fileName) => fileName.trim())
|
||||
.filter(Boolean)
|
||||
)
|
||||
.map((fileName) => buildEvidenceImageSrc(performanceId, userId, fileName));
|
||||
|
||||
if (images.length === 0) {
|
||||
alert("미리보기할 증빙사진이 없습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
openPreviewWindow(buildImagePreviewUrl("증빙 미리보기", images));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap gap-1">
|
||||
<FileActionButton icon="image" disabled={zipMutation.isPending} onClick={download}>다운로드</FileActionButton>
|
||||
<FileActionButton icon="preview" disabled={evidenceList.length === 0} onClick={preview}>증빙 미리보기</FileActionButton>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function LocalGovernmentReviewRow({performanceId, codes}: {performanceId: number; codes: CodeMap}) {
|
||||
function LocalGovernmentReviewRow({
|
||||
performance,
|
||||
codes,
|
||||
}: {
|
||||
performance: PerformanceFull | PerformanceCompact;
|
||||
codes: CodeMap;
|
||||
}) {
|
||||
const reviewType = LOCAL_GOVERNMENT_REVIEW_TYPE;
|
||||
const {data: review} = useReviewFileQuery(performanceId, reviewType, performanceId > 0);
|
||||
const fallbackReviewRow = getReviewByType(performance as PerformanceFull, reviewType);
|
||||
const userId = fallbackReviewRow?.review.regUser || fallbackReviewRow?.userId;
|
||||
const {data: fetchedReview} = useReviewFileQuery(performance.id, reviewType, userId, performance.id > 0 && Boolean(userId));
|
||||
const review = fetchedReview ?? fallbackReviewRow?.review;
|
||||
const label = getCodeLabel(codes, "review_status", review?.reviewStatus);
|
||||
const display = getReviewStatusDisplay(label, review, true);
|
||||
|
||||
@@ -166,7 +232,7 @@ function LocalGovernmentReviewRow({performanceId, codes}: {performanceId: number
|
||||
<div className="font-semibold">지자체</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<StatusPill variant={display.variant}>{display.label}</StatusPill>
|
||||
<ReviewFileActions performanceId={performanceId} reviewType={reviewType} uploadFileName={review?.uploadFileName} pdfFileName={review?.pdfFileName} />
|
||||
<ReviewFileActions performanceId={performance.id} reviewType={reviewType} userId={review?.regUser || userId} uploadFileName={review?.uploadFileName} pdfFileName={review?.pdfFileName} canEdit={true} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -177,37 +243,48 @@ function MonitoringStatusRow({
|
||||
index,
|
||||
codes,
|
||||
userMap,
|
||||
}: {
|
||||
canEdit,
|
||||
}: Readonly<{
|
||||
performance: PerformanceFull | PerformanceCompact;
|
||||
index: 0 | 1;
|
||||
codes: CodeMap;
|
||||
userMap: Map<string, UserFull>;
|
||||
}) {
|
||||
const slot = getMonitoringSlots(performance as PerformanceFull)[index];
|
||||
const user = slot.assign?.assignUser ? userMap.get(slot.assign.assignUser) : undefined;
|
||||
const reviewType = index + 1;
|
||||
const {data: review} = useReviewFileQuery(performance.id, reviewType, performance.id > 0);
|
||||
const label = getCodeLabel(codes, "monitoring_visit_status", slot.visit?.monitoringVisitStatus);
|
||||
const display = getMonitoringStatusDisplay(label, slot);
|
||||
canEdit: boolean;
|
||||
}>) {
|
||||
const row = getMonitoringDisplayRow(performance as PerformanceFull, index);
|
||||
const user = row.userId ? userMap.get(row.userId) : undefined;
|
||||
const latestVisit = row.slot.visit?.[0];
|
||||
const display = getMonitoringDisplayStatus(
|
||||
row,
|
||||
getCodeLabel(codes, "monitoring_visit_status", latestVisit?.monitoringVisitStatus),
|
||||
getCodeLabel(codes, "review_status", row.review?.reviewStatus)
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="space-y-2 border-b p-3">
|
||||
<div className="font-semibold">모니터링 {index + 1}</div>
|
||||
<div className="grid gap-1 text-sm">
|
||||
<AssignedUserInfo userId={slot.assign?.assignUser} user={user} codes={codes} type="monitoring" />
|
||||
<div>기록 사용자: {getMonitoringRecordedUser(slot.visit)}</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<AssignedUserInfo userId={row.userId} user={user} codes={codes} type="monitoring" />
|
||||
<div className="flex flex-wrap items-center gap-2 mb-2">
|
||||
<StatusPill variant={display.variant}>{display.label}</StatusPill>
|
||||
<ReviewFileActions performanceId={performance.id} reviewType={reviewType} uploadFileName={review?.uploadFileName} pdfFileName={review?.pdfFileName} />
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<span>모니터링 출발/도착 기록: {getMonitoringRecordedAt(slot.visit)}</span>
|
||||
{slot.assign?.assignUser ? (
|
||||
<EvidenceZipButton performanceId={performance.id} userId={slot.assign.assignUser} />
|
||||
) : (
|
||||
<FileActionButton icon="image" disabled>증빙사진</FileActionButton>
|
||||
)}
|
||||
<ReviewFileActions performanceId={performance.id} reviewType={row.reviewType} userId={row.review?.regUser || row.userId} uploadFileName={row.review?.uploadFileName} pdfFileName={row.review?.pdfFileName} canEdit={canEdit} />
|
||||
</div>
|
||||
{row.slot.visit?.length ? (
|
||||
<>
|
||||
<div className="rounded-md border bg-muted/30 p-2 text-sm">
|
||||
<div className="grid gap-1 text-xs text-muted-foreground sm:grid-cols-1">
|
||||
<span>출발: {getMonitoringRecordedAt(row.slot.timeline.departure)}</span>
|
||||
<span>도착: {getMonitoringRecordedAt(row.slot.timeline.arrival)}</span>
|
||||
</div>
|
||||
</div>
|
||||
{row.slot.timeline.arrival && row.evidenceUserId && (
|
||||
<EvidenceZipButton
|
||||
performanceId={performance.id}
|
||||
userId={row.evidenceUserId}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -216,16 +293,14 @@ function MonitoringStatusRow({
|
||||
function WrittenReviewRows({
|
||||
performance,
|
||||
codes,
|
||||
isWrittenReviewer,
|
||||
userMap,
|
||||
}: {
|
||||
canEdit,
|
||||
}: Readonly<{
|
||||
performance: PerformanceFull | PerformanceCompact;
|
||||
codes: CodeMap;
|
||||
isWrittenReviewer: boolean;
|
||||
userMap: Map<string, UserFull>;
|
||||
}) {
|
||||
const startMutation = useStartWrittenReviewMutation();
|
||||
const endMutation = useEndWrittenReviewMutation();
|
||||
canEdit: boolean;
|
||||
}>) {
|
||||
const rows = getWrittenReviewRows(performance as PerformanceFull);
|
||||
|
||||
if(rows.length === 0){
|
||||
@@ -233,7 +308,7 @@ function WrittenReviewRows({
|
||||
}
|
||||
|
||||
const openWrittenReviewLink = (userId: string, complete: boolean) => {
|
||||
window.open(buildWrittenReviewLink({performanceId: performance.id, userId, complete}), "_blank", "noopener,noreferrer");
|
||||
openWrittenReviewWindow(performance.id, userId, complete);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -250,20 +325,12 @@ function WrittenReviewRows({
|
||||
<div key={`${userId}-${reviewType}`} className="space-y-2 border-b p-3 last:border-b-0">
|
||||
<AssignedUserInfo userId={userId} user={user} codes={codes} type="written" />
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<StatusPill variant={display.variant} onClick={isWrittenReviewer ? () => openWrittenReviewLink(userId, complete) : undefined}>
|
||||
<StatusPill variant={display.variant} onClick={complete ? () => openWrittenReviewLink(userId, true) : undefined}>
|
||||
{display.label}
|
||||
</StatusPill>
|
||||
{isWrittenReviewer && (
|
||||
<Button type="button" size="xs" variant="outline" onClick={() => openWrittenReviewLink(userId, complete)}>
|
||||
평가 링크
|
||||
</Button>
|
||||
)}
|
||||
<Button type="button" size="xs" variant="outline" onClick={() => startMutation.mutate(performance.id)}>
|
||||
평가진행
|
||||
</Button>
|
||||
{complete && (
|
||||
<Button type="button" size="xs" variant="outline" onClick={() => endMutation.mutate({performanceId: performance.id, userId})}>
|
||||
평가완료
|
||||
{canEdit && (
|
||||
<Button type="button" size="xs" variant="outline" disabled={!complete} onClick={() => openWrittenReviewLink(userId, false)}>
|
||||
평가 수정
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
@@ -281,17 +348,15 @@ export function PerformanceDetailDialog({
|
||||
performance,
|
||||
codes,
|
||||
canEdit,
|
||||
isWrittenReviewer = false,
|
||||
onSave,
|
||||
}: {
|
||||
}: Readonly<{
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
performance: PerformanceFull | PerformanceCompact | null;
|
||||
codes: CodeMap;
|
||||
canEdit: boolean;
|
||||
isWrittenReviewer?: boolean;
|
||||
onSave?: (performance: PerformanceCompact) => void;
|
||||
}) {
|
||||
}>) {
|
||||
const [draft, setDraft] = useState<PerformanceCompact | null>(null);
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const {data: monitoringUsers = []} = useUsersQuery(ROLE.MONITORING, open);
|
||||
@@ -382,6 +447,10 @@ export function PerformanceDetailDialog({
|
||||
setIsEditing(false);
|
||||
};
|
||||
|
||||
const downloadTemplate = (reviewType: number) => {
|
||||
downloadFromUrl(`/api/review/template/download/${reviewType}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="flex max-h-[90vh] flex-col overflow-hidden sm:max-w-6xl">
|
||||
@@ -445,11 +514,23 @@ export function PerformanceDetailDialog({
|
||||
</div>
|
||||
|
||||
<section className="rounded-md border">
|
||||
<div className="border-b bg-muted px-3 py-2 font-semibold">평가 및 모니터링 현황</div>
|
||||
<LocalGovernmentReviewRow performanceId={draft.id} codes={codes} />
|
||||
<MonitoringStatusRow performance={performance ?? draft} index={0} codes={codes} userMap={monitoringUserMap} />
|
||||
<MonitoringStatusRow performance={performance ?? draft} index={1} codes={codes} userMap={monitoringUserMap} />
|
||||
<WrittenReviewRows performance={performance ?? draft} codes={codes} isWrittenReviewer={isWrittenReviewer} userMap={writtenUserMap} />
|
||||
<div className="flex flex-wrap items-center justify-between gap-2 border-b bg-muted px-3 py-2">
|
||||
<div className="font-semibold">평가 및 모니터링 현황</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button type="button" size="sm" variant="outline" onClick={() => downloadTemplate(1)}>
|
||||
<Download className="h-4 w-4" />
|
||||
모니터링 양식
|
||||
</Button>
|
||||
<Button type="button" size="sm" variant="outline" onClick={() => downloadTemplate(3)}>
|
||||
<Download className="h-4 w-4" />
|
||||
지자체 양식
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<LocalGovernmentReviewRow performance={performance ?? draft} codes={codes} />
|
||||
<MonitoringStatusRow performance={performance ?? draft} index={0} codes={codes} userMap={monitoringUserMap} canEdit={canEdit} />
|
||||
<MonitoringStatusRow performance={performance ?? draft} index={1} codes={codes} userMap={monitoringUserMap} canEdit={canEdit} />
|
||||
<WrittenReviewRows performance={performance ?? draft} codes={codes} userMap={writtenUserMap} canEdit={canEdit} />
|
||||
</section>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -21,6 +21,7 @@ import {SaveTemplateRequest, Template} from "@/types/notification";
|
||||
import {UserCompact} from "@/types/gwcf";
|
||||
import {getDetailValue} from "@/lib/gwcf/view";
|
||||
import {useAuth} from "@/hooks/useAuth";
|
||||
import {buildUserMsgParam} from "@/lib/gwcf/notification";
|
||||
|
||||
type TemplateDraft = Pick<Template, "tmplatIdx" | "tmplatNm" | "tmplatTitle" | "tmplatBody" | "sendTel">;
|
||||
|
||||
@@ -34,19 +35,6 @@ const toDraft = (template: Template, emptyBody = false): TemplateDraft => ({
|
||||
sendTel: toText(template.sendTel),
|
||||
});
|
||||
|
||||
const toParamValue = (value: unknown) => value == null ? "" : String(value);
|
||||
|
||||
const buildUserMsgParam = (user: UserCompact): Record<string, string> => ({
|
||||
...Object.fromEntries(
|
||||
Object.entries(user.userDetail ?? {}).map(([key, value]) => [key, toParamValue(value)])
|
||||
),
|
||||
userId: toParamValue(user.userId),
|
||||
userCmpn: toParamValue(user.userCmpn),
|
||||
userTeam: toParamValue(user.userTeam),
|
||||
userName: toParamValue(user.userName),
|
||||
userRole: toParamValue(user.userRole),
|
||||
});
|
||||
|
||||
export function SmsSendDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
@@ -55,6 +43,8 @@ export function SmsSendDialog({
|
||||
newMessageTemplateIdx,
|
||||
selectedUsers,
|
||||
addParams = {},
|
||||
onBeforeDefaultTemplateSend,
|
||||
isBeforeSendPending = false,
|
||||
onSent,
|
||||
}: Readonly<{
|
||||
open: boolean;
|
||||
@@ -64,6 +54,8 @@ export function SmsSendDialog({
|
||||
newMessageTemplateIdx?: number;
|
||||
selectedUsers: UserCompact[];
|
||||
addParams?: Record<string, string>;
|
||||
onBeforeDefaultTemplateSend?: () => Promise<void>;
|
||||
isBeforeSendPending?: boolean;
|
||||
onSent?: () => void;
|
||||
}>) {
|
||||
const {auth} = useAuth();
|
||||
@@ -76,7 +68,7 @@ export function SmsSendDialog({
|
||||
const saveTemplateMutation = useSaveNotificationTemplateMutation();
|
||||
const sendSmsMutation = useSendSmsBulkMutation();
|
||||
|
||||
const isBusy = templateQuery.isLoading || saveTemplateMutation.isPending || sendSmsMutation.isPending;
|
||||
const isBusy = templateQuery.isLoading || saveTemplateMutation.isPending || sendSmsMutation.isPending || isBeforeSendPending;
|
||||
const canEdit = isNewMessage || isEditing;
|
||||
|
||||
const destinations = useMemo(() => {
|
||||
@@ -170,6 +162,8 @@ export function SmsSendDialog({
|
||||
|
||||
if (isNewMessage) {
|
||||
await saveTemplate();
|
||||
} else {
|
||||
await onBeforeDefaultTemplateSend?.();
|
||||
}
|
||||
|
||||
const result = await sendSmsMutation.mutateAsync({
|
||||
|
||||
@@ -14,9 +14,11 @@ export const TOP_MENU_PATH_MAP: Record<string, string> = {
|
||||
|
||||
export const MONITORING_USER_ROLE = 9003;
|
||||
|
||||
export const WRITTEN_REVIEW_PKEY = "2605013_ZZ";
|
||||
|
||||
export const WRITTEN_REVIEW_LINK_URL = {
|
||||
incomplete: "/written-review",
|
||||
complete: "/written-review/result",
|
||||
incomplete: `https://kon.kric.com/project/${WRITTEN_REVIEW_PKEY}/INDEX.asp`,
|
||||
complete: `https://kon.kric.com/survey_to_pdf/survey_layout_total.asp?AD=FALSE&PRJCODE=${WRITTEN_REVIEW_PKEY}`,
|
||||
} as const;
|
||||
|
||||
export const buildWrittenReviewLink = ({
|
||||
@@ -30,7 +32,7 @@ export const buildWrittenReviewLink = ({
|
||||
}) => {
|
||||
const baseUrl = complete ? WRITTEN_REVIEW_LINK_URL.complete : WRITTEN_REVIEW_LINK_URL.incomplete;
|
||||
const url = new URL(baseUrl, typeof window === "undefined" ? "http://localhost" : window.location.origin);
|
||||
url.searchParams.set("performanceId", String(performanceId));
|
||||
url.searchParams.set("userId", userId);
|
||||
url.searchParams.set("SID", String(performanceId));
|
||||
url.searchParams.set("UID", userId);
|
||||
return /^https?:\/\//i.test(baseUrl) ? url.toString() : url.pathname + url.search;
|
||||
};
|
||||
|
||||
4
src/lib/gwcf/date.ts
Normal file
4
src/lib/gwcf/date.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const toLocalDateString = (date = new Date()) => {
|
||||
const pad = (value: number) => String(value).padStart(2, "0");
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
||||
};
|
||||
75
src/lib/gwcf/file.ts
Normal file
75
src/lib/gwcf/file.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import {downloadFile} from "@/lib/utils";
|
||||
import {buildWrittenReviewLink} from "@/config/gwcf.config";
|
||||
|
||||
const REVIEW_TIMESTAMP_PREFIX = /^\d{4}-\d{2}-\d{2}_\d{6}_/;
|
||||
|
||||
export const removeTimestampPrefix = (fileName?: string) =>
|
||||
fileName?.replace(REVIEW_TIMESTAMP_PREFIX, "");
|
||||
|
||||
export const downloadBlob = (
|
||||
buffer: ArrayBuffer,
|
||||
fileName: string,
|
||||
type = "application/octet-stream"
|
||||
) => {
|
||||
downloadFile(new Blob([buffer], {type}), fileName);
|
||||
};
|
||||
|
||||
export const downloadExcelBuffer = (buffer: ArrayBuffer, fileName: string) => {
|
||||
downloadBlob(buffer, fileName, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
};
|
||||
|
||||
export const downloadFromUrl = (url: string) => {
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = "";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
};
|
||||
|
||||
export const getReviewOriginalDownloadName = (
|
||||
performanceId: number,
|
||||
reviewType: number,
|
||||
uploadFileName?: string
|
||||
) => removeTimestampPrefix(uploadFileName) || `review-original-${performanceId}-${reviewType}`;
|
||||
|
||||
export const getReviewPdfDownloadName = (
|
||||
performanceId: number,
|
||||
reviewType: number,
|
||||
pdfFileName?: string
|
||||
) => removeTimestampPrefix(pdfFileName) || `review-pdf-${performanceId}-${reviewType}.pdf`;
|
||||
|
||||
export const getEvidenceZipDownloadName = (performanceId: number, userId: string) =>
|
||||
`도착 증빙_${performanceId}_${userId}.zip`;
|
||||
|
||||
export const buildReviewPdfPreviewUrl = (
|
||||
performanceId: number,
|
||||
reviewType: number,
|
||||
userId: string,
|
||||
title?: string
|
||||
) => {
|
||||
const src = `/api/review/pdf/${performanceId}/${reviewType}/${encodeURIComponent(userId)}?disposition=inline`;
|
||||
return `/file-preview?type=pdf&src=${encodeURIComponent(src)}&title=${encodeURIComponent(title || getReviewPdfDownloadName(performanceId, reviewType))}`;
|
||||
};
|
||||
|
||||
export const buildEvidenceImageSrc = (
|
||||
performanceId: number,
|
||||
userId: string,
|
||||
fileName: string
|
||||
) => `/api/file/visit/${performanceId}/${encodeURIComponent(userId)}/${encodeURIComponent(fileName)}`;
|
||||
|
||||
export const buildImagePreviewUrl = (title: string, images: string[]) =>
|
||||
`/file-preview?type=image&title=${encodeURIComponent(title)}&images=${encodeURIComponent(JSON.stringify(images))}`;
|
||||
|
||||
export const openPreviewWindow = (url: string) => {
|
||||
window.open(url, "_blank", "noopener,noreferrer");
|
||||
};
|
||||
|
||||
export const openWrittenReviewWindow = (
|
||||
performanceId: number,
|
||||
userId: string | undefined,
|
||||
complete = false
|
||||
) => {
|
||||
if (!userId) return;
|
||||
window.open(buildWrittenReviewLink({performanceId, userId, complete}), "_blank", "noopener,noreferrer");
|
||||
};
|
||||
35
src/lib/gwcf/notification.ts
Normal file
35
src/lib/gwcf/notification.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {PerformanceFull, UserCompact} from "@/types/gwcf";
|
||||
|
||||
export const toNotificationParamValue = (value: unknown) => value == null ? "" : String(value);
|
||||
|
||||
export const buildUserMsgParam = (user: UserCompact): Record<string, string> => ({
|
||||
...Object.fromEntries(
|
||||
Object.entries(user.userDetail ?? {}).map(([key, value]) => [key, toNotificationParamValue(value)])
|
||||
),
|
||||
userId: toNotificationParamValue(user.userId),
|
||||
userCmpn: toNotificationParamValue(user.userCmpn),
|
||||
userTeam: toNotificationParamValue(user.userTeam),
|
||||
userName: toNotificationParamValue(user.userName),
|
||||
userRole: toNotificationParamValue(user.userRole),
|
||||
});
|
||||
|
||||
export const buildPerformanceSmsParams = (performance: PerformanceFull): Record<string, string> => ({
|
||||
businessType: toNotificationParamValue(performance.businessType),
|
||||
performanceGenre: toNotificationParamValue(performance.performanceGenre),
|
||||
performanceArea: toNotificationParamValue(performance.performanceArea),
|
||||
artistName: toNotificationParamValue(performance.artistName),
|
||||
performanceName: toNotificationParamValue(performance.performanceName),
|
||||
performanceStartMonth: toNotificationParamValue(performance.performanceStartMonth),
|
||||
performanceDtInfo: toNotificationParamValue(performance.performanceDtInfo),
|
||||
performanceTimeInfo: toNotificationParamValue(performance.performanceTimeInfo),
|
||||
ticketReservationStatus: toNotificationParamValue(performance.ticketReservationStatus),
|
||||
ticketReservationMemo: toNotificationParamValue(performance.ticketReservationMemo),
|
||||
performanceMemo: toNotificationParamValue(performance.performanceMemo),
|
||||
...Object.fromEntries(
|
||||
Object.entries(performance.performanceDetail ?? {}).map(([key, value]) => [key, toNotificationParamValue(value)])
|
||||
),
|
||||
...Object.fromEntries(
|
||||
Object.entries(performance.performanceMonitoringSchedule ?? {}).map(([key, value]) => [key, toNotificationParamValue(value)])
|
||||
),
|
||||
performanceId: toNotificationParamValue(performance.id),
|
||||
});
|
||||
@@ -1,14 +1,37 @@
|
||||
import {PerformanceAssign, PerformanceFull, PerformanceMonitoringVisit, PerformanceReview, UserCompact} from "@/types/gwcf";
|
||||
import {Code, PerformanceAssign, PerformanceFull, PerformanceMonitoringVisit, PerformanceReview, UserCompact} from "@/types/gwcf";
|
||||
import type {StatusPillVariant} from "@/components/gwcf/StatusPill";
|
||||
|
||||
export const LOCAL_GOVERNMENT_REVIEW_TYPE = 3;
|
||||
export const MONITORING_ASSIGN_TYPE = 1;
|
||||
export const WRITTEN_REVIEW_ASSIGN_TYPE = 2;
|
||||
export const MONITORING_DEPARTURE_STATUS = 2;
|
||||
export const MONITORING_ARRIVAL_STATUS = 3;
|
||||
|
||||
export type MonitoringVisitTimeline = {
|
||||
departure?: PerformanceMonitoringVisit;
|
||||
arrival?: PerformanceMonitoringVisit;
|
||||
};
|
||||
|
||||
export type MonitoringSlot = {
|
||||
assign?: PerformanceAssign;
|
||||
user?: UserCompact;
|
||||
visit?: PerformanceMonitoringVisit;
|
||||
visit?: PerformanceMonitoringVisit[];
|
||||
timeline: MonitoringVisitTimeline;
|
||||
};
|
||||
|
||||
export type ReviewDisplayRow = {
|
||||
userId: string;
|
||||
assign?: PerformanceAssign;
|
||||
review?: PerformanceReview;
|
||||
};
|
||||
|
||||
export type MonitoringDisplayRow = {
|
||||
index: 0 | 1;
|
||||
reviewType: number;
|
||||
slot: MonitoringSlot;
|
||||
userId?: string;
|
||||
evidenceUserId?: string;
|
||||
review?: PerformanceReview;
|
||||
};
|
||||
|
||||
export type StatusDisplay = {
|
||||
@@ -16,6 +39,59 @@ export type StatusDisplay = {
|
||||
variant: StatusPillVariant;
|
||||
};
|
||||
|
||||
export const STATUS_FILTER = {
|
||||
UNASSIGNED: "-1001",
|
||||
INCOMPLETE: "-1002",
|
||||
PENDING: "-1003",
|
||||
IN_PROGRESS: "-1004",
|
||||
DEPARTED: "-1005",
|
||||
ARRIVED: "-1006",
|
||||
DONE: "-1007",
|
||||
} as const;
|
||||
|
||||
export const makeStatusOption = (value: string, label: string): Code => ({
|
||||
codeGroup: "status_filter",
|
||||
codeValue: Number(value),
|
||||
codeGroupLabel: "상태",
|
||||
codeLabel: label,
|
||||
memo: "",
|
||||
});
|
||||
|
||||
export 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, "완료"),
|
||||
};
|
||||
|
||||
export const normalizeStatusLabel = (label?: string) => label?.replace(/\s/g, "") ?? "";
|
||||
export const labelHasInProgress = (label?: string) => normalizeStatusLabel(label).includes("진행");
|
||||
export const labelHasDeparted = (label?: string) => normalizeStatusLabel(label).includes("출발");
|
||||
export const labelHasArrived = (label?: string) => normalizeStatusLabel(label).includes("도착");
|
||||
export const labelHasComplete = (label?: string) => normalizeStatusLabel(label).includes("완료");
|
||||
|
||||
const sortMonitoringVisits = (visits: PerformanceMonitoringVisit[]) => {
|
||||
return [...visits].sort((a, b) => {
|
||||
if (b.monitoringVisitStatus !== a.monitoringVisitStatus) {
|
||||
return b.monitoringVisitStatus - a.monitoringVisitStatus;
|
||||
}
|
||||
return new Date(b.regDt ?? 0).getTime() - new Date(a.regDt ?? 0).getTime();
|
||||
});
|
||||
};
|
||||
|
||||
const getMonitoringVisits = (visits: PerformanceMonitoringVisit[], userId?: string) => {
|
||||
const matchedVisits = userId ? visits.filter((item) => item.regUser === userId) : visits;
|
||||
const candidates = matchedVisits.length > 0 ? matchedVisits : visits;
|
||||
return sortMonitoringVisits(candidates);
|
||||
};
|
||||
|
||||
const getMonitoringTimeline = (visits: PerformanceMonitoringVisit[]): MonitoringVisitTimeline => ({
|
||||
departure: visits.find((visit) => visit.monitoringVisitStatus === MONITORING_DEPARTURE_STATUS),
|
||||
arrival: visits.find((visit) => visit.monitoringVisitStatus === MONITORING_ARRIVAL_STATUS),
|
||||
});
|
||||
|
||||
export const getMonitoringSlots = (performance: Partial<PerformanceFull>): [MonitoringSlot, MonitoringSlot] => {
|
||||
const confirmedAssigns = (performance.performanceAssignList ?? [])
|
||||
.filter((assign) => assign.assignType === MONITORING_ASSIGN_TYPE && assign.assignConfirm)
|
||||
@@ -26,11 +102,9 @@ export const getMonitoringSlots = (performance: Partial<PerformanceFull>): [Moni
|
||||
return [0, 1].map((index) => {
|
||||
const assign = confirmedAssigns[index];
|
||||
const userVisits = assign ? visits[assign.assignUser] ?? [] : [];
|
||||
const visit = assign
|
||||
? userVisits.find((item) => item.regUser === assign.assignUser) ?? userVisits[0]
|
||||
: undefined;
|
||||
const sortedVisits = assign ? getMonitoringVisits(userVisits, assign.assignUser) : [];
|
||||
|
||||
return {assign, visit};
|
||||
return {assign, visit: sortedVisits, timeline: getMonitoringTimeline(sortedVisits)};
|
||||
}) as [MonitoringSlot, MonitoringSlot];
|
||||
};
|
||||
|
||||
@@ -49,21 +123,55 @@ export const getReviewRows = (performance: Partial<PerformanceFull>) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const getWrittenReviewRows = (performance: Partial<PerformanceFull>) => {
|
||||
const reviewRows = getReviewRows(performance).filter(({review}) => review.reviewType !== LOCAL_GOVERNMENT_REVIEW_TYPE);
|
||||
export const getMonitoringReviewByIndex = (
|
||||
performance: Partial<PerformanceFull>,
|
||||
index: 0 | 1,
|
||||
slot?: MonitoringSlot
|
||||
) => {
|
||||
const assignedUserId = slot?.assign?.assignUser;
|
||||
const assignedReview = assignedUserId
|
||||
? (performance.performanceReviewMap?.[assignedUserId] ?? []).find((review) => review.reviewType === MONITORING_ASSIGN_TYPE)
|
||||
: undefined;
|
||||
|
||||
return assignedReview && assignedUserId
|
||||
? {userId: assignedUserId, review: assignedReview}
|
||||
: undefined;
|
||||
};
|
||||
|
||||
export const getMonitoringDisplayRow = (
|
||||
performance: Partial<PerformanceFull>,
|
||||
index: 0 | 1
|
||||
): MonitoringDisplayRow => {
|
||||
const slot = getMonitoringSlots(performance)[index];
|
||||
const reviewRow = getMonitoringReviewByIndex(performance, index, slot);
|
||||
const visit = slot.visit?.[0];
|
||||
|
||||
return {
|
||||
index,
|
||||
reviewType: MONITORING_ASSIGN_TYPE,
|
||||
slot,
|
||||
userId: slot.assign?.assignUser,
|
||||
evidenceUserId: slot.timeline.arrival?.regUser || visit?.regUser || slot.assign?.assignUser,
|
||||
review: reviewRow?.review,
|
||||
};
|
||||
};
|
||||
|
||||
export const getWrittenReviewRows = (performance: Partial<PerformanceFull>): ReviewDisplayRow[] => {
|
||||
const writtenAssigns = (performance.performanceAssignList ?? [])
|
||||
.filter((assign) => assign.assignType === WRITTEN_REVIEW_ASSIGN_TYPE);
|
||||
const assignedUserIds = writtenAssigns.map((assign) => assign.assignUser);
|
||||
|
||||
const reviewRows = getReviewRows(performance).filter(({userId, review}) =>
|
||||
review.reviewType === WRITTEN_REVIEW_ASSIGN_TYPE &&
|
||||
assignedUserIds.includes(userId)
|
||||
);
|
||||
|
||||
const reviewByUser = new Map(reviewRows.map((row) => [row.userId, row.review]));
|
||||
|
||||
const assignedUserIds = (performance.performanceAssignList ?? [])
|
||||
.filter((assign) => assign.assignType !== MONITORING_ASSIGN_TYPE)
|
||||
.map((assign) => assign.assignUser);
|
||||
|
||||
const userIds = Array.from(new Set([...assignedUserIds, ...reviewRows.map((row) => row.userId)]));
|
||||
|
||||
return userIds.map((userId) => ({
|
||||
userId,
|
||||
assign: (performance.performanceAssignList ?? []).find(
|
||||
(assign) => assign.assignType !== MONITORING_ASSIGN_TYPE && assign.assignUser === userId
|
||||
),
|
||||
assign: writtenAssigns.find((assign) => assign.assignUser === userId),
|
||||
review: reviewByUser.get(userId),
|
||||
}));
|
||||
};
|
||||
@@ -88,10 +196,35 @@ export const getMonitoringRecordedUser = (visit?: PerformanceMonitoringVisit) =>
|
||||
};
|
||||
|
||||
export const isReviewComplete = (review?: PerformanceReview) => {
|
||||
return Boolean(review?.pdfFileName || review?.pdfConvert);
|
||||
return review?.reviewStatus === 10;
|
||||
};
|
||||
|
||||
const normalizeStatusLabel = (label?: string) => label?.replace(/\s/g, "") ?? "";
|
||||
export const getReviewFilterValue = (
|
||||
review: PerformanceReview | undefined,
|
||||
label: string | undefined,
|
||||
{
|
||||
isWrittenReviewer = false,
|
||||
allowInProgress = false,
|
||||
assigned = Boolean(review),
|
||||
alwaysAssigned = false,
|
||||
}: {
|
||||
isWrittenReviewer?: boolean;
|
||||
allowInProgress?: boolean;
|
||||
assigned?: boolean;
|
||||
alwaysAssigned?: boolean;
|
||||
} = {}
|
||||
) => {
|
||||
if (isWrittenReviewer) {
|
||||
return isReviewComplete(review)
|
||||
? STATUS_FILTER.DONE
|
||||
: STATUS_FILTER.INCOMPLETE;
|
||||
}
|
||||
|
||||
if (!alwaysAssigned && !assigned && !review) return STATUS_FILTER.UNASSIGNED;
|
||||
if (isReviewComplete(review)) return STATUS_FILTER.DONE;
|
||||
if (allowInProgress && labelHasInProgress(label)) return STATUS_FILTER.IN_PROGRESS;
|
||||
return STATUS_FILTER.PENDING;
|
||||
};
|
||||
|
||||
export const getReviewStatusDisplay = (
|
||||
label?: string,
|
||||
@@ -107,6 +240,14 @@ export const getReviewStatusDisplay = (
|
||||
return {label: label || "미진행", variant: "pending"};
|
||||
};
|
||||
|
||||
export const getReviewRecordedAt = (review?: PerformanceReview) => {
|
||||
return review?.reviewDt ? formatDateTime(new Date(review.reviewDt)) : "-";
|
||||
}
|
||||
|
||||
export const getCompleteRecordedAt = (review?: PerformanceReview) => {
|
||||
return isReviewComplete(review) ? getReviewRecordedAt(review) : "-";
|
||||
}
|
||||
|
||||
export const getWrittenReviewerSimpleReviewStatusDisplay = (
|
||||
review?: PerformanceReview,
|
||||
allowInProgress = false,
|
||||
@@ -121,15 +262,29 @@ export const getWrittenReviewerSimpleReviewStatusDisplay = (
|
||||
return {label: "미완료", variant: "pending"};
|
||||
};
|
||||
|
||||
export const getWrittenReviewerSimpleMonitoringStatusDisplay = (slot?: MonitoringSlot): StatusDisplay => {
|
||||
return slot?.visit
|
||||
? {label: "완료", variant: "done"}
|
||||
: {label: "미완료", variant: "pending"};
|
||||
export const getMonitoringFilterValue = (
|
||||
row: MonitoringDisplayRow,
|
||||
visitLabel: string | undefined,
|
||||
reviewLabel: string | undefined,
|
||||
isWrittenReviewer = false
|
||||
) => {
|
||||
if (isWrittenReviewer) {
|
||||
return isReviewComplete(row.review)
|
||||
? STATUS_FILTER.DONE
|
||||
: STATUS_FILTER.INCOMPLETE;
|
||||
}
|
||||
|
||||
if (isReviewComplete(row.review)) return STATUS_FILTER.DONE;
|
||||
if (!row.slot.assign && !row.slot.visit?.length) return STATUS_FILTER.UNASSIGNED;
|
||||
if (!row.slot.visit?.length) return STATUS_FILTER.PENDING;
|
||||
if (labelHasDeparted(visitLabel)) return STATUS_FILTER.DEPARTED;
|
||||
if (labelHasArrived(visitLabel)) return STATUS_FILTER.ARRIVED;
|
||||
return STATUS_FILTER.PENDING;
|
||||
};
|
||||
|
||||
export const getMonitoringStatusDisplay = (label?: string, slot?: MonitoringSlot): StatusDisplay => {
|
||||
if (!slot?.assign) return {label: "미배치", variant: "danger"};
|
||||
if (!slot.visit) return {label: "미진행", variant: "pending"};
|
||||
if (!slot?.assign && !slot?.visit?.length) return {label: "미배치", variant: "danger"};
|
||||
if (!slot?.visit?.length) return {label: "미진행", variant: "pending"};
|
||||
|
||||
const normalized = normalizeStatusLabel(label);
|
||||
if (normalized.includes("완료")) return {label: label || "완료", variant: "done"};
|
||||
@@ -139,6 +294,22 @@ export const getMonitoringStatusDisplay = (label?: string, slot?: MonitoringSlot
|
||||
return {label: label || "미진행", variant: "pending"};
|
||||
};
|
||||
|
||||
export const getMonitoringDisplayStatus = (
|
||||
row: MonitoringDisplayRow,
|
||||
visitLabel?: string,
|
||||
reviewLabel?: string,
|
||||
isWrittenReviewer = false
|
||||
): StatusDisplay => {
|
||||
if (isWrittenReviewer) {
|
||||
return isReviewComplete(row.review)
|
||||
? {label: "완료", variant: "done"}
|
||||
: {label: "미완료", variant: "pending"};
|
||||
}
|
||||
|
||||
if (isReviewComplete(row.review)) return {label: reviewLabel || "완료", variant: "done"};
|
||||
return getMonitoringStatusDisplay(visitLabel, row.slot);
|
||||
};
|
||||
|
||||
export const getAssignStatusDisplay = (confirmed: boolean): StatusDisplay => {
|
||||
return confirmed
|
||||
? {label: "확정", variant: "done"}
|
||||
|
||||
@@ -102,6 +102,20 @@ const isJsonContentType = (ctype: string) => {
|
||||
return ct.includes("application/json") || ct.includes("+json")
|
||||
}
|
||||
|
||||
const getErrorMessage = (data: unknown) => {
|
||||
if (typeof data === "object" && data !== null) {
|
||||
const error = data as { detail?: unknown; message?: unknown; errMessage?: unknown };
|
||||
return (
|
||||
(typeof error.detail === "string" && error.detail) ||
|
||||
(typeof error.message === "string" && error.message) ||
|
||||
(typeof error.errMessage === "string" && error.errMessage) ||
|
||||
undefined
|
||||
);
|
||||
}
|
||||
|
||||
return typeof data === "string" && data ? data : undefined;
|
||||
};
|
||||
|
||||
export const createHttpClient = (baseURL: string, opts: HttpClientOptions = {}) => {
|
||||
const {
|
||||
getToken,
|
||||
@@ -179,7 +193,7 @@ export const createHttpClient = (baseURL: string, opts: HttpClientOptions = {})
|
||||
}
|
||||
|
||||
const autoLogout = options.autoLogoutOnAuthError ?? true;
|
||||
const suppressAlert = options.suppressAlert ?? true;
|
||||
const suppressAlert = options.suppressAlert ?? options.method === "GET";
|
||||
|
||||
if (res.status === 401) options.onAuthError?.();
|
||||
|
||||
@@ -191,12 +205,7 @@ export const createHttpClient = (baseURL: string, opts: HttpClientOptions = {})
|
||||
}
|
||||
|
||||
if (!suppressAlert && typeof window !== "undefined") {
|
||||
const serverMsg =
|
||||
typeof parsedError === "object" && parsedError !== null && "message" in parsedError
|
||||
? String((parsedError as { message?: unknown }).message ?? "")
|
||||
: typeof parsedError === "string"
|
||||
? parsedError
|
||||
: undefined;
|
||||
const serverMsg = getErrorMessage(parsedError);
|
||||
|
||||
const msg = setErrorMessage?.(res.status, serverMsg) ?? (serverMsg ?? `HTTP ${res.status}`);
|
||||
alert(`[${res.status}] ${msg}`);
|
||||
@@ -223,7 +232,7 @@ export const createHttpClient = (baseURL: string, opts: HttpClientOptions = {})
|
||||
|
||||
if (!res.ok) {
|
||||
const autoLogout = options.autoLogoutOnAuthError ?? true;
|
||||
const suppressAlert = options.suppressAlert ?? true;
|
||||
const suppressAlert = options.suppressAlert ?? options.method === "GET";
|
||||
|
||||
if (res.status === 401) options.onAuthError?.();
|
||||
|
||||
@@ -235,12 +244,7 @@ export const createHttpClient = (baseURL: string, opts: HttpClientOptions = {})
|
||||
}
|
||||
|
||||
if (!suppressAlert && typeof window !== "undefined") {
|
||||
const serverMsg =
|
||||
typeof parsed === "object" && parsed !== null && "message" in parsed
|
||||
? String((parsed as { message?: unknown }).message ?? "")
|
||||
: typeof parsed === "string"
|
||||
? parsed
|
||||
: undefined;
|
||||
const serverMsg = getErrorMessage(parsed);
|
||||
|
||||
const msg = setErrorMessage?.(res.status, serverMsg) ?? (serverMsg ?? `HTTP ${res.status}`);
|
||||
alert(`[${res.status}] ${msg}`);
|
||||
|
||||
@@ -15,5 +15,5 @@ export const qk = {
|
||||
|
||||
monitoringEvidence: (performanceId: number, userId: string) => ["monitoring", "evidence", performanceId, userId] as const,
|
||||
|
||||
review: (performanceId: number, reviewType: number) => ["review", performanceId, reviewType] as const,
|
||||
review: (performanceId: number, reviewType: number, userId?: string) => ["review", performanceId, reviewType, userId] as const,
|
||||
} as const;
|
||||
|
||||
@@ -5,11 +5,11 @@ import {nextApi} from "@/lib/http-client";
|
||||
import {qk} from "@/query/key/keys";
|
||||
import {PerformanceReview} from "@/types/gwcf";
|
||||
|
||||
export function useReviewFileQuery(performanceId: number, reviewType: number, enabled: boolean = true) {
|
||||
export function useReviewFileQuery(performanceId: number, reviewType: number, userId?: string, enabled: boolean = true) {
|
||||
return useQuery({
|
||||
queryKey: qk.review(performanceId, reviewType),
|
||||
queryFn: () => nextApi.get<PerformanceReview>(`/review/${performanceId}/${reviewType}`),
|
||||
enabled: enabled && performanceId > 0 && reviewType > 0,
|
||||
queryKey: qk.review(performanceId, reviewType, userId),
|
||||
queryFn: () => nextApi.get<PerformanceReview>(`/review/${performanceId}/${reviewType}/${encodeURIComponent(userId ?? "")}`),
|
||||
enabled: enabled && performanceId > 0 && reviewType > 0 && Boolean(userId),
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
});
|
||||
@@ -25,7 +25,7 @@ export function useUploadReviewFileMutation() {
|
||||
return nextApi.postForm<PerformanceReview>(`/review/${performanceId}/${reviewType}`, formData);
|
||||
},
|
||||
onSuccess: (_res, {performanceId, reviewType}) => {
|
||||
qc.invalidateQueries({ queryKey: qk.review(performanceId, reviewType) });
|
||||
qc.invalidateQueries({ queryKey: ["review", performanceId, reviewType] });
|
||||
qc.invalidateQueries({ queryKey: qk.performance(performanceId) });
|
||||
qc.invalidateQueries({ queryKey: ["performance", "list"] });
|
||||
},
|
||||
@@ -34,15 +34,15 @@ export function useUploadReviewFileMutation() {
|
||||
|
||||
export function useDownloadReviewOriginalMutation() {
|
||||
return useMutation({
|
||||
mutationFn: ({performanceId, reviewType}: {performanceId: number; reviewType: number}) =>
|
||||
nextApi.get<ArrayBuffer>(`/review/download/${performanceId}/${reviewType}`, {expectBinary: true}),
|
||||
mutationFn: ({performanceId, reviewType, userId}: {performanceId: number; reviewType: number; userId: string}) =>
|
||||
nextApi.get<ArrayBuffer>(`/review/download/${performanceId}/${reviewType}/${encodeURIComponent(userId)}`, {expectBinary: true}),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDownloadReviewPdfMutation() {
|
||||
return useMutation({
|
||||
mutationFn: ({performanceId, reviewType}: {performanceId: number; reviewType: number}) =>
|
||||
nextApi.get<ArrayBuffer>(`/review/pdf/${performanceId}/${reviewType}`, {expectBinary: true}),
|
||||
mutationFn: ({performanceId, reviewType, userId}: {performanceId: number; reviewType: number; userId: string}) =>
|
||||
nextApi.get<ArrayBuffer>(`/review/pdf/${performanceId}/${reviewType}/${encodeURIComponent(userId)}`, {expectBinary: true}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -50,8 +50,9 @@ export function useStartWrittenReviewMutation() {
|
||||
const qc = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (performanceId: number) => nextApi.post<void>(`/review/start/${performanceId}`),
|
||||
onSuccess: (_res, performanceId) => {
|
||||
mutationFn: ({performanceId, userId}: {performanceId: number; userId: string}) =>
|
||||
nextApi.post<void>(`/review/start/${performanceId}/${encodeURIComponent(userId)}`),
|
||||
onSuccess: (_res, {performanceId}) => {
|
||||
qc.invalidateQueries({ queryKey: qk.performance(performanceId) });
|
||||
qc.invalidateQueries({ queryKey: ["performance", "list"] });
|
||||
},
|
||||
|
||||
@@ -52,9 +52,9 @@ export type PerformanceApplyCount = {
|
||||
};
|
||||
|
||||
export type MonitoringGpsRequest = {
|
||||
gpsLatitude: number;
|
||||
gpsLongitude: number;
|
||||
gpsAccuracyM: number;
|
||||
gpsLatitude: number | null;
|
||||
gpsLongitude: number | null;
|
||||
gpsAccuracyM: number | null;
|
||||
gpsRaw: Record<string, unknown>;
|
||||
};
|
||||
|
||||
@@ -112,7 +112,8 @@ export type PerformanceMonitoringVisit = {
|
||||
export type PerformanceReview = {
|
||||
performanceId: number;
|
||||
reviewType: number;
|
||||
regUser?: string;
|
||||
regUser: string;
|
||||
reviewDt: string;
|
||||
reviewStatus: number;
|
||||
uploadFileName: string;
|
||||
pdfConvert: boolean;
|
||||
|
||||
Reference in New Issue
Block a user