Compare commits
2 Commits
de73dbd8db
...
bbc035c778
| Author | SHA1 | Date | |
|---|---|---|---|
| bbc035c778 | |||
| a603f6ad6f |
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.
|
||||
- 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
|
||||
|
||||
- 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 MessageTemplate from "@/components/message-template/MessageTemplate";
|
||||
import type { TemplateWithPurpose } from "@/types/message";
|
||||
|
||||
const EmailTemplatePage = () => {
|
||||
|
||||
const defaultEmailTemplate : TemplateEmail = {
|
||||
const defaultEmailTemplate : TemplateWithPurpose & TemplateEmail = {
|
||||
tmplatIdx: undefined,
|
||||
itrntPrjctCd: '',
|
||||
tmplatTy: MessageType.EMAIL,
|
||||
tmplatPurpose: 0,
|
||||
tmplatNm: '',
|
||||
tmplatTitle: '',
|
||||
tmplatBody: '',
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
import { MessageType, type TemplateSms } from "@kri/common/noti-hub";
|
||||
import MessageTemplate from "@/components/message-template/MessageTemplate";
|
||||
import type { TemplateWithPurpose } from "@/types/message";
|
||||
|
||||
const SmsTemplatePage = () => {
|
||||
|
||||
const defaultSmsTemplate : TemplateSms = {
|
||||
const defaultSmsTemplate : TemplateWithPurpose & TemplateSms = {
|
||||
tmplatIdx: undefined,
|
||||
itrntPrjctCd: '',
|
||||
tmplatTy: MessageType.SMS,
|
||||
tmplatPurpose: 0,
|
||||
tmplatNm: '',
|
||||
tmplatTitle: undefined,
|
||||
tmplatBody: '',
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
useTemplateListQuery,
|
||||
useTemplateQuery,
|
||||
} 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 { cn } from '@/lib/utils'
|
||||
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 { applyLinkPreviewClass } from '@/components/kri-editor/utils/linkPreview'
|
||||
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'
|
||||
|
||||
@@ -79,7 +80,10 @@ const MessageSendDialog = ({
|
||||
const enabled = resolvedOpen && !!selectedProject && prjctIdx > 0
|
||||
|
||||
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 selectedTemplate = templateDetailQuery.data ?? null
|
||||
const mainTemplateQuery = useMainTemplateIdxQuery(prjctIdx, chnnlTy, enabled)
|
||||
|
||||
@@ -20,8 +20,9 @@ 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 type { MessageSendChannel, PhoneVerificationSendData, TemplateEmailWithAttachments } from '@/types/message'
|
||||
import TemplateAttachmentList from '@/components/message-template/TemplateAttachmentList'
|
||||
import { TEMPLATE_PURPOSE } from '@/const/messageTemplateConst'
|
||||
|
||||
const titleMap: Record<MessageSendChannel, string> = {
|
||||
email: '메일 발송',
|
||||
@@ -74,6 +75,9 @@ const SingleMessageSendDialog = ({
|
||||
const previewValues = variableValues ?? {}
|
||||
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 mainTemplateAppliedRef = useRef(false)
|
||||
@@ -86,6 +90,11 @@ const SingleMessageSendDialog = ({
|
||||
mainTemplateAppliedRef.current = false
|
||||
}, [resolvedOpen])
|
||||
|
||||
// 인증 템플릿 선택 시 예약 발송 옵션을 강제로 즉시 발송으로 되돌린다.
|
||||
useEffect(() => {
|
||||
if (isPhoneVerificationTemplate) setScheduleType('instant')
|
||||
}, [isPhoneVerificationTemplate])
|
||||
|
||||
// 대표 템플릿이 있으면 최초 1회 자동 선택
|
||||
useEffect(() => {
|
||||
if (!enabled || mainTemplateAppliedRef.current || !mainTemplateQuery.isSuccess) return
|
||||
@@ -126,7 +135,7 @@ const SingleMessageSendDialog = ({
|
||||
|
||||
setSubmitting(true)
|
||||
try {
|
||||
await sendSingleMutation.mutateAsync({
|
||||
const res = await sendSingleMutation.mutateAsync({
|
||||
tmplatIdx: templateIdx,
|
||||
resve: scheduleType === 'reserve',
|
||||
sendDt: scheduleType === 'reserve' ? new Date(reserveAt).toISOString() : undefined,
|
||||
@@ -134,6 +143,17 @@ const SingleMessageSendDialog = ({
|
||||
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('발송 요청이 완료되었습니다.')
|
||||
onSent?.()
|
||||
handleOpenChange(false)
|
||||
@@ -177,26 +197,30 @@ const SingleMessageSendDialog = ({
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label className="text-sm">발송 일시</Label>
|
||||
<RadioGroup
|
||||
value={scheduleType}
|
||||
onValueChange={(v) => handleScheduleTypeChange(v as 'instant' | 'reserve')}
|
||||
className="flex items-center gap-4"
|
||||
>
|
||||
<div className="flex items-center gap-2 cursor-pointer">
|
||||
<RadioGroupItem value="instant" id="single-send-instant" />
|
||||
<Label htmlFor="single-send-instant">즉시</Label>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 cursor-pointer">
|
||||
<RadioGroupItem value="reserve" id="single-send-reserve" />
|
||||
<Label htmlFor="single-send-reserve">예약</Label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
{scheduleType === 'reserve' && (
|
||||
<KriDateTimePicker value={reserveAt} onChange={setReserveAt} placeholder="예약 일시 선택" />
|
||||
)}
|
||||
</div>
|
||||
{isPhoneVerificationTemplate ? (
|
||||
<p className="text-sm text-muted-foreground">휴대전화번호 인증 템플릿은 즉시 발송만 가능합니다.</p>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
<Label className="text-sm">발송 일시</Label>
|
||||
<RadioGroup
|
||||
value={scheduleType}
|
||||
onValueChange={(v) => handleScheduleTypeChange(v as 'instant' | 'reserve')}
|
||||
className="flex items-center gap-4"
|
||||
>
|
||||
<div className="flex items-center gap-2 cursor-pointer">
|
||||
<RadioGroupItem value="instant" id="single-send-instant" />
|
||||
<Label htmlFor="single-send-instant">즉시</Label>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 cursor-pointer">
|
||||
<RadioGroupItem value="reserve" id="single-send-reserve" />
|
||||
<Label htmlFor="single-send-reserve">예약</Label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
{scheduleType === 'reserve' && (
|
||||
<KriDateTimePicker value={reserveAt} onChange={setReserveAt} placeholder="예약 일시 선택" />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2 rounded-md border p-4">
|
||||
|
||||
@@ -26,6 +26,7 @@ export function KriEditorSms({
|
||||
isSmsReadOnly = false,
|
||||
smsMaxBytes = 90,
|
||||
lmsMaxBytes = 2000,
|
||||
smsPreviewSuffix = '',
|
||||
}: SmsEditorProps) {
|
||||
const [text, setText] = React.useState(value || '')
|
||||
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null)
|
||||
@@ -33,7 +34,8 @@ export function KriEditorSms({
|
||||
const lastTypeRef = React.useRef<'SMS' | 'LMS' | null>(null)
|
||||
const { scheduleChange, flushChange } = useDebouncedChange(onChange, debounceMs)
|
||||
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 maxBytes = messageType === 'SMS' ? smsMaxBytes : lmsMaxBytes
|
||||
|
||||
@@ -97,7 +99,8 @@ export function KriEditorSms({
|
||||
value={text}
|
||||
onChange={(event) => {
|
||||
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)}
|
||||
placeholder={placeholder}
|
||||
@@ -105,6 +108,11 @@ export function KriEditorSms({
|
||||
style={{ minHeight: smsTitle ? '320px' : '360px' }}
|
||||
{...textareaInsert.bindSelectionHandlers}
|
||||
/>
|
||||
{smsPreviewSuffix ? (
|
||||
<div className="whitespace-pre-wrap px-4 pb-4 text-sm leading-relaxed text-gray-700">
|
||||
{smsPreviewSuffix}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
{byteSize > maxBytes ? (
|
||||
<p className="mt-2 px-2 text-center text-xs font-medium text-red-600">
|
||||
|
||||
@@ -74,6 +74,7 @@ export type KriEditorProps = {
|
||||
isSmsReadOnly?: boolean
|
||||
smsMaxBytes?: number
|
||||
lmsMaxBytes?: number
|
||||
smsPreviewSuffix?: string
|
||||
toolbar?: KriEditorToolbarConfig | false
|
||||
fontFamilyOptions?: KriEditorFontFamilyOption[]
|
||||
renderToolbarEnd?: (context: KriEditorToolbarContext) => ReactNode
|
||||
|
||||
@@ -6,17 +6,22 @@ import {
|
||||
ChannelType,
|
||||
MessageType,
|
||||
SMS_TYPE_ARRAY,
|
||||
Template,
|
||||
TemplateSms,
|
||||
TemplateSummary
|
||||
} from "@kri/common/noti-hub";
|
||||
import {Paperclip, X} from "lucide-react";
|
||||
import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card";
|
||||
import {Label} from "@/components/ui/label";
|
||||
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 {Checkbox} from "@/components/ui/checkbox";
|
||||
import {RadioGroup, RadioGroupItem} from "@/components/ui/radio-group";
|
||||
import {KriEditor, KriEditorCommand} from "@/components/kri-editor";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import { isBlank } from "@kri/common";
|
||||
@@ -26,7 +31,11 @@ import {ProjectMainTemplateUpdateRequest, ProjectSurvey} from "@/types/project";
|
||||
import type { DataVerification } from "@kri/common";
|
||||
import {COMMON_TEXT_REGEX} from "@/const/validationConst";
|
||||
import {formatKoreanPhoneNumber} from "@/utils/phone";
|
||||
import type {TemplateEmailWithAttachments} from "@/types/message";
|
||||
import type {
|
||||
TemplateEmailWithAttachments,
|
||||
TemplateSummaryWithPurpose,
|
||||
TemplateWithPurpose,
|
||||
} from "@/types/message";
|
||||
import {
|
||||
useTemplateListQuery,
|
||||
useMainTemplateIdxQuery,
|
||||
@@ -51,7 +60,7 @@ import {
|
||||
|
||||
interface MessageTemplateProps {
|
||||
pageTitle: string;
|
||||
defaultTemplate: Template;
|
||||
defaultTemplate: TemplateWithPurpose;
|
||||
}
|
||||
|
||||
const MESSAGE_EDITOR_EXTENSIONS = [QrCode];
|
||||
@@ -62,7 +71,7 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
||||
const editorCmdRef = useRef<KriEditorCommand | null>(null);
|
||||
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);
|
||||
|
||||
// 이메일 첨부파일 draft (신규 첨부 / 기존 첨부 삭제 예정). 저장 성공 시, 템플릿 전환 시 초기화된다.
|
||||
@@ -70,7 +79,7 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
||||
const [deletedAttachmentNames, setDeletedAttachmentNames] = useState<string[]>([]);
|
||||
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);
|
||||
|
||||
const isSms = isSmsTemplate(defaultTemplate);
|
||||
@@ -93,7 +102,7 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
||||
const listHeaderQuery = useListHeaderQuery(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 listHderList = useMemo<listHeader[]>(() => listHeaderQuery.data ?? [], [listHeaderQuery.data])
|
||||
const surveys = useMemo<ProjectSurvey[]>(() => projectInfoQuery.data?.surveys ?? [], [projectInfoQuery.data?.surveys])
|
||||
@@ -161,14 +170,14 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
||||
}
|
||||
}, [selectedTemplate.tmplatIdx, mainTemplateIdx]);
|
||||
|
||||
const handleChange = <K extends KeysOfUnion<Template>>(
|
||||
const handleChange = <K extends KeysOfUnion<TemplateWithPurpose>>(
|
||||
field: K,
|
||||
value: ValueOfUnionKey<Template, K>
|
||||
value: ValueOfUnionKey<TemplateWithPurpose, K>
|
||||
) => {
|
||||
setSelectedTemplate((prev) => {
|
||||
const next = { ...prev } as any;
|
||||
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 fail = (fieldName: string, errMessage: string): DataVerification => ({
|
||||
success: false,
|
||||
@@ -361,9 +370,10 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
||||
|
||||
try {
|
||||
const templateToSave = isSmsTemplate(selectedTemplate)
|
||||
? selectedTemplate
|
||||
? { ...selectedTemplate, tmplatPurpose: selectedTemplate.tmplatPurpose ?? TEMPLATE_PURPOSE.NORMAL }
|
||||
: {
|
||||
...selectedTemplate,
|
||||
tmplatPurpose: TEMPLATE_PURPOSE.NORMAL,
|
||||
tmplatBody: normalizeQrCodeForStorage(selectedTemplate.tmplatBody),
|
||||
};
|
||||
|
||||
@@ -456,6 +466,28 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
||||
clearLabel="새 테플릿 생성"
|
||||
/>
|
||||
</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">
|
||||
<Label htmlFor="tmplatNm" className="text-base">
|
||||
템플릿 명
|
||||
@@ -659,6 +691,11 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
|
||||
editorCmdRef.current = cmd;
|
||||
}}
|
||||
smsTitle={(selectedTemplate as TemplateSms).tmplatTitle}
|
||||
smsPreviewSuffix={
|
||||
selectedTemplate.tmplatPurpose === TEMPLATE_PURPOSE.PHONE_VERIFICATION
|
||||
? PHONE_VERIFICATION_PREVIEW_SUFFIX
|
||||
: undefined
|
||||
}
|
||||
changeSmsType={(smsTypeString) => setSmsType(smsTypeString)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -15,6 +15,18 @@ export const SMS_TYPE_OPTIONS = [
|
||||
{ value: MessageType.LMS_MMS, label: SMS_TYPE_LABEL[MessageType.LMS_MMS] },
|
||||
] 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_BYTES = 1_000_000;
|
||||
|
||||
@@ -8,8 +8,6 @@ import type {
|
||||
ChannelType,
|
||||
SendResultSummaryRequest,
|
||||
SendResultSummaryResponse,
|
||||
Template,
|
||||
TemplateSummary,
|
||||
} from "@kri/common/noti-hub";
|
||||
import type { FileResponse, PageRequest, PageResponse } from "@kri/common";
|
||||
import type { ProjectMainTemplateUpdateRequest } from "@/types/project";
|
||||
@@ -19,12 +17,14 @@ import type {
|
||||
MessageSendChannel,
|
||||
MessageSendSingleRequest,
|
||||
SendResultInfo,
|
||||
SendSingleResponse,
|
||||
} from "@/types/message";
|
||||
import type { TemplateSummaryWithPurpose, TemplateWithPurpose } from "@/types/message";
|
||||
|
||||
export function useTemplateListQuery(chnnlTy: ChannelType, itrntPrjctCd: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
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,
|
||||
staleTime: 30_000,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
@@ -44,7 +44,7 @@ export function useMainTemplateIdxQuery(prjctIdx: number, chnnlTy: ChannelType,
|
||||
export function useTemplateQuery(tmplatIdx: number, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.template(tmplatIdx),
|
||||
queryFn: () => nextApi.get<Template>(`/message-template/${tmplatIdx}`),
|
||||
queryFn: () => nextApi.get<TemplateWithPurpose>(`/message-template/${tmplatIdx}`),
|
||||
enabled: enabled && tmplatIdx > 0,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
@@ -58,7 +58,7 @@ export function useSaveTemplateMutation(chnnlTy: ChannelType, itrntPrjctCd: stri
|
||||
return useMutation({
|
||||
mutationFn: async (v: {
|
||||
method: "put" | "patch";
|
||||
template: Template;
|
||||
template: TemplateWithPurpose;
|
||||
newFiles?: File[];
|
||||
deleteFileNames?: string[];
|
||||
}) => {
|
||||
@@ -73,8 +73,8 @@ export function useSaveTemplateMutation(chnnlTy: ChannelType, itrntPrjctCd: stri
|
||||
deleteFileNames.forEach((name) => formData.append("deleteFileNames", name));
|
||||
|
||||
return method === "put"
|
||||
? nextApi.putForm<Template>(`/message-template`, formData)
|
||||
: nextApi.request<Template>(`/message-template`, { method: "PATCH", form: formData });
|
||||
? nextApi.putForm<TemplateWithPurpose>(`/message-template`, formData)
|
||||
: nextApi.request<TemplateWithPurpose>(`/message-template`, { method: "PATCH", form: formData });
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
if (res.tmplatIdx) {
|
||||
@@ -189,7 +189,7 @@ export function useSendSingleMessageMutation(channel: MessageSendChannel, prjctI
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (req: MessageSendSingleRequest) =>
|
||||
nextApi.post<void>(`/message/${channel}/single/${prjctIdx}`, req),
|
||||
nextApi.post<SendSingleResponse>(`/message/${channel}/single/${prjctIdx}`, req),
|
||||
onSuccess: (_data, req) => {
|
||||
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';
|
||||
|
||||
export type TemplatePurpose = 0 | 1;
|
||||
|
||||
export type TemplateWithPurpose = Template & {
|
||||
tmplatPurpose: TemplatePurpose;
|
||||
};
|
||||
|
||||
export type TemplateSummaryWithPurpose = TemplateSummary & {
|
||||
tmplatPurpose: TemplatePurpose;
|
||||
};
|
||||
|
||||
export type MessageSendChannel = 'sms' | 'email';
|
||||
|
||||
/**
|
||||
@@ -8,9 +18,20 @@ export type MessageSendChannel = 'sms' | 'email';
|
||||
* 조회 응답 전용 필드로, 파이프(|)로 구분된 첨부파일명 목록이 내려온다. 요청 시엔 사용하지 않는다.
|
||||
*/
|
||||
export type TemplateEmailWithAttachments = TemplateEmail & {
|
||||
tmplatPurpose: TemplatePurpose;
|
||||
atchFl?: string;
|
||||
};
|
||||
|
||||
export type PhoneVerificationSendData = {
|
||||
verificationId: string;
|
||||
expireDt: string;
|
||||
};
|
||||
|
||||
export type SendSingleResponse = {
|
||||
cmid: string;
|
||||
data: Record<string, unknown>;
|
||||
};
|
||||
|
||||
export type MessageSendSingleRequest = {
|
||||
tmplatIdx: number;
|
||||
resve: boolean;
|
||||
|
||||
Reference in New Issue
Block a user