260810_04_ENH: 컨택 화면 ui 변경 및 개별 발송시 미리보기에 치환 문자열 치환 돼서 보여지도록 수정
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -22,22 +22,9 @@ import { useCtiLastCallHistId } from '@/hooks/useCtiLastCallHistId'
|
||||
import { getCurrentPositionMeta } from '@kri/common/browser'
|
||||
import type { listHeader, ListSearchWithFullResult } from '@/types/list'
|
||||
import { buildListContactVariableValues } from '@/components/list-contact/listContactVariables'
|
||||
import { substituteVariables } from '@/lib/surveyUrl'
|
||||
import { escapeHtml, substituteVariables } from '@/lib/variableSubstitution'
|
||||
import { sanitizeHtml } from '@/components/kri-editor/utils/sanitizeHtml'
|
||||
|
||||
const escapeHtml = (value: string) =>
|
||||
value.replace(
|
||||
/[&<>"']/g,
|
||||
(character) =>
|
||||
({
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
})[character] ?? character,
|
||||
)
|
||||
|
||||
const RefreshIconButton = ({ onRefresh, isFetching }: { onRefresh: () => void; isFetching: boolean }) => (
|
||||
<Button
|
||||
type="button"
|
||||
@@ -203,6 +190,7 @@ const ContactEventSection = ({
|
||||
|
||||
<CollapsibleHistorySection
|
||||
title={`${title}(최근순)`}
|
||||
defaultOpen
|
||||
showDivider={showInput}
|
||||
headerExtra={<RefreshIconButton onRefresh={() => historyQuery.refetch()} isFetching={historyQuery.isFetching} />}
|
||||
>
|
||||
@@ -261,6 +249,7 @@ const SendResultHistory = ({ sid, prjctCd }: { sid: string; prjctCd: string }) =
|
||||
<div className="space-y-2 rounded-lg border bg-white p-4">
|
||||
<CollapsibleHistorySection
|
||||
title="발송 현황(최근순)"
|
||||
defaultOpen
|
||||
showDivider={false}
|
||||
headerExtra={
|
||||
<div className="flex items-center gap-1">
|
||||
|
||||
@@ -14,7 +14,7 @@ import type { MessageSendChannel } from '@/types/message'
|
||||
import { type ProjectSurvey, type ResultCode, ResultCodeType } from '@/types/project'
|
||||
import { formatKst } from '@kri/common'
|
||||
import { isListFieldEditableForContact, isListFieldVisibleForContact } from '@/utils/listAccess'
|
||||
import { substituteVariables } from '@/lib/surveyUrl'
|
||||
import { substituteVariables } from '@/lib/variableSubstitution'
|
||||
import { formatKoreanPhoneNumber } from '@/utils/phone'
|
||||
import SurveyQrDialog from '@/components/dialog/SurveyQrDialog'
|
||||
import SingleMessageSendDialog from '@/components/dialog/SingleMessageSendDialog'
|
||||
@@ -56,7 +56,7 @@ export const buildInitialValues = (listHeaders: listHeader[], detail?: ListSearc
|
||||
return values
|
||||
}
|
||||
|
||||
const disabledContrastClass = 'disabled:opacity-100 disabled:text-foreground disabled:bg-muted/60'
|
||||
const disabledContrastClass = 'bg-white disabled:opacity-100 disabled:text-foreground disabled:bg-muted/60'
|
||||
|
||||
const getCallButtonLabel = (isDialing: boolean, isOnCall: boolean) => {
|
||||
if (isDialing) return '거는 중'
|
||||
@@ -70,9 +70,16 @@ const getCallButtonTitle = (isCtiReady: boolean, isDialing: boolean) => {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const FieldRow = ({ label, children }: { label: string; children: ReactNode }) => (
|
||||
const FieldRow = ({ label, editable, children }: { label: string; editable?: boolean; children: ReactNode }) => (
|
||||
<div className="flex items-center gap-3">
|
||||
<Label className="w-24 shrink-0 text-sm font-bold text-foreground">{label}</Label>
|
||||
<Label
|
||||
className={cn(
|
||||
'w-24 shrink-0 rounded-md px-2 py-2.5 text-sm font-bold text-foreground',
|
||||
editable && 'bg-blue-100 text-black',
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</Label>
|
||||
<div className="min-w-0 flex-1">{children}</div>
|
||||
</div>
|
||||
)
|
||||
@@ -167,7 +174,7 @@ const ListContactInfoPanel = ({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4 rounded-lg border bg-white p-4">
|
||||
<div className="space-y-2 rounded-lg border bg-white p-4">
|
||||
<h2 className="text-lg font-bold">리스트 정보</h2>
|
||||
<input type="file" ref={fileInputRef} className="hidden" onChange={handleFileSelected} />
|
||||
{visibleHeaders.map((header) => {
|
||||
@@ -180,7 +187,7 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.MEMO) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<textarea
|
||||
className={`flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed ${disabledContrastClass}`}
|
||||
value={value}
|
||||
@@ -193,7 +200,7 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.TEL_NUM) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
value={formatKoreanPhoneNumber(value)}
|
||||
@@ -234,7 +241,7 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.EMAIL) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
value={value}
|
||||
@@ -259,7 +266,7 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.FILE) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="min-w-0 flex-1 truncate text-sm">
|
||||
{value ? (
|
||||
@@ -300,7 +307,7 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.CONTENT_ITEM && (header.filterContents?.length ?? 0) > 0) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<KriSingleSelect
|
||||
items={header.filterContents ?? []}
|
||||
value={value}
|
||||
@@ -317,7 +324,7 @@ const ListContactInfoPanel = ({
|
||||
}
|
||||
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<Input
|
||||
value={value}
|
||||
disabled={!editable}
|
||||
@@ -365,6 +372,7 @@ const ListContactInfoPanel = ({
|
||||
itrntPrjctCd={itrntPrjctCd}
|
||||
sid={sid}
|
||||
destHeaderId={sendTarget?.headerId ?? 0}
|
||||
variableValues={surveyUrlValues}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ const ListUpdateHistoryPanel = ({ prjctIdx, sid, listHeaders }: ListUpdateHistor
|
||||
|
||||
return (
|
||||
<div className="space-y-2 rounded-lg border bg-white p-4">
|
||||
<CollapsibleHistorySection title="수정 이력" showDivider={false}>
|
||||
<CollapsibleHistorySection title="수정 이력" defaultOpen showDivider={false}>
|
||||
{historyQuery.isLoading ? (
|
||||
<div className="rounded-md border p-4 text-center text-sm text-muted-foreground">불러오는 중...</div>
|
||||
) : history.length === 0 ? (
|
||||
|
||||
Reference in New Issue
Block a user