develop #3

Merged
gitadmin merged 18 commits from develop into master 2026-07-16 09:38:06 +09:00
4 changed files with 64 additions and 33 deletions
Showing only changes of commit a2cd0dc2f0 - Show all commits

View File

@@ -11,7 +11,7 @@ import UserUpsertDialog from "@/components/dialog/UserUpsertDialog";
import {UserInfo, UserInfoSaveRequest, UserUploadResponse} from "@/types/user";
import UserUploadDialog from "@/components/dialog/UserUploadDialog";
import {useDialog} from "@/hooks/useDialog";
import {downloadBase64File, downloadFile, formatKst} from "@/lib/utils";
import {downloadBase64File, downloadFile} from "@/lib/utils";
import {nextApi} from "@/lib/http-client";
import {useLoading} from "@/hooks/useLoading";
import {RoleInfo} from "@/types/role";

View File

@@ -1,7 +1,6 @@
import {NextRequest, NextResponse} from "next/server";
import {DataVerification, RouteContext} from "@/types/common";
import {RouteContext} from "@/types/common";
import {createContactApi} from "@/lib/server-api";
import {UserInfo, UserUploadResponse} from "@/types/user";
import {errorToResponse} from "@/lib/http-util";
export const GET = async (req: NextRequest, context: RouteContext) => {

View File

@@ -21,10 +21,11 @@ import {Input} from "@/components/ui/input";
import {Checkbox} from "@/components/ui/checkbox";
import {KriEditor, KriEditorCommand} from "@/components/kri-editor";
import {Button} from "@/components/ui/button";
import {cn} from "@/lib/utils";
import {cn, isBlank} from "@/lib/utils";
import _ from "lodash";
import {ProjectMainTemplateUpdateRequest} from "@/types/project";
import {toast} from "sonner";
import { DataVerification } from "@/types/common";
interface MessageTemplateProps {
pageTitle: string;
@@ -103,41 +104,70 @@ const MessageTemplate = ({
};
const handleCreate = async () => {
//Todo 데이터 검증 필요
nextApi.put<Template>(`/message-template`, selectedTemplate)
.then((res) => {
settingTemplateList();
setSelectedTemplate(res);
updateMainTemplate(res.tmplatIdx!);
alert("저장되었습니다.");
})
.catch((e) => {
console.log(e);
alert("저장에 실패했습니다.");
});
await submitTemplate("put");
};
const handleUpdate = async () => {
if(!selectedTemplate.tmplatIdx) return;
if (!selectedTemplate.tmplatIdx) return;
await submitTemplate("patch");
};
//Todo 데이터 검증 필요
const submitTemplate = async (method: "put" | "patch") => {
const v = validateTemplate(selectedTemplate);
nextApi.patch<Template>(`/message-template`, selectedTemplate)
.then((res) => {
settingTemplateList();
if (!v.success) {
alert(v.errMessage);
// 필요 시: 특정 필드 focus 처리도 가능
// focusField(v.fieldName);
return;
}
setSelectedTemplate(res);
updateMainTemplate(res.tmplatIdx!);
try {
const res =
method === "put"
? await nextApi.put<Template>(`/message-template`, selectedTemplate)
: await nextApi.patch<Template>(`/message-template`, selectedTemplate);
alert("수정되었습니다.");
})
.catch((e) => {
console.log(e);
alert("저장에 실패했습니다.");
});
settingTemplateList();
setSelectedTemplate(res);
updateMainTemplate(res.tmplatIdx!);
alert(method === "put" ? "저장되었습니다." : "수정되었습니다.");
} catch (e) {
console.log(e);
alert(method === "put" ? "저장에 실패했습니다." : "수정에 실패했습니다.");
}
};
const validateTemplate = (tpl: Template): DataVerification => {
const ok = (): DataVerification => ({
success: true,
fieldName: "",
errMessage: "",
});
const fail = (fieldName: string, errMessage: string): DataVerification => ({
success: false,
fieldName,
errMessage,
});
if (isBlank(tpl.itrntPrjctCd)) return fail("itrntPrjctCd", "인트라넷 프로젝트 코드가 없습니다.");
if (isBlank(tpl.tmplatNm)) return fail("tmplatNm", "템플릿명을 입력해 주세요.");
if (isBlank(tpl.tmplatBody)) return fail("tmplatBody", "본문을 입력해 주세요.");
if (isBlank(tpl.sendNm)) return fail("sendNm", "발신자명을 입력해 주세요.");
// Email 전용
if (tpl.tmplatTy === MessageType.EMAIL) {
if (isBlank(tpl.tmplatTitle)) return fail("tmplatTitle", "이메일 제목을 입력해 주세요.");
if (isBlank(tpl.sendEml)) return fail("sendEml", "발신 이메일을 입력해 주세요.");
return ok();
}
// SMS 전용
if (isBlank(tpl.sendTel)) return fail("sendTel", "발신 전화번호를 입력해 주세요.");
return ok();
};
const updateMainTemplate = (templatIdx:number):void => {

View File

@@ -97,4 +97,6 @@ export const formatKst = (
if (opt === "dateHour") return `${yyyy}-${MM}-${dd} ${HH}`;
if (opt === "dateHourMin") return `${yyyy}-${MM}-${dd} ${HH}:${mm}`;
return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`;
};
};
export const isBlank = (v?: string | null) => !v || v.trim().length === 0;