260810_04_ENH: 컨택 화면 ui 변경 및 개별 발송시 미리보기에 치환 문자열 치환 돼서 보여지도록 수정

This commit is contained in:
2026-08-10 11:57:44 +09:00
parent ef748142f8
commit 9b93d45ed0
7 changed files with 64 additions and 30 deletions

View File

@@ -18,6 +18,7 @@ import { ChannelType, type TemplateSms, type TemplateSummary } from '@kri/common
import { sanitizeHtmlForPreview } from '@/components/kri-editor/utils/sanitizeHtml'
import { KriEditor } from '@/components/kri-editor'
import { getNearestFutureDateTime } from '@/lib/datetime'
import { escapeHtml, substituteVariables } from '@/lib/variableSubstitution'
import type { DialogId } from '@/store/jotai/dialog'
import type { MessageSendChannel, TemplateEmailWithAttachments } from '@/types/message'
import TemplateAttachmentList from '@/components/message-template/TemplateAttachmentList'
@@ -36,6 +37,7 @@ export type SingleMessageSendDialogProps = {
itrntPrjctCd: string
sid: string
destHeaderId: number
variableValues?: Record<string, string>
onSent?: () => void
}
@@ -48,6 +50,7 @@ const SingleMessageSendDialog = ({
itrntPrjctCd,
sid,
destHeaderId,
variableValues,
onSent,
}: SingleMessageSendDialogProps) => {
const { isDialogOpen, showDialog, hideDialog } = useDialog()
@@ -68,6 +71,9 @@ const SingleMessageSendDialog = ({
const mainTemplateQuery = useMainTemplateIdxQuery(prjctIdx, chnnlTy, enabled)
const mainTemplateIdx = mainTemplateQuery.data ?? null
const previewValues = variableValues ?? {}
const resolvedTitle = selectedTemplate ? substituteVariables(selectedTemplate.tmplatTitle ?? '', previewValues) : ''
const sendSingleMutation = useSendSingleMessageMutation(channel, prjctIdx)
const mainTemplateAppliedRef = useRef(false)
@@ -199,26 +205,33 @@ const SingleMessageSendDialog = ({
{selectedTemplate && (
<>
{chnnlTy !== ChannelType.SMS && (
<div className="rounded border p-2 text-sm font-semibold">{`제목: ${selectedTemplate.tmplatTitle}` || '(제목 없음)'}</div>
<div className="rounded border p-2 text-sm font-semibold">{resolvedTitle ? `제목: ${resolvedTitle}` : '(제목 없음)'}</div>
)}
{chnnlTy === ChannelType.SMS ? (
<div className="flex flex-col items-center">
<KriEditor
mode="sms"
value={(selectedTemplate as TemplateSms).tmplatBody ?? ''}
value={substituteVariables((selectedTemplate as TemplateSms).tmplatBody ?? '', previewValues)}
onChange={() => {}}
isSmsReadOnly
placeholder="문자 내용을 입력해 주세요"
className="max-w-80 mx-0"
debounceMs={600}
smsTitle={(selectedTemplate as TemplateSms).tmplatTitle}
smsTitle={resolvedTitle}
/>
</div>
) : (
<>
<div
className="rounded-md border bg-muted/30 p-3 text-sm"
dangerouslySetInnerHTML={{ __html: sanitizeHtmlForPreview(selectedTemplate.tmplatBody || '(내용 없음)') }}
dangerouslySetInnerHTML={{
__html: sanitizeHtmlForPreview(
substituteVariables(
selectedTemplate.tmplatBody || '(내용 없음)',
Object.fromEntries(Object.entries(previewValues).map(([key, val]) => [key, escapeHtml(val)])),
),
),
}}
/>
<TemplateAttachmentList
tmplatIdx={selectedTemplate.tmplatIdx}