260826_01_ENH: notihub 수정으로 인한 후속 조치

This commit is contained in:
2026-08-26 12:27:06 +09:00
parent d84c8b2c34
commit 3ea6905e00
6 changed files with 148 additions and 7 deletions

View File

@@ -24,10 +24,11 @@ import {SaveTemplateRequest, Template} from "@/types/notification";
import {UserCompact} from "@/types/gwcf";
import {getDetailValue} from "@/lib/gwcf/view";
import {useAuth} from "@/hooks/useAuth";
import {buildUserMsgParam} from "@/lib/gwcf/notification";
import {buildTemplatePreviewBody, buildUserMsgParam, getSmsByteLength, isPhoneVerificationSupported} from "@/lib/gwcf/notification";
import {getSmsParamLabel} from "@/lib/gwcf/field-labels";
import {TMPLAT_PURPOSE} from "@/types/notification";
type TemplateDraft = Pick<Template, "tmplatIdx" | "tmplatNm" | "tmplatTitle" | "tmplatBody" | "sendTel">;
type TemplateDraft = Pick<Template, "tmplatIdx" | "tmplatTy" | "tmplatPurpose" | "tmplatNm" | "tmplatTitle" | "tmplatBody" | "sendTel">;
const EMPTY_DENY_PARAM_KEYS: string[] = [];
@@ -35,6 +36,8 @@ const toText = (value: string | null | undefined) => value ?? "";
const toDraft = (template: Template, isNewMessage = false): TemplateDraft => ({
tmplatIdx: template.tmplatIdx,
tmplatTy: template.tmplatTy,
tmplatPurpose: isPhoneVerificationSupported(template) ? template.tmplatPurpose ?? TMPLAT_PURPOSE.NORMAL : TMPLAT_PURPOSE.NORMAL,
tmplatNm: toText(template.tmplatNm),
tmplatTitle: isNewMessage ? "" : toText(template.tmplatTitle),
tmplatBody: isNewMessage ? "" : toText(template.tmplatBody),
@@ -163,6 +166,7 @@ export function SmsSendDialog({
const payload: SaveTemplateRequest = {
tmplatIdx: draft.tmplatIdx,
tmplatPurpose: draft.tmplatPurpose,
tmplatNm: draft.tmplatNm,
tmplatTitle: draft.tmplatTitle,
tmplatBody: draft.tmplatBody,
@@ -205,6 +209,9 @@ export function SmsSendDialog({
setDraft(null);
};
const previewBody = draft ? buildTemplatePreviewBody(draft) : "";
const isSmsOrLms = draft ? isPhoneVerificationSupported(draft) : false;
const send = async () => {
if (!draft) return;
@@ -306,6 +313,7 @@ export function SmsSendDialog({
{templatesQuery.data.map((template) => (
<SelectItem key={template.tmplatIdx} value={String(template.tmplatIdx)}>
{toText(template.tmplatNm) || `${template.tmplatIdx}`}
{template.tmplatPurpose === TMPLAT_PURPOSE.PHONE_VERIFICATION && " (인증)"}
</SelectItem>
))}
</SelectContent>
@@ -320,6 +328,24 @@ export function SmsSendDialog({
<span className="font-medium">제목</span>
<Input value={draft.tmplatTitle} disabled={!canEdit || isBusy} onChange={(event) => updateDraft("tmplatTitle", event.target.value)} />
</label>
{isSmsOrLms && (
<label className="space-y-1 text-sm">
<span className="font-medium">템플릿 용도</span>
<Select
value={String(draft.tmplatPurpose)}
onValueChange={(value) => updateDraft("tmplatPurpose", Number(value))}
disabled={!canEdit || isBusy}
>
<SelectTrigger className="w-full">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value={String(TMPLAT_PURPOSE.NORMAL)}>일반</SelectItem>
<SelectItem value={String(TMPLAT_PURPOSE.PHONE_VERIFICATION)}>휴대전화번호 인증</SelectItem>
</SelectContent>
</Select>
</label>
)}
<label className="space-y-1 text-sm">
<span className="font-medium">내용</span>
<textarea
@@ -330,6 +356,11 @@ export function SmsSendDialog({
className="min-h-80 w-full rounded-md border border-input bg-background p-3 text-sm disabled:cursor-not-allowed disabled:opacity-70"
/>
</label>
<div className="space-y-1 rounded-md border bg-muted/20 p-3 text-sm">
<div className="font-medium">미리보기</div>
<div className="whitespace-pre-wrap text-muted-foreground">{previewBody}</div>
{isSmsOrLms && <div className="text-xs text-muted-foreground">{getSmsByteLength(previewBody)} bytes</div>}
</div>
{msgParamKeys.length > 0 && (
<div className="space-y-1 text-sm">
<div className="font-medium text-muted-foreground">사용 가능 변수값</div>