260826_01_ENH: notihub 수정으로 인한 후속 조치 #27
11
AGENTS.md
11
AGENTS.md
@@ -250,6 +250,17 @@ When implementation is complete, report in Korean:
|
|||||||
- Validate external data at runtime; a shared TypeScript type alone does not validate an API response or persisted value.
|
- Validate external data at runtime; a shared TypeScript type alone does not validate an API response or persisted value.
|
||||||
- Prefer named public exports and retain the consumer project's current module system and bundler conventions.
|
- Prefer named public exports and retain the consumer project's current module system and bundler conventions.
|
||||||
|
|
||||||
|
### React Compiler and Manual Memoization
|
||||||
|
|
||||||
|
- `createKriNextConfig` enables `reactCompiler: true` unless the project overrides it; confirm the effective configuration.
|
||||||
|
- When enabled, rely on React Compiler instead of adding `useMemo`, `useCallback`, or `React.memo` as a routine performance precaution.
|
||||||
|
- Use manual memoization only for required reference stability, an Effect or third-party contract, compiler-incompatible code, or a measured performance problem.
|
||||||
|
- Preserve existing memoization unless approved and verified for removal. Use `"use memo"` or `"use no memo"` only for a documented compiler boundary.
|
||||||
|
|
||||||
|
### Project Instruction Budget
|
||||||
|
|
||||||
|
- Keep `.agent/project.md` at or below 8 KiB (8,192 bytes) as the normal target. Do not delete material rules merely to meet the budget; move schemas, endpoint inventories, examples, and temporary issue history to linked project documentation, and keep concise read-routing instructions here.
|
||||||
|
|
||||||
### Change Safety
|
### Change Safety
|
||||||
|
|
||||||
- Pin or constrain the package version according to the consumer repository's dependency policy and commit its lockfile changes.
|
- Pin or constrain the package version according to the consumer repository's dependency policy and commit its lockfile changes.
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import { MessageType, type TemplateEmail } from "@kri/common/noti-hub";
|
import { MessageType, type TemplateEmail } from "@kri/common/noti-hub";
|
||||||
import MessageTemplate from "@/components/message-template/MessageTemplate";
|
import MessageTemplate from "@/components/message-template/MessageTemplate";
|
||||||
|
import type { TemplateWithPurpose } from "@/types/message";
|
||||||
|
|
||||||
const EmailTemplatePage = () => {
|
const EmailTemplatePage = () => {
|
||||||
|
|
||||||
const defaultEmailTemplate : TemplateEmail = {
|
const defaultEmailTemplate : TemplateWithPurpose & TemplateEmail = {
|
||||||
tmplatIdx: undefined,
|
tmplatIdx: undefined,
|
||||||
itrntPrjctCd: '',
|
itrntPrjctCd: '',
|
||||||
tmplatTy: MessageType.EMAIL,
|
tmplatTy: MessageType.EMAIL,
|
||||||
|
tmplatPurpose: 0,
|
||||||
tmplatNm: '',
|
tmplatNm: '',
|
||||||
tmplatTitle: '',
|
tmplatTitle: '',
|
||||||
tmplatBody: '',
|
tmplatBody: '',
|
||||||
|
|||||||
@@ -2,13 +2,15 @@
|
|||||||
|
|
||||||
import { MessageType, type TemplateSms } from "@kri/common/noti-hub";
|
import { MessageType, type TemplateSms } from "@kri/common/noti-hub";
|
||||||
import MessageTemplate from "@/components/message-template/MessageTemplate";
|
import MessageTemplate from "@/components/message-template/MessageTemplate";
|
||||||
|
import type { TemplateWithPurpose } from "@/types/message";
|
||||||
|
|
||||||
const SmsTemplatePage = () => {
|
const SmsTemplatePage = () => {
|
||||||
|
|
||||||
const defaultSmsTemplate : TemplateSms = {
|
const defaultSmsTemplate : TemplateWithPurpose & TemplateSms = {
|
||||||
tmplatIdx: undefined,
|
tmplatIdx: undefined,
|
||||||
itrntPrjctCd: '',
|
itrntPrjctCd: '',
|
||||||
tmplatTy: MessageType.SMS,
|
tmplatTy: MessageType.SMS,
|
||||||
|
tmplatPurpose: 0,
|
||||||
tmplatNm: '',
|
tmplatNm: '',
|
||||||
tmplatTitle: undefined,
|
tmplatTitle: undefined,
|
||||||
tmplatBody: '',
|
tmplatBody: '',
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
useTemplateListQuery,
|
useTemplateListQuery,
|
||||||
useTemplateQuery,
|
useTemplateQuery,
|
||||||
} from '@/query/message'
|
} from '@/query/message'
|
||||||
import { ChannelType, TemplateSms, type TemplateSummary } from '@kri/common/noti-hub'
|
import { ChannelType, TemplateSms } from '@kri/common/noti-hub'
|
||||||
import { sanitizeHtmlForPreview } from '@/components/kri-editor/utils/sanitizeHtml'
|
import { sanitizeHtmlForPreview } from '@/components/kri-editor/utils/sanitizeHtml'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
import { getNearestFutureDateTime } from '@/lib/datetime'
|
import { getNearestFutureDateTime } from '@/lib/datetime'
|
||||||
@@ -28,7 +28,8 @@ import { KriEditor } from '@/components/kri-editor'
|
|||||||
import { normalizeQrCodeForEditor, QR_CODE_ALLOWED_HTML, renderQrCodePreviewHtml } from '@/components/message-template/qrcode'
|
import { normalizeQrCodeForEditor, QR_CODE_ALLOWED_HTML, renderQrCodePreviewHtml } from '@/components/message-template/qrcode'
|
||||||
import { applyLinkPreviewClass } from '@/components/kri-editor/utils/linkPreview'
|
import { applyLinkPreviewClass } from '@/components/kri-editor/utils/linkPreview'
|
||||||
import TemplateAttachmentList from '@/components/message-template/TemplateAttachmentList'
|
import TemplateAttachmentList from '@/components/message-template/TemplateAttachmentList'
|
||||||
import type { TemplateEmailWithAttachments } from '@/types/message'
|
import type { TemplateEmailWithAttachments, TemplateSummaryWithPurpose } from '@/types/message'
|
||||||
|
import { TEMPLATE_PURPOSE } from '@/const/messageTemplateConst'
|
||||||
|
|
||||||
export type MessageSendMode = 'email' | 'sms'
|
export type MessageSendMode = 'email' | 'sms'
|
||||||
|
|
||||||
@@ -79,7 +80,10 @@ const MessageSendDialog = ({
|
|||||||
const enabled = resolvedOpen && !!selectedProject && prjctIdx > 0
|
const enabled = resolvedOpen && !!selectedProject && prjctIdx > 0
|
||||||
|
|
||||||
const templateListQuery = useTemplateListQuery(chnnlTy, itrntPrjctCd, enabled)
|
const templateListQuery = useTemplateListQuery(chnnlTy, itrntPrjctCd, enabled)
|
||||||
const templateList: TemplateSummary[] = templateListQuery.data ?? []
|
// 대량 발송 및 bulk key 생성 경로에서는 휴대전화번호 인증 템플릿(tmplatPurpose === 1)을 선택할 수 없다.
|
||||||
|
const templateList: TemplateSummaryWithPurpose[] = (templateListQuery.data ?? []).filter(
|
||||||
|
(t) => t.tmplatPurpose !== TEMPLATE_PURPOSE.PHONE_VERIFICATION,
|
||||||
|
)
|
||||||
const templateDetailQuery = useTemplateQuery(templateIdx ?? 0, enabled && !!templateIdx)
|
const templateDetailQuery = useTemplateQuery(templateIdx ?? 0, enabled && !!templateIdx)
|
||||||
const selectedTemplate = templateDetailQuery.data ?? null
|
const selectedTemplate = templateDetailQuery.data ?? null
|
||||||
const mainTemplateQuery = useMainTemplateIdxQuery(prjctIdx, chnnlTy, enabled)
|
const mainTemplateQuery = useMainTemplateIdxQuery(prjctIdx, chnnlTy, enabled)
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ import { KriEditor } from '@/components/kri-editor'
|
|||||||
import { getNearestFutureDateTime } from '@/lib/datetime'
|
import { getNearestFutureDateTime } from '@/lib/datetime'
|
||||||
import { escapeHtml, substituteVariables } from '@/lib/variableSubstitution'
|
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, PhoneVerificationSendData, TemplateEmailWithAttachments } from '@/types/message'
|
||||||
import TemplateAttachmentList from '@/components/message-template/TemplateAttachmentList'
|
import TemplateAttachmentList from '@/components/message-template/TemplateAttachmentList'
|
||||||
|
import { TEMPLATE_PURPOSE } from '@/const/messageTemplateConst'
|
||||||
|
|
||||||
const titleMap: Record<MessageSendChannel, string> = {
|
const titleMap: Record<MessageSendChannel, string> = {
|
||||||
email: '메일 발송',
|
email: '메일 발송',
|
||||||
@@ -74,6 +75,9 @@ const SingleMessageSendDialog = ({
|
|||||||
const previewValues = variableValues ?? {}
|
const previewValues = variableValues ?? {}
|
||||||
const resolvedTitle = selectedTemplate ? substituteVariables(selectedTemplate.tmplatTitle ?? '', previewValues) : ''
|
const resolvedTitle = selectedTemplate ? substituteVariables(selectedTemplate.tmplatTitle ?? '', previewValues) : ''
|
||||||
|
|
||||||
|
// tmplatPurpose === 1(휴대전화번호 인증) 템플릿은 SMS/LMS 단건 즉시 발송만 허용한다.
|
||||||
|
const isPhoneVerificationTemplate = selectedTemplate?.tmplatPurpose === TEMPLATE_PURPOSE.PHONE_VERIFICATION
|
||||||
|
|
||||||
const sendSingleMutation = useSendSingleMessageMutation(channel, prjctIdx)
|
const sendSingleMutation = useSendSingleMessageMutation(channel, prjctIdx)
|
||||||
|
|
||||||
const mainTemplateAppliedRef = useRef(false)
|
const mainTemplateAppliedRef = useRef(false)
|
||||||
@@ -86,6 +90,11 @@ const SingleMessageSendDialog = ({
|
|||||||
mainTemplateAppliedRef.current = false
|
mainTemplateAppliedRef.current = false
|
||||||
}, [resolvedOpen])
|
}, [resolvedOpen])
|
||||||
|
|
||||||
|
// 인증 템플릿 선택 시 예약 발송 옵션을 강제로 즉시 발송으로 되돌린다.
|
||||||
|
useEffect(() => {
|
||||||
|
if (isPhoneVerificationTemplate) setScheduleType('instant')
|
||||||
|
}, [isPhoneVerificationTemplate])
|
||||||
|
|
||||||
// 대표 템플릿이 있으면 최초 1회 자동 선택
|
// 대표 템플릿이 있으면 최초 1회 자동 선택
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!enabled || mainTemplateAppliedRef.current || !mainTemplateQuery.isSuccess) return
|
if (!enabled || mainTemplateAppliedRef.current || !mainTemplateQuery.isSuccess) return
|
||||||
@@ -126,7 +135,7 @@ const SingleMessageSendDialog = ({
|
|||||||
|
|
||||||
setSubmitting(true)
|
setSubmitting(true)
|
||||||
try {
|
try {
|
||||||
await sendSingleMutation.mutateAsync({
|
const res = await sendSingleMutation.mutateAsync({
|
||||||
tmplatIdx: templateIdx,
|
tmplatIdx: templateIdx,
|
||||||
resve: scheduleType === 'reserve',
|
resve: scheduleType === 'reserve',
|
||||||
sendDt: scheduleType === 'reserve' ? new Date(reserveAt).toISOString() : undefined,
|
sendDt: scheduleType === 'reserve' ? new Date(reserveAt).toISOString() : undefined,
|
||||||
@@ -134,6 +143,17 @@ const SingleMessageSendDialog = ({
|
|||||||
destHeaderIds: [destHeaderId],
|
destHeaderIds: [destHeaderId],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// cmid는 발송 CMID이며 verificationId와는 다른 식별자이므로 혼용하지 않는다.
|
||||||
|
const cmid = res.cmid
|
||||||
|
if (isPhoneVerificationTemplate) {
|
||||||
|
// 휴대전화번호 인증 응답. verificationId/expireDt는 이후 인증 단계에서 사용할 값이나,
|
||||||
|
// 이 시스템에서는 인증번호 확인 절차를 사용하지 않으므로 현재는 별도로 활용하지 않는다.
|
||||||
|
const { verificationId, expireDt } = res.data as PhoneVerificationSendData
|
||||||
|
void verificationId
|
||||||
|
void expireDt
|
||||||
|
}
|
||||||
|
void cmid
|
||||||
|
|
||||||
alert('발송 요청이 완료되었습니다.')
|
alert('발송 요청이 완료되었습니다.')
|
||||||
onSent?.()
|
onSent?.()
|
||||||
handleOpenChange(false)
|
handleOpenChange(false)
|
||||||
@@ -177,6 +197,9 @@ const SingleMessageSendDialog = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{isPhoneVerificationTemplate ? (
|
||||||
|
<p className="text-sm text-muted-foreground">휴대전화번호 인증 템플릿은 즉시 발송만 가능합니다.</p>
|
||||||
|
) : (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label className="text-sm">발송 일시</Label>
|
<Label className="text-sm">발송 일시</Label>
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
@@ -197,6 +220,7 @@ const SingleMessageSendDialog = ({
|
|||||||
<KriDateTimePicker value={reserveAt} onChange={setReserveAt} placeholder="예약 일시 선택" />
|
<KriDateTimePicker value={reserveAt} onChange={setReserveAt} placeholder="예약 일시 선택" />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-2 rounded-md border p-4">
|
<div className="space-y-2 rounded-md border p-4">
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export function KriEditorSms({
|
|||||||
isSmsReadOnly = false,
|
isSmsReadOnly = false,
|
||||||
smsMaxBytes = 90,
|
smsMaxBytes = 90,
|
||||||
lmsMaxBytes = 2000,
|
lmsMaxBytes = 2000,
|
||||||
|
smsPreviewSuffix = '',
|
||||||
}: SmsEditorProps) {
|
}: SmsEditorProps) {
|
||||||
const [text, setText] = React.useState(value || '')
|
const [text, setText] = React.useState(value || '')
|
||||||
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null)
|
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null)
|
||||||
@@ -33,7 +34,8 @@ export function KriEditorSms({
|
|||||||
const lastTypeRef = React.useRef<'SMS' | 'LMS' | null>(null)
|
const lastTypeRef = React.useRef<'SMS' | 'LMS' | null>(null)
|
||||||
const { scheduleChange, flushChange } = useDebouncedChange(onChange, debounceMs)
|
const { scheduleChange, flushChange } = useDebouncedChange(onChange, debounceMs)
|
||||||
const textareaInsert = useTextareaInsert(textareaRef)
|
const textareaInsert = useTextareaInsert(textareaRef)
|
||||||
const byteSize = React.useMemo(() => calculateBytes(text), [text])
|
const previewText = smsPreviewSuffix ? `${text}\n${smsPreviewSuffix}` : text
|
||||||
|
const byteSize = React.useMemo(() => calculateBytes(previewText), [previewText])
|
||||||
const messageType: 'SMS' | 'LMS' = byteSize > smsMaxBytes || Boolean(smsTitle) ? 'LMS' : 'SMS'
|
const messageType: 'SMS' | 'LMS' = byteSize > smsMaxBytes || Boolean(smsTitle) ? 'LMS' : 'SMS'
|
||||||
const maxBytes = messageType === 'SMS' ? smsMaxBytes : lmsMaxBytes
|
const maxBytes = messageType === 'SMS' ? smsMaxBytes : lmsMaxBytes
|
||||||
|
|
||||||
@@ -97,7 +99,8 @@ export function KriEditorSms({
|
|||||||
value={text}
|
value={text}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
const next = event.target.value
|
const next = event.target.value
|
||||||
if (calculateBytes(next) <= lmsMaxBytes) commitText(next)
|
const nextPreview = smsPreviewSuffix ? `${next}\n${smsPreviewSuffix}` : next
|
||||||
|
if (calculateBytes(nextPreview) <= lmsMaxBytes) commitText(next)
|
||||||
}}
|
}}
|
||||||
onBlur={() => flushChange(latestTextRef.current)}
|
onBlur={() => flushChange(latestTextRef.current)}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
@@ -105,6 +108,11 @@ export function KriEditorSms({
|
|||||||
style={{ minHeight: smsTitle ? '320px' : '360px' }}
|
style={{ minHeight: smsTitle ? '320px' : '360px' }}
|
||||||
{...textareaInsert.bindSelectionHandlers}
|
{...textareaInsert.bindSelectionHandlers}
|
||||||
/>
|
/>
|
||||||
|
{smsPreviewSuffix ? (
|
||||||
|
<div className="whitespace-pre-wrap px-4 pb-4 text-sm leading-relaxed text-gray-700">
|
||||||
|
{smsPreviewSuffix}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
{byteSize > maxBytes ? (
|
{byteSize > maxBytes ? (
|
||||||
<p className="mt-2 px-2 text-center text-xs font-medium text-red-600">
|
<p className="mt-2 px-2 text-center text-xs font-medium text-red-600">
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ export type KriEditorProps = {
|
|||||||
isSmsReadOnly?: boolean
|
isSmsReadOnly?: boolean
|
||||||
smsMaxBytes?: number
|
smsMaxBytes?: number
|
||||||
lmsMaxBytes?: number
|
lmsMaxBytes?: number
|
||||||
|
smsPreviewSuffix?: string
|
||||||
toolbar?: KriEditorToolbarConfig | false
|
toolbar?: KriEditorToolbarConfig | false
|
||||||
fontFamilyOptions?: KriEditorFontFamilyOption[]
|
fontFamilyOptions?: KriEditorFontFamilyOption[]
|
||||||
renderToolbarEnd?: (context: KriEditorToolbarContext) => ReactNode
|
renderToolbarEnd?: (context: KriEditorToolbarContext) => ReactNode
|
||||||
|
|||||||
@@ -6,17 +6,22 @@ import {
|
|||||||
ChannelType,
|
ChannelType,
|
||||||
MessageType,
|
MessageType,
|
||||||
SMS_TYPE_ARRAY,
|
SMS_TYPE_ARRAY,
|
||||||
Template,
|
|
||||||
TemplateSms,
|
TemplateSms,
|
||||||
TemplateSummary
|
|
||||||
} from "@kri/common/noti-hub";
|
} from "@kri/common/noti-hub";
|
||||||
import {Paperclip, X} from "lucide-react";
|
import {Paperclip, X} from "lucide-react";
|
||||||
import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card";
|
import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card";
|
||||||
import {Label} from "@/components/ui/label";
|
import {Label} from "@/components/ui/label";
|
||||||
import {KriSingleSelect} from "@/components/common/KriAutoComplete";
|
import {KriSingleSelect} from "@/components/common/KriAutoComplete";
|
||||||
import {SMS_TYPE_OPTIONS, TEMPLATE_ATTACHMENT_MAX_BYTES, TEMPLATE_ATTACHMENT_MAX_COUNT} from "@/const/messageTemplateConst";
|
import {
|
||||||
|
PHONE_VERIFICATION_PREVIEW_SUFFIX,
|
||||||
|
TEMPLATE_ATTACHMENT_MAX_BYTES,
|
||||||
|
TEMPLATE_ATTACHMENT_MAX_COUNT,
|
||||||
|
TEMPLATE_PURPOSE,
|
||||||
|
TEMPLATE_PURPOSE_OPTIONS,
|
||||||
|
} from "@/const/messageTemplateConst";
|
||||||
import {Input} from "@/components/ui/input";
|
import {Input} from "@/components/ui/input";
|
||||||
import {Checkbox} from "@/components/ui/checkbox";
|
import {Checkbox} from "@/components/ui/checkbox";
|
||||||
|
import {RadioGroup, RadioGroupItem} from "@/components/ui/radio-group";
|
||||||
import {KriEditor, KriEditorCommand} from "@/components/kri-editor";
|
import {KriEditor, KriEditorCommand} from "@/components/kri-editor";
|
||||||
import {Button} from "@/components/ui/button";
|
import {Button} from "@/components/ui/button";
|
||||||
import { isBlank } from "@kri/common";
|
import { isBlank } from "@kri/common";
|
||||||
@@ -26,7 +31,11 @@ import {ProjectMainTemplateUpdateRequest, ProjectSurvey} from "@/types/project";
|
|||||||
import type { DataVerification } from "@kri/common";
|
import type { DataVerification } from "@kri/common";
|
||||||
import {COMMON_TEXT_REGEX} from "@/const/validationConst";
|
import {COMMON_TEXT_REGEX} from "@/const/validationConst";
|
||||||
import {formatKoreanPhoneNumber} from "@/utils/phone";
|
import {formatKoreanPhoneNumber} from "@/utils/phone";
|
||||||
import type {TemplateEmailWithAttachments} from "@/types/message";
|
import type {
|
||||||
|
TemplateEmailWithAttachments,
|
||||||
|
TemplateSummaryWithPurpose,
|
||||||
|
TemplateWithPurpose,
|
||||||
|
} from "@/types/message";
|
||||||
import {
|
import {
|
||||||
useTemplateListQuery,
|
useTemplateListQuery,
|
||||||
useMainTemplateIdxQuery,
|
useMainTemplateIdxQuery,
|
||||||
@@ -51,7 +60,7 @@ import {
|
|||||||
|
|
||||||
interface MessageTemplateProps {
|
interface MessageTemplateProps {
|
||||||
pageTitle: string;
|
pageTitle: string;
|
||||||
defaultTemplate: Template;
|
defaultTemplate: TemplateWithPurpose;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MESSAGE_EDITOR_EXTENSIONS = [QrCode];
|
const MESSAGE_EDITOR_EXTENSIONS = [QrCode];
|
||||||
@@ -62,7 +71,7 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
|||||||
const editorCmdRef = useRef<KriEditorCommand | null>(null);
|
const editorCmdRef = useRef<KriEditorCommand | null>(null);
|
||||||
const sessionTempUrlsRef = useRef<Set<string>>(new Set());
|
const sessionTempUrlsRef = useRef<Set<string>>(new Set());
|
||||||
|
|
||||||
const [selectedTemplate, setSelectedTemplate] = useState<Template>(defaultTemplate);
|
const [selectedTemplate, setSelectedTemplate] = useState<TemplateWithPurpose>(defaultTemplate);
|
||||||
const [selectedTemplateIdx, setSelectedTemplateIdx] = useState<number | null>(null);
|
const [selectedTemplateIdx, setSelectedTemplateIdx] = useState<number | null>(null);
|
||||||
|
|
||||||
// 이메일 첨부파일 draft (신규 첨부 / 기존 첨부 삭제 예정). 저장 성공 시, 템플릿 전환 시 초기화된다.
|
// 이메일 첨부파일 draft (신규 첨부 / 기존 첨부 삭제 예정). 저장 성공 시, 템플릿 전환 시 초기화된다.
|
||||||
@@ -70,7 +79,7 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
|||||||
const [deletedAttachmentNames, setDeletedAttachmentNames] = useState<string[]>([]);
|
const [deletedAttachmentNames, setDeletedAttachmentNames] = useState<string[]>([]);
|
||||||
const attachmentInputRef = useRef<HTMLInputElement | null>(null);
|
const attachmentInputRef = useRef<HTMLInputElement | null>(null);
|
||||||
|
|
||||||
const isSmsTemplate = (t: Template): t is TemplateSms =>
|
const isSmsTemplate = (t: TemplateWithPurpose): t is TemplateSms & Pick<TemplateWithPurpose, "tmplatPurpose"> =>
|
||||||
(SMS_TYPE_ARRAY as readonly MessageType[]).includes(t.tmplatTy);
|
(SMS_TYPE_ARRAY as readonly MessageType[]).includes(t.tmplatTy);
|
||||||
|
|
||||||
const isSms = isSmsTemplate(defaultTemplate);
|
const isSms = isSmsTemplate(defaultTemplate);
|
||||||
@@ -93,7 +102,7 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
|||||||
const listHeaderQuery = useListHeaderQuery(prjctIdx, enabled)
|
const listHeaderQuery = useListHeaderQuery(prjctIdx, enabled)
|
||||||
const projectInfoQuery = useProjectInfoQuery(prjctIdx, enabled)
|
const projectInfoQuery = useProjectInfoQuery(prjctIdx, enabled)
|
||||||
|
|
||||||
const templateList = useMemo<TemplateSummary[]>(() => templateListQuery.data ?? [], [templateListQuery.data]);
|
const templateList = useMemo<TemplateSummaryWithPurpose[]>(() => templateListQuery.data ?? [], [templateListQuery.data]);
|
||||||
const mainTemplateIdx = useMemo<number | null>(() => mainTemplateQuery.data ?? null, [mainTemplateQuery.data]);
|
const mainTemplateIdx = useMemo<number | null>(() => mainTemplateQuery.data ?? null, [mainTemplateQuery.data]);
|
||||||
const listHderList = useMemo<listHeader[]>(() => listHeaderQuery.data ?? [], [listHeaderQuery.data])
|
const listHderList = useMemo<listHeader[]>(() => listHeaderQuery.data ?? [], [listHeaderQuery.data])
|
||||||
const surveys = useMemo<ProjectSurvey[]>(() => projectInfoQuery.data?.surveys ?? [], [projectInfoQuery.data?.surveys])
|
const surveys = useMemo<ProjectSurvey[]>(() => projectInfoQuery.data?.surveys ?? [], [projectInfoQuery.data?.surveys])
|
||||||
@@ -161,14 +170,14 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
|||||||
}
|
}
|
||||||
}, [selectedTemplate.tmplatIdx, mainTemplateIdx]);
|
}, [selectedTemplate.tmplatIdx, mainTemplateIdx]);
|
||||||
|
|
||||||
const handleChange = <K extends KeysOfUnion<Template>>(
|
const handleChange = <K extends KeysOfUnion<TemplateWithPurpose>>(
|
||||||
field: K,
|
field: K,
|
||||||
value: ValueOfUnionKey<Template, K>
|
value: ValueOfUnionKey<TemplateWithPurpose, K>
|
||||||
) => {
|
) => {
|
||||||
setSelectedTemplate((prev) => {
|
setSelectedTemplate((prev) => {
|
||||||
const next = { ...prev } as any;
|
const next = { ...prev } as any;
|
||||||
next[field] = value;
|
next[field] = value;
|
||||||
return next as Template;
|
return next as TemplateWithPurpose;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -185,7 +194,7 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const validateTemplate = (tpl: Template): DataVerification => {
|
const validateTemplate = (tpl: TemplateWithPurpose): DataVerification => {
|
||||||
const ok = (): DataVerification => ({ success: true, fieldName: "", errMessage: "" });
|
const ok = (): DataVerification => ({ success: true, fieldName: "", errMessage: "" });
|
||||||
const fail = (fieldName: string, errMessage: string): DataVerification => ({
|
const fail = (fieldName: string, errMessage: string): DataVerification => ({
|
||||||
success: false,
|
success: false,
|
||||||
@@ -361,9 +370,10 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const templateToSave = isSmsTemplate(selectedTemplate)
|
const templateToSave = isSmsTemplate(selectedTemplate)
|
||||||
? selectedTemplate
|
? { ...selectedTemplate, tmplatPurpose: selectedTemplate.tmplatPurpose ?? TEMPLATE_PURPOSE.NORMAL }
|
||||||
: {
|
: {
|
||||||
...selectedTemplate,
|
...selectedTemplate,
|
||||||
|
tmplatPurpose: TEMPLATE_PURPOSE.NORMAL,
|
||||||
tmplatBody: normalizeQrCodeForStorage(selectedTemplate.tmplatBody),
|
tmplatBody: normalizeQrCodeForStorage(selectedTemplate.tmplatBody),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -456,6 +466,28 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
|||||||
clearLabel="새 테플릿 생성"
|
clearLabel="새 테플릿 생성"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{isSmsTemplate(selectedTemplate) && (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label className="text-base">템플릿 용도</Label>
|
||||||
|
<RadioGroup
|
||||||
|
value={String(selectedTemplate.tmplatPurpose ?? TEMPLATE_PURPOSE.NORMAL)}
|
||||||
|
onValueChange={(value) =>
|
||||||
|
handleChange("tmplatPurpose", Number(value) as 0 | 1)
|
||||||
|
}
|
||||||
|
className="flex flex-wrap gap-4"
|
||||||
|
>
|
||||||
|
{TEMPLATE_PURPOSE_OPTIONS.map((option) => (
|
||||||
|
<div key={option.value} className="flex items-center gap-2">
|
||||||
|
<RadioGroupItem value={String(option.value)} id={`tmplatPurpose-${option.value}`} />
|
||||||
|
<Label htmlFor={`tmplatPurpose-${option.value}`} className="font-normal">
|
||||||
|
{option.label}
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</RadioGroup>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label htmlFor="tmplatNm" className="text-base">
|
<Label htmlFor="tmplatNm" className="text-base">
|
||||||
템플릿 명
|
템플릿 명
|
||||||
@@ -659,6 +691,11 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
|||||||
editorCmdRef.current = cmd;
|
editorCmdRef.current = cmd;
|
||||||
}}
|
}}
|
||||||
smsTitle={(selectedTemplate as TemplateSms).tmplatTitle}
|
smsTitle={(selectedTemplate as TemplateSms).tmplatTitle}
|
||||||
|
smsPreviewSuffix={
|
||||||
|
selectedTemplate.tmplatPurpose === TEMPLATE_PURPOSE.PHONE_VERIFICATION
|
||||||
|
? PHONE_VERIFICATION_PREVIEW_SUFFIX
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
changeSmsType={(smsTypeString) => setSmsType(smsTypeString)}
|
changeSmsType={(smsTypeString) => setSmsType(smsTypeString)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -15,6 +15,18 @@ export const SMS_TYPE_OPTIONS = [
|
|||||||
{ value: MessageType.LMS_MMS, label: SMS_TYPE_LABEL[MessageType.LMS_MMS] },
|
{ value: MessageType.LMS_MMS, label: SMS_TYPE_LABEL[MessageType.LMS_MMS] },
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
export const TEMPLATE_PURPOSE = {
|
||||||
|
NORMAL: 0,
|
||||||
|
PHONE_VERIFICATION: 1,
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const TEMPLATE_PURPOSE_OPTIONS = [
|
||||||
|
{ value: TEMPLATE_PURPOSE.NORMAL, label: "일반" },
|
||||||
|
{ value: TEMPLATE_PURPOSE.PHONE_VERIFICATION, label: "휴대전화번호 인증" },
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export const PHONE_VERIFICATION_PREVIEW_SUFFIX = "인증번호는 [######] 입니다.";
|
||||||
|
|
||||||
// 이메일 템플릿 첨부파일 제한 (첨부파일은 이메일 템플릿만 지원)
|
// 이메일 템플릿 첨부파일 제한 (첨부파일은 이메일 템플릿만 지원)
|
||||||
export const TEMPLATE_ATTACHMENT_MAX_COUNT = 5;
|
export const TEMPLATE_ATTACHMENT_MAX_COUNT = 5;
|
||||||
export const TEMPLATE_ATTACHMENT_MAX_BYTES = 1_000_000;
|
export const TEMPLATE_ATTACHMENT_MAX_BYTES = 1_000_000;
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import type {
|
|||||||
ChannelType,
|
ChannelType,
|
||||||
SendResultSummaryRequest,
|
SendResultSummaryRequest,
|
||||||
SendResultSummaryResponse,
|
SendResultSummaryResponse,
|
||||||
Template,
|
|
||||||
TemplateSummary,
|
|
||||||
} from "@kri/common/noti-hub";
|
} from "@kri/common/noti-hub";
|
||||||
import type { FileResponse, PageRequest, PageResponse } from "@kri/common";
|
import type { FileResponse, PageRequest, PageResponse } from "@kri/common";
|
||||||
import type { ProjectMainTemplateUpdateRequest } from "@/types/project";
|
import type { ProjectMainTemplateUpdateRequest } from "@/types/project";
|
||||||
@@ -19,12 +17,14 @@ import type {
|
|||||||
MessageSendChannel,
|
MessageSendChannel,
|
||||||
MessageSendSingleRequest,
|
MessageSendSingleRequest,
|
||||||
SendResultInfo,
|
SendResultInfo,
|
||||||
|
SendSingleResponse,
|
||||||
} from "@/types/message";
|
} from "@/types/message";
|
||||||
|
import type { TemplateSummaryWithPurpose, TemplateWithPurpose } from "@/types/message";
|
||||||
|
|
||||||
export function useTemplateListQuery(chnnlTy: ChannelType, itrntPrjctCd: string, enabled: boolean) {
|
export function useTemplateListQuery(chnnlTy: ChannelType, itrntPrjctCd: string, enabled: boolean) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: qk.templateList(chnnlTy, itrntPrjctCd),
|
queryKey: qk.templateList(chnnlTy, itrntPrjctCd),
|
||||||
queryFn: () => nextApi.get<TemplateSummary[]>(`/message-template/list/${chnnlTy}/${itrntPrjctCd}`),
|
queryFn: () => nextApi.get<TemplateSummaryWithPurpose[]>(`/message-template/list/${chnnlTy}/${itrntPrjctCd}`),
|
||||||
enabled: enabled && !!itrntPrjctCd,
|
enabled: enabled && !!itrntPrjctCd,
|
||||||
staleTime: 30_000,
|
staleTime: 30_000,
|
||||||
meta: { ignoreGlobalLoading: true },
|
meta: { ignoreGlobalLoading: true },
|
||||||
@@ -44,7 +44,7 @@ export function useMainTemplateIdxQuery(prjctIdx: number, chnnlTy: ChannelType,
|
|||||||
export function useTemplateQuery(tmplatIdx: number, enabled: boolean) {
|
export function useTemplateQuery(tmplatIdx: number, enabled: boolean) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: qk.template(tmplatIdx),
|
queryKey: qk.template(tmplatIdx),
|
||||||
queryFn: () => nextApi.get<Template>(`/message-template/${tmplatIdx}`),
|
queryFn: () => nextApi.get<TemplateWithPurpose>(`/message-template/${tmplatIdx}`),
|
||||||
enabled: enabled && tmplatIdx > 0,
|
enabled: enabled && tmplatIdx > 0,
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
refetchOnMount: "always",
|
refetchOnMount: "always",
|
||||||
@@ -58,7 +58,7 @@ export function useSaveTemplateMutation(chnnlTy: ChannelType, itrntPrjctCd: stri
|
|||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async (v: {
|
mutationFn: async (v: {
|
||||||
method: "put" | "patch";
|
method: "put" | "patch";
|
||||||
template: Template;
|
template: TemplateWithPurpose;
|
||||||
newFiles?: File[];
|
newFiles?: File[];
|
||||||
deleteFileNames?: string[];
|
deleteFileNames?: string[];
|
||||||
}) => {
|
}) => {
|
||||||
@@ -73,8 +73,8 @@ export function useSaveTemplateMutation(chnnlTy: ChannelType, itrntPrjctCd: stri
|
|||||||
deleteFileNames.forEach((name) => formData.append("deleteFileNames", name));
|
deleteFileNames.forEach((name) => formData.append("deleteFileNames", name));
|
||||||
|
|
||||||
return method === "put"
|
return method === "put"
|
||||||
? nextApi.putForm<Template>(`/message-template`, formData)
|
? nextApi.putForm<TemplateWithPurpose>(`/message-template`, formData)
|
||||||
: nextApi.request<Template>(`/message-template`, { method: "PATCH", form: formData });
|
: nextApi.request<TemplateWithPurpose>(`/message-template`, { method: "PATCH", form: formData });
|
||||||
},
|
},
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
if (res.tmplatIdx) {
|
if (res.tmplatIdx) {
|
||||||
@@ -189,7 +189,7 @@ export function useSendSingleMessageMutation(channel: MessageSendChannel, prjctI
|
|||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: (req: MessageSendSingleRequest) =>
|
mutationFn: (req: MessageSendSingleRequest) =>
|
||||||
nextApi.post<void>(`/message/${channel}/single/${prjctIdx}`, req),
|
nextApi.post<SendSingleResponse>(`/message/${channel}/single/${prjctIdx}`, req),
|
||||||
onSuccess: (_data, req) => {
|
onSuccess: (_data, req) => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["message-report", "send-result", String(req.sid)] });
|
queryClient.invalidateQueries({ queryKey: ["message-report", "send-result", String(req.sid)] });
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,16 @@
|
|||||||
import type { TemplateEmail } from '@kri/common/noti-hub';
|
import type { Template, TemplateEmail, TemplateSummary } from '@kri/common/noti-hub';
|
||||||
import type { ListFilter } from './list';
|
import type { ListFilter } from './list';
|
||||||
|
|
||||||
|
export type TemplatePurpose = 0 | 1;
|
||||||
|
|
||||||
|
export type TemplateWithPurpose = Template & {
|
||||||
|
tmplatPurpose: TemplatePurpose;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TemplateSummaryWithPurpose = TemplateSummary & {
|
||||||
|
tmplatPurpose: TemplatePurpose;
|
||||||
|
};
|
||||||
|
|
||||||
export type MessageSendChannel = 'sms' | 'email';
|
export type MessageSendChannel = 'sms' | 'email';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -8,9 +18,20 @@ export type MessageSendChannel = 'sms' | 'email';
|
|||||||
* 조회 응답 전용 필드로, 파이프(|)로 구분된 첨부파일명 목록이 내려온다. 요청 시엔 사용하지 않는다.
|
* 조회 응답 전용 필드로, 파이프(|)로 구분된 첨부파일명 목록이 내려온다. 요청 시엔 사용하지 않는다.
|
||||||
*/
|
*/
|
||||||
export type TemplateEmailWithAttachments = TemplateEmail & {
|
export type TemplateEmailWithAttachments = TemplateEmail & {
|
||||||
|
tmplatPurpose: TemplatePurpose;
|
||||||
atchFl?: string;
|
atchFl?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type PhoneVerificationSendData = {
|
||||||
|
verificationId: string;
|
||||||
|
expireDt: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SendSingleResponse = {
|
||||||
|
cmid: string;
|
||||||
|
data: Record<string, unknown>;
|
||||||
|
};
|
||||||
|
|
||||||
export type MessageSendSingleRequest = {
|
export type MessageSendSingleRequest = {
|
||||||
tmplatIdx: number;
|
tmplatIdx: number;
|
||||||
resve: boolean;
|
resve: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user