260810_04_ENH: 컨택 화면 ui 변경 및 개별 발송시 미리보기에 치환 문자열 치환 돼서 보여지도록 수정
This commit is contained in:
@@ -159,6 +159,11 @@ const ListContactPageContent = () => {
|
|||||||
setFormValues((prev) => ({ ...prev, [listHderId]: value }));
|
setFormValues((prev) => ({ ...prev, [listHderId]: value }));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCancelEdit = () => {
|
||||||
|
setFormValues(initialFormValues);
|
||||||
|
setIsEditing(false);
|
||||||
|
};
|
||||||
|
|
||||||
const handleToggleEdit = async () => {
|
const handleToggleEdit = async () => {
|
||||||
if (!isEditing) {
|
if (!isEditing) {
|
||||||
setIsEditing(true);
|
setIsEditing(true);
|
||||||
@@ -205,6 +210,11 @@ const ListContactPageContent = () => {
|
|||||||
<CalendarClock className="h-4 w-4" />
|
<CalendarClock className="h-4 w-4" />
|
||||||
예약리스트 조회
|
예약리스트 조회
|
||||||
</Button>
|
</Button>
|
||||||
|
{isEditing ? (
|
||||||
|
<Button type="button" variant="outline" disabled={updateListMutation.isPending} onClick={handleCancelEdit}>
|
||||||
|
취소
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
<Button type="button" disabled={updateListMutation.isPending} onClick={handleToggleEdit}>
|
<Button type="button" disabled={updateListMutation.isPending} onClick={handleToggleEdit}>
|
||||||
{isEditing ? '저장' : '수정'}
|
{isEditing ? '저장' : '수정'}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -285,6 +285,7 @@ const ListManagePage = () => {
|
|||||||
surveys={surveyArray}
|
surveys={surveyArray}
|
||||||
listHeaders={headerManageRows}
|
listHeaders={headerManageRows}
|
||||||
enableBatchEdit={canManageList}
|
enableBatchEdit={canManageList}
|
||||||
|
selectMode={canManageList ? 'multi' : 'click-event'}
|
||||||
refreshKey={listRefreshKey}
|
refreshKey={listRefreshKey}
|
||||||
onCurrentFilterChange={setCurrentListFilter}
|
onCurrentFilterChange={setCurrentListFilter}
|
||||||
onFilterSummaryChange={setFilterSummary}
|
onFilterSummaryChange={setFilterSummary}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { ChannelType, type TemplateSms, type TemplateSummary } from '@kri/common
|
|||||||
import { sanitizeHtmlForPreview } from '@/components/kri-editor/utils/sanitizeHtml'
|
import { sanitizeHtmlForPreview } from '@/components/kri-editor/utils/sanitizeHtml'
|
||||||
import { KriEditor } from '@/components/kri-editor'
|
import { KriEditor } from '@/components/kri-editor'
|
||||||
import { getNearestFutureDateTime } from '@/lib/datetime'
|
import { getNearestFutureDateTime } from '@/lib/datetime'
|
||||||
|
import { escapeHtml, substituteVariables } from '@/lib/variableSubstitution'
|
||||||
import type { DialogId } from '@/store/jotai/dialog'
|
import type { DialogId } from '@/store/jotai/dialog'
|
||||||
import type { MessageSendChannel, TemplateEmailWithAttachments } from '@/types/message'
|
import type { MessageSendChannel, TemplateEmailWithAttachments } from '@/types/message'
|
||||||
import TemplateAttachmentList from '@/components/message-template/TemplateAttachmentList'
|
import TemplateAttachmentList from '@/components/message-template/TemplateAttachmentList'
|
||||||
@@ -36,6 +37,7 @@ export type SingleMessageSendDialogProps = {
|
|||||||
itrntPrjctCd: string
|
itrntPrjctCd: string
|
||||||
sid: string
|
sid: string
|
||||||
destHeaderId: number
|
destHeaderId: number
|
||||||
|
variableValues?: Record<string, string>
|
||||||
onSent?: () => void
|
onSent?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,6 +50,7 @@ const SingleMessageSendDialog = ({
|
|||||||
itrntPrjctCd,
|
itrntPrjctCd,
|
||||||
sid,
|
sid,
|
||||||
destHeaderId,
|
destHeaderId,
|
||||||
|
variableValues,
|
||||||
onSent,
|
onSent,
|
||||||
}: SingleMessageSendDialogProps) => {
|
}: SingleMessageSendDialogProps) => {
|
||||||
const { isDialogOpen, showDialog, hideDialog } = useDialog()
|
const { isDialogOpen, showDialog, hideDialog } = useDialog()
|
||||||
@@ -68,6 +71,9 @@ const SingleMessageSendDialog = ({
|
|||||||
const mainTemplateQuery = useMainTemplateIdxQuery(prjctIdx, chnnlTy, enabled)
|
const mainTemplateQuery = useMainTemplateIdxQuery(prjctIdx, chnnlTy, enabled)
|
||||||
const mainTemplateIdx = mainTemplateQuery.data ?? null
|
const mainTemplateIdx = mainTemplateQuery.data ?? null
|
||||||
|
|
||||||
|
const previewValues = variableValues ?? {}
|
||||||
|
const resolvedTitle = selectedTemplate ? substituteVariables(selectedTemplate.tmplatTitle ?? '', previewValues) : ''
|
||||||
|
|
||||||
const sendSingleMutation = useSendSingleMessageMutation(channel, prjctIdx)
|
const sendSingleMutation = useSendSingleMessageMutation(channel, prjctIdx)
|
||||||
|
|
||||||
const mainTemplateAppliedRef = useRef(false)
|
const mainTemplateAppliedRef = useRef(false)
|
||||||
@@ -199,26 +205,33 @@ const SingleMessageSendDialog = ({
|
|||||||
{selectedTemplate && (
|
{selectedTemplate && (
|
||||||
<>
|
<>
|
||||||
{chnnlTy !== ChannelType.SMS && (
|
{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 ? (
|
{chnnlTy === ChannelType.SMS ? (
|
||||||
<div className="flex flex-col items-center">
|
<div className="flex flex-col items-center">
|
||||||
<KriEditor
|
<KriEditor
|
||||||
mode="sms"
|
mode="sms"
|
||||||
value={(selectedTemplate as TemplateSms).tmplatBody ?? ''}
|
value={substituteVariables((selectedTemplate as TemplateSms).tmplatBody ?? '', previewValues)}
|
||||||
onChange={() => {}}
|
onChange={() => {}}
|
||||||
isSmsReadOnly
|
isSmsReadOnly
|
||||||
placeholder="문자 내용을 입력해 주세요"
|
placeholder="문자 내용을 입력해 주세요"
|
||||||
className="max-w-80 mx-0"
|
className="max-w-80 mx-0"
|
||||||
debounceMs={600}
|
debounceMs={600}
|
||||||
smsTitle={(selectedTemplate as TemplateSms).tmplatTitle}
|
smsTitle={resolvedTitle}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
className="rounded-md border bg-muted/30 p-3 text-sm"
|
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
|
<TemplateAttachmentList
|
||||||
tmplatIdx={selectedTemplate.tmplatIdx}
|
tmplatIdx={selectedTemplate.tmplatIdx}
|
||||||
|
|||||||
@@ -22,22 +22,9 @@ import { useCtiLastCallHistId } from '@/hooks/useCtiLastCallHistId'
|
|||||||
import { getCurrentPositionMeta } from '@kri/common/browser'
|
import { getCurrentPositionMeta } from '@kri/common/browser'
|
||||||
import type { listHeader, ListSearchWithFullResult } from '@/types/list'
|
import type { listHeader, ListSearchWithFullResult } from '@/types/list'
|
||||||
import { buildListContactVariableValues } from '@/components/list-contact/listContactVariables'
|
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'
|
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 }) => (
|
const RefreshIconButton = ({ onRefresh, isFetching }: { onRefresh: () => void; isFetching: boolean }) => (
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -203,6 +190,7 @@ const ContactEventSection = ({
|
|||||||
|
|
||||||
<CollapsibleHistorySection
|
<CollapsibleHistorySection
|
||||||
title={`${title}(최근순)`}
|
title={`${title}(최근순)`}
|
||||||
|
defaultOpen
|
||||||
showDivider={showInput}
|
showDivider={showInput}
|
||||||
headerExtra={<RefreshIconButton onRefresh={() => historyQuery.refetch()} isFetching={historyQuery.isFetching} />}
|
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">
|
<div className="space-y-2 rounded-lg border bg-white p-4">
|
||||||
<CollapsibleHistorySection
|
<CollapsibleHistorySection
|
||||||
title="발송 현황(최근순)"
|
title="발송 현황(최근순)"
|
||||||
|
defaultOpen
|
||||||
showDivider={false}
|
showDivider={false}
|
||||||
headerExtra={
|
headerExtra={
|
||||||
<div className="flex items-center gap-1">
|
<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 { type ProjectSurvey, type ResultCode, ResultCodeType } from '@/types/project'
|
||||||
import { formatKst } from '@kri/common'
|
import { formatKst } from '@kri/common'
|
||||||
import { isListFieldEditableForContact, isListFieldVisibleForContact } from '@/utils/listAccess'
|
import { isListFieldEditableForContact, isListFieldVisibleForContact } from '@/utils/listAccess'
|
||||||
import { substituteVariables } from '@/lib/surveyUrl'
|
import { substituteVariables } from '@/lib/variableSubstitution'
|
||||||
import { formatKoreanPhoneNumber } from '@/utils/phone'
|
import { formatKoreanPhoneNumber } from '@/utils/phone'
|
||||||
import SurveyQrDialog from '@/components/dialog/SurveyQrDialog'
|
import SurveyQrDialog from '@/components/dialog/SurveyQrDialog'
|
||||||
import SingleMessageSendDialog from '@/components/dialog/SingleMessageSendDialog'
|
import SingleMessageSendDialog from '@/components/dialog/SingleMessageSendDialog'
|
||||||
@@ -56,7 +56,7 @@ export const buildInitialValues = (listHeaders: listHeader[], detail?: ListSearc
|
|||||||
return values
|
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) => {
|
const getCallButtonLabel = (isDialing: boolean, isOnCall: boolean) => {
|
||||||
if (isDialing) return '거는 중'
|
if (isDialing) return '거는 중'
|
||||||
@@ -70,9 +70,16 @@ const getCallButtonTitle = (isCtiReady: boolean, isDialing: boolean) => {
|
|||||||
return undefined
|
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">
|
<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 className="min-w-0 flex-1">{children}</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -167,7 +174,7 @@ const ListContactInfoPanel = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
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>
|
<h2 className="text-lg font-bold">리스트 정보</h2>
|
||||||
<input type="file" ref={fileInputRef} className="hidden" onChange={handleFileSelected} />
|
<input type="file" ref={fileInputRef} className="hidden" onChange={handleFileSelected} />
|
||||||
{visibleHeaders.map((header) => {
|
{visibleHeaders.map((header) => {
|
||||||
@@ -180,7 +187,7 @@ const ListContactInfoPanel = ({
|
|||||||
|
|
||||||
if (header.listHderTy === ListHeaderConst.MEMO) {
|
if (header.listHderTy === ListHeaderConst.MEMO) {
|
||||||
return (
|
return (
|
||||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||||
<textarea
|
<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}`}
|
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}
|
value={value}
|
||||||
@@ -193,7 +200,7 @@ const ListContactInfoPanel = ({
|
|||||||
|
|
||||||
if (header.listHderTy === ListHeaderConst.TEL_NUM) {
|
if (header.listHderTy === ListHeaderConst.TEL_NUM) {
|
||||||
return (
|
return (
|
||||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Input
|
<Input
|
||||||
value={formatKoreanPhoneNumber(value)}
|
value={formatKoreanPhoneNumber(value)}
|
||||||
@@ -234,7 +241,7 @@ const ListContactInfoPanel = ({
|
|||||||
|
|
||||||
if (header.listHderTy === ListHeaderConst.EMAIL) {
|
if (header.listHderTy === ListHeaderConst.EMAIL) {
|
||||||
return (
|
return (
|
||||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Input
|
<Input
|
||||||
value={value}
|
value={value}
|
||||||
@@ -259,7 +266,7 @@ const ListContactInfoPanel = ({
|
|||||||
|
|
||||||
if (header.listHderTy === ListHeaderConst.FILE) {
|
if (header.listHderTy === ListHeaderConst.FILE) {
|
||||||
return (
|
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="flex items-center gap-2">
|
||||||
<div className="min-w-0 flex-1 truncate text-sm">
|
<div className="min-w-0 flex-1 truncate text-sm">
|
||||||
{value ? (
|
{value ? (
|
||||||
@@ -300,7 +307,7 @@ const ListContactInfoPanel = ({
|
|||||||
|
|
||||||
if (header.listHderTy === ListHeaderConst.CONTENT_ITEM && (header.filterContents?.length ?? 0) > 0) {
|
if (header.listHderTy === ListHeaderConst.CONTENT_ITEM && (header.filterContents?.length ?? 0) > 0) {
|
||||||
return (
|
return (
|
||||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||||
<KriSingleSelect
|
<KriSingleSelect
|
||||||
items={header.filterContents ?? []}
|
items={header.filterContents ?? []}
|
||||||
value={value}
|
value={value}
|
||||||
@@ -317,7 +324,7 @@ const ListContactInfoPanel = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||||
<Input
|
<Input
|
||||||
value={value}
|
value={value}
|
||||||
disabled={!editable}
|
disabled={!editable}
|
||||||
@@ -365,6 +372,7 @@ const ListContactInfoPanel = ({
|
|||||||
itrntPrjctCd={itrntPrjctCd}
|
itrntPrjctCd={itrntPrjctCd}
|
||||||
sid={sid}
|
sid={sid}
|
||||||
destHeaderId={sendTarget?.headerId ?? 0}
|
destHeaderId={sendTarget?.headerId ?? 0}
|
||||||
|
variableValues={surveyUrlValues}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const ListUpdateHistoryPanel = ({ prjctIdx, sid, listHeaders }: ListUpdateHistor
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-2 rounded-lg border bg-white p-4">
|
<div className="space-y-2 rounded-lg border bg-white p-4">
|
||||||
<CollapsibleHistorySection title="수정 이력" showDivider={false}>
|
<CollapsibleHistorySection title="수정 이력" defaultOpen showDivider={false}>
|
||||||
{historyQuery.isLoading ? (
|
{historyQuery.isLoading ? (
|
||||||
<div className="rounded-md border p-4 text-center text-sm text-muted-foreground">불러오는 중...</div>
|
<div className="rounded-md border p-4 text-center text-sm text-muted-foreground">불러오는 중...</div>
|
||||||
) : history.length === 0 ? (
|
) : history.length === 0 ? (
|
||||||
|
|||||||
@@ -2,3 +2,16 @@
|
|||||||
// 값이 없는 토큰은 빈 문자열로 치환한다.
|
// 값이 없는 토큰은 빈 문자열로 치환한다.
|
||||||
export const substituteVariables = (contents: string, values: Record<string, string>) =>
|
export const substituteVariables = (contents: string, values: Record<string, string>) =>
|
||||||
contents.replace(/\[\$([^\]]+)\]/g, (_, key: string) => values[key] ?? "");
|
contents.replace(/\[\$([^\]]+)\]/g, (_, key: string) => values[key] ?? "");
|
||||||
|
|
||||||
|
export const escapeHtml = (value: string) =>
|
||||||
|
value.replace(
|
||||||
|
/[&<>"']/g,
|
||||||
|
(character) =>
|
||||||
|
({
|
||||||
|
'&': '&',
|
||||||
|
'<': '<',
|
||||||
|
'>': '>',
|
||||||
|
'"': '"',
|
||||||
|
"'": ''',
|
||||||
|
})[character] ?? character,
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user