develop #3
@@ -11,20 +11,26 @@ import {DataTableColumn} from "@/components/data-table/DataTable.type";
|
||||
import {SmsSendDialog} from "@/components/dialog/SmsSendDialog";
|
||||
import {AssignMonitoringDialog} from "@/components/dialog/AssignMonitoringDialog";
|
||||
import {useCodesQuery} from "@/query/code";
|
||||
import {usePerformanceListQuery} from "@/query/performance";
|
||||
import {usePerformanceDetailQuery, usePerformanceListQuery} from "@/query/performance";
|
||||
import {
|
||||
useMonitoringApplyUserCountsQuery,
|
||||
useMonitoringApplyUsersQuery,
|
||||
useSaveMonitoringAssignMutation,
|
||||
} from "@/query/assign";
|
||||
import {filterPerformance, getCodeLabel} from "@/lib/gwcf/view";
|
||||
import {MONITORING_ASSIGN_TYPE} from "@/lib/gwcf/performance-status";
|
||||
import {
|
||||
isAssignConfirmed,
|
||||
isAssignRejected, isAssignRequested,
|
||||
MONITORING_ASSIGN_TYPE
|
||||
} from "@/lib/gwcf/performance-status";
|
||||
import {PerformanceAssign, PerformanceFull} from "@/types/gwcf";
|
||||
import {useDialog} from "@/hooks/useDialog";
|
||||
import {useMounted} from "@/hooks/useMounted";
|
||||
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
|
||||
import {SMS_TEMPLATE_IDS} from "@/query/notification";
|
||||
import {buildPerformanceSmsParams} from "@/lib/gwcf/notification";
|
||||
import {PERFORMANCE_FIELD_LABELS} from "@/lib/gwcf/field-labels";
|
||||
import {useDebouncedValue} from "@/hooks/useDebouncedValue";
|
||||
|
||||
const AssignPage = () => {
|
||||
const mounted = useMounted();
|
||||
@@ -41,11 +47,18 @@ const AssignPage = () => {
|
||||
monitoringDate: "",
|
||||
keyword: "",
|
||||
});
|
||||
const debouncedFilters = useDebouncedValue(filters);
|
||||
const [selected, setSelected] = useState<PerformanceFull | null>(null);
|
||||
const smsAddParam = useMemo(() => selected ? buildPerformanceSmsParams(selected) : {}, [selected]);
|
||||
|
||||
const [assignSaveTargetIds, setAssignSaveTargetIds] = useState<string[]>([]);
|
||||
const filtersInitializedRef = useRef(false);
|
||||
|
||||
type SmsMode = "assignConfirm" | "normal";
|
||||
const [smsMode, setSmsMode] = useState<SmsMode>("assignConfirm");
|
||||
const [smsTargetIds, setSmsTargetIds] = useState<string[]>([]);
|
||||
const [smsTemplateIdx, setSmsTemplateIdx] = useState<number[]>([]);
|
||||
const [smsDialogTitle, setSmsDialogTitle] = useState<string>("");
|
||||
const [newSmsTemplateIdx, setNewSmsTemplateIdx] = useState<number|undefined>(undefined);
|
||||
const smsAddParam = useMemo(() => selected ? buildPerformanceSmsParams(selected) : {}, [selected]);
|
||||
|
||||
const refreshAssignList = () => {
|
||||
void refetchPerformanceList();
|
||||
@@ -54,9 +67,17 @@ const AssignPage = () => {
|
||||
|
||||
const updateFilters = (updater: (prev: typeof filters) => typeof filters) => {
|
||||
setFilters(updater);
|
||||
refreshAssignList();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!filtersInitializedRef.current) {
|
||||
filtersInitializedRef.current = true;
|
||||
return;
|
||||
}
|
||||
|
||||
refreshAssignList();
|
||||
}, [debouncedFilters, refetchApplyCounts, refetchPerformanceList]);
|
||||
|
||||
useEffect(() => {
|
||||
hideDialog("assignMonitoringDialog");
|
||||
hideDialog("assignSmsSendDialog");
|
||||
@@ -82,13 +103,13 @@ const AssignPage = () => {
|
||||
|
||||
const filteredData = useMemo(() => {
|
||||
return data
|
||||
.filter((item) => filterPerformance(item, filters))
|
||||
.filter((item) => filterPerformance(item, debouncedFilters))
|
||||
.sort((a, b) => {
|
||||
const aDate = a.performanceMonitoringSchedule?.monitoringDate ?? "";
|
||||
const bDate = b.performanceMonitoringSchedule?.monitoringDate ?? "";
|
||||
return bDate.localeCompare(aDate);
|
||||
});
|
||||
}, [data, filters]);
|
||||
}, [data, debouncedFilters]);
|
||||
|
||||
const openAssign = (performance: PerformanceFull) => {
|
||||
suppressAssignCloseRef.current = false;
|
||||
@@ -114,29 +135,76 @@ const AssignPage = () => {
|
||||
return (performance.performanceAssignList ?? []).filter((assign) => assign.assignType === MONITORING_ASSIGN_TYPE);
|
||||
};
|
||||
|
||||
const smsBeforeSendProps =
|
||||
smsMode === "assignConfirm"
|
||||
? {
|
||||
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,
|
||||
}
|
||||
: {};
|
||||
|
||||
const columns = useMemo<DataTableColumn<PerformanceFull>[]>(() => [
|
||||
{accessorKey: "id", header: "연번", cell: ({row}) => row.original.id, enableSorting: true},
|
||||
{accessorKey: "performanceName", header: "사업명", enableSorting: true},
|
||||
{id: "area", header: "지역", cell: ({row}) => getCodeLabel(codes, "area", row.original.performanceArea)},
|
||||
{accessorKey: "performanceDtInfo", header: "사업 일정"},
|
||||
{accessorKey: "performanceTimeInfo", header: "운영 시간"},
|
||||
{id: "monitoringDate", header: "모니터링 일정", cell: ({row}) => row.original.performanceMonitoringSchedule?.monitoringDate ?? "", enableSorting: true},
|
||||
{id: "monitoringTime", header: "모니터링 시간", cell: ({row}) => row.original.performanceMonitoringSchedule?.monitoringTimeInfo ?? ""},
|
||||
{id: "applyCount", header: "신청자 수", cell: ({row}) => applyCountMap.get(String(row.original.id)) ?? 0, enableSorting: true},
|
||||
{id: "requestCount", header: "확정요청 수", cell: ({row}) => getMonitoringAssigns(row.original).length},
|
||||
{id: "confirmedCount", header: "확정인원 수", cell: ({row}) => getMonitoringAssigns(row.original).filter((assign) => assign.assignConfirm).length},
|
||||
{accessorKey: "id", header: PERFORMANCE_FIELD_LABELS.id, cell: ({row}) => row.original.id},
|
||||
{
|
||||
accessorKey: "performanceName",
|
||||
header: PERFORMANCE_FIELD_LABELS.performanceName,
|
||||
cell: ({row}) => (
|
||||
<div className="max-w-[400px] truncate" title={row.original.performanceName}>
|
||||
{row.original.performanceName}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{id: "area", header: PERFORMANCE_FIELD_LABELS.performanceArea, cell: ({row}) => getCodeLabel(codes, "area", row.original.performanceArea)},
|
||||
{
|
||||
accessorKey: "performanceDtInfo",
|
||||
header: PERFORMANCE_FIELD_LABELS.performanceDtInfo,
|
||||
cell: ({row}) => (
|
||||
<div className="max-w-[250px] truncate" title={row.original.performanceDtInfo}>
|
||||
{row.original.performanceDtInfo}
|
||||
</div>
|
||||
),
|
||||
enableSorting: false
|
||||
},
|
||||
{
|
||||
accessorKey: "performanceTimeInfo",
|
||||
header: PERFORMANCE_FIELD_LABELS.performanceTimeInfo,
|
||||
cell: ({row}) => (
|
||||
<div className="max-w-[250px] truncate" title={row.original.performanceTimeInfo}>
|
||||
{row.original.performanceTimeInfo}
|
||||
</div>
|
||||
),
|
||||
enableSorting: false
|
||||
},
|
||||
{id: "monitoringDate", header: PERFORMANCE_FIELD_LABELS.monitoringDate, accessorFn:(row) => row.performanceMonitoringSchedule?.monitoringDate ?? "", cell: ({row}) => row.original.performanceMonitoringSchedule?.monitoringDate ?? ""},
|
||||
{id: "monitoringTime", header: PERFORMANCE_FIELD_LABELS.monitoringTimeInfo, cell: ({row}) => row.original.performanceMonitoringSchedule?.monitoringTimeInfo ?? ""},
|
||||
{id: "applyCount", header: "신청자 수", accessorFn:((row) => applyCountMap.get(String(row.id)) ?? 0), cell: ({row}) => applyCountMap.get(String(row.original.id)) ?? 0},
|
||||
{id: "requestedCount", header: "확정요청 수", accessorFn:((row) => getMonitoringAssigns(row).filter(isAssignRequested).length), cell: ({row}) => getMonitoringAssigns(row.original).filter(isAssignRequested).length},
|
||||
{id: "rejectedCount", header: "포기인원 수", accessorFn:((row) => getMonitoringAssigns(row).filter(isAssignRejected).length), cell: ({row}) => getMonitoringAssigns(row.original).filter(isAssignRejected).length},
|
||||
{id: "confirmedCount", header: "확정인원 수", accessorFn:((row) => getMonitoringAssigns(row).filter(isAssignConfirmed).length), cell: ({row}) => getMonitoringAssigns(row.original).filter(isAssignConfirmed).length},
|
||||
], [applyCountMap, codes]);
|
||||
|
||||
const {data: detailData} = usePerformanceDetailQuery(selected?.id ?? 0, Boolean(selected?.id && assignOpen));
|
||||
|
||||
if(!mounted) return <LoadingOverlay force={true} />
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<PagePanel>
|
||||
<div className="grid gap-2 md:grid-cols-[160px_160px_180px_1fr_auto]">
|
||||
<MultiFilterSelect value={filters.businessType} onChange={(value) => updateFilters((prev) => ({...prev, businessType: value}))} options={codes.business_type} placeholder="사업 유형" />
|
||||
<MultiFilterSelect value={filters.area} onChange={(value) => updateFilters((prev) => ({...prev, area: value}))} options={codes.area} placeholder="지역" />
|
||||
<MultiFilterSelect value={filters.businessType} onChange={(value) => updateFilters((prev) => ({...prev, businessType: value}))} options={codes.business_type} placeholder={PERFORMANCE_FIELD_LABELS.businessType} />
|
||||
<MultiFilterSelect value={filters.area} onChange={(value) => updateFilters((prev) => ({...prev, area: value}))} options={codes.area} placeholder={PERFORMANCE_FIELD_LABELS.performanceArea} />
|
||||
<Input type="date" value={filters.monitoringDate} onChange={(event) => updateFilters((prev) => ({...prev, monitoringDate: event.target.value}))} />
|
||||
<Input value={filters.keyword} onChange={(event) => updateFilters((prev) => ({...prev, keyword: event.target.value}))} placeholder="연번 or 사업명" />
|
||||
<Input value={filters.keyword} onChange={(event) => updateFilters((prev) => ({...prev, keyword: event.target.value}))} placeholder={`${PERFORMANCE_FIELD_LABELS.id} or ${PERFORMANCE_FIELD_LABELS.performanceName}`} />
|
||||
<Button type="button" variant="outline" onClick={refreshAssignList}>
|
||||
<Search className="h-4 w-4" />
|
||||
검색
|
||||
@@ -161,7 +229,7 @@ const AssignPage = () => {
|
||||
hideDialog("assignMonitoringDialog");
|
||||
refreshAssignList();
|
||||
}}
|
||||
selected={selected}
|
||||
selected={detailData ?? selected}
|
||||
codes={codes}
|
||||
applyUsers={applyUsers}
|
||||
isSavingAssign={saveAssignMutation.isPending}
|
||||
@@ -171,10 +239,29 @@ const AssignPage = () => {
|
||||
{onSuccess: (monitoringAssigns) => applySavedAssignsToSelected(performanceId, monitoringAssigns)}
|
||||
)
|
||||
}
|
||||
onOpenSms={(assignUserIds, smsUserIds) => {
|
||||
onOpenAssignSms={(assignUserIds, smsUserIds) => {
|
||||
suppressAssignCloseRef.current = true;
|
||||
|
||||
setAssignSaveTargetIds(assignUserIds);
|
||||
setSmsTargetIds(smsUserIds);
|
||||
|
||||
setSmsMode("assignConfirm");
|
||||
setSmsTemplateIdx([SMS_TEMPLATE_IDS.ASSIGN_CONFIRM])
|
||||
setSmsDialogTitle("확정 문자 발송")
|
||||
setNewSmsTemplateIdx(undefined);
|
||||
|
||||
showDialog("assignSmsSendDialog", false);
|
||||
}}
|
||||
onOpenNormalSms={(smsUserIds) => {
|
||||
suppressAssignCloseRef.current = true;
|
||||
|
||||
setSmsTargetIds(smsUserIds);
|
||||
|
||||
setSmsMode("normal");
|
||||
setSmsTemplateIdx([SMS_TEMPLATE_IDS.INFORM_ASSIGN, SMS_TEMPLATE_IDS.REMIND_ASSIGN])
|
||||
setSmsDialogTitle("문자 발송")
|
||||
setNewSmsTemplateIdx(SMS_TEMPLATE_IDS.CUSTOM);
|
||||
|
||||
showDialog("assignSmsSendDialog", false);
|
||||
}}
|
||||
/>
|
||||
@@ -194,21 +281,13 @@ const AssignPage = () => {
|
||||
suppressAssignCloseRef.current = false;
|
||||
}, 0);
|
||||
}}
|
||||
title="확정 문자 발송"
|
||||
templateIdx={SMS_TEMPLATE_IDS.ASSIGN_CONFIRM}
|
||||
newMessageTemplateIdx={SMS_TEMPLATE_IDS.CUSTOM}
|
||||
title={smsDialogTitle}
|
||||
templateIdx={smsTemplateIdx}
|
||||
newMessageTemplateIdx={newSmsTemplateIdx}
|
||||
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}
|
||||
denyParamKeys={["userCmpn", "userTeam", "userRole", "id"]}
|
||||
{...smsBeforeSendProps}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -17,13 +17,16 @@ import {useMounted} from "@/hooks/useMounted";
|
||||
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
|
||||
import {toLocalDateString} from "@/lib/gwcf/date";
|
||||
import {
|
||||
getMonitoringDisplayRow,
|
||||
getMonitoringDisplayRow, getMonitoringDisplayStatus, isAssignConfirmed,
|
||||
} from "@/lib/gwcf/performance-status";
|
||||
import {PERFORMANCE_FIELD_LABELS} from "@/lib/gwcf/field-labels";
|
||||
import {getCodeLabel} from "@/lib/gwcf/view";
|
||||
import {StatusPill} from "@/components/gwcf/StatusPill";
|
||||
|
||||
const today = toLocalDateString();
|
||||
const todayTime = new Date(`${today}T00:00:00`).getTime();
|
||||
|
||||
const toDateTime = (date?: string) => {
|
||||
const toDateTime = (date?: string | null) => {
|
||||
if (!date) return Number.POSITIVE_INFINITY;
|
||||
const time = new Date(`${date}T00:00:00`).getTime();
|
||||
return Number.isNaN(time) ? Number.POSITIVE_INFINITY : time;
|
||||
@@ -75,7 +78,6 @@ const MonitoringPage = () => {
|
||||
const userId = auth.user?.userId;
|
||||
|
||||
const [selectedId, setSelectedId] = useState<number | null>(null);
|
||||
const [detailId, setDetailId] = useState<number | null>(null);
|
||||
const [visitMode, setVisitMode] = useState<"departure" | "arrival">("departure");
|
||||
|
||||
const refreshMonitoringList = () => {
|
||||
@@ -85,7 +87,7 @@ const MonitoringPage = () => {
|
||||
const assignedItems = useMemo(() => {
|
||||
if (!userId) return [];
|
||||
return data.filter((item) =>
|
||||
item.performanceAssignList?.some((assign) => assign.assignUser === userId && assign.assignConfirm)
|
||||
item.performanceAssignList?.some((assign) => assign.assignUser === userId && isAssignConfirmed(assign))
|
||||
);
|
||||
}, [data, userId]);
|
||||
|
||||
@@ -97,11 +99,6 @@ const MonitoringPage = () => {
|
||||
return sortedItems.find((item) => item.id === selectedId) ?? sortedItems[0] ?? null;
|
||||
}, [selectedId, sortedItems]);
|
||||
|
||||
const detailSelected = useMemo(() => {
|
||||
if (!detailId) return null;
|
||||
return sortedItems.find((item) => item.id === detailId) ?? null;
|
||||
}, [detailId, sortedItems]);
|
||||
|
||||
const selectedMonitoringRow = useMemo(() => {
|
||||
if (!selected || !userId) return undefined;
|
||||
return ([0, 1] as const)
|
||||
@@ -114,28 +111,45 @@ const MonitoringPage = () => {
|
||||
const columns = useMemo<DataTableColumn<PerformanceFull>[]>(() => [
|
||||
{
|
||||
accessorKey: "performanceName",
|
||||
header: "사업명",
|
||||
cell: ({row}) => (
|
||||
<div className="max-w-[180px] whitespace-normal py-2 text-sm font-semibold leading-5">
|
||||
{row.original.performanceName}
|
||||
header: PERFORMANCE_FIELD_LABELS.performanceName,
|
||||
cell: ({row}) => {
|
||||
if (!row.original || !userId) return undefined;
|
||||
const prow = ([0, 1] as const)
|
||||
.map((index) => getMonitoringDisplayRow(row.original, index))
|
||||
.find((item) => item.userId === userId);
|
||||
|
||||
const latestVisit = prow?.slot.visit?.[0];
|
||||
const status = prow
|
||||
? getMonitoringDisplayStatus(
|
||||
prow,
|
||||
getCodeLabel(codes, "monitoring_visit_status", latestVisit?.monitoringVisitStatus),
|
||||
getCodeLabel(codes, "review_status", prow?.review?.reviewStatus)
|
||||
)
|
||||
: {label: "미배치", variant: "danger" as const};
|
||||
|
||||
return (
|
||||
<div className="max-w-[180px] whitespace-normal py-2 text-sm font-semibold leading-5">
|
||||
{row.original.performanceName}<br/>
|
||||
<StatusPill variant={status.variant}>{status.label}</StatusPill>
|
||||
</div>
|
||||
),
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "monitoringDate",
|
||||
header: "일정",
|
||||
cell: ({row}) => row.original.performanceMonitoringSchedule?.monitoringDate?.slice(5) || "-",
|
||||
header: PERFORMANCE_FIELD_LABELS.monitoringDate,
|
||||
cell: ({row}) => row.original.performanceMonitoringSchedule?.monitoringDate?.slice(5) ?? "",
|
||||
},
|
||||
{
|
||||
id: "monitoringTime",
|
||||
header: "시간",
|
||||
header: PERFORMANCE_FIELD_LABELS.monitoringTimeInfo,
|
||||
cell: ({row}) => row.original.performanceMonitoringSchedule?.monitoringTimeInfo || "-",
|
||||
},
|
||||
], []);
|
||||
], [codes]);
|
||||
|
||||
const visitOpen = isDialogOpen("monitoringVisitDialog");
|
||||
const detailOpen = isDialogOpen("monitoringDetailDialog");
|
||||
const {data: detailData} = usePerformanceDetailQuery(detailId ?? 0, Boolean(detailId && detailOpen));
|
||||
const {data: detailData} = usePerformanceDetailQuery(selectedId ?? 0, Boolean(selectedId && detailOpen));
|
||||
|
||||
const openVisit = (mode: "departure" | "arrival") => {
|
||||
setVisitMode(mode);
|
||||
@@ -239,14 +253,14 @@ const MonitoringPage = () => {
|
||||
{selected && (
|
||||
<section className="rounded-md border">
|
||||
<div className="border-b bg-muted px-3 py-2 text-center font-semibold">
|
||||
{selected.performanceMonitoringSchedule?.monitoringDate} {selected.performanceMonitoringSchedule?.monitoringTimeInfo}
|
||||
{[selected.performanceMonitoringSchedule?.monitoringDate, selected.performanceMonitoringSchedule?.monitoringTimeInfo].filter(Boolean).join(" ")}
|
||||
</div>
|
||||
<div className="grid grid-cols-[80px_1fr] border-b">
|
||||
<div className="bg-muted px-3 py-2 text-sm font-semibold">사업명</div>
|
||||
<div className="bg-muted px-3 py-2 text-sm font-semibold">{PERFORMANCE_FIELD_LABELS.performanceName}</div>
|
||||
<div className="px-3 py-2 text-sm">{selected.performanceName}</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-[80px_1fr]">
|
||||
<div className="bg-muted px-3 py-2 text-sm font-semibold">장소</div>
|
||||
<div className="bg-muted px-3 py-2 text-sm font-semibold">{PERFORMANCE_FIELD_LABELS.monitoringAddress}</div>
|
||||
<div className="px-3 py-2 text-sm">{selected.performanceMonitoringSchedule?.monitoringAddress}</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -270,7 +284,7 @@ const MonitoringPage = () => {
|
||||
getRowId={(row) => String(row.id)}
|
||||
selectMode="click-event"
|
||||
onRowClick={(item) => {
|
||||
setDetailId(item.id);
|
||||
setSelectedId(item.id);
|
||||
showDialog("monitoringDetailDialog");
|
||||
}}
|
||||
highlightRowIds={selected ? [String(selected.id)] : []}
|
||||
@@ -307,10 +321,9 @@ const MonitoringPage = () => {
|
||||
}
|
||||
|
||||
hideDialog("monitoringDetailDialog");
|
||||
setDetailId(null);
|
||||
refreshMonitoringList();
|
||||
}}
|
||||
performance={detailData ?? detailSelected}
|
||||
performance={detailData ?? selected}
|
||||
codes={codes}
|
||||
userId={userId}
|
||||
/>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import {useCallback, useMemo, useRef, useState} from "react";
|
||||
import {useCallback, useEffect, useMemo, useRef, useState} from "react";
|
||||
import {Search, Upload} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Input} from "@/components/ui/input";
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
useUploadPerformanceExcelMutation,
|
||||
} from "@/query/performance";
|
||||
import {useUploadWrittenAssignExcelMutation} from "@/query/assign";
|
||||
import {useDownloadReviewOriginalMutation, useDownloadReviewPdfMutation} from "@/query/review";
|
||||
import {useDownloadReviewOriginalByPerformanceMutation, useDownloadReviewOriginalMutation, useDownloadReviewPdfMutation} from "@/query/review";
|
||||
import {filterPerformance, getCodeLabel, isInternalRole, isWrittenReviewerRole} from "@/lib/gwcf/view";
|
||||
import {
|
||||
getMonitoringDisplayRow,
|
||||
@@ -45,6 +45,7 @@ import {Code, PerformanceFull, PerformanceReview} from "@/types/gwcf";
|
||||
import {useDialog} from "@/hooks/useDialog";
|
||||
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
|
||||
import {useMounted} from "@/hooks/useMounted";
|
||||
import {useDebouncedValue} from "@/hooks/useDebouncedValue";
|
||||
import {
|
||||
downloadBlob,
|
||||
downloadExcelBuffer, getReviewOriginalDownloadName,
|
||||
@@ -52,6 +53,7 @@ import {
|
||||
openWrittenReviewWindow,
|
||||
} from "@/lib/gwcf/file";
|
||||
import ExcelDownloadButton from "@/components/common/ExcelDownloadButton";
|
||||
import {PERFORMANCE_FIELD_LABELS} from "@/lib/gwcf/field-labels";
|
||||
|
||||
type PerformanceFilters = {
|
||||
businessType: string[];
|
||||
@@ -59,6 +61,7 @@ type PerformanceFilters = {
|
||||
area: string[];
|
||||
startMonth: string[];
|
||||
monitoringDate: string;
|
||||
monitoringAdd: string[];
|
||||
localReviewStatus: string[];
|
||||
monitoring1Status: string[];
|
||||
monitoring2Status: string[];
|
||||
@@ -66,13 +69,44 @@ type PerformanceFilters = {
|
||||
keyword: string;
|
||||
};
|
||||
|
||||
const monthOptions: Code[] = Array.from({length: 12}, (_, index) => ({
|
||||
codeGroup: "month",
|
||||
codeValue: index + 1,
|
||||
codeGroupLabel: "사업 수행 월",
|
||||
codeLabel: `${index + 1}월`,
|
||||
memo: "",
|
||||
}));
|
||||
const monthOptions: Code[] = [
|
||||
{
|
||||
codeGroup: "month",
|
||||
codeValue: 0,
|
||||
codeGroupLabel: PERFORMANCE_FIELD_LABELS.performanceStartMonth,
|
||||
codeLabel: `미정`,
|
||||
memo: "",
|
||||
},
|
||||
...Array.from({length: 12}, (_, index) => ({
|
||||
codeGroup: "month",
|
||||
codeValue: index + 1,
|
||||
codeGroupLabel: PERFORMANCE_FIELD_LABELS.performanceStartMonth,
|
||||
codeLabel: `${index + 1}월`,
|
||||
memo: "",
|
||||
}))
|
||||
];
|
||||
|
||||
const monitoringAddOptions: Code[] = [
|
||||
{
|
||||
codeGroup: "monitoring_add",
|
||||
codeValue: 0,
|
||||
codeGroupLabel: PERFORMANCE_FIELD_LABELS.monitoringAdd,
|
||||
codeLabel: "추가 X",
|
||||
memo: "",
|
||||
},
|
||||
{
|
||||
codeGroup: "monitoring_add",
|
||||
codeValue: 1,
|
||||
codeGroupLabel: PERFORMANCE_FIELD_LABELS.monitoringAdd,
|
||||
codeLabel: "추가 O",
|
||||
memo: "",
|
||||
},
|
||||
];
|
||||
|
||||
const getPerformanceGroupKey = (performanceId: number) => {
|
||||
const id = String(performanceId);
|
||||
return id.length > 2 ? id.slice(0, -2) : id;
|
||||
};
|
||||
|
||||
const PerformancePage = () => {
|
||||
const mounted = useMounted();
|
||||
@@ -93,6 +127,7 @@ const PerformancePage = () => {
|
||||
const exportMutation = useExportPerformanceMutation();
|
||||
const reviewPdfMutation = useDownloadReviewPdfMutation();
|
||||
const reviewOriginalMutation = useDownloadReviewOriginalMutation();
|
||||
const reviewOriginalByPerformanceMutation = useDownloadReviewOriginalByPerformanceMutation();
|
||||
|
||||
const [filters, setFilters] = useState<PerformanceFilters>({
|
||||
businessType: [],
|
||||
@@ -100,14 +135,17 @@ const PerformancePage = () => {
|
||||
area: [],
|
||||
startMonth: [],
|
||||
monitoringDate: "",
|
||||
monitoringAdd: [],
|
||||
localReviewStatus: [],
|
||||
monitoring1Status: [],
|
||||
monitoring2Status: [],
|
||||
writtenReviewStatus: [],
|
||||
keyword: "",
|
||||
});
|
||||
const debouncedFilters = useDebouncedValue(filters);
|
||||
const [selectedId, setSelectedId] = useState<number | null>(null);
|
||||
const lastSelectedRef = useRef<number | null>(null);
|
||||
const filtersInitializedRef = useRef(false);
|
||||
|
||||
const detailOpen = isDialogOpen("performanceDetailDialog");
|
||||
const performanceRegisterOpen = isDialogOpen("performanceExcelRegisterDialog");
|
||||
@@ -120,9 +158,17 @@ const PerformancePage = () => {
|
||||
|
||||
const updateFilters = (updater: (prev: PerformanceFilters) => PerformanceFilters) => {
|
||||
setFilters(updater);
|
||||
refreshPerformanceList();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!filtersInitializedRef.current) {
|
||||
filtersInitializedRef.current = true;
|
||||
return;
|
||||
}
|
||||
|
||||
void refetchPerformanceList();
|
||||
}, [debouncedFilters, refetchPerformanceList]);
|
||||
|
||||
const handlePerformanceDetailOpenChange = (open: boolean) => {
|
||||
if (open) {
|
||||
showDialog("performanceDetailDialog");
|
||||
@@ -183,38 +229,39 @@ const PerformancePage = () => {
|
||||
|
||||
return (
|
||||
filterPerformance(item, {
|
||||
businessType: filters.businessType,
|
||||
genre: filters.genre,
|
||||
area: filters.area,
|
||||
monitoringDate: filters.monitoringDate,
|
||||
keyword: filters.keyword,
|
||||
businessType: debouncedFilters.businessType,
|
||||
genre: debouncedFilters.genre,
|
||||
area: debouncedFilters.area,
|
||||
monitoringDate: debouncedFilters.monitoringDate,
|
||||
keyword: debouncedFilters.keyword,
|
||||
}) &&
|
||||
matchesStatus(filters.startMonth, String(item.performanceStartMonth)) &&
|
||||
matchesStatus(filters.localReviewStatus, getReviewStatusFilterValue(
|
||||
matchesStatus(debouncedFilters.startMonth, String(item.performanceStartMonth)) &&
|
||||
matchesStatus(debouncedFilters.monitoringAdd, item.id % 100 === 1 ? "0" : "1") &&
|
||||
matchesStatus(debouncedFilters.localReviewStatus, getReviewStatusFilterValue(
|
||||
localReview,
|
||||
getCodeLabel(codes, "review_status", localReview?.reviewStatus),
|
||||
{isWrittenReviewer, alwaysAssigned: true}
|
||||
)) &&
|
||||
matchesStatus(filters.monitoring1Status, getMonitoringStatusFilterValue(
|
||||
matchesStatus(debouncedFilters.monitoring1Status, getMonitoringStatusFilterValue(
|
||||
monitoring1Row,
|
||||
getCodeLabel(codes, "monitoring_visit_status", monitoring1LatestVisit?.monitoringVisitStatus),
|
||||
getCodeLabel(codes, "review_status", monitoring1Row.review?.reviewStatus),
|
||||
isWrittenReviewer
|
||||
)) &&
|
||||
matchesStatus(filters.monitoring2Status, getMonitoringStatusFilterValue(
|
||||
matchesStatus(debouncedFilters.monitoring2Status, getMonitoringStatusFilterValue(
|
||||
monitoring2Row,
|
||||
getCodeLabel(codes, "monitoring_visit_status", monitoring2LatestVisit?.monitoringVisitStatus),
|
||||
getCodeLabel(codes, "review_status", monitoring2Row.review?.reviewStatus),
|
||||
isWrittenReviewer
|
||||
)) &&
|
||||
matchesStatus(filters.writtenReviewStatus, getReviewStatusFilterValue(
|
||||
matchesStatus(debouncedFilters.writtenReviewStatus, getReviewStatusFilterValue(
|
||||
writtenReviewRow?.review,
|
||||
getCodeLabel(codes, "review_status", writtenReviewRow?.review?.reviewStatus),
|
||||
{isWrittenReviewer, allowInProgress: true, assigned: Boolean(writtenReviewRow?.assign)}
|
||||
))
|
||||
);
|
||||
});
|
||||
}, [codes, data, filters, getVisibleWrittenReviewRow, isWrittenReviewer]);
|
||||
}, [codes, data, debouncedFilters, getVisibleWrittenReviewRow, isWrittenReviewer]);
|
||||
|
||||
const openDetail = (performance: PerformanceFull) => {
|
||||
if (isWrittenReviewer) return;
|
||||
@@ -237,6 +284,16 @@ const PerformancePage = () => {
|
||||
downloadBlob(buffer, getReviewOriginalDownloadName(performanceId, review.reviewType, review.uploadFileName));
|
||||
};
|
||||
|
||||
const downloadMonitoringReviews = async (performanceId: number) => {
|
||||
const reviewType = 1;
|
||||
try {
|
||||
const buffer = await reviewOriginalByPerformanceMutation.mutateAsync({performanceId, reviewType});
|
||||
downloadBlob(buffer, `모니터링-${performanceId}-${reviewType}.zip`, "application/zip");
|
||||
} catch {
|
||||
alert("다운로드할 모니터링 파일을 찾을 수 없습니다.");
|
||||
}
|
||||
};
|
||||
|
||||
const openWrittenReviewLink = (performanceId: number, userId?: string, complete = false) => {
|
||||
openWrittenReviewWindow(performanceId, userId, complete);
|
||||
};
|
||||
@@ -268,7 +325,7 @@ const PerformancePage = () => {
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<div className="flex min-w-24 justify-center text-xs">
|
||||
<div className="flex justify-center text-xs">
|
||||
<StatusPill
|
||||
variant={display.variant}
|
||||
onClick={onClick}
|
||||
@@ -298,7 +355,7 @@ const PerformancePage = () => {
|
||||
const visitUser = getMonitoringRecordedUser(latestVisit);
|
||||
|
||||
return (
|
||||
<div className="flex min-w-24 justify-center text-xs">
|
||||
<div className="flex justify-center text-xs">
|
||||
<StatusPill
|
||||
variant={display.variant}
|
||||
onClick={isReviewComplete(row.review) ? () => downloadReviewOriginal(performance.id, row.review) : undefined}
|
||||
@@ -317,26 +374,133 @@ const PerformancePage = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const renderWrittenReviewerMonitoringStatus = (performance: PerformanceFull) => {
|
||||
const groupKey = getPerformanceGroupKey(performance.id);
|
||||
const monitoringRows = data
|
||||
.filter((item) => getPerformanceGroupKey(item.id) === groupKey)
|
||||
.flatMap((item) => ([0, 1] as const).map((index) => getMonitoringDisplayRow(item, index)));
|
||||
|
||||
const completeCount = monitoringRows.filter((item) => isReviewComplete(item.review)).length;
|
||||
const totalCount = monitoringRows.length;
|
||||
const display = completeCount === 0
|
||||
? {label: "미완료", variant: "pending" as const}
|
||||
: completeCount === totalCount
|
||||
? {label: "완료", variant: "done" as const}
|
||||
: {label: "일부 완료", variant: "inprogress" as const};
|
||||
const onClick = completeCount > 0 ? () => downloadMonitoringReviews(performance.id) : undefined;
|
||||
|
||||
return (
|
||||
<div className="flex justify-center text-xs">
|
||||
<StatusPill
|
||||
variant={display.variant}
|
||||
onClick={onClick}
|
||||
tooltip={(
|
||||
<div className="space-y-1">
|
||||
<div>완료: {completeCount}</div>
|
||||
<div>전체: {totalCount}</div>
|
||||
</div>
|
||||
)}
|
||||
>
|
||||
{display.label}
|
||||
</StatusPill>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const columns = useMemo<DataTableColumn<PerformanceFull>[]>(() => [
|
||||
{accessorKey: "id", header: "연번", cell: ({row}) => row.original.id, enableSorting: true},
|
||||
{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: "performanceName", header: "사업명", enableSorting: true},
|
||||
{id: "startMonth", header: "사업 수행 월", cell: ({row}) => `${row.original.performanceStartMonth}월`, enableSorting: true},
|
||||
{accessorKey: "performanceDtInfo", header: "사업 일정"},
|
||||
{accessorKey: "performanceTimeInfo", header: "운영 시간"},
|
||||
...(!isWrittenReviewer ? [{
|
||||
id: "monitoringDate",
|
||||
header: "모니터링 일정",
|
||||
cell: ({row}) => row.original.performanceMonitoringSchedule?.monitoringDate ?? "",
|
||||
enableSorting: true,
|
||||
} satisfies DataTableColumn<PerformanceFull>] : []),
|
||||
{accessorKey: "no", header: PERFORMANCE_FIELD_LABELS.no,
|
||||
accessorFn: (row) => row.performanceDetail["performanceNo"] ?? "",
|
||||
cell: ({row}) => row.original.performanceDetail["performanceNo"] ?? "",
|
||||
},
|
||||
{accessorKey: "id", header: PERFORMANCE_FIELD_LABELS.id, cell: ({row}) => row.original.id},
|
||||
...(!isWrittenReviewer ? [
|
||||
{accessorKey: "monitoringAdd", header: PERFORMANCE_FIELD_LABELS.monitoringAdd,
|
||||
accessorFn: (row) => row.id % 100 !== 1? "추가" : "",
|
||||
cell: ({row}) => row.original.id % 100 !== 1? "추가" : "",
|
||||
enableSorting: false
|
||||
},
|
||||
]: []) as DataTableColumn<PerformanceFull>[],
|
||||
{
|
||||
id: "businessType",
|
||||
header: PERFORMANCE_FIELD_LABELS.businessType,
|
||||
cell: ({row}) => {
|
||||
const value = getCodeLabel(codes, "business_type", row.original.businessType);
|
||||
return (
|
||||
<div className="max-w-[130px] truncate" title={value}>
|
||||
{value}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
size: 130,
|
||||
maxSize: 130,
|
||||
},
|
||||
{id: "genre", header: PERFORMANCE_FIELD_LABELS.performanceGenre, cell: ({row}) => getCodeLabel(codes, "genre", row.original.performanceGenre)},
|
||||
{id: "area", header: PERFORMANCE_FIELD_LABELS.performanceArea, cell: ({row}) => getCodeLabel(codes, "area", row.original.performanceArea)},
|
||||
{
|
||||
accessorKey: "artistName",
|
||||
header: PERFORMANCE_FIELD_LABELS.artistName,
|
||||
cell: ({row}) => (
|
||||
<div className="max-w-[120px] truncate" title={row.original.artistName}>
|
||||
{row.original.artistName}
|
||||
</div>
|
||||
),
|
||||
size: 120,
|
||||
maxSize: 120,
|
||||
},
|
||||
{
|
||||
accessorKey: "performanceName",
|
||||
header: PERFORMANCE_FIELD_LABELS.performanceName,
|
||||
cell: ({row}) => (
|
||||
<div className="max-w-[300px] truncate" title={row.original.performanceName}>
|
||||
{row.original.performanceName}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{id: "startMonth", header: PERFORMANCE_FIELD_LABELS.performanceStartMonth,
|
||||
accessorFn: (row) => row.performanceStartMonth ?? 0,
|
||||
cell: ({row}) => row.original.performanceStartMonth === 0? "미정":`${row.original.performanceStartMonth}월`},
|
||||
{
|
||||
accessorKey: "performanceDtInfo",
|
||||
header: PERFORMANCE_FIELD_LABELS.performanceDtInfo,
|
||||
cell: ({row}) => (
|
||||
<div className="max-w-[65px] truncate" title={row.original.performanceDtInfo}>
|
||||
{row.original.performanceDtInfo}
|
||||
</div>
|
||||
),
|
||||
enableSorting: false
|
||||
},
|
||||
{
|
||||
accessorKey: "performanceTimeInfo",
|
||||
header: PERFORMANCE_FIELD_LABELS.performanceTimeInfo,
|
||||
cell: ({row}) => (
|
||||
<div className="max-w-[65px] truncate" title={row.original.performanceTimeInfo}>
|
||||
{row.original.performanceTimeInfo}
|
||||
</div>
|
||||
),
|
||||
enableSorting: false
|
||||
},
|
||||
...(!isWrittenReviewer ? [
|
||||
{
|
||||
id: "monitoringDate",
|
||||
header: PERFORMANCE_FIELD_LABELS.monitoringDate,
|
||||
accessorFn: (row) => row.performanceMonitoringSchedule?.monitoringDate ?? "",
|
||||
cell: ({row}) => row.original.performanceMonitoringSchedule?.monitoringDate ?? "",
|
||||
},
|
||||
{
|
||||
id: "timeTreeCheckDt",
|
||||
header: PERFORMANCE_FIELD_LABELS.timeTreeCheckDt,
|
||||
accessorFn: (row) => row.performanceDetail["timeTreeCheckDt"] ?? "",
|
||||
cell: ({row}) => row.original.performanceDetail["timeTreeCheckDt"] ?? "",
|
||||
}
|
||||
]: []) as DataTableColumn<PerformanceFull>[],
|
||||
{
|
||||
id: "localReview",
|
||||
header: "지자체 평가",
|
||||
header: "자체 보고서",
|
||||
cell: ({row}) => {
|
||||
if(row.original.id % 100 !== 1){
|
||||
return "-";
|
||||
}
|
||||
|
||||
const found = getReviewByType(row.original, LOCAL_GOVERNMENT_REVIEW_TYPE);
|
||||
return renderReviewStatus({
|
||||
performance: row.original,
|
||||
@@ -346,13 +510,22 @@ const PerformancePage = () => {
|
||||
noTooltip: isWrittenReviewer,
|
||||
});
|
||||
},
|
||||
size:40,
|
||||
},
|
||||
{id: "monitoring1", header: "모니터링 1", cell: ({row}) => renderMonitoringStatus(row.original, 0)},
|
||||
{id: "monitoring2", header: "모니터링 2", cell: ({row}) => renderMonitoringStatus(row.original, 1)},
|
||||
...(!isWrittenReviewer ? [
|
||||
{id: "monitoring1", header: "모니터링 1", cell: ({row}) => renderMonitoringStatus(row.original, 0), size:40,},
|
||||
{id: "monitoring2", header: "모니터링 2", cell: ({row}) => renderMonitoringStatus(row.original, 1), size:40,},
|
||||
] : [
|
||||
{id: "monitoring", header: "모니터링", cell: ({row}) => renderWrittenReviewerMonitoringStatus(row.original), size:40,}
|
||||
]) as DataTableColumn<PerformanceFull>[],
|
||||
{
|
||||
id: "writtenReview",
|
||||
header: "서면 평가",
|
||||
cell: ({row}) => {
|
||||
if(row.original.id % 100 !== 1){
|
||||
return "-";
|
||||
}
|
||||
|
||||
const found = getVisibleWrittenReviewRow(row.original);
|
||||
return renderReviewStatus({
|
||||
performance: row.original,
|
||||
@@ -362,8 +535,9 @@ const PerformancePage = () => {
|
||||
alwaysAssigned: Boolean(found?.assign),
|
||||
});
|
||||
},
|
||||
size:40,
|
||||
},
|
||||
], [codes, getVisibleWrittenReviewRow, isWrittenReviewer]);
|
||||
], [codes, data, getVisibleWrittenReviewRow, isWrittenReviewer]);
|
||||
|
||||
const downloadPerformanceTemplate = async () => {
|
||||
const buffer = await performanceTemplateMutation.mutateAsync();
|
||||
@@ -394,21 +568,24 @@ const PerformancePage = () => {
|
||||
<PagePanel>
|
||||
<div className="space-y-2">
|
||||
<div className={isWrittenReviewer ? "grid gap-2 md:grid-cols-[280px_170px_140px_140px_1fr_auto]" : "grid gap-2 md:grid-cols-[280px_170px_140px_140px_140px_1fr_auto]"}>
|
||||
<MultiFilterSelect value={filters.businessType} onChange={(value) => updateFilters((prev) => ({...prev, businessType: value}))} options={codes.business_type} placeholder="사업 유형" />
|
||||
<MultiFilterSelect value={filters.genre} onChange={(value) => updateFilters((prev) => ({...prev, genre: value}))} options={codes.genre} placeholder="분야(장르)" />
|
||||
<MultiFilterSelect value={filters.area} onChange={(value) => updateFilters((prev) => ({...prev, area: value}))} options={codes.area} placeholder="지역" />
|
||||
<MultiFilterSelect value={filters.startMonth} onChange={(value) => updateFilters((prev) => ({...prev, startMonth: value}))} options={monthOptions} placeholder="사업 수행 월" />
|
||||
<MultiFilterSelect value={filters.businessType} onChange={(value) => updateFilters((prev) => ({...prev, businessType: value}))} options={codes.business_type} placeholder={PERFORMANCE_FIELD_LABELS.businessType} />
|
||||
<MultiFilterSelect value={filters.genre} onChange={(value) => updateFilters((prev) => ({...prev, genre: value}))} options={codes.genre} placeholder={PERFORMANCE_FIELD_LABELS.performanceGenre} />
|
||||
<MultiFilterSelect value={filters.area} onChange={(value) => updateFilters((prev) => ({...prev, area: value}))} options={codes.area} placeholder={PERFORMANCE_FIELD_LABELS.performanceArea} />
|
||||
<MultiFilterSelect value={filters.startMonth} onChange={(value) => updateFilters((prev) => ({...prev, startMonth: value}))} options={monthOptions} placeholder={PERFORMANCE_FIELD_LABELS.performanceStartMonth} />
|
||||
{!isWrittenReviewer && (
|
||||
<DatePicker value={filters.monitoringDate} onChange={(value) => updateFilters((prev) => ({...prev, monitoringDate: value}))} placeholder="모니터링 일정" />
|
||||
<DatePicker value={filters.monitoringDate} onChange={(value) => updateFilters((prev) => ({...prev, monitoringDate: value}))} placeholder={PERFORMANCE_FIELD_LABELS.monitoringDate} />
|
||||
)}
|
||||
<Input value={filters.keyword} onChange={(event) => updateFilters((prev) => ({...prev, keyword: event.target.value}))} placeholder="연번 or 사업명" />
|
||||
<Input value={filters.keyword} onChange={(event) => updateFilters((prev) => ({...prev, keyword: event.target.value}))} placeholder={`${PERFORMANCE_FIELD_LABELS.id} or ${PERFORMANCE_FIELD_LABELS.performanceName}`} />
|
||||
<Button type="button" variant="outline" onClick={refreshPerformanceList}>
|
||||
<Search className="h-4 w-4" />
|
||||
검색
|
||||
</Button>
|
||||
</div>
|
||||
<div className="grid gap-2 md:grid-cols-[183px_183px_183px_183px]">
|
||||
<MultiFilterSelect value={filters.localReviewStatus} onChange={(value) => updateFilters((prev) => ({...prev, localReviewStatus: value}))} options={localReviewStatusOptions} placeholder="지자체 평가 상태" />
|
||||
<div className="grid gap-2 md:grid-cols-[183px_183px_183px_183px_183px]">
|
||||
{!isWrittenReviewer && (
|
||||
<MultiFilterSelect value={filters.monitoringAdd} onChange={(value) => updateFilters((prev) => ({...prev, monitoringAdd: value}))} options={monitoringAddOptions} placeholder={PERFORMANCE_FIELD_LABELS.monitoringAdd} />
|
||||
)}
|
||||
<MultiFilterSelect value={filters.localReviewStatus} onChange={(value) => updateFilters((prev) => ({...prev, localReviewStatus: value}))} options={localReviewStatusOptions} placeholder="자체 보고서 상태" />
|
||||
<MultiFilterSelect value={filters.monitoring1Status} onChange={(value) => updateFilters((prev) => ({...prev, monitoring1Status: value}))} options={monitoringStatusOptions} placeholder="모니터링1 상태" />
|
||||
<MultiFilterSelect value={filters.monitoring2Status} onChange={(value) => updateFilters((prev) => ({...prev, monitoring2Status: value}))} options={monitoringStatusOptions} placeholder="모니터링2 상태" />
|
||||
<MultiFilterSelect value={filters.writtenReviewStatus} onChange={(value) => updateFilters((prev) => ({...prev, writtenReviewStatus: value}))} options={writtenReviewStatusOptions} placeholder="서면평가 상태" />
|
||||
@@ -441,6 +618,8 @@ const PerformancePage = () => {
|
||||
selectMode={isWrittenReviewer ? "none" : "click-event"}
|
||||
onRowClick={isWrittenReviewer ? undefined : openDetail}
|
||||
defaultPageSize={10}
|
||||
headerFontClass="content-text-base"
|
||||
cellFontClass="content-text-sm"
|
||||
/>
|
||||
</PagePanel>
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ import {useMounted} from "@/hooks/useMounted";
|
||||
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
|
||||
import {downloadExcelBuffer} from "@/lib/gwcf/file";
|
||||
import ExcelDownloadButton from "@/components/common/ExcelDownloadButton";
|
||||
import {USER_FIELD_LABELS} from "@/lib/gwcf/field-labels";
|
||||
import {useDebouncedValue} from "@/hooks/useDebouncedValue";
|
||||
|
||||
type UserTab = "monitoring" | "written";
|
||||
type UserFilters = {area: string[]; gender: string[]; genre: string[]; keyword: string};
|
||||
@@ -59,6 +61,8 @@ const UserPage = () => {
|
||||
const [, forceDraftRender] = useState(0);
|
||||
const draftRef = useRef<UserFull | null>(null);
|
||||
const [filters, setFilters] = useState<UserFilters>({area: [], gender: [], genre: [], keyword: ""});
|
||||
const debouncedFilters = useDebouncedValue(filters);
|
||||
const filtersInitializedRef = useRef(false);
|
||||
|
||||
const userRole = tabRole[tab];
|
||||
const {data = [], refetch: refetchUsers} = useUsersQuery(userRole);
|
||||
@@ -77,9 +81,17 @@ const UserPage = () => {
|
||||
|
||||
const updateFilters = (updater: (prev: UserFilters) => UserFilters) => {
|
||||
setFilters(updater);
|
||||
refreshUserList();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!filtersInitializedRef.current) {
|
||||
filtersInitializedRef.current = true;
|
||||
return;
|
||||
}
|
||||
|
||||
refreshUserList();
|
||||
}, [debouncedFilters, refetchAssignCounts, refetchUsers]);
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedIds([]);
|
||||
setEditingId(null);
|
||||
@@ -88,7 +100,7 @@ const UserPage = () => {
|
||||
setFilters({area: [], gender: [], genre: [], keyword: ""});
|
||||
}, [tab]);
|
||||
|
||||
const filteredData = useMemo(() => data.filter((user) => filterUser(user, filters)), [data, filters]);
|
||||
const filteredData = useMemo(() => data.filter((user) => filterUser(user, debouncedFilters)), [data, debouncedFilters]);
|
||||
const smsTargetUsers = useMemo(
|
||||
() => data.filter((user) => selectedIds.includes(user.userId)),
|
||||
[data, selectedIds]
|
||||
@@ -146,11 +158,11 @@ const UserPage = () => {
|
||||
downloadExcelBuffer(buffer, tab === "monitoring" ? "모니터링 요원.xlsx" : "서면 평가위원.xlsx");
|
||||
};
|
||||
|
||||
const renderEditableCell = (user: UserFull, key: string, fallbackKeys: string[], type: "text" | "select" = "text", options: Code[] = []) => {
|
||||
const renderEditableCell = (user: UserFull, key: string, type: "text" | "select" = "text", options: Code[] = []) => {
|
||||
const draft = draftRef.current;
|
||||
const isEditing = editingId === user.userId && draft;
|
||||
const source = isEditing ? draft.userDetail : user.userDetail;
|
||||
const value = getDetailValue(source, [key, ...fallbackKeys]);
|
||||
const value = getDetailValue(source, key);
|
||||
|
||||
if (!isEditing) return type === "select" ? (getOptionLabel(options, value) || "-") : (value || "-");
|
||||
|
||||
@@ -171,30 +183,30 @@ const UserPage = () => {
|
||||
|
||||
const columns = useMemo<DataTableColumn<UserFull>[]>(() => {
|
||||
const commonColumns: DataTableColumn<UserFull>[] = [
|
||||
{accessorKey: "userId", header: "ID", enableSorting: true},
|
||||
{accessorKey: "userId", header: USER_FIELD_LABELS.userId},
|
||||
{id: "password", header: "PW", cell: () => "****"},
|
||||
];
|
||||
|
||||
const monitoringColumns: DataTableColumn<UserFull>[] = [
|
||||
{id: "participationCount", header: "참여 횟수", cell: ({row}) => assignCountMap.get(row.original.userId) ?? 0, enableSorting: true},
|
||||
{id: "area", header: "지역", cell: ({row}) => renderEditableCell(row.original, "area", ["userArea", "region"], "select", codes.area)},
|
||||
{id: "gender", header: "성별", cell: ({row}) => renderEditableCell(row.original, "gender", ["userGender"], "select", codes.gender)},
|
||||
{id: "age", header: "연령", cell: ({row}) => renderEditableCell(row.original, "age", ["userAge"])},
|
||||
{id: "tel", header: "연락처", cell: ({row}) => renderEditableCell(row.original, "tel", ["phone", "userTel"])},
|
||||
{id: "email", header: "이메일", cell: ({row}) => renderEditableCell(row.original, "email", ["userEmail"])},
|
||||
{id: "hasCar", header: "자차 여부", cell: ({row}) => renderEditableCell(row.original, "userHasCar", ["has_car", "hasCar"], "select", codes.has_car)},
|
||||
{id: "participationCount", header: "참여 횟수", accessorFn: (row) => assignCountMap.get(row.userId) ?? 0, cell: ({row}) => assignCountMap.get(row.original.userId) ?? 0},
|
||||
{id: "userArea", header: USER_FIELD_LABELS.userArea, cell: ({row}) => renderEditableCell(row.original, "userArea", "select", codes.area)},
|
||||
{id: "userGender", header: USER_FIELD_LABELS.gender, cell: ({row}) => renderEditableCell(row.original, "userGender", "select", codes.gender)},
|
||||
{id: "userAge", header: USER_FIELD_LABELS.userAge, cell: ({row}) => renderEditableCell(row.original, "userAge")},
|
||||
{id: "userTel", header: USER_FIELD_LABELS.userTel, cell: ({row}) => renderEditableCell(row.original, "userTel")},
|
||||
{id: "userEmail", header: USER_FIELD_LABELS.userEmail, cell: ({row}) => renderEditableCell(row.original, "userEmail")},
|
||||
{id: "userHasCar", header: USER_FIELD_LABELS.userHasCar, cell: ({row}) => renderEditableCell(row.original, "userHasCar", "select", codes.has_car)},
|
||||
];
|
||||
|
||||
const writtenColumns: DataTableColumn<UserFull>[] = [
|
||||
{id: "genre", header: "장르", cell: ({row}) => renderEditableCell(row.original, "userGenre", ["genre", "reviewGenre"], "select", codes.genre)},
|
||||
{id: "tel", header: "연락처", cell: ({row}) => renderEditableCell(row.original, "tel", ["phone", "userTel"])},
|
||||
{id: "email", header: "이메일", cell: ({row}) => renderEditableCell(row.original, "email", ["userEmail"])},
|
||||
{id: "userGenre", header: USER_FIELD_LABELS.userGenre, cell: ({row}) => renderEditableCell(row.original, "userGenre", "select", codes.genre)},
|
||||
{id: "userTel", header: USER_FIELD_LABELS.userTel, cell: ({row}) => renderEditableCell(row.original, "userTel")},
|
||||
{id: "userEmail", header: USER_FIELD_LABELS.userEmail, cell: ({row}) => renderEditableCell(row.original, "userEmail")},
|
||||
];
|
||||
|
||||
const actionColumns: DataTableColumn<UserFull>[] = [
|
||||
{
|
||||
id: "memo",
|
||||
header: "메모",
|
||||
header: USER_FIELD_LABELS.memo,
|
||||
cell: ({row}) => {
|
||||
const draft = draftRef.current;
|
||||
return editingId === row.original.userId && draft ? (
|
||||
@@ -310,10 +322,11 @@ const UserPage = () => {
|
||||
hideDialog("userSmsSendDialog");
|
||||
refreshUserList();
|
||||
}}
|
||||
templateIdx={SMS_TEMPLATE_IDS.ACCOUNT_MONITORING}
|
||||
templateIdx={[SMS_TEMPLATE_IDS.ACCOUNT_MONITORING]}
|
||||
newMessageTemplateIdx={SMS_TEMPLATE_IDS.CUSTOM}
|
||||
selectedUsers={smsTargetUsers}
|
||||
onSent={refreshUserList}
|
||||
denyParamKeys={["userCmpn", "userTeam", "userRole"]}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import {headers} from "next/headers";
|
||||
import {getFileNameFromContentDisposition} from "@/lib/gwcf/file";
|
||||
|
||||
type FilePreviewPageProps = {
|
||||
searchParams: Promise<{
|
||||
src?: string;
|
||||
@@ -17,14 +20,56 @@ const parseImages = (images?: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
const isAllowedSrc = (src: string) => src.startsWith("/api/review/pdf/") || src.startsWith("/api/file/");
|
||||
const isAllowedSrc = (src: string) =>
|
||||
src.startsWith("/api/review/pdf/") ||
|
||||
src.startsWith("/api/review/template/pdf/") ||
|
||||
src.startsWith("/api/file/");
|
||||
|
||||
const getAbsoluteSrc = async (src: string) => {
|
||||
const headersList = await headers();
|
||||
const host = headersList.get("x-forwarded-host") ?? headersList.get("host");
|
||||
if (!host) return undefined;
|
||||
|
||||
const protocol = headersList.get("x-forwarded-proto") ?? "http";
|
||||
return new URL(src, `${protocol}://${host}`).toString();
|
||||
};
|
||||
|
||||
const getPdfTitleFromSrc = async (src: string) => {
|
||||
if (!isAllowedSrc(src)) return undefined;
|
||||
|
||||
try {
|
||||
const headersList = await headers();
|
||||
const absoluteSrc = await getAbsoluteSrc(src);
|
||||
if (!absoluteSrc) return undefined;
|
||||
|
||||
const response = await fetch(absoluteSrc, {
|
||||
headers: {
|
||||
cookie: headersList.get("cookie") ?? "",
|
||||
},
|
||||
cache: "no-store",
|
||||
});
|
||||
const fileName = getFileNameFromContentDisposition(response.headers.get("content-disposition"));
|
||||
await response.body?.cancel().catch(() => undefined);
|
||||
return fileName;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
const getTitle = async (paramTitle: string, src: string, type: "image" | "pdf") => {
|
||||
const defaultTitle = "파일 미리보기";
|
||||
|
||||
if(paramTitle) return paramTitle;
|
||||
if(type === "pdf") return await getPdfTitleFromSrc(src) ?? defaultTitle;
|
||||
return defaultTitle;
|
||||
}
|
||||
|
||||
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");
|
||||
const src = params.src ?? "";
|
||||
const title = await getTitle(params.title ?? "", src, type) ;
|
||||
|
||||
return (
|
||||
<main className="flex min-h-screen flex-col bg-background text-foreground">
|
||||
@@ -64,4 +109,4 @@ export default async function FilePreviewPage({ searchParams }: FilePreviewPageP
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,12 @@ export const POST = async (
|
||||
);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
if (action === "reject" && second && third && slug.length === 3) {
|
||||
const result = await backApi.post<string>(
|
||||
`/assign/reject/${encodeURIComponent(second)}/${encodeURIComponent(third)}`
|
||||
);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "written" && second === "excel-template"){
|
||||
const result = await backApi.post<ArrayBuffer>(
|
||||
|
||||
@@ -2,7 +2,7 @@ import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {errorToResponse} from "@/lib/http-util";
|
||||
import {createBackApi} from "@/lib/server-api";
|
||||
import {PerformanceCompact} from "@/types/gwcf";
|
||||
import {Code, PerformanceCompact, PerformanceFull} from "@/types/gwcf";
|
||||
|
||||
const ALLOWED_ORIGIN = "https://kon.kric.com";
|
||||
|
||||
@@ -66,6 +66,11 @@ export const POST = async (
|
||||
const [action] = slug;
|
||||
const backApi = await createBackApi();
|
||||
|
||||
if(action === "code" && slug.length === 2) {
|
||||
const result = await backApi.get<Code[]>(`/code/${encodeURIComponent(slug[1])}`)
|
||||
return withCors(NextResponse.json(result, { status: 200 }));
|
||||
}
|
||||
|
||||
if(action === "assign-confirm" && slug.length === 3) {
|
||||
const result = await backApi.post<string>(
|
||||
`/assign/confirm/${encodeURIComponent(slug[1])}/${encodeURIComponent(slug[2])}`
|
||||
@@ -73,6 +78,18 @@ export const POST = async (
|
||||
return withCors(NextResponse.json(result, { status: 200 }));
|
||||
}
|
||||
|
||||
if(action === "assign-reject" && slug.length === 3) {
|
||||
const result = await backApi.post<string>(
|
||||
`/assign/reject/${encodeURIComponent(slug[1])}/${encodeURIComponent(slug[2])}`
|
||||
);
|
||||
return withCors(NextResponse.json(result, { status: 200 }));
|
||||
}
|
||||
|
||||
if(action === "performance" && slug.length === 2) {
|
||||
const result = await backApi.get<PerformanceFull>(`/performance/${encodeURIComponent(slug[1])}`)
|
||||
return withCors(NextResponse.json(result, { status: 200 }));
|
||||
}
|
||||
|
||||
if(action === "performance-list") {
|
||||
const result = await backApi.get<PerformanceCompact[]>(`/performance/list/compact`)
|
||||
return withCors(NextResponse.json(result, { status: 200 }));
|
||||
|
||||
@@ -10,6 +10,17 @@ import {CookieKeys} from "@/store/cookie/cookie-keys";
|
||||
const reviewFileName = (prefix: string, performanceId: string, reviewType: string) =>
|
||||
`${prefix}-${performanceId}-${reviewType}`;
|
||||
|
||||
const replaceContentDispositionType = (
|
||||
contentDisposition: string | null,
|
||||
disposition: "inline" | "attachment",
|
||||
fallbackFileName: string
|
||||
) => {
|
||||
const fileNamePart = contentDisposition?.split(";").slice(1).join(";");
|
||||
return fileNamePart
|
||||
? `${disposition};${fileNamePart}`
|
||||
: `${disposition}; filename="${fallbackFileName}"`;
|
||||
};
|
||||
|
||||
export const GET = async (
|
||||
req: NextRequest,
|
||||
context: RouteContext
|
||||
@@ -19,10 +30,10 @@ export const GET = async (
|
||||
const [action, second, third, fourth] = slug;
|
||||
const backApi = await createBackApi();
|
||||
|
||||
if (action === "template" && second === "download" && third && slug.length === 3) {
|
||||
if (action === "template" && second === "download" && third && fourth && slug.length === 4) {
|
||||
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)}`, {
|
||||
const response = await fetch(`${serverEnv.API_BACK_SERVER.replace(/\/+$/, "")}/review/template/download/${encodeURIComponent(third)}/${encodeURIComponent(fourth)}`, {
|
||||
headers: accessToken ? {authorization: `Bearer ${accessToken}`} : undefined,
|
||||
cache: "no-store",
|
||||
});
|
||||
@@ -43,12 +54,54 @@ export const GET = async (
|
||||
});
|
||||
}
|
||||
|
||||
if (action === "template" && second === "pdf" && third && fourth && slug.length === 4) {
|
||||
const cookieStore = await cookies();
|
||||
const accessToken = cookieStore.get(CookieKeys.AuthToken)?.value;
|
||||
const response = await fetch(`${serverEnv.API_BACK_SERVER.replace(/\/+$/, "")}/review/template/pdf/${encodeURIComponent(third)}/${encodeURIComponent(fourth)}`, {
|
||||
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 disposition = req.nextUrl.searchParams.get("disposition") === "inline" ? "inline" : "attachment";
|
||||
return new NextResponse(result, {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/pdf",
|
||||
"Content-Disposition": replaceContentDispositionType(
|
||||
response.headers.get("content-disposition"),
|
||||
disposition,
|
||||
`review-template-${third}-${fourth}.pdf`
|
||||
),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (action === "download" && second && third && fourth && slug.length === 4) {
|
||||
const result = await backApi.get<ArrayBuffer>(
|
||||
`/review/download/${encodeURIComponent(second)}/${encodeURIComponent(third)}/${encodeURIComponent(fourth)}`,
|
||||
{ expectBinary: true }
|
||||
);
|
||||
|
||||
return new NextResponse(result, {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/zip",
|
||||
"Content-Disposition": `attachment; filename="${reviewFileName("review-original", second, third)}.zip"`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (action === "download" && second && third && slug.length === 3) {
|
||||
const result = await backApi.get<ArrayBuffer>(
|
||||
`/review/download/${encodeURIComponent(second)}/${encodeURIComponent(third)}`,
|
||||
{ expectBinary: true }
|
||||
);
|
||||
|
||||
return new NextResponse(result, {
|
||||
status: 200,
|
||||
headers: {
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import {useIsFetching} from "@tanstack/react-query";
|
||||
import {useIsFetching, useIsMutating} from "@tanstack/react-query";
|
||||
import {useLoading} from "@/hooks/useLoading";
|
||||
import {useEffect} from "react";
|
||||
|
||||
const ReactQueryLoadingSync = () => {
|
||||
const fetching = useIsFetching();
|
||||
const mutating = useIsMutating();
|
||||
const { showLoading, hideLoading } = useLoading();
|
||||
|
||||
useEffect(() => {
|
||||
if (fetching > 0) showLoading();
|
||||
if (fetching > 0 || mutating > 0) showLoading();
|
||||
else hideLoading();
|
||||
}, [fetching, showLoading, hideLoading]);
|
||||
}, [fetching, mutating, showLoading, hideLoading]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export default ReactQueryLoadingSync;
|
||||
export default ReactQueryLoadingSync;
|
||||
|
||||
@@ -48,7 +48,9 @@ export function DataTable<TData>({
|
||||
defaultPageSize = 10,
|
||||
pageSizeOptions = [5, 10, 25, 50],
|
||||
showPagination = true,
|
||||
paginationItemsToDisplay = 5
|
||||
paginationItemsToDisplay = 5,
|
||||
headerFontClass = 'content-text-lg',
|
||||
cellFontClass = 'content-text-base',
|
||||
}: Readonly<DataTableProps<TData>>) {
|
||||
// Pagination state
|
||||
const [pagination, setPagination] = useState<PaginationState>({
|
||||
@@ -200,7 +202,8 @@ export function DataTable<TData>({
|
||||
<TableHead
|
||||
key={header.id}
|
||||
className={cn(
|
||||
'content-text-lg font-semibold text-gray-900',
|
||||
'font-semibold text-gray-900',
|
||||
headerFontClass,
|
||||
column.id === 'actions' && 'w-[140px] text-center'
|
||||
)}
|
||||
style={{ width: header.getSize() !== 150 ? header.getSize() : undefined }}
|
||||
@@ -209,7 +212,7 @@ export function DataTable<TData>({
|
||||
<Button
|
||||
type='button'
|
||||
variant='ghost'
|
||||
className='px-0 font-semibold content-text-lg flex items-center gap-1'
|
||||
className={cn('px-0 font-semibold flex items-center gap-1', headerFontClass)}
|
||||
onClick={column.getToggleSortingHandler()}
|
||||
>
|
||||
<span>{headerContent}</span>
|
||||
@@ -240,8 +243,8 @@ export function DataTable<TData>({
|
||||
onPointerCancel={drag.onPointerCancel}
|
||||
onClick={drag.wrapClick(() => handleRowClick(row))}
|
||||
className={cn(
|
||||
'content-text-base',
|
||||
'[&>td]:py-3 [&>td]:px-3',
|
||||
cellFontClass,
|
||||
'[&>td]:py-2 [&>td]:px-2',
|
||||
selectMode !== 'none' && 'cursor-pointer',
|
||||
'data-[state=selected]:bg-slate-100 data-[state=selected]:font-semibold',
|
||||
shouldHighlight && 'bg-emerald-50',
|
||||
|
||||
@@ -38,4 +38,6 @@ export interface DataTableProps<TData> {
|
||||
pageSizeOptions?: number[];
|
||||
showPagination?: boolean;
|
||||
paginationItemsToDisplay?: number;
|
||||
headerFontClass?: string;
|
||||
cellFontClass?: string;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,13 @@ import {StatusPill} from "@/components/gwcf/StatusPill";
|
||||
import {Code, MonitoringApplyUser, PerformanceFull} from "@/types/gwcf";
|
||||
import {CodeGroup} from "@/query/code";
|
||||
import {getCodeLabel, getDetailValue} from "@/lib/gwcf/view";
|
||||
import {getAssignStatusDisplay, MONITORING_ASSIGN_TYPE} from "@/lib/gwcf/performance-status";
|
||||
import {
|
||||
getAssignStatusDisplay,
|
||||
isAssignConfirmed, isAssignRejected,
|
||||
isNotAssignRejected,
|
||||
MONITORING_ASSIGN_TYPE
|
||||
} from "@/lib/gwcf/performance-status";
|
||||
import {PERFORMANCE_FIELD_LABELS, USER_FIELD_LABELS} from "@/lib/gwcf/field-labels";
|
||||
|
||||
type CodeMap = Partial<Record<CodeGroup, Code[]>>;
|
||||
|
||||
@@ -23,7 +29,8 @@ export function AssignMonitoringDialog({
|
||||
applyUsers,
|
||||
isSavingAssign,
|
||||
onSaveAssign,
|
||||
onOpenSms,
|
||||
onOpenAssignSms,
|
||||
onOpenNormalSms,
|
||||
}: Readonly<{
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
@@ -32,7 +39,8 @@ export function AssignMonitoringDialog({
|
||||
applyUsers: MonitoringApplyUser[];
|
||||
isSavingAssign?: boolean;
|
||||
onSaveAssign: (performanceId: number, userIds: string[]) => void;
|
||||
onOpenSms: (assignUserIds: string[], smsUserIds: string[]) => void;
|
||||
onOpenAssignSms: (assignUserIds: string[], smsUserIds: string[]) => void;
|
||||
onOpenNormalSms: (smsUserIds: string[]) => void;
|
||||
}>) {
|
||||
const monitoringAssigns = useMemo(
|
||||
() => (selected?.performanceAssignList ?? []).filter((item) => item.assignType === MONITORING_ASSIGN_TYPE),
|
||||
@@ -46,13 +54,13 @@ export function AssignMonitoringDialog({
|
||||
return;
|
||||
}
|
||||
|
||||
setCheckedIds(monitoringAssigns.map((item) => item.assignUser));
|
||||
setCheckedIds(monitoringAssigns.filter(isNotAssignRejected).map((item) => item.assignUser));
|
||||
}, [monitoringAssigns, open, selected?.id]);
|
||||
|
||||
const confirmRequestCount = monitoringAssigns.length;
|
||||
const confirmedCount = monitoringAssigns.filter((item) => item.assignConfirm).length;
|
||||
const smsTargetIds = checkedIds.filter(
|
||||
(userId) => !monitoringAssigns.some((assign) => assign.assignUser === userId && assign.assignConfirm)
|
||||
const confirmedCount = monitoringAssigns.filter(isAssignConfirmed).length;
|
||||
const assignSmsTargetIds = checkedIds.filter(
|
||||
(userId) => !monitoringAssigns.some((assign) => assign.assignUser === userId && isAssignConfirmed(assign))
|
||||
);
|
||||
|
||||
const updateChecked = (applyUser: MonitoringApplyUser, checked: boolean) => {
|
||||
@@ -66,15 +74,19 @@ export function AssignMonitoringDialog({
|
||||
return;
|
||||
}
|
||||
|
||||
if(isAssignRejected(currentAssign)) {
|
||||
if (!confirm("이미 포기한 사용자 입니다. 정말로 다시 배정하시겠습니까?")) return;
|
||||
}
|
||||
|
||||
const next = Array.from(new Set([...checkedIds, applyUser.userId]));
|
||||
setCheckedIds(next);
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentAssign?.assignConfirm) {
|
||||
if (!confirm("이미 승인된 상태입니다. 정말로 취소 하시 겠습니까?")) return;
|
||||
} else if (currentAssign) {
|
||||
if (!confirm("이미 문자 발송된 상태입니다. 정말로 취소 하시 겠습니까?")) return;
|
||||
if (isAssignConfirmed(currentAssign)) {
|
||||
if (!confirm("이미 승인된 상태입니다. 정말로 취소하시겠습니까?")) return;
|
||||
} else if (isNotAssignRejected(currentAssign) && currentAssign) {
|
||||
if (!confirm("이미 문자 발송된 상태입니다. 정말로 취소하시겠습니까?")) return;
|
||||
}
|
||||
|
||||
const next = checkedIds.filter((userId) => userId !== applyUser.userId);
|
||||
@@ -107,7 +119,7 @@ export function AssignMonitoringDialog({
|
||||
},
|
||||
{
|
||||
id: "user",
|
||||
header: "신청자",
|
||||
header: USER_FIELD_LABELS.userName,
|
||||
cell: ({row}) => (
|
||||
<div>
|
||||
<div className="font-semibold">{row.original.user?.userName || row.original.userId}</div>
|
||||
@@ -117,14 +129,14 @@ export function AssignMonitoringDialog({
|
||||
},
|
||||
{
|
||||
id: "area",
|
||||
header: "지역",
|
||||
header: USER_FIELD_LABELS.userArea,
|
||||
cell: ({row}) =>
|
||||
getCodeLabel(codes, "area", getDetailValue(row.original.user?.userDetail, ["area", "userArea", "region"])) || "-",
|
||||
getCodeLabel(codes, "area", getDetailValue(row.original.user?.userDetail, "userArea")) || "-",
|
||||
},
|
||||
{
|
||||
id: "tel",
|
||||
header: "연락처",
|
||||
cell: ({row}) => getDetailValue(row.original.user?.userDetail, ["tel", "phone", "userTel"], "-"),
|
||||
header: USER_FIELD_LABELS.userTel,
|
||||
cell: ({row}) => getDetailValue(row.original.user?.userDetail, "userTel", "-"),
|
||||
},
|
||||
{
|
||||
id: "status",
|
||||
@@ -133,7 +145,7 @@ export function AssignMonitoringDialog({
|
||||
const assigned = monitoringAssigns.find((item) => item.assignUser === row.original.userId);
|
||||
if (!assigned) return null;
|
||||
|
||||
const display = getAssignStatusDisplay(assigned.assignConfirm);
|
||||
const display = getAssignStatusDisplay(assigned.assignStatus);
|
||||
return <StatusPill variant={display.variant}>{display.label}</StatusPill>;
|
||||
},
|
||||
},
|
||||
@@ -152,23 +164,23 @@ export function AssignMonitoringDialog({
|
||||
<table className="w-full border-collapse text-sm">
|
||||
<tbody>
|
||||
{[
|
||||
["연번", selected?.id],
|
||||
["사업유형", getCodeLabel(codes, "business_type", selected?.businessType)],
|
||||
["분야(장르)", getCodeLabel(codes, "genre", selected?.performanceGenre)],
|
||||
["지역", getCodeLabel(codes, "area", selected?.performanceArea)],
|
||||
["단체(팀)명", selected?.artistName],
|
||||
["사업명", selected?.performanceName],
|
||||
["사업 일정", selected?.performanceDtInfo],
|
||||
["운영 시간", selected?.performanceTimeInfo],
|
||||
["모니터링 일정", selected?.performanceMonitoringSchedule?.monitoringDate],
|
||||
["모니터링 시간", selected?.performanceMonitoringSchedule?.monitoringTimeInfo],
|
||||
["방문 장소", selected?.performanceMonitoringSchedule?.monitoringAddress],
|
||||
["예매 예약", getCodeLabel(codes, "ticket_reservation_status", selected?.ticketReservationStatus)],
|
||||
["예매 비고", selected?.ticketReservationMemo],
|
||||
[PERFORMANCE_FIELD_LABELS.id, selected?.id],
|
||||
[PERFORMANCE_FIELD_LABELS.businessType, getCodeLabel(codes, "business_type", selected?.businessType)],
|
||||
[PERFORMANCE_FIELD_LABELS.performanceGenre, getCodeLabel(codes, "genre", selected?.performanceGenre)],
|
||||
[PERFORMANCE_FIELD_LABELS.performanceArea, getCodeLabel(codes, "area", selected?.performanceArea)],
|
||||
[PERFORMANCE_FIELD_LABELS.artistName, selected?.artistName],
|
||||
[PERFORMANCE_FIELD_LABELS.performanceName, selected?.performanceName],
|
||||
[PERFORMANCE_FIELD_LABELS.performanceDtInfo, selected?.performanceDtInfo],
|
||||
[PERFORMANCE_FIELD_LABELS.performanceTimeInfo, selected?.performanceTimeInfo],
|
||||
[PERFORMANCE_FIELD_LABELS.monitoringDate, selected?.performanceMonitoringSchedule?.monitoringDate ?? ""],
|
||||
[PERFORMANCE_FIELD_LABELS.monitoringTimeInfo, selected?.performanceMonitoringSchedule?.monitoringTimeInfo],
|
||||
[PERFORMANCE_FIELD_LABELS.monitoringAddress, selected?.performanceMonitoringSchedule?.monitoringAddress],
|
||||
[PERFORMANCE_FIELD_LABELS.ticketReservationStatus, getCodeLabel(codes, "ticket_reservation_status", selected?.ticketReservationStatus)],
|
||||
[PERFORMANCE_FIELD_LABELS.ticketReservationMemo, selected?.ticketReservationMemo],
|
||||
].map(([label, value]) => (
|
||||
<tr key={String(label)}>
|
||||
<th className="w-32 border bg-muted p-2 text-left">{label}</th>
|
||||
<td className="border p-2">{value || "-"}</td>
|
||||
<td className="border p-2">{value || (label === PERFORMANCE_FIELD_LABELS.monitoringDate ? "" : "-")}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@@ -208,10 +220,14 @@ export function AssignMonitoringDialog({
|
||||
<Save className="h-4 w-4" />
|
||||
저장
|
||||
</Button>
|
||||
<Button type="button" variant="outline" disabled={smsTargetIds.length === 0 || isSavingAssign} onClick={() => onOpenSms(checkedIds, smsTargetIds)}>
|
||||
<Button type="button" variant="outline" disabled={assignSmsTargetIds.length === 0 || isSavingAssign} onClick={() => onOpenAssignSms(checkedIds, assignSmsTargetIds)}>
|
||||
<Send className="h-4 w-4" />
|
||||
확정 문자 발송
|
||||
</Button>
|
||||
<Button type="button" variant="outline" disabled={checkedIds.length === 0} onClick={() => onOpenNormalSms(checkedIds)}>
|
||||
<Send className="h-4 w-4" />
|
||||
문자 발송
|
||||
</Button>
|
||||
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>닫기</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
buildEvidenceImageSrc,
|
||||
buildImagePreviewUrl,
|
||||
buildReviewPdfPreviewUrl,
|
||||
buildReviewTemplatePdfPreviewUrl,
|
||||
downloadBlob,
|
||||
downloadFromUrl,
|
||||
getEvidenceZipDownloadName,
|
||||
@@ -31,6 +32,7 @@ import {
|
||||
getReviewPdfDownloadName,
|
||||
openPreviewWindow,
|
||||
} from "@/lib/gwcf/file";
|
||||
import {PERFORMANCE_FIELD_LABELS} from "@/lib/gwcf/field-labels";
|
||||
|
||||
type CodeMap = Partial<Record<CodeGroup, Code[]>>;
|
||||
|
||||
@@ -38,25 +40,27 @@ 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 className="break-words text-sm">{children ?? "-"}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ActionButton({
|
||||
children,
|
||||
className,
|
||||
icon = "download",
|
||||
disabled = false,
|
||||
onClick,
|
||||
}: Readonly<{
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
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">
|
||||
<Button type="button" size="sm" variant="outline" disabled={disabled} onClick={onClick} className={className? className : "min-h-10 flex-1"}>
|
||||
<Icon className="h-4 w-4" />
|
||||
{children}
|
||||
</Button>
|
||||
@@ -189,7 +193,27 @@ export function MonitoringPerformanceDetailDialog({
|
||||
)
|
||||
: {label: "미배치", variant: "danger" as const};
|
||||
|
||||
const downloadTemplate = () => downloadFromUrl("/api/review/template/download/1");
|
||||
const reviewType = row?.reviewType ?? 1;
|
||||
const templateClassification = Number(String(performance?.id ?? 0).charAt(0));
|
||||
|
||||
const buildTemplateDownloadUrl = (classification: number) => `/api/review/template/download/${reviewType}/${classification}`;
|
||||
const downloadTemplate = () => downloadFromUrl(buildTemplateDownloadUrl(templateClassification));
|
||||
|
||||
const previewTemplateFile = async (classification: number, title: string) => {
|
||||
const previewWindow = window.open("about:blank", "_blank");
|
||||
if (previewWindow) previewWindow.opener = null;
|
||||
const previewUrl = buildReviewTemplatePdfPreviewUrl(reviewType, classification, title);
|
||||
|
||||
if (previewWindow) {
|
||||
previewWindow.location.href = previewUrl;
|
||||
return;
|
||||
}
|
||||
|
||||
openPreviewWindow(previewUrl);
|
||||
};
|
||||
|
||||
const previewTemplate = () => void previewTemplateFile(templateClassification, "모니터링 현장 점검표.pdf");
|
||||
const previewEduFile = () => void previewTemplateFile(99, "도민 모니터링단 매뉴얼.pdf");
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
@@ -202,33 +226,32 @@ export function MonitoringPerformanceDetailDialog({
|
||||
{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>
|
||||
<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.id}>{performance.id}</MobileDetailRow>
|
||||
<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.businessType}>{getCodeLabel(codes, "business_type", performance.businessType)}</MobileDetailRow>
|
||||
<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.performanceGenre}>{getCodeLabel(codes, "genre", performance.performanceGenre)}</MobileDetailRow>
|
||||
<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.performanceArea}>{getCodeLabel(codes, "area", performance.performanceArea)}</MobileDetailRow>
|
||||
<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.artistName}>{performance.artistName}</MobileDetailRow>
|
||||
<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.performanceName}>{performance.performanceName}</MobileDetailRow>
|
||||
<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.performanceStartMonth}>{performance.performanceStartMonth}월</MobileDetailRow>
|
||||
<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.performanceDtInfo}>{performance.performanceDtInfo}</MobileDetailRow>
|
||||
<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.performanceTimeInfo}>{performance.performanceTimeInfo}</MobileDetailRow>
|
||||
<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.ticketReservationStatus}>{getCodeLabel(codes, "ticket_reservation_status", performance.ticketReservationStatus)}</MobileDetailRow>
|
||||
<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.ticketReservationMemo}>{performance.ticketReservationMemo}</MobileDetailRow>
|
||||
<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.monitoringDate}>{performance.performanceMonitoringSchedule?.monitoringDate ?? ""}</MobileDetailRow>
|
||||
<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.monitoringTimeInfo}>{performance.performanceMonitoringSchedule?.monitoringTimeInfo}</MobileDetailRow>
|
||||
<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.monitoringAddress}>{performance.performanceMonitoringSchedule?.monitoringAddress}</MobileDetailRow>
|
||||
{/*<MobileDetailRow label={PERFORMANCE_FIELD_LABELS.performanceMemo}>{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 className="flex items-start justify-between gap-3">
|
||||
<div className="shrink-0 font-semibold leading-6">나의 진행 상태</div>
|
||||
<StatusPill variant={status.variant}>{status.label}</StatusPill>
|
||||
</div>
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
<ActionButton icon="preview" onClick={previewEduFile} className="h-8 min-h-0 shrink-0 px-2 text-xs">교육자료</ActionButton>
|
||||
<ActionButton icon="preview" onClick={previewTemplate} className="h-8 min-h-0 shrink-0 px-2 text-xs">양식</ActionButton>
|
||||
<ActionButton icon="download" onClick={downloadTemplate} className="h-8 min-h-0 shrink-0 px-2 text-xs">양식 다운로드</ActionButton>
|
||||
</div>
|
||||
{row ? (
|
||||
<MonitoringReviewActions
|
||||
|
||||
@@ -15,7 +15,7 @@ function DetailRow({label, children}: {label: string; children: ReactNode}) {
|
||||
return (
|
||||
<div className="grid grid-cols-[130px_1fr] border-b last:border-b-0">
|
||||
<div className="bg-muted px-3 py-2 text-sm font-semibold">{label}</div>
|
||||
<div className="min-h-9 px-3 py-2 text-sm">{children || "-"}</div>
|
||||
<div className="min-h-9 px-3 py-2 text-sm">{children ?? "-"}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export function MonitoringVisitDialog({
|
||||
<div className="rounded-md border">
|
||||
<DetailRow label="현재 시간">{nowText}</DetailRow>
|
||||
<DetailRow label="모니터링 일정">
|
||||
{performance?.performanceMonitoringSchedule?.monitoringDate} {performance?.performanceMonitoringSchedule?.monitoringTimeInfo}
|
||||
{[performance?.performanceMonitoringSchedule?.monitoringDate, performance?.performanceMonitoringSchedule?.monitoringTimeInfo].filter(Boolean).join(" ")}
|
||||
</DetailRow>
|
||||
<DetailRow label="사업명">{performance?.performanceName}</DetailRow>
|
||||
<DetailRow label="장소">{performance?.performanceMonitoringSchedule?.monitoringAddress}</DetailRow>
|
||||
|
||||
@@ -42,14 +42,16 @@ import {
|
||||
openPreviewWindow,
|
||||
openWrittenReviewWindow,
|
||||
} from "@/lib/gwcf/file";
|
||||
import {PERFORMANCE_FIELD_LABELS, USER_FIELD_LABELS} from "@/lib/gwcf/field-labels";
|
||||
|
||||
type CodeMap = Partial<Record<CodeGroup, Code[]>>;
|
||||
type PerformanceDetail = PerformanceCompact["performanceDetail"];
|
||||
|
||||
function DetailRow({label, children}: {label: string; children: ReactNode}) {
|
||||
return (
|
||||
<div className="grid grid-cols-[130px_1fr] border-b last:border-b-0">
|
||||
<div className="bg-muted px-3 py-2 text-sm font-semibold">{label}</div>
|
||||
<div className="min-h-9 px-3 py-2 text-sm">{children || "-"}</div>
|
||||
<div className="min-h-9 px-3 py-2 text-sm">{children ?? "-"}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -86,22 +88,22 @@ function AssignedUserInfo({
|
||||
type: "monitoring" | "written";
|
||||
}>) {
|
||||
const detail = user?.userDetail;
|
||||
const tel = getDetailValue(detail, ["tel", "phone", "userTel"], "-");
|
||||
const email = getDetailValue(detail, ["email", "userEmail"], "-");
|
||||
const tel = getDetailValue(detail, "userTel", "-");
|
||||
const email = getDetailValue(detail, "userEmail", "-");
|
||||
const metaValue = type === "monitoring"
|
||||
? getCodeLabel(codes, "area", getDetailValue(detail, ["area", "userArea", "region"]))
|
||||
: getCodeLabel(codes, "genre", getDetailValue(detail, ["userGenre", "genre", "reviewGenre"]));
|
||||
const metaLabel = type === "monitoring" ? "지역" : "장르";
|
||||
const hasCar = getCodeLabel(codes, "has_car", getDetailValue(detail, ["userHasCar", "has_car", "hasCar"])) || "-";
|
||||
? getCodeLabel(codes, "area", getDetailValue(detail, "userArea"))
|
||||
: getCodeLabel(codes, "genre", getDetailValue(detail, "userGenre"));
|
||||
const metaLabel = type === "monitoring" ? USER_FIELD_LABELS.userArea : USER_FIELD_LABELS.userGenre;
|
||||
const hasCar = getCodeLabel(codes, "has_car", getDetailValue(detail, "userHasCar")) || "-";
|
||||
|
||||
return (
|
||||
<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-2">
|
||||
<span>ID: {userId || "-"}</span>
|
||||
<span>{metaLabel}: {metaValue || "-"}</span>
|
||||
<span>연락처: {tel}</span>
|
||||
<span>이메일: {email}</span>
|
||||
{type === "monitoring" && <span>자차유무: {hasCar}</span>}
|
||||
<span>{USER_FIELD_LABELS.userTel}: {tel}</span>
|
||||
<span>{USER_FIELD_LABELS.userEmail}: {email}</span>
|
||||
{type === "monitoring" && <span>{USER_FIELD_LABELS.userHasCar}: {hasCar}</span>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -224,13 +226,18 @@ function LocalGovernmentReviewRow({
|
||||
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));
|
||||
|
||||
if(performance.id % 100 !== 1){
|
||||
return null;
|
||||
}
|
||||
|
||||
const review = fetchedReview ?? fallbackReviewRow?.review;
|
||||
const label = getCodeLabel(codes, "review_status", review?.reviewStatus);
|
||||
const display = getReviewStatusDisplay(label, review, true);
|
||||
|
||||
return (
|
||||
<div className="space-y-2 border-b p-3">
|
||||
<div className="font-semibold">지자체</div>
|
||||
<div className="font-semibold">자체 보고서</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<StatusPill variant={display.variant}>{display.label}</StatusPill>
|
||||
<ReviewFileActions
|
||||
@@ -318,6 +325,10 @@ function WrittenReviewRows({
|
||||
userMap: Map<string, UserFull>;
|
||||
canEdit: boolean;
|
||||
}>) {
|
||||
if(performance.id % 100 !== 1){
|
||||
return null;
|
||||
}
|
||||
|
||||
const rows = getWrittenReviewRows(performance as PerformanceFull);
|
||||
|
||||
if(rows.length === 0){
|
||||
@@ -418,6 +429,16 @@ export function PerformanceDetailDialog({
|
||||
setDraft((prev) => prev ? {...prev, [key]: value} : prev);
|
||||
};
|
||||
|
||||
const updateDetail = <K extends keyof PerformanceDetail>(key: K, value: PerformanceDetail[K]) => {
|
||||
setDraft((prev) => prev ? {
|
||||
...prev,
|
||||
performanceDetail: {
|
||||
...prev.performanceDetail,
|
||||
[key]: value,
|
||||
},
|
||||
} : prev);
|
||||
};
|
||||
|
||||
const updateSchedule = <K extends keyof PerformanceMonitoringSchedule>(key: K, value: PerformanceMonitoringSchedule[K]) => {
|
||||
setDraft((prev) => prev ? {
|
||||
...prev,
|
||||
@@ -464,8 +485,8 @@ export function PerformanceDetailDialog({
|
||||
setIsEditing(false);
|
||||
};
|
||||
|
||||
const downloadTemplate = (reviewType: number) => {
|
||||
downloadFromUrl(`/api/review/template/download/${reviewType}`);
|
||||
const downloadTemplate = (reviewType: number, classification: number) => {
|
||||
downloadFromUrl(`/api/review/template/download/${reviewType}/${classification}`);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -480,25 +501,37 @@ export function PerformanceDetailDialog({
|
||||
<div className="grid gap-4 lg:grid-cols-[1.1fr_0.9fr]">
|
||||
<div className="space-y-4">
|
||||
<section className="rounded-md border">
|
||||
<DetailRow label="연번">{draft.id}</DetailRow>
|
||||
<DetailRow label="사업유형">{getCodeLabel(codes, "business_type", draft.businessType)}</DetailRow>
|
||||
<DetailRow label="분야(장르)">{getCodeLabel(codes, "genre", draft.performanceGenre)}</DetailRow>
|
||||
<DetailRow label="지역">{getCodeLabel(codes, "area", draft.performanceArea)}</DetailRow>
|
||||
<DetailRow label="단체(인)명">{draft.artistName}</DetailRow>
|
||||
<DetailRow label="사업명">{isEditing ? <Input value={draft.performanceName} onChange={(event) => updateDraft("performanceName", event.target.value)} /> : draft.performanceName}</DetailRow>
|
||||
<DetailRow label="사업 수행 월">{isEditing ? <Input type="number" value={draft.performanceStartMonth} onChange={(event) => updateDraft("performanceStartMonth", Number(event.target.value))} /> : `${draft.performanceStartMonth}월`}</DetailRow>
|
||||
<DetailRow label="사업 일정">{isEditing ? <Input value={draft.performanceDtInfo} onChange={(event) => updateDraft("performanceDtInfo", event.target.value)} /> : draft.performanceDtInfo}</DetailRow>
|
||||
<DetailRow label="운영 시간">{isEditing ? <Input value={draft.performanceTimeInfo} onChange={(event) => updateDraft("performanceTimeInfo", event.target.value)} /> : draft.performanceTimeInfo}</DetailRow>
|
||||
<DetailRow label="예매 예약">
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.no}>{draft.performanceDetail["performanceNo"] ?? ""}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.id}>{draft.id}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.monitoringAdd}>{draft.id % 100 !== 1? "추가" : ""}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.businessType}>{getCodeLabel(codes, "business_type", draft.businessType)}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.performanceGenre}>{getCodeLabel(codes, "genre", draft.performanceGenre)}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.performanceArea}>
|
||||
{isEditing ? (
|
||||
<FilterSelect value={String(draft.ticketReservationStatus ?? "")} onChange={(value) => updateDraft("ticketReservationStatus", Number(value))} options={codes.ticket_reservation_status ?? []} placeholder="예매 예약" />
|
||||
<FilterSelect value={String(draft.performanceArea ?? "")} onChange={(value) => updateDraft("performanceArea", Number(value))} options={codes.area ?? []} placeholder={PERFORMANCE_FIELD_LABELS.performanceArea} />
|
||||
) : getCodeLabel(codes, "area", draft.performanceArea)}
|
||||
</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.performanceAreaDetail}>{isEditing ? <Input value={draft.performanceDetail["performanceAreaDetail"] ?? ""} onChange={(event) => updateDetail("performanceAreaDetail", event.target.value)} /> : draft.performanceDetail["performanceAreaDetail"] ?? ""}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.artistName}>{draft.artistName}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.performanceName}>{isEditing ? <Input value={draft.performanceName} onChange={(event) => updateDraft("performanceName", event.target.value)} /> : draft.performanceName}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.performanceStartMonth}>{isEditing ? <Input type="number" value={draft.performanceStartMonth} onChange={(event) => updateDraft("performanceStartMonth", Number(event.target.value))} /> : `${draft.performanceStartMonth}월`}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.performanceDtInfo}>{isEditing ? <Input value={draft.performanceDtInfo} onChange={(event) => updateDraft("performanceDtInfo", event.target.value)} /> : draft.performanceDtInfo}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.performanceTimeInfo}>{isEditing ? <Input value={draft.performanceTimeInfo} onChange={(event) => updateDraft("performanceTimeInfo", event.target.value)} /> : draft.performanceTimeInfo}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.ticketReservationStatus}>
|
||||
{isEditing ? (
|
||||
<FilterSelect value={String(draft.ticketReservationStatus ?? "")} onChange={(value) => updateDraft("ticketReservationStatus", Number(value))} options={codes.ticket_reservation_status ?? []} placeholder={PERFORMANCE_FIELD_LABELS.ticketReservationStatus} />
|
||||
) : getCodeLabel(codes, "ticket_reservation_status", draft.ticketReservationStatus)}
|
||||
</DetailRow>
|
||||
<DetailRow label="예매 비고">{isEditing ? <Input value={draft.ticketReservationMemo} onChange={(event) => updateDraft("ticketReservationMemo", event.target.value)} /> : draft.ticketReservationMemo}</DetailRow>
|
||||
<DetailRow label="모니터링 일정">{isEditing ? <DatePicker value={draft.performanceMonitoringSchedule?.monitoringDate ?? ""} onChange={(value) => updateSchedule("monitoringDate", value)} /> : draft.performanceMonitoringSchedule?.monitoringDate}</DetailRow>
|
||||
<DetailRow label="모니터링 시간">{isEditing ? <Input value={draft.performanceMonitoringSchedule?.monitoringTimeInfo ?? ""} onChange={(event) => updateSchedule("monitoringTimeInfo", event.target.value)} /> : draft.performanceMonitoringSchedule?.monitoringTimeInfo}</DetailRow>
|
||||
<DetailRow label="방문 장소">{isEditing ? <Input value={draft.performanceMonitoringSchedule?.monitoringAddress ?? ""} onChange={(event) => updateSchedule("monitoringAddress", event.target.value)} /> : draft.performanceMonitoringSchedule?.monitoringAddress}</DetailRow>
|
||||
<DetailRow label="메모">{isEditing ? <Input value={draft.performanceMemo} onChange={(event) => updateDraft("performanceMemo", event.target.value)} /> : draft.performanceMemo}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.ticketReservationMemo}>{isEditing ? <Input value={draft.ticketReservationMemo} onChange={(event) => updateDraft("ticketReservationMemo", event.target.value)} /> : draft.ticketReservationMemo}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.monitoringDate}>{isEditing ? <DatePicker value={draft.performanceMonitoringSchedule?.monitoringDate ?? ""} onChange={(value) => updateSchedule("monitoringDate", value)} /> : draft.performanceMonitoringSchedule?.monitoringDate ?? ""}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.monitoringTimeInfo}>{isEditing ? <Input value={draft.performanceMonitoringSchedule?.monitoringTimeInfo ?? ""} onChange={(event) => updateSchedule("monitoringTimeInfo", event.target.value)} /> : draft.performanceMonitoringSchedule?.monitoringTimeInfo}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.needMonitoring}>{isEditing ? <Input value={draft.performanceDetail["needMonitoring"] ?? ""} onChange={(event) => updateDetail("needMonitoring", event.target.value)} /> : draft.performanceDetail["needMonitoring"] ?? ""}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.needWrittenReview}>{isEditing ? <Input value={draft.performanceDetail["needWrittenReview"] ?? ""} onChange={(event) => updateDetail("needWrittenReview", event.target.value)} /> : draft.performanceDetail["needWrittenReview"] ?? ""}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.checkDeliver}>{isEditing ? <Input value={draft.performanceDetail["checkDeliver"] ?? ""} onChange={(event) => updateDetail("checkDeliver", event.target.value)} /> : draft.performanceDetail["checkDeliver"] ?? ""}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.timeTreeCheckDt}>{isEditing ? <DatePicker value={draft.performanceDetail["timeTreeCheckDt"] ?? ""} onChange={(value) => updateDetail("timeTreeCheckDt", value)} /> : draft.performanceDetail["timeTreeCheckDt"] ?? ""}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.monitoringAddress}>{isEditing ? <Input value={draft.performanceMonitoringSchedule?.monitoringAddress ?? ""} onChange={(event) => updateSchedule("monitoringAddress", event.target.value)} /> : draft.performanceMonitoringSchedule?.monitoringAddress}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.performanceMemo}>{isEditing ? <Input value={draft.performanceMemo} onChange={(event) => updateDraft("performanceMemo", event.target.value)} /> : draft.performanceMemo}</DetailRow>
|
||||
<DetailRow label={PERFORMANCE_FIELD_LABELS.checkReport}>{isEditing ? <Input value={draft.performanceDetail["checkReport"] ?? ""} onChange={(event) => updateDetail("checkReport", event.target.value)} /> : draft.performanceDetail["checkReport"] ?? ""}</DetailRow>
|
||||
</section>
|
||||
|
||||
<section className="rounded-md border">
|
||||
@@ -534,14 +567,10 @@ export function PerformanceDetailDialog({
|
||||
<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)}>
|
||||
<Button type="button" size="sm" variant="outline" onClick={() => downloadTemplate(1, Number(String(performance?.id ?? 0).charAt(0)))}>
|
||||
<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} />
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import {useEffect, useMemo, useState} from "react";
|
||||
import {Edit, RotateCcw, Save, Send} from "lucide-react";
|
||||
import {useEffect, useMemo, useRef, useState} from "react";
|
||||
import {Edit, RotateCcw, Save, Send, X} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from "@/components/ui/select";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
@@ -14,6 +16,7 @@ import {
|
||||
import {
|
||||
NOTIFICATION_REQUEST_SERVICE,
|
||||
useNotificationTemplateQuery,
|
||||
useNotificationTemplatesQuery,
|
||||
useSaveNotificationTemplateMutation,
|
||||
useSendSmsBulkMutation,
|
||||
} from "@/query/notification";
|
||||
@@ -22,16 +25,19 @@ import {UserCompact} from "@/types/gwcf";
|
||||
import {getDetailValue} from "@/lib/gwcf/view";
|
||||
import {useAuth} from "@/hooks/useAuth";
|
||||
import {buildUserMsgParam} from "@/lib/gwcf/notification";
|
||||
import {getSmsParamLabel} from "@/lib/gwcf/field-labels";
|
||||
|
||||
type TemplateDraft = Pick<Template, "tmplatIdx" | "tmplatNm" | "tmplatTitle" | "tmplatBody" | "sendTel">;
|
||||
|
||||
const EMPTY_DENY_PARAM_KEYS: string[] = [];
|
||||
|
||||
const toText = (value: string | null | undefined) => value ?? "";
|
||||
|
||||
const toDraft = (template: Template, emptyBody = false): TemplateDraft => ({
|
||||
const toDraft = (template: Template, isNewMessage = false): TemplateDraft => ({
|
||||
tmplatIdx: template.tmplatIdx,
|
||||
tmplatNm: toText(template.tmplatNm),
|
||||
tmplatTitle: toText(template.tmplatTitle),
|
||||
tmplatBody: emptyBody ? "" : toText(template.tmplatBody),
|
||||
tmplatTitle: isNewMessage ? "" : toText(template.tmplatTitle),
|
||||
tmplatBody: isNewMessage ? "" : toText(template.tmplatBody),
|
||||
sendTel: toText(template.sendTel),
|
||||
});
|
||||
|
||||
@@ -43,6 +49,7 @@ export function SmsSendDialog({
|
||||
newMessageTemplateIdx,
|
||||
selectedUsers,
|
||||
addParams = {},
|
||||
denyParamKeys = EMPTY_DENY_PARAM_KEYS,
|
||||
onBeforeDefaultTemplateSend,
|
||||
isBeforeSendPending = false,
|
||||
onSent,
|
||||
@@ -50,61 +57,107 @@ export function SmsSendDialog({
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
title?: string;
|
||||
templateIdx: number;
|
||||
templateIdx: number[];
|
||||
newMessageTemplateIdx?: number;
|
||||
selectedUsers: UserCompact[];
|
||||
addParams?: Record<string, string>;
|
||||
denyParamKeys?: string[];
|
||||
onBeforeDefaultTemplateSend?: () => Promise<void>;
|
||||
isBeforeSendPending?: boolean;
|
||||
onSent?: () => void;
|
||||
}>) {
|
||||
const {auth} = useAuth();
|
||||
const [activeTemplateIdx, setActiveTemplateIdx] = useState(templateIdx);
|
||||
const templateIdxKey = templateIdx.join(",");
|
||||
const templateIdxList = useMemo(
|
||||
() => Array.from(new Set(templateIdx.filter((idx) => idx > 0))),
|
||||
[templateIdxKey]
|
||||
);
|
||||
const defaultTemplateIdx = templateIdxList[0] ?? 0;
|
||||
|
||||
const [activeTemplateIdx, setActiveTemplateIdx] = useState(defaultTemplateIdx);
|
||||
const [isNewMessage, setIsNewMessage] = useState(false);
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const [draft, setDraft] = useState<TemplateDraft | null>(null);
|
||||
const bodyTextareaRef = useRef<HTMLTextAreaElement | null>(null);
|
||||
|
||||
const templateQuery = useNotificationTemplateQuery(activeTemplateIdx, open);
|
||||
const templatesQuery = useNotificationTemplatesQuery(templateIdxList, open);
|
||||
const newMessageTemplateQuery = useNotificationTemplateQuery(newMessageTemplateIdx ?? 0, Boolean(open && isNewMessage && newMessageTemplateIdx));
|
||||
const saveTemplateMutation = useSaveNotificationTemplateMutation();
|
||||
const sendSmsMutation = useSendSmsBulkMutation();
|
||||
const activeTemplate = isNewMessage
|
||||
? newMessageTemplateQuery.data
|
||||
: templatesQuery.data.find((template) => template.tmplatIdx === activeTemplateIdx);
|
||||
|
||||
const isBusy = templateQuery.isLoading || saveTemplateMutation.isPending || sendSmsMutation.isPending || isBeforeSendPending;
|
||||
const isBusy = templatesQuery.isLoading || newMessageTemplateQuery.isLoading || saveTemplateMutation.isPending || sendSmsMutation.isPending || isBeforeSendPending;
|
||||
const canEdit = isNewMessage || isEditing;
|
||||
|
||||
const denyParamKeySet = useMemo(() => new Set(denyParamKeys), [denyParamKeys]);
|
||||
|
||||
const destinations = useMemo(() => {
|
||||
return selectedUsers
|
||||
.map((user) => ({
|
||||
sid: user.userId,
|
||||
destTel: getDetailValue(user.userDetail, ["userTel"]),
|
||||
destNm: user.userName || user.userId,
|
||||
msgParam: {
|
||||
.map((user) => {
|
||||
const msgParam = Object.fromEntries(
|
||||
Object.entries({
|
||||
...buildUserMsgParam(user),
|
||||
...addParams,
|
||||
},
|
||||
}))
|
||||
}).filter(([key]) => !denyParamKeySet.has(key))
|
||||
);
|
||||
|
||||
return {
|
||||
sid: user.userId,
|
||||
destTel: getDetailValue(user.userDetail, "userTel"),
|
||||
destNm: user.userName || user.userId,
|
||||
msgParam,
|
||||
};
|
||||
})
|
||||
.filter((item) => item.destTel);
|
||||
}, [selectedUsers, addParams]);
|
||||
}, [selectedUsers, addParams, denyParamKeySet]);
|
||||
|
||||
const msgParamKeys = useMemo(() => {
|
||||
return Array.from(
|
||||
new Set(destinations.flatMap((destination) => Object.keys(destination.msgParam)))
|
||||
);
|
||||
}, [destinations]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
|
||||
setActiveTemplateIdx(templateIdx);
|
||||
setActiveTemplateIdx(defaultTemplateIdx);
|
||||
setIsNewMessage(false);
|
||||
setIsEditing(false);
|
||||
setDraft(null);
|
||||
}, [open, templateIdx]);
|
||||
}, [defaultTemplateIdx, open]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open || !templateQuery.data) return;
|
||||
if (!open || !activeTemplate) return;
|
||||
|
||||
setDraft(toDraft(templateQuery.data, isNewMessage));
|
||||
setDraft(toDraft(activeTemplate, isNewMessage));
|
||||
setIsEditing(false);
|
||||
}, [isNewMessage, open, templateQuery.data]);
|
||||
}, [activeTemplate, isNewMessage, open]);
|
||||
|
||||
const updateDraft = <K extends keyof TemplateDraft>(key: K, value: TemplateDraft[K]) => {
|
||||
setDraft((prev) => prev ? {...prev, [key]: value} : prev);
|
||||
};
|
||||
|
||||
const insertMsgParam = (key: string) => {
|
||||
if (!draft || !canEdit || isBusy) return;
|
||||
|
||||
const token = `#{${key}}`;
|
||||
const textarea = bodyTextareaRef.current;
|
||||
const body = draft.tmplatBody;
|
||||
const selectionStart = textarea?.selectionStart ?? body.length;
|
||||
const selectionEnd = textarea?.selectionEnd ?? selectionStart;
|
||||
const nextBody = `${body.slice(0, selectionStart)}${token}${body.slice(selectionEnd)}`;
|
||||
const nextCursor = selectionStart + token.length;
|
||||
|
||||
updateDraft("tmplatBody", nextBody);
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
textarea?.focus();
|
||||
textarea?.setSelectionRange(nextCursor, nextCursor);
|
||||
});
|
||||
};
|
||||
|
||||
const saveTemplate = async () => {
|
||||
if (!draft) return null;
|
||||
|
||||
@@ -122,6 +175,20 @@ export function SmsSendDialog({
|
||||
return saved;
|
||||
};
|
||||
|
||||
const cancelEdit = () => {
|
||||
if (activeTemplate) {
|
||||
setDraft(toDraft(activeTemplate, isNewMessage));
|
||||
}
|
||||
setIsEditing(false);
|
||||
};
|
||||
|
||||
const changeTemplate = (value: string) => {
|
||||
setActiveTemplateIdx(Number(value));
|
||||
setIsNewMessage(false);
|
||||
setIsEditing(false);
|
||||
setDraft(null);
|
||||
};
|
||||
|
||||
const switchToNewMessage = () => {
|
||||
if (!newMessageTemplateIdx) return;
|
||||
|
||||
@@ -132,7 +199,7 @@ export function SmsSendDialog({
|
||||
};
|
||||
|
||||
const restoreTemplate = () => {
|
||||
setActiveTemplateIdx(templateIdx);
|
||||
setActiveTemplateIdx(defaultTemplateIdx);
|
||||
setIsNewMessage(false);
|
||||
setIsEditing(false);
|
||||
setDraft(null);
|
||||
@@ -181,14 +248,11 @@ export function SmsSendDialog({
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="flex max-h-[90vh] flex-col overflow-hidden sm:max-w-2xl">
|
||||
<DialogHeader>
|
||||
<DialogContent showCloseButton={false} className="flex max-h-[90vh] flex-col overflow-hidden sm:max-w-2xl">
|
||||
<DialogHeader className="flex-row flex-wrap items-center justify-between gap-3 space-y-0">
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="min-h-0 flex-1 space-y-4 overflow-y-auto pr-1">
|
||||
<div className="flex flex-wrap items-center justify-between gap-2 rounded-md border bg-muted/30 p-3">
|
||||
<div className="text-sm text-muted-foreground">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<div className="text-sm text-muted-foreground whitespace-nowrap">
|
||||
선택 인원: <span className="font-semibold text-foreground">{selectedUsers.length}</span>명
|
||||
{destinations.length !== selectedUsers.length && (
|
||||
<span className="ml-2 text-destructive">발송 가능 {destinations.length}명</span>
|
||||
@@ -206,9 +270,17 @@ export function SmsSendDialog({
|
||||
</Button>
|
||||
)
|
||||
)}
|
||||
<DialogClose asChild>
|
||||
<Button type="button" size="icon" variant="ghost" className="h-8 w-8 shrink-0">
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">닫기</span>
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</div>
|
||||
</DialogHeader>
|
||||
|
||||
{templateQuery.isLoading && (
|
||||
<div className="min-h-0 flex-1 space-y-4 pr-1">
|
||||
{(templatesQuery.isLoading || newMessageTemplateQuery.isLoading) && (
|
||||
<div className="rounded-md border p-4 text-sm text-muted-foreground">템플릿 정보를 불러오는 중입니다.</div>
|
||||
)}
|
||||
|
||||
@@ -217,7 +289,27 @@ export function SmsSendDialog({
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
<label className="space-y-1 text-sm">
|
||||
<span className="font-medium">템플릿명</span>
|
||||
<Input value={draft.tmplatNm} disabled />
|
||||
<Select
|
||||
value={String(activeTemplateIdx)}
|
||||
onValueChange={changeTemplate}
|
||||
disabled={isBusy || isEditing || isNewMessage || templateIdxList.length <= 1}
|
||||
>
|
||||
<SelectTrigger className="w-full">
|
||||
<SelectValue placeholder="템플릿 선택" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{isNewMessage && draft && (
|
||||
<SelectItem value={String(draft.tmplatIdx)}>
|
||||
{toText(draft.tmplatNm) || `${draft.tmplatIdx}`}
|
||||
</SelectItem>
|
||||
)}
|
||||
{templatesQuery.data.map((template) => (
|
||||
<SelectItem key={template.tmplatIdx} value={String(template.tmplatIdx)}>
|
||||
{toText(template.tmplatNm) || `${template.tmplatIdx}`}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</label>
|
||||
<label className="space-y-1 text-sm">
|
||||
<span className="font-medium">발신번호</span>
|
||||
@@ -231,12 +323,34 @@ export function SmsSendDialog({
|
||||
<label className="space-y-1 text-sm">
|
||||
<span className="font-medium">내용</span>
|
||||
<textarea
|
||||
ref={bodyTextareaRef}
|
||||
value={draft.tmplatBody}
|
||||
disabled={!canEdit || isBusy}
|
||||
onChange={(event) => updateDraft("tmplatBody", event.target.value)}
|
||||
className="min-h-56 w-full rounded-md border border-input bg-background p-3 text-sm disabled:cursor-not-allowed disabled:opacity-70"
|
||||
className="min-h-80 w-full rounded-md border border-input bg-background p-3 text-sm disabled:cursor-not-allowed disabled:opacity-70"
|
||||
/>
|
||||
</label>
|
||||
{msgParamKeys.length > 0 && (
|
||||
<div className="space-y-1 text-sm">
|
||||
<div className="font-medium text-muted-foreground">사용 가능 변수값</div>
|
||||
<div className="max-h-36 overflow-y-auto rounded-md border bg-muted/20 p-2">
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{msgParamKeys.map((key) => (
|
||||
<Button
|
||||
key={key}
|
||||
type="button"
|
||||
className="h-auto flex-col items-start gap-0 rounded bg-muted px-2 py-1 text-center text-xs text-foreground hover:bg-muted/80 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
disabled={!canEdit || isBusy}
|
||||
onClick={() => insertMsgParam(key)}
|
||||
>
|
||||
<span className="text-center">{getSmsParamLabel(key)}</span>
|
||||
<code className="font-mono text-muted-foreground">{`#{${key}}`}</code>
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -249,10 +363,16 @@ export function SmsSendDialog({
|
||||
</Button>
|
||||
)}
|
||||
{!isNewMessage && draft && isEditing && (
|
||||
<Button type="button" variant="outline" onClick={saveTemplate} disabled={isBusy}>
|
||||
<Save className="h-4 w-4" />
|
||||
저장
|
||||
</Button>
|
||||
<>
|
||||
<Button type="button" variant="outline" onClick={saveTemplate} disabled={isBusy}>
|
||||
<Save className="h-4 w-4" />
|
||||
저장
|
||||
</Button>
|
||||
<Button type="button" variant="outline" onClick={cancelEdit} disabled={isBusy}>
|
||||
<RotateCcw className="h-4 w-4" />
|
||||
취소
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
<Button type="button" disabled={!draft || isBusy || isEditing || selectedUsers.length === 0} onClick={send}>
|
||||
<Send className="h-4 w-4" />
|
||||
|
||||
@@ -48,9 +48,9 @@ const MainLayout = ({ children }: MainLayoutProps) => {
|
||||
/>
|
||||
|
||||
{/* 본문 */}
|
||||
<div className="flex flex-1 min-h-0">
|
||||
<div className="flex min-h-0 min-w-0 flex-1">
|
||||
{/* 메인 콘텐츠만 가변 높이 적용 */}
|
||||
<main className="flex-1 p-4">
|
||||
<main className="min-w-0 max-w-full flex-1 overflow-x-hidden p-4">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export function useDebouncedValue<T>(value: T, delayMs = 1200) {
|
||||
export function useDebouncedValue<T>(value: T, delayMs = 500) {
|
||||
const [debounced, setDebounced] = useState(value);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
52
src/lib/gwcf/field-labels.ts
Normal file
52
src/lib/gwcf/field-labels.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
export const USER_FIELD_LABELS = {
|
||||
userId: "ID",
|
||||
userName: "이름",
|
||||
userCmpn: "소속",
|
||||
userTeam: "팀",
|
||||
userRole: "권한",
|
||||
memo: "메모",
|
||||
userArea: "지역",
|
||||
gender: "성별",
|
||||
userGender: "성별",
|
||||
userAge: "연령",
|
||||
userTel: "연락처",
|
||||
userEmail: "이메일",
|
||||
userHasCar: "자차 여부",
|
||||
userGenre: "장르",
|
||||
} as const;
|
||||
|
||||
export const PERFORMANCE_FIELD_LABELS = {
|
||||
no: "No.",
|
||||
id: "연번",
|
||||
monitoringAdd: "분류",
|
||||
businessType: "사업유형",
|
||||
performanceGenre: "분야(장르)",
|
||||
performanceArea: "지역",
|
||||
performanceAreaDetail: "지역 세부",
|
||||
artistName: "단체(인)명",
|
||||
performanceName: "사업명",
|
||||
performanceStartMonth: "사업 수행 월",
|
||||
performanceDtInfo: "사업 일정",
|
||||
performanceTimeInfo: "운영 시간",
|
||||
ticketReservationStatus: "티켓 예약",
|
||||
ticketReservationMemo: "티켓 비고",
|
||||
performanceMemo: "메모",
|
||||
monitoringDate: "모니터링 일정",
|
||||
monitoringTimeInfo: "모니터링 시간",
|
||||
needMonitoring: "모니터링 필요여부",
|
||||
needWrittenReview: "서면평가 필요여부",
|
||||
checkDeliver: "교부여부",
|
||||
timeTreeCheckDt: "타임트리 확인일시",
|
||||
monitoringAddress: "방문 장소",
|
||||
checkReport: "보고서 확인여부",
|
||||
performanceId: "사업 ID",
|
||||
monitoringPaymentDate: "요원 비용지급일",
|
||||
} as const;
|
||||
|
||||
export const SMS_PARAM_LABELS = {
|
||||
...USER_FIELD_LABELS,
|
||||
...PERFORMANCE_FIELD_LABELS,
|
||||
} as const;
|
||||
|
||||
export const getSmsParamLabel = (key: string) =>
|
||||
SMS_PARAM_LABELS[key as keyof typeof SMS_PARAM_LABELS] ?? key;
|
||||
@@ -6,6 +6,41 @@ const REVIEW_TIMESTAMP_PREFIX = /^\d{4}-\d{2}-\d{2}_\d{6}_/;
|
||||
export const removeTimestampPrefix = (fileName?: string) =>
|
||||
fileName?.replace(REVIEW_TIMESTAMP_PREFIX, "");
|
||||
|
||||
const trimDispositionValue = (value: string) => value.trim().replace(/^"|"$/g, "");
|
||||
|
||||
const decodeDispositionValue = (value: string) => {
|
||||
const trimmed = trimDispositionValue(value);
|
||||
const encodedValue = trimmed.includes("''") ? trimmed.split("''").slice(1).join("''") : trimmed;
|
||||
try {
|
||||
return decodeURIComponent(encodedValue);
|
||||
} catch {
|
||||
return encodedValue;
|
||||
}
|
||||
};
|
||||
|
||||
const getDispositionParams = (contentDisposition: string) =>
|
||||
contentDisposition
|
||||
.split(";")
|
||||
.slice(1)
|
||||
.map((part) => part.trim())
|
||||
.reduce<Record<string, string>>((params, part) => {
|
||||
const separatorIndex = part.indexOf("=");
|
||||
if (separatorIndex < 0) return params;
|
||||
|
||||
const key = part.slice(0, separatorIndex).trim().toLowerCase();
|
||||
const value = part.slice(separatorIndex + 1).trim();
|
||||
if (key && value) params[key] = value;
|
||||
return params;
|
||||
}, {});
|
||||
|
||||
export const getFileNameFromContentDisposition = (contentDisposition?: string | null) => {
|
||||
if (!contentDisposition) return undefined;
|
||||
|
||||
const params = getDispositionParams(contentDisposition);
|
||||
const fileName = params["filename*"] || params.filename;
|
||||
return fileName ? decodeDispositionValue(fileName) : undefined;
|
||||
};
|
||||
|
||||
export const downloadBlob = (
|
||||
buffer: ArrayBuffer,
|
||||
fileName: string,
|
||||
@@ -49,7 +84,16 @@ export const buildReviewPdfPreviewUrl = (
|
||||
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))}`;
|
||||
return `/file-preview?type=pdf&src=${encodeURIComponent(src)}${title ? `&title=${encodeURIComponent(title)}` : ""}`;
|
||||
};
|
||||
|
||||
export const buildReviewTemplatePdfPreviewUrl = (
|
||||
reviewType: number,
|
||||
classification: number,
|
||||
title?: string
|
||||
) => {
|
||||
const src = `/api/review/template/pdf/${reviewType}/${classification}?disposition=inline`;
|
||||
return `/file-preview?type=pdf&src=${encodeURIComponent(src)}${title ? `&title=${encodeURIComponent(title)}` : ""}`;
|
||||
};
|
||||
|
||||
export const buildEvidenceImageSrc = (
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {Code, PerformanceAssign, PerformanceFull, PerformanceMonitoringVisit, PerformanceReview, UserCompact} from "@/types/gwcf";
|
||||
import type {StatusPillVariant} from "@/components/gwcf/StatusPill";
|
||||
import {ASSIGN_STATUS, AssignStatus} from "@/types/gwcf";
|
||||
|
||||
export const LOCAL_GOVERNMENT_REVIEW_TYPE = 3;
|
||||
export const MONITORING_ASSIGN_TYPE = 1;
|
||||
@@ -49,6 +50,22 @@ export const STATUS_FILTER = {
|
||||
DONE: "-1007",
|
||||
} as const;
|
||||
|
||||
export const isAssignRequested = (assign?: Pick<PerformanceAssign, "assignStatus">) => {
|
||||
return assign?.assignStatus === ASSIGN_STATUS.REQUESTED;
|
||||
};
|
||||
|
||||
export const isAssignConfirmed = (assign?: Pick<PerformanceAssign, "assignStatus">) => {
|
||||
return assign?.assignStatus === ASSIGN_STATUS.CONFIRMED;
|
||||
};
|
||||
|
||||
export const isAssignRejected = (assign?: Pick<PerformanceAssign, "assignStatus">) => {
|
||||
return assign?.assignStatus === ASSIGN_STATUS.REJECTED;
|
||||
};
|
||||
|
||||
export const isNotAssignRejected = (assign?: Pick<PerformanceAssign, "assignStatus">) => {
|
||||
return assign?.assignStatus !== ASSIGN_STATUS.REJECTED;
|
||||
};
|
||||
|
||||
export const makeStatusOption = (value: string, label: string): Code => ({
|
||||
codeGroup: "status_filter",
|
||||
codeValue: Number(value),
|
||||
@@ -94,7 +111,7 @@ const getMonitoringTimeline = (visits: PerformanceMonitoringVisit[]): Monitoring
|
||||
|
||||
export const getMonitoringSlots = (performance: Partial<PerformanceFull>): [MonitoringSlot, MonitoringSlot] => {
|
||||
const confirmedAssigns = (performance.performanceAssignList ?? [])
|
||||
.filter((assign) => assign.assignType === MONITORING_ASSIGN_TYPE && assign.assignConfirm)
|
||||
.filter((assign) => assign.assignType === MONITORING_ASSIGN_TYPE && isAssignConfirmed(assign))
|
||||
.sort((a, b) => a.assignOrder - b.assignOrder || a.id - b.id);
|
||||
|
||||
const visits = performance.performanceMonitoringVisitMap ?? {};
|
||||
@@ -125,7 +142,6 @@ export const getReviewRows = (performance: Partial<PerformanceFull>) => {
|
||||
|
||||
export const getMonitoringReviewByIndex = (
|
||||
performance: Partial<PerformanceFull>,
|
||||
index: 0 | 1,
|
||||
slot?: MonitoringSlot
|
||||
) => {
|
||||
const assignedUserId = slot?.assign?.assignUser;
|
||||
@@ -140,10 +156,11 @@ export const getMonitoringReviewByIndex = (
|
||||
|
||||
export const getMonitoringDisplayRow = (
|
||||
performance: Partial<PerformanceFull>,
|
||||
index: 0 | 1
|
||||
index: 0 | 1,
|
||||
isWrittenReviewer: boolean = false
|
||||
): MonitoringDisplayRow => {
|
||||
const slot = getMonitoringSlots(performance)[index];
|
||||
const reviewRow = getMonitoringReviewByIndex(performance, index, slot);
|
||||
const reviewRow = getMonitoringReviewByIndex(performance, slot);
|
||||
const visit = slot.visit?.[0];
|
||||
|
||||
return {
|
||||
@@ -310,8 +327,8 @@ export const getMonitoringDisplayStatus = (
|
||||
return getMonitoringStatusDisplay(visitLabel, row.slot);
|
||||
};
|
||||
|
||||
export const getAssignStatusDisplay = (confirmed: boolean): StatusDisplay => {
|
||||
return confirmed
|
||||
? {label: "확정", variant: "done"}
|
||||
: {label: "요청", variant: "inprogress"};
|
||||
export const getAssignStatusDisplay = (status: AssignStatus): StatusDisplay => {
|
||||
if (status === ASSIGN_STATUS.CONFIRMED) return {label: "확정", variant: "done"};
|
||||
if (status === ASSIGN_STATUS.REJECTED) return {label: "포기", variant: "danger"};
|
||||
return {label: "요청", variant: "inprogress"};
|
||||
};
|
||||
|
||||
@@ -35,14 +35,12 @@ export const getCodeLabel = (
|
||||
|
||||
export const getDetailValue = (
|
||||
detail: Record<string, string> | undefined,
|
||||
keys: string[],
|
||||
key: string,
|
||||
fallback = ""
|
||||
) => {
|
||||
if (!detail) return fallback;
|
||||
for (const key of keys) {
|
||||
const value = detail[key];
|
||||
if (value !== undefined && value !== "") return value;
|
||||
}
|
||||
const value = detail[key];
|
||||
if (value !== undefined && value !== "") return value;
|
||||
return fallback;
|
||||
};
|
||||
|
||||
@@ -92,9 +90,9 @@ export const filterUser = (
|
||||
}
|
||||
) => {
|
||||
const detail = user.userDetail ?? {};
|
||||
const area = getDetailValue(detail, ["area", "userArea", "region"]);
|
||||
const gender = getDetailValue(detail, ["gender", "userGender"]);
|
||||
const genre = getDetailValue(detail, ["genre", "performanceGenre", "reviewGenre"]);
|
||||
const area = getDetailValue(detail, "userArea");
|
||||
const gender = getDetailValue(detail, "userGender");
|
||||
const genre = getDetailValue(detail, "userGenre");
|
||||
const keyword = filters.keyword?.trim() ?? "";
|
||||
const matches = (filter: string | string[] | undefined, value: string) => {
|
||||
if (!filter || filter.length === 0) return true;
|
||||
@@ -112,8 +110,8 @@ export const filterUser = (
|
||||
includesText(user.userTeam, keyword) ||
|
||||
includesText(user.userCmpn, keyword) ||
|
||||
includesText(user.memo, keyword) ||
|
||||
includesText(getDetailValue(detail, ["tel", "phone", "userTel"]), keyword) ||
|
||||
includesText(getDetailValue(detail, ["email", "userEmail"]), keyword)
|
||||
includesText(getDetailValue(detail, "userTel"), keyword) ||
|
||||
includesText(getDetailValue(detail, "userEmail"), keyword)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -91,19 +91,6 @@ export function useAssignCancelMutation() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useKonAssignConfirmMutation() {
|
||||
const qc = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({performanceId, userId}: {performanceId: number; userId: string}) =>
|
||||
nextApi.post<string>(`/assign/confirm/${performanceId}/${encodeURIComponent(userId)}`),
|
||||
onSuccess: (_res, {performanceId, userId}) => {
|
||||
qc.invalidateQueries({ queryKey: qk.assignConfirm(performanceId, userId) });
|
||||
qc.invalidateQueries({ queryKey: ["performance", "list"] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useUploadWrittenAssignExcelMutation() {
|
||||
const qc = useQueryClient();
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ export const useLogoutMutation = () => {
|
||||
const userId = auth.user?.userId ?? "";
|
||||
try {
|
||||
if (userId){
|
||||
await nextApi.post(`/logout/${userId}`, null, { autoLogoutOnAuthError: false });
|
||||
await nextApi.post(`/logout/${userId}`, null, { autoLogoutOnAuthError: false, suppressAlert: true });
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@@ -38,4 +38,4 @@ export const useLogoutMutation = () => {
|
||||
qc.clear(); // 다음 사용자/세션에 서버상태 남지 않게
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import {useMutation, useQuery} from "@tanstack/react-query";
|
||||
import {useMutation, useQueries, useQuery} from "@tanstack/react-query";
|
||||
import {nextApi} from "@/lib/http-client";
|
||||
import {BulkSendResponse, SaveTemplateRequest, SendSmsBulkRequest, Template} from "@/types/notification";
|
||||
|
||||
@@ -8,6 +8,8 @@ export const SMS_TEMPLATE_IDS = {
|
||||
ACCOUNT_MONITORING: 45,
|
||||
ASSIGN_CONFIRM: 46,
|
||||
CUSTOM: 47,
|
||||
INFORM_ASSIGN: 48,
|
||||
REMIND_ASSIGN: 49,
|
||||
} as const;
|
||||
|
||||
export const NOTIFICATION_REQUEST_SERVICE = "gwcf-review";
|
||||
@@ -20,6 +22,21 @@ export function useNotificationTemplateQuery(templateIdx: number, enabled = true
|
||||
});
|
||||
}
|
||||
|
||||
export function useNotificationTemplatesQuery(templateIdxList: number[], enabled = true) {
|
||||
return useQueries({
|
||||
queries: templateIdxList.map((templateIdx) => ({
|
||||
queryKey: ["notification", "template", templateIdx],
|
||||
queryFn: () => nextApi.get<Template>(`/notification/template/${templateIdx}`),
|
||||
enabled: enabled && templateIdx > 0,
|
||||
})),
|
||||
combine: (results) => ({
|
||||
data: results.flatMap((result) => result.data ? [result.data] : []),
|
||||
isLoading: results.some((result) => result.isLoading),
|
||||
isError: results.some((result) => result.isError),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
export function useSaveNotificationTemplateMutation() {
|
||||
return useMutation({
|
||||
mutationFn: (data: SaveTemplateRequest) =>
|
||||
|
||||
@@ -39,6 +39,13 @@ export function useDownloadReviewOriginalMutation() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useDownloadReviewOriginalByPerformanceMutation() {
|
||||
return useMutation({
|
||||
mutationFn: ({performanceId, reviewType}: {performanceId: number; reviewType: number}) =>
|
||||
nextApi.get<ArrayBuffer>(`/review/download/${performanceId}/${reviewType}`, {expectBinary: true}),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDownloadReviewPdfMutation() {
|
||||
return useMutation({
|
||||
mutationFn: ({performanceId, reviewType, userId}: {performanceId: number; reviewType: number; userId: string}) =>
|
||||
|
||||
@@ -26,13 +26,21 @@ export type Code = {
|
||||
memo: string;
|
||||
};
|
||||
|
||||
export const ASSIGN_STATUS = {
|
||||
REQUESTED: 0,
|
||||
CONFIRMED: 1,
|
||||
REJECTED: 9,
|
||||
} as const;
|
||||
|
||||
export type AssignStatus = typeof ASSIGN_STATUS[keyof typeof ASSIGN_STATUS];
|
||||
|
||||
export type PerformanceAssign = {
|
||||
id: number;
|
||||
performanceId: number;
|
||||
assignType: number;
|
||||
assignOrder: number;
|
||||
assignUser: string;
|
||||
assignConfirm: boolean;
|
||||
assignStatus: AssignStatus;
|
||||
};
|
||||
|
||||
export type MonitoringApplyUser = {
|
||||
@@ -91,7 +99,7 @@ export type PerformanceFull = PerformanceBase & {
|
||||
export type PerformanceMonitoringSchedule = {
|
||||
id: number;
|
||||
performanceId: number;
|
||||
monitoringDate: string;
|
||||
monitoringDate: string | null;
|
||||
monitoringTimeInfo: string;
|
||||
monitoringAddress: string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user