Merge pull request '261001_03_ENH: sub 공연 신청자 수 부모 공연 기준 적용 및 sub가 있는 마스터 공연 목록 제외, 연번 문자 정렬 적용' (#5) from develop into master
Reviewed-on: #5
This commit is contained in:
@@ -19,7 +19,13 @@ import {
|
||||
useMonitoringApplyUsersQuery,
|
||||
} from "@/query/assign";
|
||||
import {useReviewSlotsQuery} from "@/query/review";
|
||||
import {filterPerformance, getCodeLabel, type PerformanceFilterState} from "@/lib/kmusical/view";
|
||||
import {
|
||||
excludeMastersWithSub,
|
||||
filterPerformance,
|
||||
getApplyPerformanceId,
|
||||
getCodeLabel,
|
||||
type PerformanceFilterState,
|
||||
} from "@/lib/kmusical/view";
|
||||
import {buildPerformanceSmsParams} from "@/lib/kmusical/notification";
|
||||
import {PERFORMANCE_FIELD_LABELS} from "@/lib/kmusical/field-labels";
|
||||
import {REVIEW_TYPE, type PerformanceFull, type ReviewType} from "@/types/kmusical";
|
||||
@@ -54,7 +60,7 @@ const AssignPage = () => {
|
||||
const smsOpen = isDialogOpen("assignSmsSendDialog");
|
||||
const calendarOpen = isDialogOpen("assignCalendarDialog");
|
||||
const {data: detail, refetch: refetchDetail} = usePerformanceQuery(assignOpen ? selectedId : "");
|
||||
const {data: applyUsers = []} = useMonitoringApplyUsersQuery(selectedId);
|
||||
const {data: applyUsers = []} = useMonitoringApplyUsersQuery(getApplyPerformanceId(selectedId));
|
||||
const {data: users = []} = useUserListQuery(MONITORING_USER_ROLE);
|
||||
const suppressAssignCloseRef = useRef(false);
|
||||
const confirmMutation = useConfirmAssignMutation();
|
||||
@@ -64,7 +70,8 @@ const AssignPage = () => {
|
||||
const reviewSlotTypeMap = new Map(reviewSlots.map((slot) => [slot.reviewSlot, slot.reviewType]));
|
||||
const countConfirmedAssigns = (row: PerformanceFull, reviewType: ReviewType) =>
|
||||
row.performanceAssignList.filter((assign) => reviewSlotTypeMap.get(assign.reviewSlot) === reviewType).length;
|
||||
const filteredData = data
|
||||
const assignableData = excludeMastersWithSub(data);
|
||||
const filteredData = assignableData
|
||||
.filter((item) => filterPerformance(item, filters))
|
||||
.sort((a, b) => (b.performanceMonitoringSchedule?.monitoringDate ?? "").localeCompare(a.performanceMonitoringSchedule?.monitoringDate ?? ""));
|
||||
const selected = detail ?? data.find((item) => item.performanceId === selectedId) ?? null;
|
||||
@@ -75,7 +82,7 @@ const AssignPage = () => {
|
||||
const smsTargetUsers = availableUsers.filter((user) => smsTargetIds.includes(user.userId));
|
||||
|
||||
const columns: DataTableColumn<PerformanceFull>[] = [
|
||||
{accessorKey: "performanceId", header: PERFORMANCE_FIELD_LABELS.performanceId, size: 90},
|
||||
{accessorKey: "performanceId", header: PERFORMANCE_FIELD_LABELS.performanceId, size: 90, sortingFn: "text"},
|
||||
{
|
||||
accessorKey: "performanceName",
|
||||
header: PERFORMANCE_FIELD_LABELS.performanceName,
|
||||
@@ -109,7 +116,7 @@ const AssignPage = () => {
|
||||
),
|
||||
enableSorting: false
|
||||
},
|
||||
{id: "applyCount", header: "신청자 수", size: 100, accessorFn: (row) => applyCountMap.get(row.performanceId) ?? 0},
|
||||
{id: "applyCount", header: "신청자 수", size: 100, accessorFn: (row) => applyCountMap.get(getApplyPerformanceId(row.performanceId)) ?? 0},
|
||||
{id: "monitoringAssignCount", header: "모니터링 확정자 수", size: 140, accessorFn: (row) => countConfirmedAssigns(row, REVIEW_TYPE.MONITORING)},
|
||||
{id: "consultingAssignCount", header: "컨설팅 확정자 수", size: 140, accessorFn: (row) => countConfirmedAssigns(row, REVIEW_TYPE.CONSULTING)},
|
||||
];
|
||||
@@ -269,7 +276,7 @@ const AssignPage = () => {
|
||||
<AssignCalendarDialog
|
||||
open={calendarOpen}
|
||||
onOpenChange={(open) => open ? showDialog("assignCalendarDialog") : hideDialog("assignCalendarDialog")}
|
||||
performances={data}
|
||||
performances={assignableData}
|
||||
applyCountMap={applyCountMap}
|
||||
reviewSlots={reviewSlots}
|
||||
reviewers={users}
|
||||
|
||||
@@ -21,7 +21,15 @@ import {
|
||||
useUploadPerformanceExcelMutation,
|
||||
} from "@/query/performance";
|
||||
import {useDownloadReviewOriginalMutation, useReviewSlotsQuery} from "@/query/review";
|
||||
import {filterPerformance, getCodeLabel, isInternalRole, isResearcherRole, type PerformanceFilterState} from "@/lib/kmusical/view";
|
||||
import {
|
||||
excludeMastersWithSub,
|
||||
filterPerformance,
|
||||
getCodeLabel,
|
||||
isFoundationRole,
|
||||
isInternalRole,
|
||||
isResearcherRole,
|
||||
type PerformanceFilterState,
|
||||
} from "@/lib/kmusical/view";
|
||||
import {getMonitoringStatusDisplay, isReviewComplete} from "@/lib/kmusical/performance-status";
|
||||
import {downloadBlob, downloadExcelBuffer} from "@/lib/kmusical/file";
|
||||
import {PERFORMANCE_FIELD_LABELS} from "@/lib/kmusical/field-labels";
|
||||
@@ -59,7 +67,9 @@ const PerformancePage = () => {
|
||||
|
||||
const visibleData = isMonitoring
|
||||
? data.filter((item) => Boolean(auth.user?.userId && item.performanceAssignList.some((assign) => assign.assignUser === auth.user?.userId)))
|
||||
: data;
|
||||
: isFoundationRole(auth.user?.userRole)
|
||||
? excludeMastersWithSub(data)
|
||||
: data;
|
||||
const filteredData = visibleData.filter((item) => filterPerformance(item, filters));
|
||||
|
||||
const downloadReview = async (performance: PerformanceFull, reviewSlot: number) => {
|
||||
@@ -71,7 +81,7 @@ const PerformancePage = () => {
|
||||
|
||||
const columns: DataTableColumn<PerformanceFull>[] = [
|
||||
{accessorKey: "performanceNo", header: PERFORMANCE_FIELD_LABELS.performanceNo, size: 60},
|
||||
{accessorKey: "performanceId", header: PERFORMANCE_FIELD_LABELS.performanceId, size: 90},
|
||||
{accessorKey: "performanceId", header: PERFORMANCE_FIELD_LABELS.performanceId, size: 90, sortingFn: "text"},
|
||||
{id: "businessType", header: PERFORMANCE_FIELD_LABELS.businessType, size: 100, cell: ({row}) => getCodeLabel(codes, "business_type", row.original.businessType)},
|
||||
{id: "area", header: PERFORMANCE_FIELD_LABELS.performanceArea, size: 80, cell: ({row}) => getCodeLabel(codes, "area", row.original.performanceArea)},
|
||||
{accessorKey: "artistName", header: PERFORMANCE_FIELD_LABELS.artistName, size: 160},
|
||||
|
||||
@@ -11,7 +11,7 @@ import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from "@/compon
|
||||
import {KriMultiSelect} from "@/components/common/KriAutoComplete";
|
||||
import {StatusPill} from "@/components/kmusical/StatusPill";
|
||||
import {useAllMonitoringApplyUsersQuery} from "@/query/assign";
|
||||
import {getDetailValue, includesText} from "@/lib/kmusical/view";
|
||||
import {getApplyPerformanceId, getDetailValue, includesText} from "@/lib/kmusical/view";
|
||||
import {
|
||||
buildMonthGrid,
|
||||
chunkIntoWeeks,
|
||||
@@ -151,10 +151,12 @@ export function AssignCalendarDialog({
|
||||
list.push(applyUser);
|
||||
applyUsersByPerformanceId.set(applyUser.performanceId, list);
|
||||
}
|
||||
const detailApplyUsers = detailPerformance ? applyUsersByPerformanceId.get(detailPerformance.performanceId) ?? [] : [];
|
||||
const detailApplyUsers = detailPerformance ? applyUsersByPerformanceId.get(getApplyPerformanceId(detailPerformance.performanceId)) ?? [] : [];
|
||||
|
||||
const orderedPerformanceIds = performances.map((performance) => performance.performanceId);
|
||||
const searchedPerformances = performances.filter((performance) => includesText(performance.performanceName, performanceSearch));
|
||||
const searchedPerformances = performances
|
||||
.filter((performance) => includesText(performance.performanceName, performanceSearch))
|
||||
.sort((a, b) => a.performanceId.localeCompare(b.performanceId, "ko"));
|
||||
const allSelected = performances.length > 0 && selectedPerformanceIds.size === performances.length;
|
||||
|
||||
const togglePerformance = (performanceId: string) => {
|
||||
@@ -278,7 +280,7 @@ export function AssignCalendarDialog({
|
||||
colorClassName={PERFORMANCE_BADGE_COLOR_CLASSES[getPerformanceColorSlot(performance.performanceId, orderedPerformanceIds)]}
|
||||
reviewSlots={reviewSlots}
|
||||
userById={userById}
|
||||
applyUsers={applyUsersByPerformanceId.get(performance.performanceId) ?? []}
|
||||
applyUsers={applyUsersByPerformanceId.get(getApplyPerformanceId(performance.performanceId)) ?? []}
|
||||
onClick={() => setSelectedDetailPerformanceId(performance.performanceId)}
|
||||
/>
|
||||
))}
|
||||
@@ -301,7 +303,7 @@ export function AssignCalendarDialog({
|
||||
colorClassName={PERFORMANCE_BADGE_COLOR_CLASSES[getPerformanceColorSlot(performance.performanceId, orderedPerformanceIds)]}
|
||||
reviewSlots={reviewSlots}
|
||||
userById={userById}
|
||||
applyUsers={applyUsersByPerformanceId.get(performance.performanceId) ?? []}
|
||||
applyUsers={applyUsersByPerformanceId.get(getApplyPerformanceId(performance.performanceId)) ?? []}
|
||||
onClick={() => {
|
||||
setExpandedDayKey(null);
|
||||
setSelectedDetailPerformanceId(performance.performanceId);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {parseLocalDateString, toLocalDateString} from "@/lib/kmusical/date";
|
||||
import {getApplyPerformanceId} from "@/lib/kmusical/view";
|
||||
import type {PerformanceFull, PerformanceReviewSlot} from "@/types/kmusical";
|
||||
|
||||
export const WEEKDAY_LABELS = ["일", "월", "화", "수", "목", "금", "토"] as const;
|
||||
@@ -99,7 +100,7 @@ export const getPerformanceBadgeInfo = (
|
||||
applyCountMap: Map<string, number>,
|
||||
reviewSlots: PerformanceReviewSlot[]
|
||||
): PerformanceBadgeInfo => {
|
||||
const applyCount = applyCountMap.get(performance.performanceId) ?? 0;
|
||||
const applyCount = applyCountMap.get(getApplyPerformanceId(performance.performanceId)) ?? 0;
|
||||
const assignCount = performance.performanceAssignList.length;
|
||||
const requiredAssignCount = reviewSlots.length;
|
||||
const isMatchingComplete = requiredAssignCount > 0 && assignCount >= requiredAssignCount;
|
||||
|
||||
@@ -49,6 +49,23 @@ export const includesText = (value: unknown, keyword: string) => {
|
||||
return String(value ?? "").toLowerCase().includes(keyword.toLowerCase());
|
||||
};
|
||||
|
||||
// 4자리 연번은 sub 공연이며 앞 3자리가 부모 공연 연번이다. 신청은 부모 공연 기준으로 받는다.
|
||||
export const isSubPerformanceId = (performanceId: string) => /^\d{4}$/.test(performanceId);
|
||||
|
||||
export const getApplyPerformanceId = (performanceId: string) =>
|
||||
isSubPerformanceId(performanceId) ? performanceId.slice(0, 3) : performanceId;
|
||||
|
||||
// sub 공연이 있는 마스터 공연을 목록에서 제외한다.
|
||||
export const excludeMastersWithSub = <T extends {performanceId: string}>(performances: T[]): T[] => {
|
||||
const masterIdsWithSub = new Set(
|
||||
performances
|
||||
.map((performance) => performance.performanceId)
|
||||
.filter(isSubPerformanceId)
|
||||
.map(getApplyPerformanceId)
|
||||
);
|
||||
return performances.filter((performance) => !masterIdsWithSub.has(performance.performanceId));
|
||||
};
|
||||
|
||||
export type PerformanceFilterState = {
|
||||
businessType: string[];
|
||||
area: string[];
|
||||
|
||||
Reference in New Issue
Block a user