From 3d4fa65b0e40bc095db1e587eb7a5b9e544c5a46 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Wed, 24 Jun 2026 09:40:24 +0900 Subject: [PATCH 01/24] =?UTF-8?q?260624=5F01=5FENH:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=20=EC=88=98=EC=A0=95=20=EA=B4=80=EB=A0=A8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(pages)/(main)/user/page.tsx | 22 +++++++++---------- .../dialog/AssignMonitoringDialog.tsx | 4 ++-- src/components/dialog/SmsSendDialog.tsx | 12 ++++++++++ src/lib/gwcf/view.ts | 18 +++++++-------- 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/app/(pages)/(main)/user/page.tsx b/src/app/(pages)/(main)/user/page.tsx index cf31d34..c7fa000 100644 --- a/src/app/(pages)/(main)/user/page.tsx +++ b/src/app/(pages)/(main)/user/page.tsx @@ -146,11 +146,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 || "-"); @@ -177,18 +177,18 @@ const UserPage = () => { const monitoringColumns: DataTableColumn[] = [ {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: "area", header: "지역", cell: ({row}) => renderEditableCell(row.original, "userArea", "select", codes.area)}, + {id: "gender", header: "성별", cell: ({row}) => renderEditableCell(row.original, "gender", "select", codes.gender)}, + {id: "userAge", header: "연령", cell: ({row}) => renderEditableCell(row.original, "userAge")}, + {id: "userTel", header: "연락처", cell: ({row}) => renderEditableCell(row.original, "userTel")}, + {id: "userEmail", header: "이메일", cell: ({row}) => renderEditableCell(row.original, "userEmail")}, + {id: "userHasCar", header: "자차 여부", cell: ({row}) => renderEditableCell(row.original, "userHasCar", "select", codes.has_car)}, ]; const writtenColumns: DataTableColumn[] = [ - {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: "장르", cell: ({row}) => renderEditableCell(row.original, "userGenre", "select", codes.genre)}, + {id: "userTel", header: "연락처", cell: ({row}) => renderEditableCell(row.original, "userTel")}, + {id: "userEmail", header: "이메일", cell: ({row}) => renderEditableCell(row.original, "userEmail")}, ]; const actionColumns: DataTableColumn[] = [ diff --git a/src/components/dialog/AssignMonitoringDialog.tsx b/src/components/dialog/AssignMonitoringDialog.tsx index 9c964d2..46504e7 100644 --- a/src/components/dialog/AssignMonitoringDialog.tsx +++ b/src/components/dialog/AssignMonitoringDialog.tsx @@ -163,8 +163,8 @@ export function AssignMonitoringDialog({ ["모니터링 일정", selected?.performanceMonitoringSchedule?.monitoringDate], ["모니터링 시간", selected?.performanceMonitoringSchedule?.monitoringTimeInfo], ["방문 장소", selected?.performanceMonitoringSchedule?.monitoringAddress], - ["예매 예약", getCodeLabel(codes, "ticket_reservation_status", selected?.ticketReservationStatus)], - ["예매 비고", selected?.ticketReservationMemo], + ["티켓 예약", getCodeLabel(codes, "ticket_reservation_status", selected?.ticketReservationStatus)], + ["티 비고", selected?.ticketReservationMemo], ].map(([label, value]) => ( {label} diff --git a/src/components/dialog/SmsSendDialog.tsx b/src/components/dialog/SmsSendDialog.tsx index 4efb276..dae3dfc 100644 --- a/src/components/dialog/SmsSendDialog.tsx +++ b/src/components/dialog/SmsSendDialog.tsx @@ -85,6 +85,12 @@ export function SmsSendDialog({ .filter((item) => item.destTel); }, [selectedUsers, addParams]); + const msgParamKeys = useMemo(() => { + return Array.from( + new Set(destinations.flatMap((destination) => Object.keys(destination.msgParam))) + ); + }, [destinations]); + useEffect(() => { if (!open) return; @@ -105,6 +111,12 @@ export function SmsSendDialog({ setDraft((prev) => prev ? {...prev, [key]: value} : prev); }; + useEffect(() => { + if (!open) return; + + console.log("d\estinations msgParam keys", msgParamKeys, destinations); + }, [msgParamKeys, open]); + const saveTemplate = async () => { if (!draft) return null; diff --git a/src/lib/gwcf/view.ts b/src/lib/gwcf/view.ts index ad1de34..9beb35a 100644 --- a/src/lib/gwcf/view.ts +++ b/src/lib/gwcf/view.ts @@ -35,14 +35,12 @@ export const getCodeLabel = ( export const getDetailValue = ( detail: Record | 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) ) ); }; From 438e6258dcaeb3e10b7129937efb932129d6f2fc Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Wed, 24 Jun 2026 09:53:34 +0900 Subject: [PATCH 02/24] =?UTF-8?q?260624=5F02=5FENH:=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=20=EC=83=81=EC=84=B8=20=EC=A0=95=EB=B3=B4=20=EA=B0=80?= =?UTF-8?q?=EC=A0=B8=EC=98=A4=EA=B8=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/dialog/AssignMonitoringDialog.tsx | 4 ++-- src/components/dialog/PerformanceDetailDialog.tsx | 10 +++++----- src/components/dialog/SmsSendDialog.tsx | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/dialog/AssignMonitoringDialog.tsx b/src/components/dialog/AssignMonitoringDialog.tsx index 46504e7..3ddfb28 100644 --- a/src/components/dialog/AssignMonitoringDialog.tsx +++ b/src/components/dialog/AssignMonitoringDialog.tsx @@ -119,12 +119,12 @@ export function AssignMonitoringDialog({ id: "area", header: "지역", 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"], "-"), + cell: ({row}) => getDetailValue(row.original.user?.userDetail, "userTel", "-"), }, { id: "status", diff --git a/src/components/dialog/PerformanceDetailDialog.tsx b/src/components/dialog/PerformanceDetailDialog.tsx index 3ebfc28..6a642c6 100644 --- a/src/components/dialog/PerformanceDetailDialog.tsx +++ b/src/components/dialog/PerformanceDetailDialog.tsx @@ -86,13 +86,13 @@ 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"])); + ? getCodeLabel(codes, "area", getDetailValue(detail, "userArea")) + : getCodeLabel(codes, "genre", getDetailValue(detail, "userGenre")); const metaLabel = type === "monitoring" ? "지역" : "장르"; - const hasCar = getCodeLabel(codes, "has_car", getDetailValue(detail, ["userHasCar", "has_car", "hasCar"])) || "-"; + const hasCar = getCodeLabel(codes, "has_car", getDetailValue(detail, "userHasCar")) || "-"; return (
diff --git a/src/components/dialog/SmsSendDialog.tsx b/src/components/dialog/SmsSendDialog.tsx index dae3dfc..b1adced 100644 --- a/src/components/dialog/SmsSendDialog.tsx +++ b/src/components/dialog/SmsSendDialog.tsx @@ -75,7 +75,7 @@ export function SmsSendDialog({ return selectedUsers .map((user) => ({ sid: user.userId, - destTel: getDetailValue(user.userDetail, ["userTel"]), + destTel: getDetailValue(user.userDetail, "userTel"), destNm: user.userName || user.userId, msgParam: { ...buildUserMsgParam(user), From c4f8e630ea46977a316a71e4192c075b36c512d1 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Wed, 24 Jun 2026 10:39:47 +0900 Subject: [PATCH 03/24] =?UTF-8?q?260624=5F03=5FENH:=20label=20=EC=9D=BC?= =?UTF-8?q?=EA=B4=84=20=EA=B4=80=EB=A6=AC=20=EB=B0=8F=20=EB=AC=B8=EC=9E=90?= =?UTF-8?q?=20=EB=B0=9C=EC=86=A1=20=ED=8C=9D=EC=97=85=EC=97=90=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EA=B0=80=EB=8A=A5=20=EB=B3=80=EC=88=98=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(pages)/(main)/assign/page.tsx | 22 +++-- src/app/(pages)/(main)/monitoring/page.tsx | 11 ++- src/app/(pages)/(main)/performance/page.tsx | 35 +++---- src/app/(pages)/(main)/user/page.tsx | 24 ++--- .../dialog/AssignMonitoringDialog.tsx | 33 +++---- .../MonitoringPerformanceDetailDialog.tsx | 31 +++--- .../dialog/PerformanceDetailDialog.tsx | 41 ++++---- src/components/dialog/SmsSendDialog.tsx | 94 +++++++++++++++---- src/lib/gwcf/field-labels.ts | 44 +++++++++ 9 files changed, 224 insertions(+), 111 deletions(-) create mode 100644 src/lib/gwcf/field-labels.ts diff --git a/src/app/(pages)/(main)/assign/page.tsx b/src/app/(pages)/(main)/assign/page.tsx index ef3f64d..b2e5067 100644 --- a/src/app/(pages)/(main)/assign/page.tsx +++ b/src/app/(pages)/(main)/assign/page.tsx @@ -25,6 +25,7 @@ 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"; const AssignPage = () => { const mounted = useMounted(); @@ -115,13 +116,13 @@ const AssignPage = () => { }; const columns = useMemo[]>(() => [ - {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 ?? ""}, + {accessorKey: "id", header: PERFORMANCE_FIELD_LABELS.id, cell: ({row}) => row.original.id, enableSorting: true}, + {accessorKey: "performanceName", header: PERFORMANCE_FIELD_LABELS.performanceName, enableSorting: true}, + {id: "area", header: PERFORMANCE_FIELD_LABELS.performanceArea, cell: ({row}) => getCodeLabel(codes, "area", row.original.performanceArea)}, + {accessorKey: "performanceDtInfo", header: PERFORMANCE_FIELD_LABELS.performanceDtInfo}, + {accessorKey: "performanceTimeInfo", header: PERFORMANCE_FIELD_LABELS.performanceTimeInfo}, + {id: "monitoringDate", header: PERFORMANCE_FIELD_LABELS.monitoringDate, cell: ({row}) => row.original.performanceMonitoringSchedule?.monitoringDate ?? "", enableSorting: true}, + {id: "monitoringTime", header: PERFORMANCE_FIELD_LABELS.monitoringTimeInfo, 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}, @@ -133,10 +134,10 @@ const AssignPage = () => {
- updateFilters((prev) => ({...prev, businessType: value}))} options={codes.business_type} placeholder="사업 유형" /> - updateFilters((prev) => ({...prev, area: value}))} options={codes.area} placeholder="지역" /> + updateFilters((prev) => ({...prev, businessType: value}))} options={codes.business_type} placeholder={PERFORMANCE_FIELD_LABELS.businessType} /> + updateFilters((prev) => ({...prev, area: value}))} options={codes.area} placeholder={PERFORMANCE_FIELD_LABELS.performanceArea} /> updateFilters((prev) => ({...prev, monitoringDate: event.target.value}))} /> - updateFilters((prev) => ({...prev, keyword: event.target.value}))} placeholder="연번 or 사업명" /> + updateFilters((prev) => ({...prev, keyword: event.target.value}))} placeholder={`${PERFORMANCE_FIELD_LABELS.id} or ${PERFORMANCE_FIELD_LABELS.performanceName}`} />
); diff --git a/src/components/dialog/AssignMonitoringDialog.tsx b/src/components/dialog/AssignMonitoringDialog.tsx index 3ddfb28..aa6352a 100644 --- a/src/components/dialog/AssignMonitoringDialog.tsx +++ b/src/components/dialog/AssignMonitoringDialog.tsx @@ -12,6 +12,7 @@ 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 {PERFORMANCE_FIELD_LABELS, USER_FIELD_LABELS} from "@/lib/gwcf/field-labels"; type CodeMap = Partial>; @@ -107,7 +108,7 @@ export function AssignMonitoringDialog({ }, { id: "user", - header: "신청자", + header: USER_FIELD_LABELS.userName, cell: ({row}) => (
{row.original.user?.userName || row.original.userId}
@@ -117,13 +118,13 @@ export function AssignMonitoringDialog({ }, { id: "area", - header: "지역", + header: USER_FIELD_LABELS.userArea, cell: ({row}) => getCodeLabel(codes, "area", getDetailValue(row.original.user?.userDetail, "userArea")) || "-", }, { id: "tel", - header: "연락처", + header: USER_FIELD_LABELS.userTel, cell: ({row}) => getDetailValue(row.original.user?.userDetail, "userTel", "-"), }, { @@ -152,19 +153,19 @@ export function AssignMonitoringDialog({ {[ - ["연번", 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]) => ( diff --git a/src/components/dialog/MonitoringPerformanceDetailDialog.tsx b/src/components/dialog/MonitoringPerformanceDetailDialog.tsx index f2564b8..dd7ac29 100644 --- a/src/components/dialog/MonitoringPerformanceDetailDialog.tsx +++ b/src/components/dialog/MonitoringPerformanceDetailDialog.tsx @@ -31,6 +31,7 @@ import { getReviewPdfDownloadName, openPreviewWindow, } from "@/lib/gwcf/file"; +import {PERFORMANCE_FIELD_LABELS} from "@/lib/gwcf/field-labels"; type CodeMap = Partial>; @@ -202,21 +203,21 @@ export function MonitoringPerformanceDetailDialog({ {performance ? ( <>
- {performance.id} - {getCodeLabel(codes, "business_type", performance.businessType)} - {getCodeLabel(codes, "genre", performance.performanceGenre)} - {getCodeLabel(codes, "area", performance.performanceArea)} - {performance.artistName} - {performance.performanceName} - {performance.performanceStartMonth}월 - {performance.performanceDtInfo} - {performance.performanceTimeInfo} - {getCodeLabel(codes, "ticket_reservation_status", performance.ticketReservationStatus)} - {performance.ticketReservationMemo} - {performance.performanceMonitoringSchedule?.monitoringDate} - {performance.performanceMonitoringSchedule?.monitoringTimeInfo} - {performance.performanceMonitoringSchedule?.monitoringAddress} - {performance.performanceMemo} + {performance.id} + {getCodeLabel(codes, "business_type", performance.businessType)} + {getCodeLabel(codes, "genre", performance.performanceGenre)} + {getCodeLabel(codes, "area", performance.performanceArea)} + {performance.artistName} + {performance.performanceName} + {performance.performanceStartMonth}월 + {performance.performanceDtInfo} + {performance.performanceTimeInfo} + {getCodeLabel(codes, "ticket_reservation_status", performance.ticketReservationStatus)} + {performance.ticketReservationMemo} + {performance.performanceMonitoringSchedule?.monitoringDate} + {performance.performanceMonitoringSchedule?.monitoringTimeInfo} + {performance.performanceMonitoringSchedule?.monitoringAddress} + {performance.performanceMemo}
diff --git a/src/components/dialog/PerformanceDetailDialog.tsx b/src/components/dialog/PerformanceDetailDialog.tsx index 6a642c6..3d77cf6 100644 --- a/src/components/dialog/PerformanceDetailDialog.tsx +++ b/src/components/dialog/PerformanceDetailDialog.tsx @@ -42,6 +42,7 @@ import { openPreviewWindow, openWrittenReviewWindow, } from "@/lib/gwcf/file"; +import {PERFORMANCE_FIELD_LABELS, USER_FIELD_LABELS} from "@/lib/gwcf/field-labels"; type CodeMap = Partial>; @@ -91,7 +92,7 @@ function AssignedUserInfo({ const metaValue = type === "monitoring" ? getCodeLabel(codes, "area", getDetailValue(detail, "userArea")) : getCodeLabel(codes, "genre", getDetailValue(detail, "userGenre")); - const metaLabel = type === "monitoring" ? "지역" : "장르"; + const metaLabel = type === "monitoring" ? USER_FIELD_LABELS.userArea : USER_FIELD_LABELS.userGenre; const hasCar = getCodeLabel(codes, "has_car", getDetailValue(detail, "userHasCar")) || "-"; return ( @@ -99,9 +100,9 @@ function AssignedUserInfo({
ID: {userId || "-"} {metaLabel}: {metaValue || "-"} - 연락처: {tel} - 이메일: {email} - {type === "monitoring" && 자차유무: {hasCar}} + {USER_FIELD_LABELS.userTel}: {tel} + {USER_FIELD_LABELS.userEmail}: {email} + {type === "monitoring" && {USER_FIELD_LABELS.userHasCar}: {hasCar}}
); @@ -480,25 +481,25 @@ export function PerformanceDetailDialog({
- {draft.id} - {getCodeLabel(codes, "business_type", draft.businessType)} - {getCodeLabel(codes, "genre", draft.performanceGenre)} - {getCodeLabel(codes, "area", draft.performanceArea)} - {draft.artistName} - {isEditing ? updateDraft("performanceName", event.target.value)} /> : draft.performanceName} - {isEditing ? updateDraft("performanceStartMonth", Number(event.target.value))} /> : `${draft.performanceStartMonth}월`} - {isEditing ? updateDraft("performanceDtInfo", event.target.value)} /> : draft.performanceDtInfo} - {isEditing ? updateDraft("performanceTimeInfo", event.target.value)} /> : draft.performanceTimeInfo} - + {draft.id} + {getCodeLabel(codes, "business_type", draft.businessType)} + {getCodeLabel(codes, "genre", draft.performanceGenre)} + {getCodeLabel(codes, "area", draft.performanceArea)} + {draft.artistName} + {isEditing ? updateDraft("performanceName", event.target.value)} /> : draft.performanceName} + {isEditing ? updateDraft("performanceStartMonth", Number(event.target.value))} /> : `${draft.performanceStartMonth}월`} + {isEditing ? updateDraft("performanceDtInfo", event.target.value)} /> : draft.performanceDtInfo} + {isEditing ? updateDraft("performanceTimeInfo", event.target.value)} /> : draft.performanceTimeInfo} + {isEditing ? ( - updateDraft("ticketReservationStatus", Number(value))} options={codes.ticket_reservation_status ?? []} placeholder="예매 예약" /> + updateDraft("ticketReservationStatus", Number(value))} options={codes.ticket_reservation_status ?? []} placeholder={PERFORMANCE_FIELD_LABELS.ticketReservationStatus} /> ) : getCodeLabel(codes, "ticket_reservation_status", draft.ticketReservationStatus)} - {isEditing ? updateDraft("ticketReservationMemo", event.target.value)} /> : draft.ticketReservationMemo} - {isEditing ? updateSchedule("monitoringDate", value)} /> : draft.performanceMonitoringSchedule?.monitoringDate} - {isEditing ? updateSchedule("monitoringTimeInfo", event.target.value)} /> : draft.performanceMonitoringSchedule?.monitoringTimeInfo} - {isEditing ? updateSchedule("monitoringAddress", event.target.value)} /> : draft.performanceMonitoringSchedule?.monitoringAddress} - {isEditing ? updateDraft("performanceMemo", event.target.value)} /> : draft.performanceMemo} + {isEditing ? updateDraft("ticketReservationMemo", event.target.value)} /> : draft.ticketReservationMemo} + {isEditing ? updateSchedule("monitoringDate", value)} /> : draft.performanceMonitoringSchedule?.monitoringDate} + {isEditing ? updateSchedule("monitoringTimeInfo", event.target.value)} /> : draft.performanceMonitoringSchedule?.monitoringTimeInfo} + {isEditing ? updateSchedule("monitoringAddress", event.target.value)} /> : draft.performanceMonitoringSchedule?.monitoringAddress} + {isEditing ? updateDraft("performanceMemo", event.target.value)} /> : draft.performanceMemo}
diff --git a/src/components/dialog/SmsSendDialog.tsx b/src/components/dialog/SmsSendDialog.tsx index b1adced..04d13ed 100644 --- a/src/components/dialog/SmsSendDialog.tsx +++ b/src/components/dialog/SmsSendDialog.tsx @@ -1,6 +1,6 @@ "use client"; -import {useEffect, useMemo, useState} from "react"; +import {useEffect, useMemo, useRef, useState} from "react"; import {Edit, RotateCcw, Save, Send} from "lucide-react"; import {Button} from "@/components/ui/button"; import {Input} from "@/components/ui/input"; @@ -22,9 +22,12 @@ 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; +const EMPTY_DENY_PARAM_KEYS: string[] = []; + const toText = (value: string | null | undefined) => value ?? ""; const toDraft = (template: Template, emptyBody = false): TemplateDraft => ({ @@ -43,6 +46,7 @@ export function SmsSendDialog({ newMessageTemplateIdx, selectedUsers, addParams = {}, + denyParamKeys = EMPTY_DENY_PARAM_KEYS, onBeforeDefaultTemplateSend, isBeforeSendPending = false, onSent, @@ -54,6 +58,7 @@ export function SmsSendDialog({ newMessageTemplateIdx?: number; selectedUsers: UserCompact[]; addParams?: Record; + denyParamKeys?: string[]; onBeforeDefaultTemplateSend?: () => Promise; isBeforeSendPending?: boolean; onSent?: () => void; @@ -63,6 +68,7 @@ export function SmsSendDialog({ const [isNewMessage, setIsNewMessage] = useState(false); const [isEditing, setIsEditing] = useState(false); const [draft, setDraft] = useState(null); + const bodyTextareaRef = useRef(null); const templateQuery = useNotificationTemplateQuery(activeTemplateIdx, open); const saveTemplateMutation = useSaveNotificationTemplateMutation(); @@ -71,19 +77,27 @@ export function SmsSendDialog({ const isBusy = templateQuery.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( @@ -111,11 +125,24 @@ export function SmsSendDialog({ setDraft((prev) => prev ? {...prev, [key]: value} : prev); }; - useEffect(() => { - if (!open) return; + const insertMsgParam = (key: string) => { + if (!draft || !canEdit || isBusy) return; - console.log("d\estinations msgParam keys", msgParamKeys, destinations); - }, [msgParamKeys, open]); + 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; @@ -134,6 +161,13 @@ export function SmsSendDialog({ return saved; }; + const cancelEdit = () => { + if (templateQuery.data) { + setDraft(toDraft(templateQuery.data, isNewMessage)); + } + setIsEditing(false); + }; + const switchToNewMessage = () => { if (!newMessageTemplateIdx) return; @@ -243,12 +277,32 @@ export function SmsSendDialog({
{label}