Merge branch 'master' into develop
# Conflicts: # package-lock.json # package.json # src/components/dialog/MessageHistoryDialog.tsx # src/components/list-contact/ListContactEventPanel.tsx
This commit is contained in:
@@ -9,6 +9,7 @@ import { useDialog } from '@/hooks/useDialog'
|
||||
import { useSelectedProject } from '@/hooks/useSelectedProject'
|
||||
import { useBulkSendDetailExcelMutation, useBulkSendDetailQuery, useBulkSendListQuery } from '@/query/message'
|
||||
import { isSendCancelable, 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'
|
||||
@@ -93,6 +94,7 @@ const buildHistoryColumns = ({ canCancel, onCancel, cancelPending }: CancelColum
|
||||
]
|
||||
|
||||
const buildDetailColumns = ({ canCancel, onCancel, cancelPending }: CancelColumnOptions): 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) : '') || '-' },
|
||||
@@ -132,21 +134,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, isSendCancelable } from '@kri/common/noti-hub'
|
||||
import { MESSAGE_TYPE_LABEL } from '@/const/messageTemplateConst'
|
||||
import type { SendResultInfo } from '@kri/common/noti-hub'
|
||||
import { useSendCancel } from '@/hooks/useSendCancel'
|
||||
import { formatKst } from '@kri/common'
|
||||
@@ -255,6 +256,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>
|
||||
@@ -268,6 +270,7 @@ const SendResultTable = ({ isLoading, results }: { isLoading: boolean; results:
|
||||
const canCancel = isSendCancelable(item) && !!sendIdx
|
||||
return (
|
||||
<tr key={sendIdx ?? 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="문자 내용을 입력해 주세요"
|
||||
|
||||
Reference in New Issue
Block a user