260624_05_ENH: 문자발송 팝업 다중 템플릿 적용
This commit is contained in:
@@ -43,10 +43,15 @@ const AssignPage = () => {
|
||||
keyword: "",
|
||||
});
|
||||
const [selected, setSelected] = useState<PerformanceFull | null>(null);
|
||||
const smsAddParam = useMemo(() => selected ? buildPerformanceSmsParams(selected) : {}, [selected]);
|
||||
|
||||
const [assignSaveTargetIds, setAssignSaveTargetIds] = useState<string[]>([]);
|
||||
|
||||
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();
|
||||
@@ -115,17 +120,35 @@ 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: PERFORMANCE_FIELD_LABELS.id, cell: ({row}) => row.original.id, enableSorting: true},
|
||||
{accessorKey: "performanceName", header: PERFORMANCE_FIELD_LABELS.performanceName, enableSorting: true},
|
||||
{accessorKey: "id", header: PERFORMANCE_FIELD_LABELS.id, cell: ({row}) => row.original.id},
|
||||
{accessorKey: "performanceName", header: PERFORMANCE_FIELD_LABELS.performanceName},
|
||||
{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},
|
||||
{accessorKey: "performanceDtInfo", header: PERFORMANCE_FIELD_LABELS.performanceDtInfo, enableSorting: false},
|
||||
{accessorKey: "performanceTimeInfo", header: PERFORMANCE_FIELD_LABELS.performanceTimeInfo, 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: "신청자 수", 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},
|
||||
{id: "applyCount", header: "신청자 수", accessorFn:((row) => applyCountMap.get(String(row.id)) ?? 0), cell: ({row}) => applyCountMap.get(String(row.original.id)) ?? 0},
|
||||
{id: "requestCount", header: "확정요청 수", accessorFn:((row) => getMonitoringAssigns(row).length), cell: ({row}) => getMonitoringAssigns(row.original).length},
|
||||
{id: "confirmedCount", header: "확정인원 수", accessorFn:((row) => getMonitoringAssigns(row).filter((assign) => assign.assignConfirm ).length), cell: ({row}) => getMonitoringAssigns(row.original).filter((assign) => assign.assignConfirm).length},
|
||||
], [applyCountMap, codes]);
|
||||
|
||||
if(!mounted) return <LoadingOverlay force={true} />
|
||||
@@ -172,10 +195,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);
|
||||
}}
|
||||
/>
|
||||
@@ -195,22 +237,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}
|
||||
denyParamKeys={["userCmpn", "userTeam", "userRole", "id"]}
|
||||
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}
|
||||
{...smsBeforeSendProps}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -319,20 +319,22 @@ const PerformancePage = () => {
|
||||
};
|
||||
|
||||
const columns = useMemo<DataTableColumn<PerformanceFull>[]>(() => [
|
||||
{accessorKey: "id", header: PERFORMANCE_FIELD_LABELS.id, cell: ({row}) => row.original.id, enableSorting: true},
|
||||
{accessorKey: "id", header: PERFORMANCE_FIELD_LABELS.id, cell: ({row}) => row.original.id},
|
||||
{id: "businessType", header: PERFORMANCE_FIELD_LABELS.businessType, cell: ({row}) => getCodeLabel(codes, "business_type", row.original.businessType)},
|
||||
{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, enableSorting: true},
|
||||
{accessorKey: "performanceName", header: PERFORMANCE_FIELD_LABELS.performanceName, enableSorting: true},
|
||||
{id: "startMonth", header: PERFORMANCE_FIELD_LABELS.performanceStartMonth, cell: ({row}) => `${row.original.performanceStartMonth}월`, enableSorting: true},
|
||||
{accessorKey: "performanceDtInfo", header: PERFORMANCE_FIELD_LABELS.performanceDtInfo},
|
||||
{accessorKey: "performanceTimeInfo", header: PERFORMANCE_FIELD_LABELS.performanceTimeInfo},
|
||||
{accessorKey: "artistName", header: PERFORMANCE_FIELD_LABELS.artistName},
|
||||
{accessorKey: "performanceName", header: PERFORMANCE_FIELD_LABELS.performanceName},
|
||||
{id: "startMonth", header: PERFORMANCE_FIELD_LABELS.performanceStartMonth,
|
||||
accessorFn: (row) => row.performanceStartMonth ?? 99,
|
||||
cell: ({row}) => `${row.original.performanceStartMonth}월`},
|
||||
{accessorKey: "performanceDtInfo", header: PERFORMANCE_FIELD_LABELS.performanceDtInfo, enableSorting: false},
|
||||
{accessorKey: "performanceTimeInfo", header: PERFORMANCE_FIELD_LABELS.performanceTimeInfo, enableSorting: false},
|
||||
...(!isWrittenReviewer ? [{
|
||||
id: "monitoringDate",
|
||||
header: PERFORMANCE_FIELD_LABELS.monitoringDate,
|
||||
accessorFn: (row) => row.performanceMonitoringSchedule?.monitoringDate ?? "",
|
||||
cell: ({row}) => row.original.performanceMonitoringSchedule?.monitoringDate ?? "",
|
||||
enableSorting: true,
|
||||
} satisfies DataTableColumn<PerformanceFull>] : []),
|
||||
{
|
||||
id: "localReview",
|
||||
|
||||
@@ -172,12 +172,12 @@ const UserPage = () => {
|
||||
|
||||
const columns = useMemo<DataTableColumn<UserFull>[]>(() => {
|
||||
const commonColumns: DataTableColumn<UserFull>[] = [
|
||||
{accessorKey: "userId", header: USER_FIELD_LABELS.userId, 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: "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")},
|
||||
@@ -311,7 +311,7 @@ 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}
|
||||
|
||||
@@ -24,7 +24,8 @@ export function AssignMonitoringDialog({
|
||||
applyUsers,
|
||||
isSavingAssign,
|
||||
onSaveAssign,
|
||||
onOpenSms,
|
||||
onOpenAssignSms,
|
||||
onOpenNormalSms,
|
||||
}: Readonly<{
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
@@ -33,7 +34,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),
|
||||
@@ -52,7 +54,7 @@ export function AssignMonitoringDialog({
|
||||
|
||||
const confirmRequestCount = monitoringAssigns.length;
|
||||
const confirmedCount = monitoringAssigns.filter((item) => item.assignConfirm).length;
|
||||
const smsTargetIds = checkedIds.filter(
|
||||
const assignSmsTargetIds = checkedIds.filter(
|
||||
(userId) => !monitoringAssigns.some((assign) => assign.assignUser === userId && assign.assignConfirm)
|
||||
);
|
||||
|
||||
@@ -209,10 +211,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>
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import {useEffect, useMemo, useRef, useState} from "react";
|
||||
import {Edit, RotateCcw, Save, Send} from "lucide-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";
|
||||
@@ -30,11 +33,11 @@ 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),
|
||||
});
|
||||
|
||||
@@ -54,7 +57,7 @@ export function SmsSendDialog({
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
title?: string;
|
||||
templateIdx: number;
|
||||
templateIdx: number[];
|
||||
newMessageTemplateIdx?: number;
|
||||
selectedUsers: UserCompact[];
|
||||
addParams?: Record<string, string>;
|
||||
@@ -64,17 +67,28 @@ export function SmsSendDialog({
|
||||
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]);
|
||||
@@ -108,18 +122,18 @@ export function SmsSendDialog({
|
||||
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);
|
||||
@@ -162,12 +176,19 @@ export function SmsSendDialog({
|
||||
};
|
||||
|
||||
const cancelEdit = () => {
|
||||
if (templateQuery.data) {
|
||||
setDraft(toDraft(templateQuery.data, isNewMessage));
|
||||
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;
|
||||
|
||||
@@ -178,7 +199,7 @@ export function SmsSendDialog({
|
||||
};
|
||||
|
||||
const restoreTemplate = () => {
|
||||
setActiveTemplateIdx(templateIdx);
|
||||
setActiveTemplateIdx(defaultTemplateIdx);
|
||||
setIsNewMessage(false);
|
||||
setIsEditing(false);
|
||||
setDraft(null);
|
||||
@@ -227,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>
|
||||
@@ -252,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>
|
||||
)}
|
||||
|
||||
@@ -263,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>
|
||||
@@ -281,13 +327,14 @@ export function SmsSendDialog({
|
||||
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="flex flex-wrap gap-1.5">
|
||||
<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}
|
||||
@@ -300,6 +347,7 @@ export function SmsSendDialog({
|
||||
<code className="font-mono text-muted-foreground">{`#{${key}}`}</code>
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user