251212_01_ENH : kri-editor 1차 완성, 프로젝트 정보 저장 api연동 완료
This commit is contained in:
@@ -109,7 +109,7 @@ const MainPage = () => {
|
||||
if (lastReqKeyRef.current === reqKey) return;
|
||||
lastReqKeyRef.current = reqKey;
|
||||
|
||||
const sort = sorting?.[0];
|
||||
const sort = sorting?.[0] ?? {id: "prjctIdx", desc: true};
|
||||
const searchBody: ProjectListRequest = {
|
||||
prjctText: query?.prjctText || "",
|
||||
prjctStatusList: query?.prjctStatusList || [],
|
||||
@@ -117,8 +117,8 @@ const MainPage = () => {
|
||||
ownerFwList: query?.ownerFwList || [],
|
||||
pageIndex: pagination.pageIndex,
|
||||
pageSize: pagination.pageSize,
|
||||
sortBy: sort?.id ?? "prjctIdx",
|
||||
sortDir: sort?.desc ? "desc" : "asc"
|
||||
sortBy: sort.id,
|
||||
sortDir: sort.desc ? "desc" : "asc"
|
||||
}
|
||||
|
||||
withLoadingAsync(() =>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import {useEffect, useState} from 'react'
|
||||
import {useEffect, useState, useCallback, useRef} from 'react'
|
||||
import BodyTitle from '@/components/layout/BodyTitle'
|
||||
import {Button} from '@/components/ui/button'
|
||||
import {Input} from '@/components/ui/input'
|
||||
@@ -13,11 +13,11 @@ 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} from "@/types/project";
|
||||
import {KonKiwiProjectInfo, ProjectInfo, ProjectUpdateRequest, ResultCode} from "@/types/project";
|
||||
import {
|
||||
PROJECT_STATUS_LABEL,
|
||||
PROJECT_STATUS_ORDER,
|
||||
ProjectStatus,
|
||||
ProjectStatus, ResultCodeType,
|
||||
SURVEY_TYPE_LABEL,
|
||||
SURVEY_TYPE_ORDER,
|
||||
SurveyType
|
||||
@@ -31,20 +31,24 @@ import {UserInfo} from "@/types/user";
|
||||
import {useDebouncedValue} from "@/hooks/useDebouncedValue";
|
||||
import {useAuth} from "@/hooks/useAuth";
|
||||
import {KriEditor} from "@/components/kri-editor";
|
||||
import _ from "lodash";
|
||||
|
||||
|
||||
const defaultProjectInfo: Partial<ProjectInfo> = {
|
||||
const defaultProjectInfo: ProjectInfo = {
|
||||
prjctIdx: 0,
|
||||
prjctCd: '',
|
||||
prjctName: '',
|
||||
prjctStatus: 0,
|
||||
itrntPrjctCd: '',
|
||||
prjctStatus: ProjectStatus.WAITING,
|
||||
ownerDept: '',
|
||||
ownerFw: '',
|
||||
surveyTy: 0,
|
||||
surveyTy: SurveyType.NONE,
|
||||
surveyPrjctCd: '',
|
||||
surveyUrl: '',
|
||||
ff: false,
|
||||
useContactSenario: false,
|
||||
contactSenario: '',
|
||||
regUser: '',
|
||||
regDt: '',
|
||||
}
|
||||
|
||||
type ExternalTab = 'redirect' | 'api'
|
||||
@@ -56,8 +60,10 @@ const ProjectInfoPage = () => {
|
||||
const { users, isLoading } = useItrntUserList();
|
||||
const { auth } = useAuth();
|
||||
|
||||
const [projectInfo, setProjectInfo] = useState<Partial<ProjectInfo>>(defaultProjectInfo);
|
||||
const [projectInfo, setProjectInfo] = useState<ProjectInfo>(defaultProjectInfo);
|
||||
const [outsourceUserArray, setOutsourceUserArray] = useState<string[]>([]);
|
||||
const [resultCodeArray, setResultCodeArray] = useState<ResultCode[]>([]);
|
||||
const [changeResultCodeType, setChangeResultCodeType] = useState<ResultCodeType[]>([]);
|
||||
|
||||
const [outsourceOptionArray, setOutsourceOptionArray] = useState<MultiSelectOption[]>([]);
|
||||
const [deptArray, setDeptArray] = useState<string[]>([]);
|
||||
@@ -68,6 +74,7 @@ const ProjectInfoPage = () => {
|
||||
const [surveyProjectArray, setSurveyProjectArray] = useState<KonKiwiProjectInfo[]>([]);
|
||||
|
||||
const [externalTab, setExternalTab] = useState<ExternalTab>('redirect')
|
||||
const sessionTempUrlsRef = useRef<Set<string>>(new Set());
|
||||
|
||||
const internalSurvey = [SurveyType.KON, SurveyType.KIWI];
|
||||
const baseUrl = 'https://kcont.kric.com'
|
||||
@@ -92,6 +99,7 @@ const ProjectInfoPage = () => {
|
||||
|
||||
const searchKonKiwiPrjct = async (keyword:string): Promise<void> => {
|
||||
const surveyType = projectInfo.surveyTy ?? SurveyType.NONE;
|
||||
|
||||
if(internalSurvey.includes(surveyType) && userTeam){
|
||||
const isKiwi = surveyType === SurveyType.KON? 0 : 1;
|
||||
const res = await nextApi.get<KonKiwiProjectInfo[]>(
|
||||
@@ -107,6 +115,19 @@ const ProjectInfoPage = () => {
|
||||
setProjectInfo((prev) => ({ ...prev, [field]: value }))
|
||||
}
|
||||
|
||||
const handleImageUpload = useCallback(
|
||||
async (file: File): Promise<{ url: string }> => {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
|
||||
const url = await nextApi.putForm<string>(`/project/senario-image/${projectInfo.prjctCd}`, formData);
|
||||
|
||||
// 이 세션에서 업로드한 temp 파일 목록에 기록
|
||||
sessionTempUrlsRef.current.add(url);
|
||||
|
||||
return { url }
|
||||
}, [projectInfo.prjctCd]);
|
||||
|
||||
const handleResultCodeClick = () => {
|
||||
showDialog('resultCodeDialog')
|
||||
}
|
||||
@@ -116,7 +137,20 @@ const ProjectInfoPage = () => {
|
||||
alert('프로젝트명을 입력해주세요.')
|
||||
return
|
||||
}
|
||||
// TODO: 저장 API
|
||||
|
||||
const updateCodeArray = _.cloneDeep(
|
||||
resultCodeArray.filter((rc) => changeResultCodeType.includes(rc.resultCdTy))
|
||||
);
|
||||
|
||||
const requestUpdateProject:ProjectUpdateRequest = {
|
||||
projectInfo: projectInfo,
|
||||
resultCodeList: updateCodeArray,
|
||||
assignUserIdList: outsourceUserArray,
|
||||
}
|
||||
console.log(requestUpdateProject, projectInfo.prjctIdx)
|
||||
await nextApi.patch(`/project/${projectInfo.prjctIdx}`, requestUpdateProject);
|
||||
|
||||
alert("저장되었습니다.");
|
||||
}
|
||||
|
||||
const handleDeleteClick = async () => {
|
||||
@@ -135,7 +169,10 @@ const ProjectInfoPage = () => {
|
||||
useEffect(() => {
|
||||
if(selectedProject){
|
||||
nextApi.get<ProjectInfo>(`/project/info/${selectedProject.prjctIdx}`)
|
||||
.then((res) => { setProjectInfo(res)});
|
||||
.then((res) => setProjectInfo(res));
|
||||
|
||||
nextApi.get<ResultCode[]>(`/project/result-code/${selectedProject.prjctIdx}`)
|
||||
.then((res) => {setResultCodeArray(res)});
|
||||
|
||||
nextApi.get<UserInfo[]>(`/user/outsource`)
|
||||
.then((res) => {
|
||||
@@ -170,6 +207,7 @@ const ProjectInfoPage = () => {
|
||||
}
|
||||
}, [projectInfo.surveyTy, projectInfo.surveyPrjctCd])
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
let userTeams = Array.from(new Set(users.map(u => u.userTeam)));
|
||||
if(!userTeams.includes("T900")){ //TFT
|
||||
@@ -194,7 +232,6 @@ const ProjectInfoPage = () => {
|
||||
searchKonKiwiPrjct(keyword).then();
|
||||
}, [debouncedKeyword, projectInfo.surveyTy, userTeam]);
|
||||
|
||||
|
||||
if (!mounted) return <LoadingOverlay force />
|
||||
|
||||
return (
|
||||
@@ -286,9 +323,10 @@ const ProjectInfoPage = () => {
|
||||
<KriMultiSelect
|
||||
items={outsourceOptionArray}
|
||||
value={outsourceUserArray}
|
||||
onChange={(value) => console.log(value)}
|
||||
onChange={(value) => setOutsourceUserArray(value)}
|
||||
getValue={(item) => item.value}
|
||||
getLabel={(item) => item.label}
|
||||
maxCount={2}
|
||||
placeholder="없음"
|
||||
heightClassName="h-9"
|
||||
widthClassName="w-full"
|
||||
@@ -438,10 +476,12 @@ const ProjectInfoPage = () => {
|
||||
{projectInfo.useContactSenario && (
|
||||
<div className="ml-6 border rounded p-4 bg-gray-50 text-sm text-gray-600">
|
||||
<KriEditor
|
||||
value={projectInfo.contactSenario || ""}
|
||||
onChange={(str: string) => {handleChange('contactSenario', str); console.log(str)}}
|
||||
value={projectInfo.contactSenario ?? "<p></p>"}
|
||||
onChange={(html: string) => handleChange("contactSenario", html)}
|
||||
placeholder="컨택 시나리오를 작성해 주세요"
|
||||
className="w-full"
|
||||
debounceMs={600} // 기본 400ms, 원하면 늘리세요(예: 600~1000)
|
||||
onImageUpload={async (file) => await handleImageUpload(file)} // 사용 시만
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
@@ -472,6 +512,10 @@ const ProjectInfoPage = () => {
|
||||
<ResultCodeDialog
|
||||
open={isDialogOpen('resultCodeDialog')}
|
||||
onOpenChange={(open) => (open ? showDialog('resultCodeDialog') : hideDialog('resultCodeDialog'))}
|
||||
changeCodeType={changeResultCodeType}
|
||||
onChangeCodeType={setChangeResultCodeType}
|
||||
sourceArray={resultCodeArray}
|
||||
onSave={setResultCodeArray}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -16,7 +16,6 @@ import {apiError} from "@/lib/http-util";
|
||||
import {NONE_HTTP_ERROR} from "@/const/commonConst";
|
||||
|
||||
const LoginPage = () => {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const { setFromLoginResponse } = useAuth();
|
||||
const { withLoadingAsync } = useLoading();
|
||||
@@ -63,7 +62,7 @@ const LoginPage = () => {
|
||||
console.warn("Failed to persist SeatNumber to secure storage:", e);
|
||||
}
|
||||
// 메인 페이지로 이동 (보호 라우트 진입)
|
||||
router.replace("/");
|
||||
window.location.replace("/");
|
||||
}).catch((e) => {
|
||||
const err = apiError(e);
|
||||
console.error(err.status, err.code, err.message);
|
||||
|
||||
@@ -19,28 +19,4 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const PUT = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const [action] = slug ?? [];
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if(!action){
|
||||
const body = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json(
|
||||
{ message: "요청 바디가 없습니다." },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
await contactApi.put(`/assign/prjct-outsource/${slug[1]}`, body);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -2,7 +2,7 @@ import {NextRequest, NextResponse} from "next/server";
|
||||
import {createContactApi, createIntranetApi} from "@/lib/server-api";
|
||||
import {errorToResponse} from "@/lib/http-util";
|
||||
import {PageResponse, RouteContext} from "@/types/common";
|
||||
import {IntranetProjectSearchResponse, ProjectInfo, ProjectOwnerResponse} from "@/types/project";
|
||||
import {IntranetProjectSearchResponse, ProjectInfo, ProjectOwnerResponse, ResultCode} from "@/types/project";
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
@@ -32,6 +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 });
|
||||
}
|
||||
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
@@ -57,6 +63,18 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "senario-image" && slug[1] === "clean" && slug.length === 3){
|
||||
const prjctCd = slug[2];
|
||||
const body = await req.json().catch(() => null);
|
||||
|
||||
await contactApi.post(
|
||||
`/project/senario-image/clean/${prjctCd}`,
|
||||
body
|
||||
);
|
||||
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
@@ -69,6 +87,27 @@ export const PUT = async (req: NextRequest, context: RouteContext) => {
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if(action === "senario-image" && slug.length === 2){
|
||||
const prjctCd = 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 contactApi.putForm<string>(
|
||||
`/project/senario-image/${prjctCd}`,
|
||||
formData
|
||||
);
|
||||
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(!action){
|
||||
const body = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
@@ -94,6 +133,24 @@ export const PATCH = async (req: NextRequest, context: RouteContext) => {
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if(slug.length === 1){
|
||||
const body = await req.json().catch(() => null);
|
||||
|
||||
if (!body) {
|
||||
return NextResponse.json(
|
||||
{ message: "요청 바디가 없습니다." },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
await contactApi.patch<void>(
|
||||
`/project/${slug[0]}`,
|
||||
body
|
||||
);
|
||||
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
|
||||
@@ -188,3 +188,68 @@
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************TipTap 이미지 Resize Node*******************************/
|
||||
.ProseMirror img {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ProseMirror .ProseMirror-selectednode img {
|
||||
outline: 5px solid #0ea5e9;
|
||||
outline-offset: -5px;
|
||||
}
|
||||
/* 리사이즈 컨테이너 기본 배치 */
|
||||
.ProseMirror [data-resize-container] {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* 리사이즈 핸들 공통 스타일 */
|
||||
.ProseMirror [data-resize-handle] {
|
||||
position: absolute;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
box-sizing: border-box;
|
||||
background: #ffffff;
|
||||
border: 1px solid #0ea5e9; /* 하늘색 테두리 */
|
||||
z-index: 10;
|
||||
|
||||
opacity: 0; /* 안 보이게 */
|
||||
pointer-events: none; /* 마우스 이벤트도 막기 */
|
||||
transition: opacity 0.12s ease-out;
|
||||
}
|
||||
/* 이 이미지 래퍼에 마우스가 올라갔을 때만, 해당 핸들만 보이기 */
|
||||
.ProseMirror [data-resize-container]:hover [data-resize-handle] {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
/* 각 방향별 위치 + 커서 모양 */
|
||||
.ProseMirror [data-resize-handle="bottom-right"] {
|
||||
right: -5px;
|
||||
bottom: -5px;
|
||||
cursor: se-resize !important;
|
||||
}
|
||||
|
||||
.ProseMirror [data-resize-handle="bottom-left"] {
|
||||
left: -5px;
|
||||
bottom: -5px;
|
||||
cursor: sw-resize !important;
|
||||
}
|
||||
|
||||
.ProseMirror [data-resize-handle="top-right"] {
|
||||
right: -5px;
|
||||
top: -5px;
|
||||
cursor: ne-resize !important;
|
||||
}
|
||||
|
||||
.ProseMirror [data-resize-handle="top-left"] {
|
||||
left: -5px;
|
||||
top: -5px;
|
||||
cursor: nw-resize !important;
|
||||
}
|
||||
|
||||
/* 리사이즈 중인 상태를 잡고 싶으면 */
|
||||
.ProseMirror [data-resize-container][data-resize-state="resizing"] {
|
||||
outline: 1px dashed #0ea5e9;
|
||||
}
|
||||
Reference in New Issue
Block a user