260714_01_ENH: 테스트 서버에서 기동 후 중간 테스트를 위한 커밋
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import {useEffect, useState, useCallback, useRef, useMemo} from 'react'
|
||||
import BodyTitle from '@/components/layout/BodyTitle'
|
||||
import AppPageTitle from '@/components/app-shell/AppPageTitle'
|
||||
import {Button} from '@/components/ui/button'
|
||||
import {Input} from '@/components/ui/input'
|
||||
import {Label} from '@/components/ui/label'
|
||||
@@ -12,7 +12,7 @@ import {KriMultiSelect, KriSingleSelect} from '@/components/common/KriAutoComple
|
||||
import {useDialog} from '@/hooks/useDialog'
|
||||
import ResultCodeDialog from '@/components/dialog/ResultCodeDialog'
|
||||
import { useDebouncedValue, useMounted } from "@kri/common/hooks";
|
||||
import {LoadingOverlay} from '@/components/common/LoadingOverlay'
|
||||
import { LoadingOverlayAdapter } from '@/components/app-shell/LoadingOverlayAdapter'
|
||||
import {
|
||||
ProjectInfo, ProjectUpdateRequest, ResultCode,
|
||||
ProjectStatus, ResultCodeType, SurveyType
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
SURVEY_TYPE_LABEL,
|
||||
SURVEY_TYPE_ORDER,
|
||||
} from "@/const/projectConst";
|
||||
import {MultiSelectOption} from "@/components/ui/multi-select";
|
||||
import type { MultiSelectOption } from "@/components/common/KriAutoComplete";
|
||||
import {FW_TEAM} from "@/const/userConst";
|
||||
import {useItrntUserList} from "@/hooks/useItrntUserList";
|
||||
import {useSelectedProject} from "@/hooks/useSelectedProject";
|
||||
@@ -33,12 +33,12 @@ import {useRouter} from "next/navigation";
|
||||
import {
|
||||
useProjectInfoQuery,
|
||||
useResultCodesQuery,
|
||||
useAssignedOutsourceIdsQuery,
|
||||
useAssignedCmpnIdsQuery,
|
||||
useUpdateProjectMutation,
|
||||
useDeleteProjectMutation,
|
||||
useUploadScenarioImageMutation, useKartProjectListQuery,
|
||||
} from "@/query/project";
|
||||
import {useOutsourceUsersQuery} from "@/query/user";
|
||||
import { useCmpnListQuery } from "@/query/cmpn";
|
||||
|
||||
const defaultProjectInfo: ProjectInfo = {
|
||||
prjctIdx: 0,
|
||||
@@ -51,6 +51,7 @@ const defaultProjectInfo: ProjectInfo = {
|
||||
surveyTy: SurveyType.NONE,
|
||||
surveyPrjctCd: '',
|
||||
surveyUrl: '',
|
||||
surveyDashboardUrl: '',
|
||||
ff: false,
|
||||
useContactSenario: false,
|
||||
contactSenario: '',
|
||||
@@ -61,7 +62,7 @@ const defaultProjectInfo: ProjectInfo = {
|
||||
type ExternalTab = 'redirect' | 'api'
|
||||
|
||||
const baseUrl = 'https://kcont.kric.com'
|
||||
const sidParam = 'sid=${$SID}'
|
||||
const sidParam = 'sid=[$SID]'
|
||||
|
||||
const externalUrls = {
|
||||
redirect: {
|
||||
@@ -94,6 +95,7 @@ const ProjectInfoPage = () => {
|
||||
|
||||
const [externalTab, setExternalTab] = useState<ExternalTab>('redirect')
|
||||
const sessionTempUrlsRef = useRef<Set<string>>(new Set());
|
||||
const initialProjectInfoRef = useRef<ProjectInfo | null>(null);
|
||||
|
||||
const userTeam = auth.user?.userTeam ?? "";
|
||||
const prjctIdx = selectedProject?.prjctIdx ?? 0;
|
||||
@@ -107,8 +109,8 @@ const ProjectInfoPage = () => {
|
||||
// 조회 쿼리들
|
||||
const projectInfoQuery = useProjectInfoQuery(prjctIdx, enabled);
|
||||
const resultCodesQuery = useResultCodesQuery(prjctIdx, enabled);
|
||||
const outsourceUsersQuery = useOutsourceUsersQuery(enabled);
|
||||
const assignedOutsourceQuery = useAssignedOutsourceIdsQuery(prjctIdx, enabled);
|
||||
const cmpnListQuery = useCmpnListQuery();
|
||||
const assignedCmpnQuery = useAssignedCmpnIdsQuery(prjctIdx, enabled);
|
||||
|
||||
const kartEnabled =
|
||||
mounted &&
|
||||
@@ -129,16 +131,16 @@ const ProjectInfoPage = () => {
|
||||
const uploadScenarioMutation = useUploadScenarioImageMutation(prjctIdx, projectInfo.prjctCd);
|
||||
|
||||
const [resultCodeArray, setResultCodeArray] = useState<ResultCode[]>([]);
|
||||
const [outsourceUserArray, setOutsourceUserArray] = useState<string[]>([]);
|
||||
const [assignCmpnIdArray, setAssignCmpnIdArray] = useState<string[]>([]);
|
||||
const [changeResultCodeType, setChangeResultCodeType] = useState<ResultCodeType[]>([]);
|
||||
|
||||
const outsourceOptionArray: MultiSelectOption[] = useMemo(() => {
|
||||
const arr = outsourceUsersQuery.data ?? [];
|
||||
return arr.map((u) => ({
|
||||
value: u.userId,
|
||||
label: `${u.userCmpn} / ${u.userName}(${u.userId})`,
|
||||
const cmpnOptionArray: MultiSelectOption[] = useMemo(() => {
|
||||
const arr = cmpnListQuery.data ?? [];
|
||||
return arr.filter((cmpn) => !cmpn.ownCmpn).map((cmpn) => ({
|
||||
value: cmpn.cmpnId,
|
||||
label: cmpn.cmpnAlias || cmpn.cmpnId,
|
||||
}));
|
||||
}, [outsourceUsersQuery.data]);
|
||||
}, [cmpnListQuery.data]);
|
||||
|
||||
|
||||
const surveyProjectArray = kartProjectListQuery.data ?? [];
|
||||
@@ -162,15 +164,15 @@ const ProjectInfoPage = () => {
|
||||
}
|
||||
|
||||
const handleImageUpload = useCallback(
|
||||
async (file: File): Promise<{ url: string }> => {
|
||||
async (file: File): Promise<string> => {
|
||||
if (!projectInfo.prjctCd) {
|
||||
alert("프로젝트 코드가 없습니다. 잠시 후 다시 시도해주세요.");
|
||||
return {url: ""};
|
||||
return "";
|
||||
}
|
||||
|
||||
const url = await uploadScenarioMutation.mutateAsync(file);
|
||||
sessionTempUrlsRef.current.add(url);
|
||||
return {url};
|
||||
return url;
|
||||
},
|
||||
[uploadScenarioMutation, projectInfo.prjctCd]
|
||||
);
|
||||
@@ -192,10 +194,11 @@ const ProjectInfoPage = () => {
|
||||
const requestUpdateProject: ProjectUpdateRequest = {
|
||||
projectInfo: projectInfo,
|
||||
resultCodeList: updateCodeArray,
|
||||
assignUserIdList: outsourceUserArray,
|
||||
assignCmpnIdList: assignCmpnIdArray,
|
||||
}
|
||||
|
||||
await updateMutation.mutateAsync(requestUpdateProject);
|
||||
initialProjectInfoRef.current = projectInfo;
|
||||
alert("저장되었습니다.");
|
||||
}
|
||||
|
||||
@@ -213,6 +216,7 @@ const ProjectInfoPage = () => {
|
||||
useEffect(() => {
|
||||
if (projectInfoQuery.data) {
|
||||
setProjectInfo(projectInfoQuery.data);
|
||||
initialProjectInfoRef.current = projectInfoQuery.data;
|
||||
}
|
||||
}, [projectInfoQuery.data]);
|
||||
|
||||
@@ -223,36 +227,61 @@ const ProjectInfoPage = () => {
|
||||
}, [resultCodesQuery.data]);
|
||||
|
||||
useEffect(() => {
|
||||
if (assignedOutsourceQuery.data) {
|
||||
setOutsourceUserArray(assignedOutsourceQuery.data);
|
||||
if (assignedCmpnQuery.data) {
|
||||
setAssignCmpnIdArray(assignedCmpnQuery.data);
|
||||
}
|
||||
}, [assignedOutsourceQuery.data]);
|
||||
}, [assignedCmpnQuery.data]);
|
||||
|
||||
useEffect(() => {
|
||||
if (projectInfo.surveyTy !== SurveyType.EXTERNAL) {
|
||||
setExternalTab('redirect')
|
||||
}
|
||||
}, [projectInfo.surveyTy]);
|
||||
|
||||
if (projectInfo.surveyPrjctCd && internalSurvey.has(projectInfo.surveyTy || SurveyType.NONE)){
|
||||
let surveyUrl = `/project/${projectInfo.surveyPrjctCd}/INDEX.asp?${sidParam}`;
|
||||
if(projectInfo.surveyTy === SurveyType.KON){
|
||||
// KON/KIWI 프로젝트 "선택"을 사용자가 직접 바꿨을 때만 surveyUrl을 자동 생성한다.
|
||||
// 저장된 프로젝트를 불러오는 경우(조회) 등에는 저장돼 있는 surveyUrl을 그대로 보여줘야 한다.
|
||||
const handleSurveyPrjctCdChange = (value: string) => {
|
||||
setProjectInfo((prev) => {
|
||||
const next = {...prev, surveyPrjctCd: value};
|
||||
|
||||
if (value && internalSurvey.has(prev.surveyTy || SurveyType.NONE)) {
|
||||
let surveyUrl = `/project/${value}/INDEX.asp?${sidParam}`;
|
||||
if (prev.surveyTy === SurveyType.KON) {
|
||||
surveyUrl = `https://kon.kric.com` + surveyUrl
|
||||
}
|
||||
else if(projectInfo.surveyTy === SurveyType.KIWI){
|
||||
} else if (prev.surveyTy === SurveyType.KIWI) {
|
||||
surveyUrl = `https://kon.kiwisurvey.kr` + surveyUrl
|
||||
}
|
||||
|
||||
handleChange('surveyUrl', surveyUrl)
|
||||
next.surveyUrl = surveyUrl;
|
||||
}
|
||||
}
|
||||
}, [projectInfo.surveyTy, projectInfo.surveyPrjctCd]);
|
||||
|
||||
if (!mounted) return <LoadingOverlay force />
|
||||
return next;
|
||||
})
|
||||
}
|
||||
|
||||
// 설문 연동(surveyTy)을 바꾸면 선택된 KON/KIWI 프로젝트, 설문 URL, 설문 대시보드 URL을 초기화한다.
|
||||
// 단, 최초 조회 시점의 surveyTy로 다시 돌아오면 그때 저장돼 있던 값을 복원한다.
|
||||
const handleSurveyTyChange = (value: string) => {
|
||||
const nextSurveyTy = Number(value) as SurveyType;
|
||||
const initial = initialProjectInfoRef.current;
|
||||
const backToInitial = !!initial && initial.surveyTy === nextSurveyTy;
|
||||
|
||||
setProjectInfo((prev) => ({
|
||||
...prev,
|
||||
surveyTy: nextSurveyTy,
|
||||
surveyPrjctCd: backToInitial ? (initial!.surveyPrjctCd ?? '') : '',
|
||||
surveyUrl: backToInitial ? (initial!.surveyUrl ?? '') : '',
|
||||
surveyDashboardUrl: backToInitial ? (initial!.surveyDashboardUrl ?? '') : '',
|
||||
}))
|
||||
}
|
||||
|
||||
if (!mounted) return <LoadingOverlayAdapter force />
|
||||
|
||||
return (
|
||||
<div className="min-h-full">
|
||||
<div className="space-y-6 pb-24 px-6">
|
||||
<div className="max-w-[900px]">
|
||||
<BodyTitle titleText="프로젝트 정보" />
|
||||
<AppPageTitle titleText="프로젝트 정보" />
|
||||
|
||||
{/* 1. 기본 정보 */}
|
||||
<div className="border rounded-lg p-6 space-y-5 bg-white mt-6">
|
||||
@@ -335,9 +364,9 @@ const ProjectInfoPage = () => {
|
||||
<div className="border rounded-lg p-6 space-y-4 bg-white mt-3">
|
||||
<h3 className="text-xl font-semibold">외주사</h3>
|
||||
<KriMultiSelect
|
||||
items={outsourceOptionArray}
|
||||
value={outsourceUserArray}
|
||||
onChange={(value) => setOutsourceUserArray(value)}
|
||||
items={cmpnOptionArray}
|
||||
value={assignCmpnIdArray}
|
||||
onChange={(value) => setAssignCmpnIdArray(value)}
|
||||
getValue={(item) => item.value}
|
||||
getLabel={(item) => item.label}
|
||||
maxCount={2}
|
||||
@@ -352,7 +381,7 @@ const ProjectInfoPage = () => {
|
||||
|
||||
<RadioGroup
|
||||
value={String(projectInfo.surveyTy ?? SurveyType.NONE)}
|
||||
onValueChange={(v) => handleChange('surveyTy', Number(v) as SurveyType)}
|
||||
onValueChange={handleSurveyTyChange}
|
||||
className="flex gap-4"
|
||||
>
|
||||
{SURVEY_TYPE_ORDER.map((t) => {
|
||||
@@ -374,7 +403,7 @@ const ProjectInfoPage = () => {
|
||||
<KriSingleSelect
|
||||
items={surveyProjectArray}
|
||||
value={projectInfo.surveyPrjctCd || ''}
|
||||
onChange={(value) => handleChange('surveyPrjctCd', value)}
|
||||
onChange={handleSurveyPrjctCdChange}
|
||||
getValue={(item) => item.pkey}
|
||||
getLabel={(item) => `[${item.pkey}] ${item.title}`}
|
||||
searchMode={"inputOnly"}
|
||||
@@ -397,6 +426,18 @@ const ProjectInfoPage = () => {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{projectInfo.surveyTy === SurveyType.EXTERNAL && (
|
||||
<div className="space-y-2">
|
||||
<Label className="text-base">설문 대시보드 URL</Label>
|
||||
<Input
|
||||
value={projectInfo.surveyDashboardUrl || ''}
|
||||
onChange={(e) => handleChange('surveyDashboardUrl', e.target.value)}
|
||||
placeholder="https://"
|
||||
className="h-9"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{projectInfo.surveyTy === SurveyType.EXTERNAL && (
|
||||
<div className="space-y-2">
|
||||
<Tabs value={externalTab} onValueChange={(v) => setExternalTab(v as ExternalTab)} className="w-full">
|
||||
@@ -490,7 +531,6 @@ const ProjectInfoPage = () => {
|
||||
{projectInfo.useContactSenario && (
|
||||
<div className="ml-6 border rounded p-4 bg-gray-50 text-sm text-gray-600">
|
||||
<KriEditor
|
||||
//editorMode={"both"}
|
||||
value={projectInfo.contactSenario ?? "<p></p>"}
|
||||
onChange={(html: string) => handleChange("contactSenario", html)}
|
||||
placeholder="컨택 시나리오를 작성해 주세요"
|
||||
|
||||
Reference in New Issue
Block a user