diff --git a/.env.development b/.env.development
index 1d5d633..b47c859 100644
--- a/.env.development
+++ b/.env.development
@@ -4,6 +4,7 @@ NEXT_PUBLIC_API_BASE=http://localhost:3000/api
ENV=dev
CONTACT_SERVER=http://localhost:4001
API_CONTACT_SERVER=http://localhost:4001/api/v1
+API_NOTIHUB_SERVER=http://localhost:4011/api/v1
API_INTRANET_SERVER=http://localhost:3031/api/v1
API_KART_SERVER=https://rapi.kric.com/api/v1
KART_API_KEY=4B726963-436F6E74616374-46726F6E74-402531213230
\ No newline at end of file
diff --git a/.env.local b/.env.local
index fc8580d..25bde02 100644
--- a/.env.local
+++ b/.env.local
@@ -4,6 +4,7 @@ NEXT_PUBLIC_API_BASE=http://localhost:3000/api
ENV=local
CONTACT_SERVER=http://localhost:4001
API_CONTACT_SERVER=http://localhost:4001/api/v1
+API_NOTIHUB_SERVER=http://localhost:4011/api/v1
API_INTRANET_SERVER=http://localhost:3031/api/v1
API_KART_SERVER=https://rapi.kric.com/api/v1
KART_API_KEY=4B726963-436F6E74616374-46726F6E74-402531213230
\ No newline at end of file
diff --git a/.env.production b/.env.production
index 92036b2..4466434 100644
--- a/.env.production
+++ b/.env.production
@@ -4,6 +4,7 @@ NEXT_PUBLIC_API_BASE=http://localhost:3000/api
ENV=prod
CONTACT_SERVER=http://localhost:4001
API_CONTACT_SERVER=http://localhost:4001/api/v1
+API_NOTIHUB_SERVER=http://localhost:4011/api/v1
API_INTRANET_SERVER=http://localhost:3031/api/v1
API_KART_SERVER=https://rapi.kric.com/api/v1
KART_API_KEY=4B726963-436F6E74616374-46726F6E74-402531213230
\ No newline at end of file
diff --git a/src/app/(pages)/(main)/layout.tsx b/src/app/(pages)/(main)/layout.tsx
index 5b0cd18..6b1db33 100644
--- a/src/app/(pages)/(main)/layout.tsx
+++ b/src/app/(pages)/(main)/layout.tsx
@@ -22,9 +22,9 @@ export default async function MainLayoutWrapper({
children: React.ReactNode;
}) {
const cookieStore = await cookies();
- const cookie = cookieStore.get(CookieKeys.FontSize);
+ const fontSize = cookieStore.get(CookieKeys.FontSize);
const accessToken = cookieStore.get("access_token")?.value;
- const initialFontSize = parseFontSize(cookie?.value);
+ const initialFontSize = parseFontSize(fontSize?.value);
if (!accessToken) {
redirect("/logout");
diff --git a/src/app/(pages)/(main)/manage/user/page.tsx b/src/app/(pages)/(main)/manage/user/page.tsx
index 338863f..6aa163a 100644
--- a/src/app/(pages)/(main)/manage/user/page.tsx
+++ b/src/app/(pages)/(main)/manage/user/page.tsx
@@ -5,7 +5,7 @@ import {Button} from "@/components/ui/button";
import {Input} from "@/components/ui/input";
import BodyTitle from "@/components/layout/BodyTitle";
import { DataTable } from "@/components/data-table/DataTable";
-import { getUserColumns } from "./UserTableColumn";
+import { getUserColumns } from "../../../../../components/table-column/UserTableColumn";
import _ from "lodash";
import UserUpsertDialog from "@/components/dialog/UserUpsertDialog";
import {UserInfo, UserInfoSaveRequest, UserUploadResponse} from "@/types/user";
diff --git a/src/app/(pages)/(main)/message/template/email/page.tsx b/src/app/(pages)/(main)/message/template/email/page.tsx
index 70bacdc..84b2100 100644
--- a/src/app/(pages)/(main)/message/template/email/page.tsx
+++ b/src/app/(pages)/(main)/message/template/email/page.tsx
@@ -1,9 +1,25 @@
-const EmailTemplatePage = () => {
- //파라미터 받기
- //const url = buildUrlWithParams("/login", searchParams, { ref: "root" });
- //redirect(url);
+import {MessageType, TemplateEmail} from "@/types/messageTemplate";
+import MessageTemplate from "@/components/message-template/MessageTemplate";
+import BodyTitle from "@/components/layout/BodyTitle";
- return (
This is Email Template Page
)
+const EmailTemplatePage = () => {
+
+ const defaultEmailTemplate : TemplateEmail = {
+ tmplatIdx: undefined,
+ itrntPrjctCd: '',
+ tmplatTy: MessageType.EMAIL,
+ tmplatNm: '',
+ tmplatTitle: '',
+ tmplatBody: '',
+ sendEml: '',
+ sendNm: ''
+ }
+
+ return (
+
+
+
+ )
}
export default EmailTemplatePage;
\ No newline at end of file
diff --git a/src/app/(pages)/(main)/message/template/sms/page.tsx b/src/app/(pages)/(main)/message/template/sms/page.tsx
new file mode 100644
index 0000000..d1aea99
--- /dev/null
+++ b/src/app/(pages)/(main)/message/template/sms/page.tsx
@@ -0,0 +1,27 @@
+'use client'
+
+import {MessageType, TemplateSms} from "@/types/messageTemplate";
+import MessageTemplate from "@/components/message-template/MessageTemplate";
+import BodyTitle from "@/components/layout/BodyTitle";
+
+const SmsTemplatePage = () => {
+
+ const defaultSmsTemplate : TemplateSms = {
+ tmplatIdx: undefined,
+ itrntPrjctCd: '',
+ tmplatTy: MessageType.SMS,
+ tmplatNm: '',
+ tmplatTitle: undefined,
+ tmplatBody: '',
+ sendTel: '',
+ sendNm: ''
+ }
+
+ return (
+
+
+
+ )
+}
+
+export default SmsTemplatePage;
\ No newline at end of file
diff --git a/src/app/(pages)/(main)/message/template/text/page.tsx b/src/app/(pages)/(main)/message/template/text/page.tsx
deleted file mode 100644
index 61b3c94..0000000
--- a/src/app/(pages)/(main)/message/template/text/page.tsx
+++ /dev/null
@@ -1,9 +0,0 @@
-const TextTemplatePage = () => {
- //파라미터 받기
- //const url = buildUrlWithParams("/login", searchParams, { ref: "root" });
- //redirect(url);
-
- return (This is Text Message Template Page
)
-}
-
-export default TextTemplatePage;
\ No newline at end of file
diff --git a/src/app/(pages)/(main)/page.tsx b/src/app/(pages)/(main)/page.tsx
index 3896b90..efad0a0 100644
--- a/src/app/(pages)/(main)/page.tsx
+++ b/src/app/(pages)/(main)/page.tsx
@@ -3,18 +3,19 @@ import {useEffect, useRef, useState} from "react";
import BodyTitle from "@/components/layout/BodyTitle";
import {Button} from "@/components/ui/button";
import {DataTable} from "@/components/data-table/DataTable";
-import {getProjectColumns} from "./ProjectTableColumn";
+import {getProjectColumns} from "../../../components/table-column/ProjectTableColumn";
import {
ProjectCreateRequest,
ProjectInfo,
ProjectListQuery,
ProjectListRequest, ProjectOwnerResponse,
+ ProjectStatus
} from "@/types/project";
import {Input} from "@/components/ui/input";
import {KriMultiSelect} from "@/components/common/KriAutoComplete";
import {MultiSelectOption} from "@/components/ui/multi-select";
import {PaginationState, SortingState} from "@tanstack/react-table";
-import {PageResponse} from "@/types/common";
+import {PageRequest, PageResponse} from "@/types/common";
import ProjectCreateDialog from "@/components/dialog/ProjectCreateDialog";
import {useDialog} from "@/hooks/useDialog";
import {useLoading} from "@/hooks/useLoading";
@@ -25,7 +26,6 @@ import {SelectedProject} from "@/store/jotai/project";
import {useMounted} from "@/hooks/useMounted";
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
import {FW_USER_ROLE} from "@/const/userConst";
-import {ProjectStatus} from "@/const/projectConst";
import {useItrntUserList} from "@/hooks/useItrntUserList";
const MainPage = () => {
@@ -82,6 +82,7 @@ const MainPage = () => {
prjctIdx: projectInfo.prjctIdx,
prjctCd: projectInfo.prjctCd,
prjctName: projectInfo.prjctName,
+ itrntPrjctCd: projectInfo.itrntPrjctCd,
ownerDept: projectInfo.ownerDept,
ownerFw: projectInfo.ownerFw,
} as SelectedProject);
@@ -94,6 +95,7 @@ const MainPage = () => {
prjctIdx: projectInfo.prjctIdx,
prjctCd: projectInfo.prjctCd,
prjctName: projectInfo.prjctName,
+ itrntPrjctCd: projectInfo.itrntPrjctCd,
ownerDept: projectInfo.ownerDept,
ownerFw: projectInfo.ownerFw,
} as SelectedProject);
@@ -110,15 +112,19 @@ const MainPage = () => {
lastReqKeyRef.current = reqKey;
const sort = sorting?.[0] ?? {id: "prjctIdx", desc: true};
+ const pageReq: PageRequest = {
+ pageIndex: pagination.pageIndex,
+ pageSize: pagination.pageSize,
+ sortBy: sort.id,
+ sortDir: sort.desc ? "desc" : "asc"
+ };
+
const searchBody: ProjectListRequest = {
prjctText: query?.prjctText || "",
prjctStatusList: query?.prjctStatusList || [],
ownerDeptList: query?.ownerDeptList || [],
ownerFwList: query?.ownerFwList || [],
- pageIndex: pagination.pageIndex,
- pageSize: pagination.pageSize,
- sortBy: sort.id,
- sortDir: sort.desc ? "desc" : "asc"
+ pageRequest: pageReq,
}
withLoadingAsync(() =>
diff --git a/src/app/(pages)/(main)/project/info/page.tsx b/src/app/(pages)/(main)/project/info/page.tsx
index bef9771..04ae8db 100644
--- a/src/app/(pages)/(main)/project/info/page.tsx
+++ b/src/app/(pages)/(main)/project/info/page.tsx
@@ -13,14 +13,15 @@ import {useDialog} from '@/hooks/useDialog'
import ResultCodeDialog from '@/components/dialog/ResultCodeDialog'
import {useMounted} from '@/hooks/useMounted'
import {LoadingOverlay} from '@/components/common/LoadingOverlay'
-import {KonKiwiProjectInfo, ProjectInfo, ProjectUpdateRequest, ResultCode} from "@/types/project";
+import {
+ KonKiwiProjectInfo, ProjectInfo, ProjectUpdateRequest, ResultCode,
+ ProjectStatus, ResultCodeType, SurveyType
+} from "@/types/project";
import {
PROJECT_STATUS_LABEL,
PROJECT_STATUS_ORDER,
- ProjectStatus, ResultCodeType,
SURVEY_TYPE_LABEL,
SURVEY_TYPE_ORDER,
- SurveyType
} from "@/const/projectConst";
import {MultiSelectOption} from "@/components/ui/multi-select";
import {FW_TEAM} from "@/const/userConst";
@@ -171,7 +172,7 @@ const ProjectInfoPage = () => {
nextApi.get(`/project/info/${selectedProject.prjctIdx}`)
.then((res) => setProjectInfo(res));
- nextApi.get(`/project/result-code/${selectedProject.prjctIdx}`)
+ nextApi.get(`/result-code/${selectedProject.prjctIdx}`)
.then((res) => {setResultCodeArray(res)});
nextApi.get(`/user/outsource`)
diff --git a/src/app/(pages)/login/page.tsx b/src/app/(pages)/login/page.tsx
index e6c2ebb..c9b5b09 100644
--- a/src/app/(pages)/login/page.tsx
+++ b/src/app/(pages)/login/page.tsx
@@ -52,15 +52,15 @@ const LoginPage = () => {
nextApi.post(
"/login", loginRequestBody, loginRequestOptions
).then(async (data) => { // Jotai 기반 전역 인증 상태 갱신
- setFromLoginResponse(data, seatNum);
- // 요구사항: 페이지 이동 전에 SeatNumber를 secure-local-storage에 저장
- try {
- setSeatNumberStorage(seatNum);
- setLoginTypeStorage(loginType);
- } catch (e) {
- // 저장 실패는 치명적이지 않으므로 콘솔 로깅만
- console.warn("Failed to persist SeatNumber to secure storage:", e);
- }
+ try {
+ setSeatNumberStorage(seatNum);
+ setLoginTypeStorage(loginType);
+ } catch (e) {
+ // 저장 실패는 치명적이지 않으므로 콘솔 로깅만
+ console.warn("Failed to persist SeatNumber to secure storage:", e);
+ }
+
+ setFromLoginResponse(data, seatNum);
}).catch((e) => {
const err = apiError(e);
console.error(err.status, err.code, err.message);
@@ -82,7 +82,7 @@ const LoginPage = () => {
if(auth.user){
window.location.replace("/");
}
- }, [auth]);
+ }, [auth.user]);
// URL 쿼리 파라미터에서 type 수신
useEffect(() => {
diff --git a/src/app/api/message-template/[[...slug]]/route.ts b/src/app/api/message-template/[[...slug]]/route.ts
new file mode 100644
index 0000000..aa18ef7
--- /dev/null
+++ b/src/app/api/message-template/[[...slug]]/route.ts
@@ -0,0 +1,105 @@
+import {NextRequest, NextResponse} from "next/server";
+import {RouteContext} from "@/types/common";
+import {createNotihubApi} from "@/lib/server-api";
+import {errorToResponse} from "@/lib/http-util";
+import {Template, TemplateSummary} from "@/types/messageTemplate";
+
+export const GET = async (req: NextRequest, context: RouteContext) => {
+ try{
+ const { searchParams } = new URL(req.url);
+ const {slug = []} = await context.params;
+ const [action] = slug;
+ const notihubApi = await createNotihubApi();
+
+ if(slug.length === 1){
+ const result = await notihubApi.get(
+ `/template/${slug[0]}`,
+ );
+ return NextResponse.json(result, { status: 200 });
+ }
+
+ if(action === "list" && slug.length === 3){
+ const result = await notihubApi.get(
+ `/template/list/${slug[1]}/${slug[2]}`,
+ );
+ return NextResponse.json(result, { status: 200 });
+ }
+
+ return NextResponse.json({ message: "Not found" }, { status: 404 });
+ } catch (error: unknown) {
+ return errorToResponse(error);
+ }
+}
+
+export const PUT = async (req: NextRequest, context: RouteContext) => {
+ try{
+ const { searchParams } = new URL(req.url);
+ const {slug = []} = await context.params;
+ const [action] = slug;
+ const notihubApi = await createNotihubApi();
+
+ if(action === "body-image" && slug.length === 2){
+ const itrntPrjctCd = slug[1];
+
+ const formData = await req.formData();
+ const file = formData.get("file") as File | null;
+
+ if (!file) {
+ return NextResponse.json(
+ { message: "file 필드가 없습니다." },
+ { status: 400 }
+ );
+ }
+
+ const result = await notihubApi.putForm(
+ `/template/body-image/${itrntPrjctCd}`,
+ formData
+ );
+
+ return NextResponse.json(result, { status: 200 });
+ }
+
+ if(!action){
+ const body = await req.json().catch(() => null);
+ if (!body) {
+ return NextResponse.json(
+ { message: "요청 바디가 없습니다." },
+ { status: 400 }
+ );
+ }
+
+ const result = await notihubApi.put(`/template`, body);
+ return NextResponse.json(result, { status: 200 });
+ }
+
+ return NextResponse.json({ message: "Not found" }, { status: 404 });
+ } catch (error: unknown) {
+ return errorToResponse(error);
+ }
+}
+
+export const PATCH = async (req: NextRequest, context: RouteContext) => {
+ try{
+ const { searchParams } = new URL(req.url);
+ const {slug = []} = await context.params;
+ const [action] = slug;
+ const notihubApi = await createNotihubApi();
+
+ if(!action){
+ const body = await req.json().catch(() => null);
+ if (!body) {
+ return NextResponse.json(
+ { message: "요청 바디가 없습니다." },
+ { status: 400 }
+ );
+ }
+
+ const result = await notihubApi.patch(`/template`, body);
+ return NextResponse.json(result, { status: 200 });
+ }
+
+ return NextResponse.json({ message: "Not found" }, { status: 404 });
+ } catch (error: unknown) {
+ return errorToResponse(error);
+ }
+}
\ No newline at end of file
diff --git a/src/app/api/project/[[...slug]]/route.ts b/src/app/api/project/[[...slug]]/route.ts
index fd3e485..1181de4 100644
--- a/src/app/api/project/[[...slug]]/route.ts
+++ b/src/app/api/project/[[...slug]]/route.ts
@@ -32,12 +32,12 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
return NextResponse.json(result, { status: 200 });
}
- if(action === "result-code" && slug.length === 2){
- const result = await contactApi.get(`/result-code/${slug[1]}`);
- return NextResponse.json(result, { status: 200 });
+ if(action === "main-template" && slug.length === 3){
+ const result = await contactApi.get(`/project/main-template/${slug[1]}/${slug[2]}`);
+ const returValue = result === null || result === "" ? null : Number(result);
+ return NextResponse.json(returValue, { status: 200 });
}
-
return NextResponse.json({ message: "Not found" }, { status: 404 });
} catch (error: unknown) {
return errorToResponse(error);
@@ -133,6 +133,20 @@ export const PATCH = async (req: NextRequest, context: RouteContext) => {
const [action] = slug;
const contactApi = await createContactApi();
+
+ if(action === "main-template"){
+ const body = await req.json().catch(() => null);
+ if (!body) {
+ return NextResponse.json(
+ { message: "요청 바디가 없습니다." },
+ { status: 400 }
+ );
+ }
+
+ await contactApi.patch(`/project/main-template`, body);
+ return new NextResponse(null, { status: 204 });
+ }
+
if(slug.length === 1){
const body = await req.json().catch(() => null);
diff --git a/src/app/api/result-code/[[...slug]]/route.ts b/src/app/api/result-code/[[...slug]]/route.ts
new file mode 100644
index 0000000..64a4e2d
--- /dev/null
+++ b/src/app/api/result-code/[[...slug]]/route.ts
@@ -0,0 +1,23 @@
+import {NextRequest, NextResponse} from "next/server";
+import {RouteContext} from "@/types/common";
+import {createContactApi} from "@/lib/server-api";
+import {ProjectInfo, ProjectOwnerResponse, ResultCode} from "@/types/project";
+import {errorToResponse} from "@/lib/http-util";
+
+export const GET = async (req: NextRequest, context: RouteContext) => {
+ try {
+ const { searchParams } = new URL(req.url);
+ const {slug = []} = await context.params;
+ const [action] = slug;
+ const contactApi = await createContactApi();
+
+ if(slug.length === 1){
+ const result = await contactApi.get(`/result-code/${slug[0]}`);
+ return NextResponse.json(result, { status: 200 });
+ }
+
+ return NextResponse.json({ message: "Not found" }, { status: 404 });
+ } catch (error: unknown) {
+ return errorToResponse(error);
+ }
+};
\ No newline at end of file
diff --git a/src/components/dialog/ResultCodeDialog.tsx b/src/components/dialog/ResultCodeDialog.tsx
index 5d95ba4..414cee6 100644
--- a/src/components/dialog/ResultCodeDialog.tsx
+++ b/src/components/dialog/ResultCodeDialog.tsx
@@ -1,6 +1,6 @@
'use client'
-import {useEffect, useMemo, useState} from 'react'
+import {useEffect, useState} from 'react'
import {
Dialog,
DialogContent,
@@ -10,10 +10,10 @@ import {
} from '@/components/ui/dialog'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
-import {Trash2, Plus, Download, Search, XIcon} from 'lucide-react'
-import {ProjectInfo, ResultCode} from "@/types/project";
+import {Trash2, Plus, Download} from 'lucide-react'
+import {ProjectInfo, ResultCode, ResultCodeType} from "@/types/project";
import {nextApi} from "@/lib/http-client";
-import {PROJECT_SEARCH_COUNT, RESULT_CODE_TYPE_OPTIONS, ResultCodeType} from "@/const/projectConst";
+import {PROJECT_SEARCH_COUNT, RESULT_CODE_TYPE_OPTIONS} from "@/const/projectConst";
import {useDebouncedValue} from "@/hooks/useDebouncedValue";
import {SelectedProject} from "@/store/jotai/project";
import {KriSingleSelect} from "@/components/common/KriAutoComplete";
@@ -221,7 +221,7 @@ const ResultCodeDialog = ({
useEffect(() => {
if(importProject){
- nextApi.get(`/project/result-code/${importProject.prjctIdx}`)
+ nextApi.get(`/result-code/${importProject.prjctIdx}`)
.then((res) => setImportCodeArray(res));
}
}, [importProject]);
diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx
index 8060930..120c07b 100644
--- a/src/components/layout/Header.tsx
+++ b/src/components/layout/Header.tsx
@@ -39,7 +39,7 @@ export const Header = ({
else{
window.location.replace("/logout");
}
- }, [auth])
+ }, [auth.user])
return (
diff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsx
index e8eee28..c43c428 100644
--- a/src/components/layout/Sidebar.tsx
+++ b/src/components/layout/Sidebar.tsx
@@ -3,8 +3,6 @@
import { Button } from "@/components/ui/button";
import { ChevronDown } from "lucide-react";
import { SideMenuItem } from "@/config/menu.types";
-import {KriSingleSelect} from "@/components/common/KriAutoComplete";
-import {useDebouncedValue} from "@/hooks/useDebouncedValue";
import {SidebarProjectSearch} from "@/components/layout/SidebarProjectSearch ";
interface SidebarProps {
diff --git a/src/components/message-template/MessageTemplate.tsx b/src/components/message-template/MessageTemplate.tsx
new file mode 100644
index 0000000..f4add0e
--- /dev/null
+++ b/src/components/message-template/MessageTemplate.tsx
@@ -0,0 +1,424 @@
+'use client'
+
+import {useSelectedProject} from "@/hooks/useSelectedProject";
+import {useCallback, useEffect, useRef, useState} from "react";
+import {listHder, ListHeaderGrade, ListHeaderType} from "@/types/list";
+import {
+ ChannelType,
+ MessageType,
+ SMS_TYPE_ARRAY,
+ Template,
+ TemplateSms,
+ TemplateSummary
+} from "@/types/messageTemplate";
+import {isTextAreaElement, isTipTapEditor} from "@/components/kri-editor/utils/editorTypeGuards";
+import {nextApi} from "@/lib/http-client";
+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} from "@/const/messageTemplateConst";
+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 _ from "lodash";
+import {ProjectMainTemplateUpdateRequest} from "@/types/project";
+import {toast} from "sonner";
+
+interface MessageTemplateProps {
+ pageTitle: string;
+ defaultTemplate: Template;
+}
+
+const MessageTemplate = ({
+ pageTitle,
+ defaultTemplate,
+ }: MessageTemplateProps) => {
+ const { selectedProject } = useSelectedProject();
+
+ const editorCmdRef = useRef(null);
+ const sessionTempUrlsRef = useRef>(new Set());
+
+ const [mainTemplateIdx, setMainTemplateIdx] = useState(null);
+ const [listHderList, setListHderList] = useState([])
+ const [templateList, setTemplateList] = useState([]);
+ const [selectedTemplate, setSelectedTemplate] = useState(defaultTemplate);
+ const [isMainTemplate, setIsMainTemplate] = useState(false);
+
+
+ const isSmsTemplate = (t: Template): t is TemplateSms =>
+ (SMS_TYPE_ARRAY as readonly MessageType[]).includes(t.tmplatTy);
+
+ const isSms = isSmsTemplate(defaultTemplate);
+ const chnnlTy:ChannelType = isSms? ChannelType.SMS : ChannelType.EMAIL;
+
+ // 유니온의 키를 합집합으로 뽑기
+ type KeysOfUnion = T extends unknown ? keyof T : never;
+
+ // 특정 키의 값 타입을 유니온에서 안전하게 뽑기
+ type ValueOfUnionKey> =
+ T extends unknown ? (K extends keyof T ? T[K] : never) : never;
+
+ const handleSelectTemplate = (templateIdxString: string) => {
+ if(!selectedProject) return
+
+ if(!templateIdxString){
+ const projectDefaultTemplate = _.cloneDeep(defaultTemplate);
+ projectDefaultTemplate.itrntPrjctCd = selectedProject.itrntPrjctCd;
+ setSelectedTemplate(projectDefaultTemplate);
+ }
+ else{
+ nextApi.get(`/message-template/${templateIdxString}`).then(setSelectedTemplate);
+ }
+ }
+
+ const handleChange = >(
+ field: K,
+ value: ValueOfUnionKey
+ ) => {
+ setSelectedTemplate(prev => {
+ const next = { ...prev } as any;
+ next[field] = value;
+ return next as Template;
+ });
+ };
+
+ const setTemplateBody = (newString: string) => {
+ setSelectedTemplate(prev => ({ ...prev, tmplatBody: newString }));
+ };
+
+ const setSmsType = (smsTypeString: "SMS" | "LMS") => {
+ const smsType =
+ smsTypeString === "SMS" ? MessageType.SMS : MessageType.LMS_MMS;
+
+ setSelectedTemplate((prev) => {
+ if (!isSmsTemplate(prev)) return prev;
+
+ return {
+ ...prev,
+ tmplatTy: smsType,
+ };
+ });
+ };
+
+ const handleCreate = async () => {
+ //Todo 데이터 검증 필요
+
+ nextApi.put(`/message-template`, selectedTemplate)
+ .then((res) => {
+ settingTemplateList();
+
+ setSelectedTemplate(res);
+ updateMainTemplate(res.tmplatIdx!);
+
+ alert("저장되었습니다.");
+ })
+ .catch((e) => {
+ console.log(e);
+ alert("저장에 실패했습니다.");
+ });
+ };
+
+ const handleUpdate = async () => {
+ if(!selectedTemplate.tmplatIdx) return;
+
+ //Todo 데이터 검증 필요
+
+ nextApi.patch(`/message-template`, selectedTemplate)
+ .then((res) => {
+ settingTemplateList();
+
+ setSelectedTemplate(res);
+ updateMainTemplate(res.tmplatIdx!);
+
+ alert("수정되었습니다.");
+ })
+ .catch((e) => {
+ console.log(e);
+ alert("저장에 실패했습니다.");
+ });
+ };
+
+ const updateMainTemplate = (templatIdx:number):void => {
+ if(!selectedProject || !selectedProject.prjctIdx) return;
+
+ let updateFlag = false;
+ let updateTemplateIdx: number | null = null;
+
+ if(isMainTemplate && mainTemplateIdx !== templatIdx){
+ updateFlag = true;
+ updateTemplateIdx = templatIdx;
+ }
+
+ if(!isMainTemplate && mainTemplateIdx === templatIdx){
+ updateFlag = true;
+ }
+
+ if(updateFlag){
+ const req:ProjectMainTemplateUpdateRequest = {
+ prjctIdx: selectedProject.prjctIdx,
+ chnnlTy:chnnlTy,
+ tmplatIdx:updateTemplateIdx,
+ }
+
+ nextApi.patch(`/project/main-template`, req);
+ setMainTemplateIdx(updateTemplateIdx);
+ }
+ }
+
+ const handleVariableClick = (placeholder: string) => {
+ editorCmdRef.current?.insertText(placeholder);
+ };
+
+ const toggleIsMainTemplate = () => {
+ setIsMainTemplate(!isMainTemplate);
+ }
+
+ const handleImageUpload = useCallback(async (file: File): Promise<{ url: string }> => {
+ if(selectedProject) {
+ const formData = new FormData();
+ formData.append("file", file);
+
+ const url = await nextApi.putForm(`/message-template/body-image/${selectedProject?.itrntPrjctCd}`, formData);
+ // 이 세션에서 업로드한 temp 파일 목록에 기록
+ sessionTempUrlsRef.current.add(url);
+
+ return { url }
+ }
+
+ return { url: '' }
+ }, [selectedProject]);
+
+ const settingTemplateList = useCallback(() => {
+ if(!selectedProject) return;
+
+ nextApi.get(`/message-template/list/${chnnlTy}/${selectedProject.itrntPrjctCd}`).then(setTemplateList);
+ }, [selectedProject, chnnlTy]);
+
+ useEffect(() => {
+ if(!selectedProject) return;
+
+ settingTemplateList();
+ nextApi.get(`/project/main-template/${selectedProject.prjctIdx}/${chnnlTy}`).then(setMainTemplateIdx);
+
+ const projectDefaultTemplate = _.cloneDeep(defaultTemplate);
+ projectDefaultTemplate.itrntPrjctCd = selectedProject.itrntPrjctCd;
+ setSelectedTemplate(projectDefaultTemplate);
+
+ //Todo: 프로젝트 별 리스트 헤더 조회해서 세팅하기
+ setListHderList([]);
+ }, [selectedProject]);
+
+ useEffect(() => {
+ setIsMainTemplate(selectedTemplate.tmplatIdx === mainTemplateIdx);
+ }, [selectedTemplate.tmplatIdx]);
+
+ return (
+
+
+
+ {pageTitle}
+
+
+
+
+
+
+
+
+
+
+
+
+
handleSelectTemplate(value)}
+ placeholder="템플릿을 선택해 주세요"
+ heightClassName="h-9"
+ widthClassName="w-full"
+ getLabel={(item) => item.tmplatNm}
+ getValue={(item) => String(item.tmplatIdx)}
+ preventDeselect={true}
+ useClear={true}
+ clearLabel="새 테플릿 생성"
+ />
+
+
+ {isSms && (
+
+
+ handleChange('tmplatTy', Number(value))}
+ placeholder="템플릿 타입을 선택해 주세요"
+ heightClassName="h-9"
+ widthClassName="w-full"
+ getLabel={(item) => item.label}
+ getValue={(item) => String(item.value)}
+ />
+
+ )}
+
+
+ handleChange('tmplatNm', e.target.value)}
+ />
+
+
+
+ handleChange('tmplatTitle', e.target.value)}
+ />
+
+
+
+
+
+
+
+
+ {listHderList.map((listHder) =>
+ {
+ const placeholder = `[\$${listHder.listHderNm}]`
+ return (
+
{
+ e.preventDefault();
+ handleVariableClick(placeholder);
+ }}
+ >
+
{listHder.listHderNm}
+
{placeholder}
+
+ )
+ }
+ )}
+
+
+
+ {selectedTemplate && (
+ isSmsTemplate(selectedTemplate)?
+
+
+
handleChange('sendTel', e.target.value)}
+ placeholder="발신 번호를 입력하세요"
+ className="w-full"
+ />
+
+ ⚠️ 비즈 뿌리오에 등록된 발신 번호가 아니면 전송되지 않습니다.
+
+
+ :
+
+
+ handleChange('sendEml', e.target.value)}
+ placeholder="발신 이메일을 입력하세요"
+ className="w-full"
+ />
+
+ )}
+
+
+
+ handleChange('sendNm', e.target.value)}
+ />
+
+
+ {!isSms && (
+
"}
+ onChange={(html: string) => setTemplateBody(html)}
+ placeholder="이메일 내용을 입력해 주세요"
+ className="w-full"
+ debounceMs={600}
+ onCommandReady={(cmd) => { editorCmdRef.current = cmd; }}
+ onImageUpload={async (file) => await handleImageUpload(file)} // 사용 시만
+ />
+ )}
+
+
+ {isSms && (
+
+ setTemplateBody(html)}
+ placeholder="문자 내용을 입력해 주세요"
+ className="max-w-none mx-0"
+ debounceMs={600}
+ onCommandReady={(cmd) => { editorCmdRef.current = cmd; }}
+ smsTitle={(selectedTemplate as TemplateSms).tmplatTitle}
+ changeSmsType={(smsTypeString) => setSmsType(smsTypeString)}
+ />
+
+ )}
+
+
+
+
+ {selectedTemplate.tmplatIdx && (
+
+ )}
+
+
+
+
+ )
+}
+
+export default MessageTemplate
\ No newline at end of file
diff --git a/src/app/(pages)/(main)/ProjectTableColumn.tsx b/src/components/table-column/ProjectTableColumn.tsx
similarity index 100%
rename from src/app/(pages)/(main)/ProjectTableColumn.tsx
rename to src/components/table-column/ProjectTableColumn.tsx
diff --git a/src/app/(pages)/(main)/manage/user/UserTableColumn.tsx b/src/components/table-column/UserTableColumn.tsx
similarity index 100%
rename from src/app/(pages)/(main)/manage/user/UserTableColumn.tsx
rename to src/components/table-column/UserTableColumn.tsx
diff --git a/src/components/ui/multi-select.tsx b/src/components/ui/multi-select.tsx
index 0a1a4d5..d712f68 100644
--- a/src/components/ui/multi-select.tsx
+++ b/src/components/ui/multi-select.tsx
@@ -1381,6 +1381,7 @@ function MultiSelectInner(
toggleOption(option.value)}
role="option"
aria-selected={isSelected}
@@ -1470,6 +1472,7 @@ function MultiSelectInner(
return (
toggleOption(option.value)}
role="option"
aria-selected={isSelected}
diff --git a/src/config/menu.data.ts b/src/config/menu.data.ts
index e92b7a9..f2cff52 100644
--- a/src/config/menu.data.ts
+++ b/src/config/menu.data.ts
@@ -54,7 +54,7 @@ export const projectSideMenus: SideMenuItem[] = [
label: "문자/메일 템플릿",
icon: MessageSquare,
children: [
- { id: "message-template-text", label: "문자 템플릿 관리", path: "/message/template/text" },
+ { id: "message-template-sms", label: "문자 템플릿 관리", path: "/message/template/sms" },
{ id: "message-template-email", label: "이메일 템플릿 관리", path: "/message/template/email" },
],
},
diff --git a/src/const/listConst.ts b/src/const/listConst.ts
new file mode 100644
index 0000000..0389407
--- /dev/null
+++ b/src/const/listConst.ts
@@ -0,0 +1,28 @@
+import {ListHeaderGrade, ListHeaderType} from "@/types/list";
+
+export const LIST_HEADER_GRADE_ORDER = [
+ ListHeaderGrade.IMMUTABLE,
+ ListHeaderGrade.DEFAULT,
+ ListHeaderGrade.NORMAL,
+] as const;
+
+export const LIST_HEADER_TYPE_ORDER = [
+ ListHeaderType.TEXT,
+ ListHeaderType.TEL,
+ ListHeaderType.EMAIL,
+ ListHeaderType.FILE_UPLOAD,
+] as const;
+
+export const LIST_HEADER_TYPE_LABEL = {
+ [ListHeaderType.TEXT]: "일반",
+ [ListHeaderType.TEL]: "전화번호",
+ [ListHeaderType.EMAIL]: "이메일",
+ [ListHeaderType.FILE_UPLOAD]: "파일 업로드",
+} as const satisfies Record;
+
+export const LIST_HEADER_TYPE_OPTIONS = [
+ { value: ListHeaderType.TEXT, label: LIST_HEADER_TYPE_LABEL[ListHeaderType.TEXT] },
+ { value: ListHeaderType.TEL, label: LIST_HEADER_TYPE_LABEL[ListHeaderType.TEL] },
+ { value: ListHeaderType.EMAIL, label: LIST_HEADER_TYPE_LABEL[ListHeaderType.EMAIL] },
+ { value: ListHeaderType.FILE_UPLOAD, label: LIST_HEADER_TYPE_LABEL[ListHeaderType.FILE_UPLOAD] },
+] as const;
\ No newline at end of file
diff --git a/src/const/messageTemplateConst.ts b/src/const/messageTemplateConst.ts
new file mode 100644
index 0000000..0c6bf85
--- /dev/null
+++ b/src/const/messageTemplateConst.ts
@@ -0,0 +1,16 @@
+import {MessageType, SmsType} from "@/types/messageTemplate";
+
+export const SMS_TYPE_ORDER = [
+ MessageType.SMS,
+ MessageType.LMS_MMS,
+] as const;
+
+export const SMS_TYPE_LABEL = {
+ [MessageType.SMS]: "SMS",
+ [MessageType.LMS_MMS]: "LMS",
+} as const satisfies Record;
+
+export const SMS_TYPE_OPTIONS = [
+ { value: MessageType.SMS, label: SMS_TYPE_LABEL[MessageType.SMS] },
+ { value: MessageType.LMS_MMS, label: SMS_TYPE_LABEL[MessageType.LMS_MMS] },
+] as const;
\ No newline at end of file
diff --git a/src/const/projectConst.ts b/src/const/projectConst.ts
index f0d0002..b71737a 100644
--- a/src/const/projectConst.ts
+++ b/src/const/projectConst.ts
@@ -1,9 +1,4 @@
-export enum SurveyType {
- NONE = 0,
- KON = 1,
- KIWI = 2,
- EXTERNAL = 99,
-}
+import {ProjectStatus, ResultCodeType, SurveyType} from "@/types/project";
export const SURVEY_TYPE_ORDER = [
SurveyType.NONE,
@@ -12,7 +7,6 @@ export const SURVEY_TYPE_ORDER = [
SurveyType.EXTERNAL,
] as const;
-// 라벨 맵 (단일 소스)
export const SURVEY_TYPE_LABEL = {
[SurveyType.NONE]: "없음",
[SurveyType.KON]: "KON",
@@ -20,11 +14,12 @@ export const SURVEY_TYPE_LABEL = {
[SurveyType.EXTERNAL]: "외부 설문",
} as const satisfies Record;
-export enum ProjectStatus {
- WAITING = 0,
- IN_PROGRESS = 1,
- COMPLETED = 10,
-}
+export const SURVEY_TYPE_OPTIONS = [
+ { value: SurveyType.NONE, label: SURVEY_TYPE_LABEL[SurveyType.NONE] },
+ { value: SurveyType.KON, label: SURVEY_TYPE_LABEL[SurveyType.KON] },
+ { value: SurveyType.KIWI, label: SURVEY_TYPE_LABEL[SurveyType.KIWI] },
+ { value: SurveyType.EXTERNAL, label: SURVEY_TYPE_LABEL[SurveyType.EXTERNAL] },
+] as const;
export const PROJECT_STATUS_ORDER = [
ProjectStatus.WAITING,
@@ -44,13 +39,6 @@ export const PROJECT_STATUS_CLASS = {
[ProjectStatus.COMPLETED]: "bg-green-100 text-green-800",
} as const satisfies Record;
-// 옵션이 필요하면(셀렉트/라디오 등) 이것만 돌려 쓰기
-export const SURVEY_TYPE_OPTIONS = [
- { value: SurveyType.NONE, label: SURVEY_TYPE_LABEL[SurveyType.NONE] },
- { value: SurveyType.KON, label: SURVEY_TYPE_LABEL[SurveyType.KON] },
- { value: SurveyType.KIWI, label: SURVEY_TYPE_LABEL[SurveyType.KIWI] },
- { value: SurveyType.EXTERNAL, label: SURVEY_TYPE_LABEL[SurveyType.EXTERNAL] },
-] as const;
export const PROJECT_STATUS_OPTIONS = [
{ value: ProjectStatus.WAITING, label: PROJECT_STATUS_LABEL[ProjectStatus.WAITING] },
@@ -58,12 +46,6 @@ export const PROJECT_STATUS_OPTIONS = [
{ value: ProjectStatus.COMPLETED, label: PROJECT_STATUS_LABEL[ProjectStatus.COMPLETED] },
] as const;
-export enum ResultCodeType {
- CONTACT = 0,
- INTERVIEW = 1,
- SURVEY = 2,
-}
-
export const RESULT_CODE_TYPE_LABEL = {
[ResultCodeType.CONTACT]: "컨택",
[ResultCodeType.INTERVIEW]: "인터뷰",
diff --git a/src/hooks/useAuth.ts b/src/hooks/useAuth.ts
index f4c643c..61c2deb 100644
--- a/src/hooks/useAuth.ts
+++ b/src/hooks/useAuth.ts
@@ -27,15 +27,6 @@ export const useAuth = () => {
);
const logout = useCallback(() => {
- // 저장소의 인증 정보(암호화 localStorage + session cache) 즉시 제거하여
- // 리다이렉트/새로고침 시 재하이드레이션되는 문제를 방지
- try {
-
- } catch {
- // 스토리지 접근 실패는 무시하고 메모리 상태만이라도 초기화
- }
-
- // 메모리 상태도 초기화
setAuth({
user: null,
seatNumber: null,
diff --git a/src/lib/env.server.ts b/src/lib/env.server.ts
index 155d493..100b480 100644
--- a/src/lib/env.server.ts
+++ b/src/lib/env.server.ts
@@ -8,6 +8,7 @@ export const serverEnv = {
ENV: required("ENV"),
CONTACT_SERVER: required("CONTACT_SERVER"),
API_CONTACT_SERVER: required("API_CONTACT_SERVER"),
+ API_NOTIHUB_SERVER: required("API_NOTIHUB_SERVER"),
API_INTRANET_SERVER: required("API_INTRANET_SERVER"),
API_KART_SERVER: required("API_KART_SERVER"),
KART_API_KEY: required("KART_API_KEY"),
diff --git a/src/lib/server-api.ts b/src/lib/server-api.ts
index f183ec3..52fdff5 100644
--- a/src/lib/server-api.ts
+++ b/src/lib/server-api.ts
@@ -19,6 +19,10 @@ export const createContactApi = () => {
return createServerApi(serverEnv.API_CONTACT_SERVER);
}
+export const createNotihubApi = () => {
+ return createServerApi(serverEnv.API_NOTIHUB_SERVER);
+}
+
export const createIntranetApi = () => {
return createServerApi(serverEnv.API_INTRANET_SERVER);
}
diff --git a/src/store/jotai/project.ts b/src/store/jotai/project.ts
index dbed348..1257e77 100644
--- a/src/store/jotai/project.ts
+++ b/src/store/jotai/project.ts
@@ -5,8 +5,9 @@ import {createSessionStorageAtom} from "@/store/jotai/utils";
export type SelectedProject = {
prjctIdx: number;
- prjctCd: string
+ prjctCd: string;
prjctName: string;
+ itrntPrjctCd: string;
ownerDept: string;
ownerFw: string;
};
diff --git a/src/store/jotai/utils.ts b/src/store/jotai/utils.ts
index 1f287d0..0a5a716 100644
--- a/src/store/jotai/utils.ts
+++ b/src/store/jotai/utils.ts
@@ -55,17 +55,7 @@ export const createLocalStorageAtom = (
// 사용자 쓰기 발생 표시 (하이드레이션이 도착해도 무시하도록)
wasOverridden = true;
- // 값이 초기값과 동일하면 키 제거로 처리하여 '비움'을 명확히 함
- const isInitial = (() => {
- try {
- return JSON.stringify(next) === JSON.stringify(realInitialValue);
- } catch {
- // 비교 실패 시 보수적으로 저장하도록 함
- return false;
- }
- })();
-
- if (isInitial) {
+ if (next === null || (next as unknown) === undefined) {
// 암호화 localStorage 및 캐시 제거
removeLocalStorage(key);
} else {
diff --git a/src/types/common.ts b/src/types/common.ts
index 9bf429c..a9d7e47 100644
--- a/src/types/common.ts
+++ b/src/types/common.ts
@@ -6,6 +6,13 @@ export type DataVerification = {
export type RouteContext = { params: Promise<{ slug?: string[] }> };
+export type PageRequest = {
+ pageIndex: number;
+ pageSize: number;
+ sortBy: string;
+ sortDir: "asc" | "desc";
+}
+
export type PageResponse = {
content: T[];
totalElements: number;
diff --git a/src/types/list.ts b/src/types/list.ts
new file mode 100644
index 0000000..dd3c91a
--- /dev/null
+++ b/src/types/list.ts
@@ -0,0 +1,27 @@
+export enum ListHeaderGrade {
+ IMMUTABLE = 0,
+ DEFAULT = 1,
+ NORMAL = 2,
+}
+
+export enum ListHeaderType {
+ TEL = 21,
+ EMAIL = 31,
+ FILE_UPLOAD = 81,
+ TEXT = 91,
+}
+
+export type listHder = {
+ listHderId: number;
+ listHderGrad: ListHeaderGrade;
+ listHderNm: string;
+ listHderTy: ListHeaderType
+ useFilter: boolean;
+ useView: boolean;
+ useIntrvwerView: boolean;
+ useIntrvwerEdit: boolean;
+ regUser: string;
+ regDt: string;
+ modUser?: string;
+ modDt?: string;
+}
\ No newline at end of file
diff --git a/src/types/messageTemplate.ts b/src/types/messageTemplate.ts
new file mode 100644
index 0000000..82c55ea
--- /dev/null
+++ b/src/types/messageTemplate.ts
@@ -0,0 +1,40 @@
+export enum MessageType {
+ EMAIL = 11,
+ SMS = 21,
+ LMS_MMS = 22
+}
+
+export enum ChannelType{
+ EMAIL = 1,
+ SMS = 2
+}
+
+export const SMS_TYPE_ARRAY = [MessageType.SMS, MessageType.LMS_MMS] as const;
+export type SmsType = typeof SMS_TYPE_ARRAY[number];
+
+export type TemplateSummary = {
+ tmplatIdx: number;
+ tmplatNm: string;
+}
+
+export type TemplateBasic = {
+ tmplatIdx?: number;
+ itrntPrjctCd: string;
+ tmplatNm: string;
+ tmplatBody: string;
+ sendNm: string;
+};
+
+export type TemplateSms = TemplateBasic & {
+ tmplatTy: SmsType;
+ tmplatTitle?: string;
+ sendTel: string;
+}
+
+export type TemplateEmail = TemplateBasic & {
+ tmplatTy: MessageType.EMAIL;
+ tmplatTitle: string;
+ sendEml: string;
+}
+
+export type Template = TemplateSms | TemplateEmail;
\ No newline at end of file
diff --git a/src/types/project.ts b/src/types/project.ts
index e543bbb..f1b99b5 100644
--- a/src/types/project.ts
+++ b/src/types/project.ts
@@ -1,4 +1,24 @@
-import {ProjectStatus, SurveyType, ResultCodeType} from "@/const/projectConst";
+import {PageRequest} from "@/types/common";
+import {ChannelType} from "@/types/messageTemplate";
+
+export enum SurveyType {
+ NONE = 0,
+ KON = 1,
+ KIWI = 2,
+ EXTERNAL = 99,
+}
+
+export enum ProjectStatus {
+ WAITING = 0,
+ IN_PROGRESS = 1,
+ COMPLETED = 10,
+}
+
+export enum ResultCodeType {
+ CONTACT = 0,
+ INTERVIEW = 1,
+ SURVEY = 2,
+}
export type ProjectInfo = {
prjctIdx: number; // Long
@@ -46,11 +66,7 @@ export type ProjectListRequest = {
ownerDeptList: string[];
ownerFwList: string[];
- pageIndex: number;
- pageSize: number;
-
- sortBy: string;
- sortDir: "asc" | "desc";
+ pageRequest: PageRequest;
}
export type ProjectOwnerResponse = {
@@ -81,4 +97,10 @@ export type ResultCode = {
resultCdTy:ResultCodeType;
resultCd:number;
resultCdLbl:string;
+}
+
+export type ProjectMainTemplateUpdateRequest = {
+ prjctIdx:number;
+ chnnlTy:ChannelType;
+ tmplatIdx:number|null;
}
\ No newline at end of file