261012_01_ENH: ai 하네스 수정 및 배정 캘린더·모니터링 계정 표시 개선
- AI 하네스 참조 문서·스킬 추가 및 AGENTS.md, .agent/project.md 갱신 - 사업정보: 수정 권한(내부·재단) 계정에 배정 캘린더 버튼 추가 - 사업정보: 모니터링 계정은 본인 배정 슬롯만 표시, 툴팁에 모니터링/컨설팅 구분 표시 - 공연 상세: 모니터링 계정에는 관계자 정보 숨김 - 신청자 수·평가위원 조회 hook에 enabled 옵션 추가
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
"use client";
|
||||
|
||||
import {useState} from "react";
|
||||
import {Download, Upload} from "lucide-react";
|
||||
import {CalendarDays, Download, Upload} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {PagePanel} from "@/components/kmusical/PagePanel";
|
||||
import {PerformanceFilterBar} from "@/components/kmusical/PerformanceFilterBar";
|
||||
import {StatusPill} from "@/components/kmusical/StatusPill";
|
||||
import {ExcelRegisterDialog} from "@/components/dialog/ExcelRegisterDialog";
|
||||
import {PerformanceDetailDialog} from "@/components/dialog/PerformanceDetailDialog";
|
||||
import {AssignCalendarDialog} from "@/components/dialog/AssignCalendarDialog";
|
||||
import {DataTable} from "@/components/data-table/DataTable";
|
||||
import type {DataTableColumn} from "@/components/data-table/DataTable.type";
|
||||
import {useCodesQuery} from "@/query/code";
|
||||
@@ -21,6 +22,9 @@ import {
|
||||
useUploadPerformanceExcelMutation,
|
||||
} from "@/query/performance";
|
||||
import {useDownloadReviewOriginalMutation, useReviewSlotsQuery} from "@/query/review";
|
||||
import {useMonitoringApplyUsersCountQuery} from "@/query/assign";
|
||||
import {useUserListQuery} from "@/query/user";
|
||||
import {MONITORING_USER_ROLE} from "@/config/kmusical.config";
|
||||
import {
|
||||
excludeMastersWithSub,
|
||||
filterPerformance,
|
||||
@@ -33,7 +37,7 @@ import {
|
||||
import {getMonitoringStatusDisplay, isReviewComplete} from "@/lib/kmusical/performance-status";
|
||||
import {downloadBlob, downloadExcelBuffer} from "@/lib/kmusical/file";
|
||||
import {PERFORMANCE_FIELD_LABELS} from "@/lib/kmusical/field-labels";
|
||||
import type {PerformanceFull} from "@/types/kmusical";
|
||||
import {REVIEW_TYPE, type PerformanceFull, type PerformanceReviewSlot} from "@/types/kmusical";
|
||||
import {useAuth} from "@/hooks/useAuth";
|
||||
import {useDialog} from "@/hooks/useDialog";
|
||||
import ExcelDownloadButton from "@/components/kmusical/ExcelDownloadButton";
|
||||
@@ -61,14 +65,20 @@ const PerformancePage = () => {
|
||||
const originalMutation = useDownloadReviewOriginalMutation();
|
||||
const detailOpen = isDialogOpen("performanceDetailDialog");
|
||||
const registerOpen = isDialogOpen("performanceExcelRegisterDialog");
|
||||
const calendarOpen = isDialogOpen("assignCalendarDialog");
|
||||
const {data: detail, refetch: refetchDetail} = usePerformanceQuery(detailOpen ? selectedId : "");
|
||||
const isFoundation = isFoundationRole(auth.user?.userRole);
|
||||
const canRegister = isInternalRole(auth.user?.userRole);
|
||||
const canEdit = canRegister || isFoundationRole(auth.user?.userRole);
|
||||
const canEdit = canRegister || isFoundation;
|
||||
|
||||
const {data: applyCounts = []} = useMonitoringApplyUsersCountQuery(canEdit && calendarOpen);
|
||||
const {data: reviewers = []} = useUserListQuery(MONITORING_USER_ROLE, canEdit && calendarOpen);
|
||||
const applyCountMap = new Map(applyCounts.map((item) => [item.performanceId, item.applyCnt]));
|
||||
const canDelete = isResearcherRole(auth.user?.userRole);
|
||||
|
||||
const visibleData = isMonitoring
|
||||
? data.filter((item) => Boolean(auth.user?.userId && item.performanceAssignList.some((assign) => assign.assignUser === auth.user?.userId)))
|
||||
: isFoundationRole(auth.user?.userRole)
|
||||
: isFoundation
|
||||
? excludeMastersWithSub(data)
|
||||
: data;
|
||||
const filteredData = visibleData.filter((item) => filterPerformance(item, filters));
|
||||
@@ -80,6 +90,27 @@ const PerformancePage = () => {
|
||||
downloadBlob(buffer, review.uploadFileName);
|
||||
};
|
||||
|
||||
const renderReviewSlotCell = (performance: PerformanceFull, slot: PerformanceReviewSlot) => {
|
||||
const assign = performance.performanceAssignList.find((item) => item.reviewSlot === slot.reviewSlot);
|
||||
const review = Object.values(performance.performanceReviewMap ?? {}).find((item) => item.reviewSlot === slot.reviewSlot);
|
||||
const display = getMonitoringStatusDisplay(getCodeLabel(codes, "review_status", review?.reviewStatus), {
|
||||
reviewSlot: slot.reviewSlot,
|
||||
reviewType: slot.reviewType,
|
||||
assign,
|
||||
review,
|
||||
});
|
||||
const reviewTypeLabel = slot.reviewType === REVIEW_TYPE.CONSULTING ? "컨설팅" : "모니터링";
|
||||
return (
|
||||
<StatusPill
|
||||
variant={display.variant}
|
||||
onClick={isReviewComplete(review) ? () => downloadReview(performance, slot.reviewSlot) : undefined}
|
||||
tooltip={<span>{isMonitoring ? reviewTypeLabel : `담당자: ${assign?.assignUser || "-"}`}</span>}
|
||||
>
|
||||
{display.label}
|
||||
</StatusPill>
|
||||
);
|
||||
};
|
||||
|
||||
const columns: DataTableColumn<PerformanceFull>[] = [
|
||||
{accessorKey: "performanceNo", header: PERFORMANCE_FIELD_LABELS.performanceNo, size: 60},
|
||||
{accessorKey: "performanceId", header: PERFORMANCE_FIELD_LABELS.performanceId, size: 90, sortingFn: "text"},
|
||||
@@ -103,31 +134,26 @@ const PerformancePage = () => {
|
||||
accessorFn: (row) => row.performanceMonitoringSchedule.monitoringTimeInfo ?? 0,
|
||||
cell: ({row}) => !row.original.performanceMonitoringSchedule.monitoringTimeInfo? "미정":`${row.original.performanceMonitoringSchedule.monitoringTimeInfo}`
|
||||
},
|
||||
...reviewSlots.map<DataTableColumn<PerformanceFull>>((slot) => ({
|
||||
id: `review-${slot.reviewSlot}`,
|
||||
header: slot.reviewLabel,
|
||||
size: 110,
|
||||
enableSorting: false,
|
||||
cell: ({row}) => {
|
||||
const assign = row.original.performanceAssignList.find((item) => item.reviewSlot === slot.reviewSlot);
|
||||
const review = Object.values(row.original.performanceReviewMap ?? {}).find((item) => item.reviewSlot === slot.reviewSlot);
|
||||
const display = getMonitoringStatusDisplay(getCodeLabel(codes, "review_status", review?.reviewStatus), {
|
||||
reviewSlot: slot.reviewSlot,
|
||||
reviewType: slot.reviewType,
|
||||
assign,
|
||||
review,
|
||||
});
|
||||
return (
|
||||
<StatusPill
|
||||
variant={display.variant}
|
||||
onClick={isReviewComplete(review) ? () => downloadReview(row.original, slot.reviewSlot) : undefined}
|
||||
tooltip={<span>담당자: {assign?.assignUser || "-"}</span>}
|
||||
>
|
||||
{display.label}
|
||||
</StatusPill>
|
||||
);
|
||||
},
|
||||
})),
|
||||
// 모니터링 계정은 한 사업에 한 번만 배정되므로 본인이 배정된 슬롯 하나만 보여준다.
|
||||
...(isMonitoring
|
||||
? [{
|
||||
id: "review-assigned",
|
||||
header: "모니터링/컨설팅",
|
||||
size: 110,
|
||||
enableSorting: false,
|
||||
cell: ({row}) => {
|
||||
const assign = row.original.performanceAssignList.find((item) => item.assignUser === auth.user?.userId);
|
||||
const slot = reviewSlots.find((item) => item.reviewSlot === assign?.reviewSlot);
|
||||
return slot ? renderReviewSlotCell(row.original, slot) : "-";
|
||||
},
|
||||
} satisfies DataTableColumn<PerformanceFull>]
|
||||
: reviewSlots.map<DataTableColumn<PerformanceFull>>((slot) => ({
|
||||
id: `review-${slot.reviewSlot}`,
|
||||
header: slot.reviewLabel,
|
||||
size: 110,
|
||||
enableSorting: false,
|
||||
cell: ({row}) => renderReviewSlotCell(row.original, slot),
|
||||
}))),
|
||||
];
|
||||
|
||||
const downloadTemplate = async () => {
|
||||
@@ -159,6 +185,11 @@ const PerformancePage = () => {
|
||||
|
||||
<PagePanel className="overflow-x-auto">
|
||||
<div className="mb-3 flex flex-wrap justify-end gap-2">
|
||||
{canEdit && (
|
||||
<Button type="button" variant="outline" onClick={() => showDialog("assignCalendarDialog")}>
|
||||
<CalendarDays className="h-4 w-4" />배정 캘린더
|
||||
</Button>
|
||||
)}
|
||||
{canRegister && <Button type="button" onClick={() => showDialog("performanceExcelRegisterDialog")}><Upload className="h-4 w-4" />공연 등록</Button>}
|
||||
<ExcelDownloadButton requestExcelExport={downloadPerformances} />
|
||||
</div>
|
||||
@@ -210,6 +241,17 @@ const PerformancePage = () => {
|
||||
}}
|
||||
isUploading={uploadMutation.isPending}
|
||||
/>
|
||||
|
||||
{canEdit && (
|
||||
<AssignCalendarDialog
|
||||
open={calendarOpen}
|
||||
onOpenChange={(open) => open ? showDialog("assignCalendarDialog") : hideDialog("assignCalendarDialog")}
|
||||
performances={visibleData}
|
||||
applyCountMap={applyCountMap}
|
||||
reviewSlots={reviewSlots}
|
||||
reviewers={reviewers}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -367,26 +367,29 @@ export function PerformanceDetailDialog({
|
||||
/>
|
||||
))}
|
||||
</section>
|
||||
{!isMonitoring && (
|
||||
<section className="rounded-md border">
|
||||
<div className="border-b bg-muted px-3 py-2 font-semibold">관계자 정보</div>
|
||||
<div className="overflow-auto">
|
||||
<table className="kmf-table min-w-[620px]">
|
||||
<thead><tr><th>유형</th><th>이름</th><th>연락처1</th><th>연락처2</th><th>이메일</th></tr></thead>
|
||||
<tbody>
|
||||
{draft.performanceStaff.map((staff, index) => (
|
||||
<tr key={staff.id}>
|
||||
<td>{getCodeLabel(codes, "staff_type", staff.staffType)}</td>
|
||||
<td>{isEditing ? <Input value={staff.staffName} onChange={(event) => updateStaff(index, "staffName", event.target.value)} /> : staff.staffName}</td>
|
||||
<td>{isEditing ? <Input value={staff.staffTel1} onChange={(event) => updateStaff(index, "staffTel1", event.target.value)} /> : staff.staffTel1}</td>
|
||||
<td>{isEditing ? <Input value={staff.staffTel2} onChange={(event) => updateStaff(index, "staffTel2", event.target.value)} /> : staff.staffTel2}</td>
|
||||
<td>{isEditing ? <Input value={staff.staffEmail} onChange={(event) => updateStaff(index, "staffEmail", event.target.value)} /> : staff.staffEmail}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
<section className="rounded-md border">
|
||||
<div className="border-b bg-muted px-3 py-2 font-semibold">관계자 정보</div>
|
||||
<div className="overflow-auto">
|
||||
<table className="kmf-table min-w-[620px]">
|
||||
<thead><tr><th>유형</th><th>이름</th><th>연락처1</th><th>연락처2</th><th>이메일</th></tr></thead>
|
||||
<tbody>
|
||||
{draft.performanceStaff.map((staff, index) => (
|
||||
<tr key={staff.id}>
|
||||
<td>{getCodeLabel(codes, "staff_type", staff.staffType)}</td>
|
||||
<td>{isEditing ? <Input value={staff.staffName} onChange={(event) => updateStaff(index, "staffName", event.target.value)} /> : staff.staffName}</td>
|
||||
<td>{isEditing ? <Input value={staff.staffTel1} onChange={(event) => updateStaff(index, "staffTel1", event.target.value)} /> : staff.staffTel1}</td>
|
||||
<td>{isEditing ? <Input value={staff.staffTel2} onChange={(event) => updateStaff(index, "staffTel2", event.target.value)} /> : staff.staffTel2}</td>
|
||||
<td>{isEditing ? <Input value={staff.staffEmail} onChange={(event) => updateStaff(index, "staffEmail", event.target.value)} /> : staff.staffEmail}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section className="rounded-md border">
|
||||
|
||||
@@ -11,9 +11,10 @@ import type {
|
||||
PerformanceAssignRequest,
|
||||
} from "@/types/kmusical";
|
||||
|
||||
export const useMonitoringApplyUsersCountQuery = () => useQuery({
|
||||
export const useMonitoringApplyUsersCountQuery = (enabled = true) => useQuery({
|
||||
queryKey: queryKeys.assign.monitoringApplyUsersCount,
|
||||
queryFn: () => nextApi.get<PerformanceApplyCount[]>("/assign/monitoring/apply-users/count"),
|
||||
enabled,
|
||||
});
|
||||
|
||||
export const useMonitoringApplyUsersQuery = (performanceId: string, options?: {ignoreGlobalLoading?: boolean}) => useQuery({
|
||||
|
||||
@@ -6,9 +6,10 @@ import { nextApi } from "@/lib/http-client";
|
||||
import { queryKeys } from "@/query/key/keys";
|
||||
import type { UserFull } from "@/types/kmusical";
|
||||
|
||||
export const useUserListQuery = (userRole: number) => useQuery({
|
||||
export const useUserListQuery = (userRole: number, enabled = true) => useQuery({
|
||||
queryKey: queryKeys.user.list(userRole),
|
||||
queryFn: () => nextApi.get<UserFull[]>(`/user/list/${userRole}`),
|
||||
enabled,
|
||||
});
|
||||
|
||||
export const useUserQuery = (userId: string) => useQuery({
|
||||
|
||||
Reference in New Issue
Block a user