261023_01_ENH: 문자 SMS·LMS·MMS 유형 분리 및 템플릿·발송 이력·통계 반영 #58
8
package-lock.json
generated
8
package-lock.json
generated
@@ -11,7 +11,7 @@
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
"@dnd-kit/sortable": "^10.0.0",
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"@kri/common": "^0.19.2",
|
||||
"@kri/common": "^0.19.5",
|
||||
"@radix-ui/react-checkbox": "^1.3.3",
|
||||
"@radix-ui/react-dialog": "^1.1.15",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
||||
@@ -1194,9 +1194,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@kri/common": {
|
||||
"version": "0.19.2",
|
||||
"resolved": "https://gitea.kric.com/api/packages/KRi/npm/%40kri%2Fcommon/-/0.19.2/common-0.19.2.tgz",
|
||||
"integrity": "sha512-Y/FL9IsOj7MBdlvLn2YwPCzqbtr49zrVPdErmR7eWnIajwwTAzPQX4xLib5QEIysaLr2nA/ysQ4ex0JuE+1q6g==",
|
||||
"version": "0.19.5",
|
||||
"resolved": "https://gitea.kric.com/api/packages/KRi/npm/%40kri%2Fcommon/-/0.19.5/common-0.19.5.tgz",
|
||||
"integrity": "sha512-Ib+fO3cak17pcRbmxME7m9XwmiWYN8LM4gA8ZhCmRvEv4dopCTY0b2qO80CJXqUybFV4jRRh50+OajANIRyw4w==",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"clsx": "^2.1.1",
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
"@dnd-kit/sortable": "^10.0.0",
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"@kri/common": "^0.19.2",
|
||||
"@kri/common": "^0.19.5",
|
||||
"@radix-ui/react-checkbox": "^1.3.3",
|
||||
"@radix-ui/react-dialog": "^1.1.15",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
||||
|
||||
@@ -11,11 +11,12 @@ import { clientEnv } from "@/lib/env.client";
|
||||
import { MessageType } from "@kri/common/noti-hub";
|
||||
import type { SendResultSummaryResponse } from "@kri/common/noti-hub";
|
||||
|
||||
const SEND_TYPE_ORDER = [MessageType.SMS, MessageType.LMS_MMS, MessageType.EMAIL, MessageType.KKO] as const;
|
||||
const SEND_TYPE_ORDER = [MessageType.SMS, MessageType.LMS, MessageType.MMS, MessageType.EMAIL, MessageType.KKO] as const;
|
||||
|
||||
const SEND_TYPE_LABEL: Record<number, string> = {
|
||||
[MessageType.SMS]: "단문",
|
||||
[MessageType.LMS_MMS]: "장문",
|
||||
[MessageType.LMS]: "장문",
|
||||
[MessageType.MMS]: "첨부 문자",
|
||||
[MessageType.EMAIL]: "메일",
|
||||
[MessageType.KKO]: "알림톡",
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useDialog } from '@/hooks/useDialog'
|
||||
import { useSelectedProject } from '@/hooks/useSelectedProject'
|
||||
import { useBulkSendDetailExcelMutation, useBulkSendDetailQuery, useBulkSendListQuery } from '@/query/message'
|
||||
import { MessageType } from '@kri/common/noti-hub'
|
||||
import { MESSAGE_TYPE_LABEL } from '@/const/messageTemplateConst'
|
||||
import { downloadBase64File, XLSX_MIME_TYPE } from '@kri/common/browser'
|
||||
import { formatKst } from '@kri/common'
|
||||
import type { PaginationState } from '@tanstack/react-table'
|
||||
@@ -44,6 +45,7 @@ const historyColumns: DataTableColumn<BulkSendInfo>[] = [
|
||||
]
|
||||
|
||||
const detailColumns: DataTableColumn<SendResultInfo>[] = [
|
||||
{ id: 'sendTy', header: '유형', accessorFn: (row) => MESSAGE_TYPE_LABEL[row.sendTy] ?? String(row.sendTy) },
|
||||
{ id: 'destTo', header: '수신처', accessorFn: (row) => row.destEml || (row.destTel ? formatKoreanPhoneNumber(row.destTel) : '') || '-' },
|
||||
{ id: 'destNm', header: '수신자명', accessorFn: (row) => row.destNm ?? '-' },
|
||||
{ id: 'sendFrom', header: '발신지', accessorFn: (row) => row.sendEml || (row.sendTel ? formatKoreanPhoneNumber(row.sendTel) : '') || '-' },
|
||||
@@ -69,21 +71,15 @@ const MessageHistoryDialog = ({
|
||||
|
||||
const emailListQuery = useBulkSendListQuery(MessageType.EMAIL, clientEnv.REQUEST_SVC, prjctCd, enabled && tab === 'email')
|
||||
const smsListQuery = useBulkSendListQuery(MessageType.SMS, clientEnv.REQUEST_SVC, prjctCd, enabled && tab === 'sms')
|
||||
const lmsListQuery = useBulkSendListQuery(MessageType.LMS_MMS, clientEnv.REQUEST_SVC, prjctCd, enabled && tab === 'sms')
|
||||
const kkoListQuery = useBulkSendListQuery(MessageType.KKO, clientEnv.REQUEST_SVC, prjctCd, enabled && tab === 'kko')
|
||||
|
||||
const visibleRows = useMemo(() => {
|
||||
if (tab === 'email') return emailListQuery.data ?? []
|
||||
if (tab === 'kko') return kkoListQuery.data ?? []
|
||||
|
||||
// 문자 길이에 따라 SMS로 발송된 건도 자동으로 LMS/MMS로 전환될 수 있는데, 이 경우 두 목록 API가
|
||||
// 같은 bulkSendKey를 각각 반환해 합치면 행이 중복된다. bulkSendKey 기준으로 한 번만 남긴다.
|
||||
const merged = new Map<string, BulkSendInfo>()
|
||||
for (const row of [...(smsListQuery.data ?? []), ...(lmsListQuery.data ?? [])]) {
|
||||
merged.set(row.bulkSendKey, row)
|
||||
}
|
||||
return Array.from(merged.values()).sort((a, b) => (b.regDt ?? '').localeCompare(a.regDt ?? ''))
|
||||
}, [tab, emailListQuery.data, smsListQuery.data, lmsListQuery.data, kkoListQuery.data])
|
||||
// 21/22/23 경로는 모두 문자 채널 전체를 반환하므로 한 번만 조회한다.
|
||||
return [...(smsListQuery.data ?? [])].sort((a, b) => (b.regDt ?? '').localeCompare(a.regDt ?? ''))
|
||||
}, [tab, emailListQuery.data, smsListQuery.data, kkoListQuery.data])
|
||||
|
||||
const detailQuery = useBulkSendDetailQuery(
|
||||
selectedKey ?? '',
|
||||
|
||||
@@ -9,7 +9,7 @@ import { useTextareaInsert } from './hooks/useTextareaInsert'
|
||||
type SmsEditorProps = Omit<KriEditorProps, 'mode'> & { mode: 'sms' }
|
||||
|
||||
function calculateBytes(value: string): number {
|
||||
return Array.from(value).reduce((total, character) => total + (character.charCodeAt(0) > 127 ? 2 : 1), 0)
|
||||
return new TextEncoder().encode(value).byteLength
|
||||
}
|
||||
|
||||
export function KriEditorSms({
|
||||
@@ -34,14 +34,25 @@ export function KriEditorSms({
|
||||
const [text, setText] = React.useState(value || '')
|
||||
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null)
|
||||
const latestTextRef = React.useRef(text)
|
||||
const lastTypeRef = React.useRef<'SMS' | 'LMS' | null>(null)
|
||||
const lastTypeRef = React.useRef<'SMS' | 'LMS' | 'MMS' | null>(null)
|
||||
const { scheduleChange, flushChange } = useDebouncedChange(onChange, debounceMs)
|
||||
const textareaInsert = useTextareaInsert(textareaRef)
|
||||
const previewText = smsPreviewSuffix ? `${text}\n${smsPreviewSuffix}` : text
|
||||
const byteSize = React.useMemo(() => calculateBytes(previewText), [previewText])
|
||||
const messageType: 'SMS' | 'LMS' = byteSize > smsMaxBytes || Boolean(smsTitle) || smsHasAttachment ? 'LMS' : 'SMS'
|
||||
const messageType: 'SMS' | 'LMS' | 'MMS' = smsHasAttachment ? 'MMS' : byteSize >= smsMaxBytes || Boolean(smsTitle) ? 'LMS' : 'SMS'
|
||||
const maxBytes = messageType === 'SMS' ? smsMaxBytes : lmsMaxBytes
|
||||
|
||||
function getBadgeColor(): string {
|
||||
switch (messageType) {
|
||||
case 'SMS':
|
||||
return 'bg-red-500'
|
||||
case 'LMS':
|
||||
return 'bg-blue-500'
|
||||
case 'MMS':
|
||||
return 'bg-green-500'
|
||||
}
|
||||
}
|
||||
|
||||
const commitText = React.useCallback((next: string, immediate = false) => {
|
||||
setText(next)
|
||||
latestTextRef.current = next
|
||||
@@ -90,8 +101,8 @@ export function KriEditorSms({
|
||||
<div className="flex h-full flex-col bg-gray-50 px-4 pt-8 pb-4">
|
||||
<div className="mb-3 flex items-center justify-between px-2">
|
||||
<span className="text-xs font-medium text-gray-600">{byteSize}/{maxBytes}byte</span>
|
||||
<span className={cn('rounded-md px-3 py-1 text-xs font-bold text-white', messageType === 'LMS' ? 'bg-blue-500' : 'bg-red-500')}>
|
||||
{messageType === 'LMS' ? 'LMS/MMS' : 'SMS'}
|
||||
<span className={cn('rounded-md px-3 py-1 text-xs font-bold text-white', getBadgeColor())}>
|
||||
{messageType}
|
||||
</span>
|
||||
</div>
|
||||
<div className={cn('flex flex-1 flex-col rounded-2xl bg-white shadow-sm', smsImages.length > 0 ? 'overflow-y-auto' : 'overflow-hidden')}>
|
||||
|
||||
@@ -80,12 +80,13 @@ export type KriEditorProps = {
|
||||
onImageUploadError?: (error: unknown) => void
|
||||
debounceMs?: number
|
||||
smsTitle?: string
|
||||
changeSmsType?: (type: 'SMS' | 'LMS') => void
|
||||
/** Preview only; consumers must handle MMS. Actual delivery type is determined by the server. */
|
||||
changeSmsType?: (type: 'SMS' | 'LMS' | 'MMS') => void
|
||||
isSmsReadOnly?: boolean
|
||||
smsMaxBytes?: number
|
||||
lmsMaxBytes?: number
|
||||
smsPreviewSuffix?: string
|
||||
/** 첨부파일이 있으면 길이·제목과 무관하게 LMS/MMS로 판정한다. */
|
||||
/** 첨부파일이 있으면 길이·제목과 무관하게 MMS로 판정한다. */
|
||||
smsHasAttachment?: boolean
|
||||
/** 문자 미리보기의 제목과 본문 사이에 표시할 첨부 이미지 */
|
||||
smsImages?: KriEditorSmsImage[]
|
||||
|
||||
@@ -11,6 +11,7 @@ import { useSendResultBySidQuery } from '@/query/message'
|
||||
import { useInternalInfoQuery } from '@/query/internal'
|
||||
import { clientEnv } from '@/lib/env.client'
|
||||
import { ChannelType } from '@kri/common/noti-hub'
|
||||
import { MESSAGE_TYPE_LABEL } from '@/const/messageTemplateConst'
|
||||
import type { SendResultInfo } from '@kri/common/noti-hub'
|
||||
import { formatKst } from '@kri/common'
|
||||
import { type ResultCode, ResultCodeType } from '@/types/project'
|
||||
@@ -252,6 +253,7 @@ const SendResultTable = ({ isLoading, results }: { isLoading: boolean; results:
|
||||
<table className="w-full text-sm">
|
||||
<thead className="sticky top-0 bg-muted">
|
||||
<tr>
|
||||
<th className="p-2 text-left">유형</th>
|
||||
<th className="p-2 text-left">수신처</th>
|
||||
<th className="p-2 text-left">결과</th>
|
||||
<th className="p-2 text-left">발송일시</th>
|
||||
@@ -260,6 +262,7 @@ const SendResultTable = ({ isLoading, results }: { isLoading: boolean; results:
|
||||
<tbody>
|
||||
{results.map((item) => (
|
||||
<tr key={item.cmid} className="border-t">
|
||||
<td className="p-2">{MESSAGE_TYPE_LABEL[item.sendTy] ?? String(item.sendTy)}</td>
|
||||
<td className="p-2">{item.destEml || item.destTel || '-'}</td>
|
||||
<td className="p-2">{item.resultViewLabel || item.resultLabel || item.resultCode}</td>
|
||||
<td className="p-2">{formatKst(item.sendDt, 'dateHourMin')}</td>
|
||||
|
||||
@@ -221,8 +221,8 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
||||
setSelectedTemplate((prev) => ({ ...prev, tmplatBody: newString }));
|
||||
};
|
||||
|
||||
const setSmsType = (smsTypeString: "SMS" | "LMS") => {
|
||||
const smsType = smsTypeString === "SMS" ? MessageType.SMS : MessageType.LMS_MMS;
|
||||
const setSmsType = (smsTypeString: "SMS" | "LMS" | "MMS") => {
|
||||
const smsType = MessageType[smsTypeString];
|
||||
|
||||
setSelectedTemplate((prev) => {
|
||||
if (!isSmsTemplate(prev)) return prev;
|
||||
@@ -570,7 +570,7 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
||||
/>
|
||||
{isSmsTemplate(selectedTemplate) &&
|
||||
<p className="text-sm text-red-600 font-medium">
|
||||
⚠️ 제목이 있으면 본문 길이와 상관없이 LMS/MMS로 발송 됩니다.
|
||||
⚠️ 제목이 있으면 본문 길이와 상관없이 LMS로 발송됩니다. 이미지가 있으면 MMS로 발송됩니다.
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
@@ -749,7 +749,7 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
||||
)}
|
||||
{isSms && attachmentCount > 0 && (
|
||||
<p className="text-xs text-red-600">
|
||||
⚠️ 이미지가 첨부되면 본문 길이와 상관없이 LMS/MMS로 저장됩니다.
|
||||
⚠️ 이미지가 첨부되면 본문 길이와 상관없이 MMS로 저장됩니다.
|
||||
</p>
|
||||
)}
|
||||
{selectedTemplate.tmplatIdx && (
|
||||
@@ -767,7 +767,7 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
||||
</p>
|
||||
<KriEditor
|
||||
mode="sms"
|
||||
label={selectedTemplate.tmplatTy === MessageType.SMS ? "️️* 발송 시 길이에 따라 LMS/MMS로 발송 될 수 있음" : undefined}
|
||||
label="미리보기 유형은 예상값이며, 실제 유형은 수신자별 변수 치환 후 결정됩니다."
|
||||
value={selectedTemplate.tmplatBody ?? ""}
|
||||
onChange={(html: string) => setTemplateBody(html)}
|
||||
placeholder="문자 내용을 입력해 주세요"
|
||||
|
||||
@@ -18,19 +18,28 @@ export const KKO_TEMPLATE_KEYWORD_MAX_LENGTH = 50;
|
||||
|
||||
export const SMS_TYPE_ORDER = [
|
||||
MessageType.SMS,
|
||||
MessageType.LMS_MMS,
|
||||
MessageType.LMS,
|
||||
MessageType.MMS,
|
||||
] as const;
|
||||
|
||||
export const SMS_TYPE_LABEL = {
|
||||
[MessageType.SMS]: "SMS",
|
||||
[MessageType.LMS_MMS]: "LMS/MMS",
|
||||
[MessageType.LMS]: "LMS",
|
||||
[MessageType.MMS]: "MMS",
|
||||
} as const satisfies Record<SmsType, string>;
|
||||
|
||||
export const SMS_TYPE_OPTIONS = [
|
||||
{ value: MessageType.SMS, label: SMS_TYPE_LABEL[MessageType.SMS] },
|
||||
{ value: MessageType.LMS_MMS, label: SMS_TYPE_LABEL[MessageType.LMS_MMS] },
|
||||
{ value: MessageType.LMS, label: SMS_TYPE_LABEL[MessageType.LMS] },
|
||||
{ value: MessageType.MMS, label: SMS_TYPE_LABEL[MessageType.MMS] },
|
||||
] as const;
|
||||
|
||||
export const MESSAGE_TYPE_LABEL: Record<number, string> = {
|
||||
...SMS_TYPE_LABEL,
|
||||
[MessageType.EMAIL]: "메일",
|
||||
[MessageType.KKO]: "알림톡",
|
||||
};
|
||||
|
||||
export const TEMPLATE_PURPOSE = {
|
||||
NORMAL: TemplatePurpose.NORMAL,
|
||||
PHONE_VERIFICATION: TemplatePurpose.PHONE_VERIFICATION,
|
||||
@@ -47,7 +56,7 @@ export const PHONE_VERIFICATION_PREVIEW_SUFFIX = "인증번호는 [######] 입
|
||||
export const EMAIL_TEMPLATE_ATTACHMENT_MAX_COUNT = 5;
|
||||
export const EMAIL_TEMPLATE_ATTACHMENT_MAX_BYTES = 1_000_000;
|
||||
|
||||
// 문자 템플릿 첨부파일 제한 (JPG만 허용, 파일당 이하 기준, 첨부 시 LMS/MMS로 저장됨)
|
||||
// 문자 템플릿 첨부파일 제한 (JPG만 허용, 파일당 이하 기준, 첨부 시 MMS로 저장됨)
|
||||
export const SMS_TEMPLATE_ATTACHMENT_MAX_COUNT = 3;
|
||||
export const SMS_TEMPLATE_ATTACHMENT_MAX_BYTES = 61_440;
|
||||
export const SMS_TEMPLATE_ATTACHMENT_EXTENSION = ".jpg";
|
||||
|
||||
Reference in New Issue
Block a user