260115_02_ENH : 로그인 오류 수정 및 템플릿 생성 연동 완료
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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");
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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 (<div>This is Email Template Page</div>)
|
||||
const EmailTemplatePage = () => {
|
||||
|
||||
const defaultEmailTemplate : TemplateEmail = {
|
||||
tmplatIdx: undefined,
|
||||
itrntPrjctCd: '',
|
||||
tmplatTy: MessageType.EMAIL,
|
||||
tmplatNm: '',
|
||||
tmplatTitle: '',
|
||||
tmplatBody: '',
|
||||
sendEml: '',
|
||||
sendNm: ''
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6 content-text-sm">
|
||||
<MessageTemplate pageTitle={"이메일 템플릿 관리"} defaultTemplate={defaultEmailTemplate}/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default EmailTemplatePage;
|
||||
27
src/app/(pages)/(main)/message/template/sms/page.tsx
Normal file
27
src/app/(pages)/(main)/message/template/sms/page.tsx
Normal file
@@ -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 (
|
||||
<div className="space-y-6 content-text-sm">
|
||||
<MessageTemplate pageTitle="문자 템플릿 관리" defaultTemplate={defaultSmsTemplate}/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default SmsTemplatePage;
|
||||
@@ -1,9 +0,0 @@
|
||||
const TextTemplatePage = () => {
|
||||
//파라미터 받기
|
||||
//const url = buildUrlWithParams("/login", searchParams, { ref: "root" });
|
||||
//redirect(url);
|
||||
|
||||
return (<div>This is Text Message Template Page</div>)
|
||||
}
|
||||
|
||||
export default TextTemplatePage;
|
||||
@@ -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(() =>
|
||||
|
||||
@@ -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<ProjectInfo>(`/project/info/${selectedProject.prjctIdx}`)
|
||||
.then((res) => setProjectInfo(res));
|
||||
|
||||
nextApi.get<ResultCode[]>(`/project/result-code/${selectedProject.prjctIdx}`)
|
||||
nextApi.get<ResultCode[]>(`/result-code/${selectedProject.prjctIdx}`)
|
||||
.then((res) => {setResultCodeArray(res)});
|
||||
|
||||
nextApi.get<UserInfo[]>(`/user/outsource`)
|
||||
|
||||
@@ -52,15 +52,15 @@ const LoginPage = () => {
|
||||
nextApi.post<LoginUser>(
|
||||
"/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(() => {
|
||||
|
||||
105
src/app/api/message-template/[[...slug]]/route.ts
Normal file
105
src/app/api/message-template/[[...slug]]/route.ts
Normal file
@@ -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>(
|
||||
`/template/${slug[0]}`,
|
||||
);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "list" && slug.length === 3){
|
||||
const result = await notihubApi.get<TemplateSummary[]>(
|
||||
`/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<string>(
|
||||
`/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>(`/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>(`/template`, body);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
@@ -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<ResultCode[]>(`/result-code/${slug[1]}`);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
if(action === "main-template" && slug.length === 3){
|
||||
const result = await contactApi.get<number | null | "">(`/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);
|
||||
|
||||
|
||||
23
src/app/api/result-code/[[...slug]]/route.ts
Normal file
23
src/app/api/result-code/[[...slug]]/route.ts
Normal file
@@ -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<ResultCode[]>(`/result-code/${slug[0]}`);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
@@ -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<ResultCode[]>(`/project/result-code/${importProject.prjctIdx}`)
|
||||
nextApi.get<ResultCode[]>(`/result-code/${importProject.prjctIdx}`)
|
||||
.then((res) => setImportCodeArray(res));
|
||||
}
|
||||
}, [importProject]);
|
||||
|
||||
@@ -39,7 +39,7 @@ export const Header = ({
|
||||
else{
|
||||
window.location.replace("/logout");
|
||||
}
|
||||
}, [auth])
|
||||
}, [auth.user])
|
||||
|
||||
return (
|
||||
<header className="bg-white border-b border-gray-200 sticky top-0 z-40">
|
||||
|
||||
@@ -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 {
|
||||
|
||||
424
src/components/message-template/MessageTemplate.tsx
Normal file
424
src/components/message-template/MessageTemplate.tsx
Normal file
@@ -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<KriEditorCommand | null>(null);
|
||||
const sessionTempUrlsRef = useRef<Set<string>>(new Set());
|
||||
|
||||
const [mainTemplateIdx, setMainTemplateIdx] = useState<number|null>(null);
|
||||
const [listHderList, setListHderList] = useState<listHder[]>([])
|
||||
const [templateList, setTemplateList] = useState<TemplateSummary[]>([]);
|
||||
const [selectedTemplate, setSelectedTemplate] = useState<Template>(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> = T extends unknown ? keyof T : never;
|
||||
|
||||
// 특정 키의 값 타입을 유니온에서 안전하게 뽑기
|
||||
type ValueOfUnionKey<T, K extends KeysOfUnion<T>> =
|
||||
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<Template>(`/message-template/${templateIdxString}`).then(setSelectedTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
const handleChange = <K extends KeysOfUnion<Template>>(
|
||||
field: K,
|
||||
value: ValueOfUnionKey<Template, K>
|
||||
) => {
|
||||
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<Template>(`/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<Template>(`/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<string>(`/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<TemplateSummary[]>(`/message-template/list/${chnnlTy}/${selectedProject.itrntPrjctCd}`).then(setTemplateList);
|
||||
}, [selectedProject, chnnlTy]);
|
||||
|
||||
useEffect(() => {
|
||||
if(!selectedProject) return;
|
||||
|
||||
settingTemplateList();
|
||||
nextApi.get<number | null>(`/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 (
|
||||
<div className={cn(
|
||||
"w-full mx-auto p-6",
|
||||
isSms ? "max-w-7xl" : "max-w-4xl"
|
||||
)}>
|
||||
<Card>
|
||||
<CardHeader className="border-b">
|
||||
<CardTitle className="text-center content-text-lg font-bold">{pageTitle}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="pt-6 relative">
|
||||
<div
|
||||
className={cn(
|
||||
isSms
|
||||
? "grid grid-cols-1 lg:grid-cols-[1fr_340px] gap-6 items-start"
|
||||
: ""
|
||||
)}
|
||||
>
|
||||
<div className="space-y-6">
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label htmlFor="tmplatNm" className="content-text-base">
|
||||
템플릿
|
||||
</Label>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
id="mainTemplate"
|
||||
checked={isMainTemplate}
|
||||
onClick={toggleIsMainTemplate}
|
||||
/>
|
||||
<label htmlFor="mainTemplate" className="content-text-base cursor-pointer">
|
||||
대표 템플릿
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<KriSingleSelect
|
||||
items={templateList}
|
||||
value={String(selectedTemplate.tmplatIdx || "")}
|
||||
onChange={(value) => handleSelectTemplate(value)}
|
||||
placeholder="템플릿을 선택해 주세요"
|
||||
heightClassName="h-9"
|
||||
widthClassName="w-full"
|
||||
getLabel={(item) => item.tmplatNm}
|
||||
getValue={(item) => String(item.tmplatIdx)}
|
||||
preventDeselect={true}
|
||||
useClear={true}
|
||||
clearLabel="새 테플릿 생성"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{isSms && (
|
||||
<div className="space-y-2">
|
||||
<Label className="content-text-base">타입</Label>
|
||||
<KriSingleSelect
|
||||
items={[...SMS_TYPE_OPTIONS]}
|
||||
value={String(selectedTemplate.tmplatTy || MessageType.SMS)}
|
||||
onChange={(value) => handleChange('tmplatTy', Number(value))}
|
||||
placeholder="템플릿 타입을 선택해 주세요"
|
||||
heightClassName="h-9"
|
||||
widthClassName="w-full"
|
||||
getLabel={(item) => item.label}
|
||||
getValue={(item) => String(item.value)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="tmplatNm" className="content-text-base">
|
||||
템플릿 명
|
||||
</Label>
|
||||
<Input
|
||||
id="tmplatNm"
|
||||
placeholder="템플릿 명을 입력하세요"
|
||||
value={selectedTemplate.tmplatNm}
|
||||
onChange={(e) => handleChange('tmplatNm', e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="tmplatTitle" className="content-text-base">
|
||||
제목
|
||||
</Label>
|
||||
<Input
|
||||
id="tmplatTitle"
|
||||
placeholder="제목을 입력하세요"
|
||||
value={selectedTemplate.tmplatTitle || ''}
|
||||
onChange={(e) => handleChange('tmplatTitle', e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center">
|
||||
<Label className="content-text-base">변수 리스트</Label>
|
||||
</div>
|
||||
<div className="border rounded-md overflow-hidden">
|
||||
<div className="bg-blue-100 grid grid-cols-2 border-b">
|
||||
<div className="py-2 px-3 text-center font-medium border-r content-text-base">리스트 헤더명</div>
|
||||
<div className="py-2 px-3 text-center font-medium content-text-base">치환 문자</div>
|
||||
</div>
|
||||
<div className="max-h-32 overflow-y-auto">
|
||||
{listHderList.map((listHder) =>
|
||||
{
|
||||
const placeholder = `[\$${listHder.listHderNm}]`
|
||||
return (
|
||||
<div
|
||||
key={listHder.listHderId}
|
||||
className="grid grid-cols-2 border-b last:border-b-0 hover:bg-blue-50 cursor-pointer transition-colors"
|
||||
onPointerDown={(e) => {
|
||||
e.preventDefault();
|
||||
handleVariableClick(placeholder);
|
||||
}}
|
||||
>
|
||||
<div className="py-2 px-3 text-center border-r content-text-base">{listHder.listHderNm}</div>
|
||||
<div className="py-2 px-3 text-center content-text-base">{placeholder}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{selectedTemplate && (
|
||||
isSmsTemplate(selectedTemplate)?
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="sendTel" className="content-text-base">발신 번호</Label>
|
||||
<Input
|
||||
id="sendTel"
|
||||
value={selectedTemplate.sendTel}
|
||||
onChange={(e) => handleChange('sendTel', e.target.value)}
|
||||
placeholder="발신 번호를 입력하세요"
|
||||
className="w-full"
|
||||
/>
|
||||
<p className="content-text-sm text-red-600 font-medium">
|
||||
⚠️ 비즈 뿌리오에 등록된 발신 번호가 아니면 전송되지 않습니다.
|
||||
</p>
|
||||
</div>
|
||||
:
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="sendEmail" className="content-text-base">발신 이메일</Label>
|
||||
<Input
|
||||
id="sendEmail"
|
||||
value={selectedTemplate.sendEml}
|
||||
onChange={(e) => handleChange('sendEml', e.target.value)}
|
||||
placeholder="발신 이메일을 입력하세요"
|
||||
className="w-full"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="sendNm" className="content-text-base">
|
||||
발신자 명
|
||||
</Label>
|
||||
<Input
|
||||
id="sendNm"
|
||||
placeholder="발신자 명을 입력하세요"
|
||||
value={selectedTemplate.sendNm}
|
||||
onChange={(e) => handleChange('sendNm', e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{!isSms && (
|
||||
<KriEditor
|
||||
editorMode={'both'}
|
||||
value={selectedTemplate.tmplatBody ?? "<p></p>"}
|
||||
onChange={(html: string) => setTemplateBody(html)}
|
||||
placeholder="이메일 내용을 입력해 주세요"
|
||||
className="w-full"
|
||||
debounceMs={600}
|
||||
onCommandReady={(cmd) => { editorCmdRef.current = cmd; }}
|
||||
onImageUpload={async (file) => await handleImageUpload(file)} // 사용 시만
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{isSms && (
|
||||
<div className="mt-6 lg:mt-0 lg:border-l lg:pl-6">
|
||||
<KriEditor
|
||||
editorMode={"sms"}
|
||||
value={(selectedTemplate as TemplateSms).tmplatBody ?? ""}
|
||||
onChange={(html: string) => 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)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-center gap-3 pt-4">
|
||||
<Button onClick={handleCreate} className="w-32 h-10">
|
||||
{selectedTemplate.tmplatIdx ? "복사 후 저장" : "저장"}
|
||||
</Button>
|
||||
|
||||
{selectedTemplate.tmplatIdx && (
|
||||
<Button
|
||||
onClick={handleUpdate}
|
||||
className="w-32 h-10 bg-blue-500 text-white hover:bg-blue-600"
|
||||
>
|
||||
수정
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default MessageTemplate
|
||||
@@ -1381,6 +1381,7 @@ function MultiSelectInner(
|
||||
<CommandGroup>
|
||||
<CommandItem
|
||||
key="all"
|
||||
value={"all"}
|
||||
onSelect={toggleAll}
|
||||
role="option"
|
||||
aria-selected={isAllSelected}
|
||||
@@ -1424,6 +1425,7 @@ function MultiSelectInner(
|
||||
return (
|
||||
<CommandItem
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
onSelect={() => toggleOption(option.value)}
|
||||
role="option"
|
||||
aria-selected={isSelected}
|
||||
@@ -1470,6 +1472,7 @@ function MultiSelectInner(
|
||||
return (
|
||||
<CommandItem
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
onSelect={() => toggleOption(option.value)}
|
||||
role="option"
|
||||
aria-selected={isSelected}
|
||||
|
||||
@@ -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" },
|
||||
],
|
||||
},
|
||||
|
||||
28
src/const/listConst.ts
Normal file
28
src/const/listConst.ts
Normal file
@@ -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<ListHeaderType, string>;
|
||||
|
||||
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;
|
||||
16
src/const/messageTemplateConst.ts
Normal file
16
src/const/messageTemplateConst.ts
Normal file
@@ -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<SmsType, string>;
|
||||
|
||||
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;
|
||||
@@ -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<SurveyType, string>;
|
||||
|
||||
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<ProjectStatus, string>;
|
||||
|
||||
// 옵션이 필요하면(셀렉트/라디오 등) 이것만 돌려 쓰기
|
||||
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]: "인터뷰",
|
||||
|
||||
@@ -27,15 +27,6 @@ export const useAuth = () => {
|
||||
);
|
||||
|
||||
const logout = useCallback(() => {
|
||||
// 저장소의 인증 정보(암호화 localStorage + session cache) 즉시 제거하여
|
||||
// 리다이렉트/새로고침 시 재하이드레이션되는 문제를 방지
|
||||
try {
|
||||
|
||||
} catch {
|
||||
// 스토리지 접근 실패는 무시하고 메모리 상태만이라도 초기화
|
||||
}
|
||||
|
||||
// 메모리 상태도 초기화
|
||||
setAuth({
|
||||
user: null,
|
||||
seatNumber: null,
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -55,17 +55,7 @@ export const createLocalStorageAtom = <T>(
|
||||
// 사용자 쓰기 발생 표시 (하이드레이션이 도착해도 무시하도록)
|
||||
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 {
|
||||
|
||||
@@ -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<T> = {
|
||||
content: T[];
|
||||
totalElements: number;
|
||||
|
||||
27
src/types/list.ts
Normal file
27
src/types/list.ts
Normal file
@@ -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;
|
||||
}
|
||||
40
src/types/messageTemplate.ts
Normal file
40
src/types/messageTemplate.ts
Normal file
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user