260623_01_ENH: 엑셀 다운로드를 제외한 기능 완성
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import {useMemo, useRef, useState} from "react";
|
||||
import {useEffect, useMemo, useRef, useState} from "react";
|
||||
import {Search} from "lucide-react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Input} from "@/components/ui/input";
|
||||
@@ -24,29 +24,7 @@ import {useDialog} from "@/hooks/useDialog";
|
||||
import {useMounted} from "@/hooks/useMounted";
|
||||
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
|
||||
import {SMS_TEMPLATE_IDS} from "@/query/notification";
|
||||
|
||||
const toParamValue = (value: unknown) => value == null ? "" : String(value);
|
||||
|
||||
const buildPerformanceSmsParams = (performance: PerformanceFull): Record<string, string> => ({
|
||||
businessType: toParamValue(performance.businessType),
|
||||
performanceGenre: toParamValue(performance.performanceGenre),
|
||||
performanceArea: toParamValue(performance.performanceArea),
|
||||
artistName: toParamValue(performance.artistName),
|
||||
performanceName: toParamValue(performance.performanceName),
|
||||
performanceStartMonth: toParamValue(performance.performanceStartMonth),
|
||||
performanceDtInfo: toParamValue(performance.performanceDtInfo),
|
||||
performanceTimeInfo: toParamValue(performance.performanceTimeInfo),
|
||||
ticketReservationStatus: toParamValue(performance.ticketReservationStatus),
|
||||
ticketReservationMemo: toParamValue(performance.ticketReservationMemo),
|
||||
performanceMemo: toParamValue(performance.performanceMemo),
|
||||
...Object.fromEntries(
|
||||
Object.entries(performance.performanceDetail ?? {}).map(([key, value]) => [key, toParamValue(value)])
|
||||
),
|
||||
...Object.fromEntries(
|
||||
Object.entries(performance.performanceMonitoringSchedule ?? {}).map(([key, value]) => [key, toParamValue(value)])
|
||||
),
|
||||
performanceId: toParamValue(performance.id),
|
||||
});
|
||||
import {buildPerformanceSmsParams} from "@/lib/gwcf/notification";
|
||||
|
||||
const AssignPage = () => {
|
||||
const mounted = useMounted();
|
||||
@@ -66,6 +44,7 @@ const AssignPage = () => {
|
||||
const [selected, setSelected] = useState<PerformanceFull | null>(null);
|
||||
const smsAddParam = useMemo(() => selected ? buildPerformanceSmsParams(selected) : {}, [selected]);
|
||||
|
||||
const [assignSaveTargetIds, setAssignSaveTargetIds] = useState<string[]>([]);
|
||||
const [smsTargetIds, setSmsTargetIds] = useState<string[]>([]);
|
||||
|
||||
const refreshAssignList = () => {
|
||||
@@ -78,6 +57,14 @@ const AssignPage = () => {
|
||||
refreshAssignList();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
hideDialog("assignMonitoringDialog");
|
||||
hideDialog("assignSmsSendDialog");
|
||||
setSelected(null);
|
||||
setAssignSaveTargetIds([]);
|
||||
setSmsTargetIds([]);
|
||||
}, []);
|
||||
|
||||
const assignOpen = isDialogOpen("assignMonitoringDialog");
|
||||
const smsOpen = isDialogOpen("assignSmsSendDialog");
|
||||
const selectedPerformanceId = selected?.id ?? 0;
|
||||
@@ -184,9 +171,10 @@ const AssignPage = () => {
|
||||
{onSuccess: (monitoringAssigns) => applySavedAssignsToSelected(performanceId, monitoringAssigns)}
|
||||
)
|
||||
}
|
||||
onOpenSms={(userIds) => {
|
||||
onOpenSms={(assignUserIds, smsUserIds) => {
|
||||
suppressAssignCloseRef.current = true;
|
||||
setSmsTargetIds(userIds);
|
||||
setAssignSaveTargetIds(assignUserIds);
|
||||
setSmsTargetIds(smsUserIds);
|
||||
showDialog("assignSmsSendDialog", false);
|
||||
}}
|
||||
/>
|
||||
@@ -211,6 +199,15 @@ const AssignPage = () => {
|
||||
newMessageTemplateIdx={SMS_TEMPLATE_IDS.CUSTOM}
|
||||
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}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user