251210_01_ENH : 프로젝트 수정, 에디터 구현중
This commit is contained in:
53
src/app/(pages)/(main)/ProjectTableColumn.tsx
Normal file
53
src/app/(pages)/(main)/ProjectTableColumn.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
import {ProjectInfo} from "@/types/project";
|
||||
import {ColumnDef} from "@tanstack/react-table";
|
||||
import {Badge} from "@/components/ui/badge";
|
||||
import {cn, formatKst} from "@/lib/utils";
|
||||
import {PROJECT_STATUS_CLASS, PROJECT_STATUS_LABEL} from "@/const/projectConst";
|
||||
import {ItrntUserInfo} from "@/types/user";
|
||||
|
||||
export const getProjectColumns = (users:ItrntUserInfo[]): ColumnDef<ProjectInfo>[] => [
|
||||
{
|
||||
accessorKey: "prjctIdx",
|
||||
header: "No",
|
||||
enableSorting: true,
|
||||
},
|
||||
{
|
||||
accessorKey: "prjctCd",
|
||||
header: "프로젝트 코드",
|
||||
enableSorting: true,
|
||||
},
|
||||
{
|
||||
accessorKey: "prjctName",
|
||||
header: "프로젝트 명",
|
||||
enableSorting: true,
|
||||
},
|
||||
{
|
||||
accessorKey: "prjctStatus",
|
||||
header: "진행 상태",
|
||||
cell: ({row}) => (
|
||||
<Badge className={cn("w-15 h-7 my-1.5", PROJECT_STATUS_CLASS[row.original.prjctStatus])}>
|
||||
{PROJECT_STATUS_LABEL[row.original.prjctStatus]}
|
||||
</Badge>
|
||||
) ,
|
||||
enableSorting: true,
|
||||
},
|
||||
{
|
||||
accessorKey: "ownerDept",
|
||||
header: "담당 그룹",
|
||||
enableSorting: true,
|
||||
},
|
||||
{
|
||||
accessorKey: "ownerFw",
|
||||
header: "담당 실사",
|
||||
enableSorting: true,
|
||||
cell: ({row}) => (
|
||||
users.find(u => u.userId === row.original.ownerFw)?.userNm ?? ""
|
||||
) ,
|
||||
},
|
||||
{
|
||||
accessorKey: "regDt",
|
||||
header: "등록일",
|
||||
cell: ({row}) => (formatKst(row.original.regDt ?? "", "date")),
|
||||
enableSorting: true,
|
||||
}
|
||||
];
|
||||
@@ -2,17 +2,17 @@ import MainLayout from "@/components/layout/MainLayout";
|
||||
import { cookies } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
import {CookieKeys} from "@/store/cookie/cookie-keys";
|
||||
import commonConst from "@/config/commonConst";
|
||||
import {FONT_SIZE} from "@/const/commonConst";
|
||||
|
||||
function parseFontSize(raw: string | undefined | null) {
|
||||
if (!raw) return commonConst.fontSizeMin;
|
||||
if (!raw) return FONT_SIZE.MIN;
|
||||
|
||||
const parsed = parseInt(raw, 10);
|
||||
if (Number.isNaN(parsed)) return commonConst.fontSizeMin;
|
||||
if (Number.isNaN(parsed)) return FONT_SIZE.MIN;
|
||||
|
||||
return Math.min(
|
||||
commonConst.fontSizeMax,
|
||||
Math.max(commonConst.fontSizeMin, parsed),
|
||||
FONT_SIZE.MAX,
|
||||
Math.max(FONT_SIZE.MIN, parsed),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
"use client";
|
||||
|
||||
import {useFontSizeValue} from "@/hooks/useFontSize";
|
||||
import {useEffect, useState} from "react";
|
||||
import {useMounted} from "@/hooks/useMounted";
|
||||
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
|
||||
import BodyTitle from "@/components/layout/BodyTitle";
|
||||
import {useSelectedProject} from "@/hooks/useSelectedProject";
|
||||
import ProjectTitle from "@/components/layout/ProjectTitle";
|
||||
|
||||
const ListManagePage = () => {
|
||||
const fontSize = useFontSizeValue();
|
||||
const mounted = useMounted();
|
||||
|
||||
const [mounted, setMounted] = useState(false);
|
||||
|
||||
useEffect(() => setMounted(true), []);
|
||||
if (!mounted) return null;
|
||||
if (!mounted) return <LoadingOverlay force />;
|
||||
|
||||
return (
|
||||
<div>
|
||||
This is Manage List Page <span>{fontSize}</span>
|
||||
<div className="space-y-6 content-text-sm">
|
||||
<div>
|
||||
This is Manage List Page <span>{fontSize}</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import {ColumnDef} from "@tanstack/react-table";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Pencil, Trash2} from "lucide-react";
|
||||
import {UserTableInfo} from "@/types/user";
|
||||
import {UserInfo} from "@/types/user";
|
||||
import {formatKst} from "@/lib/utils";
|
||||
import {MultiSelectOption} from "@/components/ui/multi-select";
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +12,7 @@ export type UserColumnsActions = {
|
||||
onDelete: (userId: string) => void
|
||||
}
|
||||
|
||||
export const getUserColumns = (actions: UserColumnsActions): ColumnDef<UserTableInfo>[] => [
|
||||
export const getUserColumns = (actions: UserColumnsActions, userRoleArray:MultiSelectOption[]): ColumnDef<UserInfo>[] => [
|
||||
{
|
||||
accessorKey: "userId",
|
||||
header: "아이디",
|
||||
@@ -29,11 +31,16 @@ export const getUserColumns = (actions: UserColumnsActions): ColumnDef<UserTable
|
||||
{
|
||||
accessorKey: "userRole",
|
||||
header: "권한",
|
||||
cell: ({row}) => {
|
||||
const role = userRoleArray.filter((r) => r.value === String(row.original.userRole));
|
||||
return role.length > 0 ? role[0].label : String(row.original.userRole);
|
||||
},
|
||||
enableSorting: true,
|
||||
},
|
||||
{
|
||||
accessorKey: "regDt",
|
||||
header: "등록일",
|
||||
cell: ({row}) => (formatKst(row.original.regDt ?? "", "date")),
|
||||
enableSorting: true,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
'use client'
|
||||
|
||||
import {useEffect, useState} from "react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Input} from "@/components/ui/input";
|
||||
@@ -7,7 +8,7 @@ import { DataTable } from "@/components/data-table/DataTable";
|
||||
import { getUserColumns } from "./UserTableColumn";
|
||||
import _ from "lodash";
|
||||
import UserUpsertDialog from "@/components/dialog/UserUpsertDialog";
|
||||
import {UserInfo, UserInfoSaveRequest, UserTableInfo, UserUploadResponse} from "@/types/user";
|
||||
import {UserInfo, UserInfoSaveRequest, UserUploadResponse} from "@/types/user";
|
||||
import UserUploadDialog from "@/components/dialog/UserUploadDialog";
|
||||
import {useDialog} from "@/hooks/useDialog";
|
||||
import {downloadBase64File, downloadFile, formatKst} from "@/lib/utils";
|
||||
@@ -17,19 +18,21 @@ import {RoleInfo} from "@/types/role";
|
||||
import {DataVerification} from "@/types/common";
|
||||
import {apiError} from "@/lib/http-util";
|
||||
import {KriMultiSelect} from "@/components/common/KriAutoComplete";
|
||||
import commonConst from "@/config/commonConst";
|
||||
import {useAuth} from "@/hooks/useAuth";
|
||||
import {MultiSelectOption} from "@/components/ui/multi-select";
|
||||
import {useMounted} from "@/hooks/useMounted";
|
||||
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
|
||||
import {DEFAULT_COMPANY_NAME, EXTERNAL_USER_ROLE} from "@/const/userConst";
|
||||
|
||||
const UserManagePage = () => {
|
||||
const { showDialog } = useDialog();
|
||||
const mounted = useMounted();
|
||||
const { withLoadingAsync } = useLoading();
|
||||
const { auth } = useAuth();
|
||||
|
||||
const [mounted, setMounted] = useState(false);
|
||||
const [userList, setUserList] = useState<UserTableInfo[]>([]);
|
||||
const [viewList, setViewList] = useState<UserTableInfo[]>([]);
|
||||
const [selectedUserArray, setSelectedUserArray] = useState<UserTableInfo[]>([]);
|
||||
const [userList, setUserList] = useState<UserInfo[]>([]);
|
||||
const [viewList, setViewList] = useState<UserInfo[]>([]);
|
||||
const [selectedUserArray, setSelectedUserArray] = useState<UserInfo[]>([]);
|
||||
const [userCmpnArray, setUserCmpnArray] = useState<string[]>([]);
|
||||
const [userRoleArray, setUserRoleArray] = useState<MultiSelectOption[]>([]);
|
||||
|
||||
@@ -52,19 +55,7 @@ const UserManagePage = () => {
|
||||
const cmpnList = await nextApi.get<string[]>("/user/cmpn");
|
||||
setUserCmpnArray(cmpnList);
|
||||
|
||||
const userData: UserTableInfo[] = (await nextApi.get<UserInfo[]>("/user")).map((user) => {
|
||||
const role = roleList.filter((r) => r.roleCd === user.userRole);
|
||||
const roleName = role.length > 0 ? role[0].roleNm : String(user.userRole);
|
||||
return {
|
||||
userId: user.userId,
|
||||
userCmpn: user.userCmpn,
|
||||
userName: user.userName,
|
||||
userRole: roleName,
|
||||
regDt: formatKst(user.regDt ?? "", "date"),
|
||||
memo: user.memo ?? "",
|
||||
}
|
||||
});
|
||||
|
||||
const userData = await nextApi.get<UserInfo[]>("/user");
|
||||
setUserList(userData);
|
||||
|
||||
const cmpnArray = Array.from(
|
||||
@@ -159,14 +150,16 @@ const UserManagePage = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const columns = getUserColumns({
|
||||
onEdit: handleEdit,
|
||||
onDelete: handleDelete
|
||||
});
|
||||
const columns = getUserColumns(
|
||||
{
|
||||
onEdit: handleEdit,
|
||||
onDelete: handleDelete
|
||||
},
|
||||
userRoleArray
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
withLoadingAsync(setUserData);
|
||||
setMounted(true);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -183,7 +176,7 @@ const UserManagePage = () => {
|
||||
}
|
||||
|
||||
if(searchRole.length > 0){
|
||||
tempData = tempData.filter((row) => searchRole.includes(row.userRole));
|
||||
tempData = tempData.filter((row) => searchRole.includes(String(row.userRole)));
|
||||
}
|
||||
|
||||
setViewList(tempData);
|
||||
@@ -192,9 +185,11 @@ const UserManagePage = () => {
|
||||
const isInternal =
|
||||
mounted &&
|
||||
auth.user?.userRole != null &&
|
||||
auth.user.userRole < commonConst.externalUserRole
|
||||
auth.user.userRole < EXTERNAL_USER_ROLE
|
||||
|
||||
const userCmpn = auth.user?.userCmpn ?? commonConst.defaultCmpn;
|
||||
const userCmpn = auth.user?.userCmpn ?? DEFAULT_COMPANY_NAME;
|
||||
|
||||
if (!mounted) return <LoadingOverlay force />;
|
||||
|
||||
return (
|
||||
<div className="space-y-6 content-text-sm">
|
||||
@@ -223,7 +218,7 @@ const UserManagePage = () => {
|
||||
items={userRoleArray}
|
||||
value={searchRole}
|
||||
onChange={setSearchRole}
|
||||
getValue={(item) => item.label}
|
||||
getValue={(item) => item.value}
|
||||
getLabel={(item) => item.label}
|
||||
placeholder="사용자 권한"
|
||||
widthClassName="w-70"
|
||||
@@ -250,7 +245,6 @@ const UserManagePage = () => {
|
||||
data={viewList}
|
||||
isClient={true}
|
||||
selectMode='single'
|
||||
enableRowClickSelection={true}
|
||||
onRowSelectionChange={setSelectedUserArray}
|
||||
defaultPageSize={10}
|
||||
pageSizeOptions={[10, 20, 30, 50]}
|
||||
|
||||
@@ -1,8 +1,244 @@
|
||||
const MainPage = () => {
|
||||
//const url = buildUrlWithParams("/login", searchParams, { ref: "root" });
|
||||
//redirect(url);
|
||||
'use client'
|
||||
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 {
|
||||
ProjectCreateRequest,
|
||||
ProjectInfo,
|
||||
ProjectListQuery,
|
||||
ProjectListRequest, ProjectOwnerResponse,
|
||||
} 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 ProjectCreateDialog from "@/components/dialog/ProjectCreateDialog";
|
||||
import {useDialog} from "@/hooks/useDialog";
|
||||
import {useLoading} from "@/hooks/useLoading";
|
||||
import {useAuth} from "@/hooks/useAuth";
|
||||
import {nextApi} from "@/lib/http-client";
|
||||
import {useSelectedProject} from "@/hooks/useSelectedProject";
|
||||
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";
|
||||
|
||||
return (<div>Hello, Next.JS</div>)
|
||||
const MainPage = () => {
|
||||
const { users, isLoading } = useItrntUserList();
|
||||
const { showDialog } = useDialog();
|
||||
const { withLoadingAsync } = useLoading();
|
||||
const mounted = useMounted();
|
||||
const { auth } = useAuth();
|
||||
const { clearSelectedProject, setSelectedProject } = useSelectedProject();
|
||||
|
||||
const [statusArray, setStatusArray] = useState<MultiSelectOption[]>([]);
|
||||
const [deptArray, setDeptArray] = useState<string[]>([]);
|
||||
const [fwArray, setFwArray] = useState<string[]>([]);
|
||||
|
||||
const [searchText, setSearchText] = useState('');
|
||||
const [searchStatus, setSearchStatus] = useState<string[]>([]);
|
||||
const [searchDept, setSearchDept] = useState<string[]>([]);
|
||||
const [searchFw, setSearchFw] = useState<string[]>([]);
|
||||
|
||||
const [pagination, setPagination] = useState<PaginationState>({ pageIndex: 0, pageSize: 10 });
|
||||
const [sorting, setSorting] = useState<SortingState>([]);
|
||||
const [query, setQuery] = useState<ProjectListQuery>();
|
||||
|
||||
const [viewList, setViewList] = useState<ProjectInfo[]>([]);
|
||||
const [pageCount, setPageCount] = useState(0);
|
||||
const [totalCount, setTotalCount] = useState(0);
|
||||
|
||||
const columns = getProjectColumns(users);
|
||||
const userId = auth.user?.userId ?? "";
|
||||
const userRole = auth.user?.userRole ?? FW_USER_ROLE;
|
||||
|
||||
const handleSearchClick = () => {
|
||||
const searchStatusCode:ProjectStatus[] = searchStatus
|
||||
.map((value) => Number(value))
|
||||
.filter((v): v is ProjectStatus => v !== undefined);
|
||||
|
||||
setQuery({
|
||||
prjctText: searchText,
|
||||
prjctStatusList: searchStatusCode,
|
||||
ownerDeptList: searchDept,
|
||||
ownerFwList: searchFw,
|
||||
});
|
||||
|
||||
setPagination(prev => ({ ...prev, pageIndex: 0 }))
|
||||
}
|
||||
|
||||
const handleCreateClick = () => {
|
||||
showDialog('projectCreateDialog');
|
||||
}
|
||||
|
||||
const handleSubmit = async (data:ProjectCreateRequest): Promise<void> => {
|
||||
const projectInfo = await nextApi.put<ProjectInfo>("/project", data);
|
||||
setSelectedProject({
|
||||
prjctIdx: projectInfo.prjctIdx,
|
||||
prjctCd: projectInfo.prjctCd,
|
||||
prjctName: projectInfo.prjctName,
|
||||
ownerDept: projectInfo.ownerDept,
|
||||
ownerFw: projectInfo.ownerFw,
|
||||
} as SelectedProject);
|
||||
|
||||
window.location.href = `/project/info`;
|
||||
}
|
||||
|
||||
const handleClick = (projectInfo:ProjectInfo) => {
|
||||
setSelectedProject({
|
||||
prjctIdx: projectInfo.prjctIdx,
|
||||
prjctCd: projectInfo.prjctCd,
|
||||
prjctName: projectInfo.prjctName,
|
||||
ownerDept: projectInfo.ownerDept,
|
||||
ownerFw: projectInfo.ownerFw,
|
||||
} as SelectedProject);
|
||||
|
||||
window.location.href = `/list/manage`;
|
||||
}
|
||||
|
||||
// 중복 호출 방지(초기 mount에서 pagination/sorting 콜백이 각각 한번씩 날아오는 케이스 방어)
|
||||
const lastReqKeyRef = useRef<string>("");
|
||||
|
||||
useEffect(() => {
|
||||
const reqKey = JSON.stringify({ query, pagination, sorting});
|
||||
if (lastReqKeyRef.current === reqKey) return;
|
||||
lastReqKeyRef.current = reqKey;
|
||||
|
||||
const sort = sorting?.[0];
|
||||
const searchBody: ProjectListRequest = {
|
||||
prjctText: query?.prjctText || "",
|
||||
prjctStatusList: query?.prjctStatusList || [],
|
||||
ownerDeptList: query?.ownerDeptList || [],
|
||||
ownerFwList: query?.ownerFwList || [],
|
||||
pageIndex: pagination.pageIndex,
|
||||
pageSize: pagination.pageSize,
|
||||
sortBy: sort?.id ?? "prjctIdx",
|
||||
sortDir: sort?.desc ? "desc" : "asc"
|
||||
}
|
||||
|
||||
withLoadingAsync(() =>
|
||||
nextApi.post<PageResponse<ProjectInfo>>("/project/list", searchBody)
|
||||
.then((r) => {
|
||||
setViewList(r.content);
|
||||
setTotalCount(r.totalElements);
|
||||
setPageCount(r.totalPages);
|
||||
})
|
||||
.catch(() => {
|
||||
setViewList([]);
|
||||
setTotalCount(0);
|
||||
setPageCount(0);
|
||||
})
|
||||
);
|
||||
|
||||
}, [query, pagination, sorting]);
|
||||
|
||||
useEffect(() => {
|
||||
clearSelectedProject();
|
||||
|
||||
const options: MultiSelectOption[] = Object.entries(ProjectStatus)
|
||||
.sort(([a], [b]) => Number(a) - Number(b))
|
||||
.map(([key, label]) => ({ value: key, label: String(label) }));
|
||||
|
||||
setStatusArray(options);
|
||||
|
||||
nextApi.get<ProjectOwnerResponse>("/project/owner-list")
|
||||
.then((res) => {
|
||||
setDeptArray(res.ownerDeptList);
|
||||
setFwArray(res.ownerFwList);
|
||||
});
|
||||
}, []);
|
||||
|
||||
if (!mounted || isLoading) return <LoadingOverlay force />;
|
||||
|
||||
return (
|
||||
<div className="space-y-6 content-text-sm">
|
||||
<BodyTitle titleText={"프로젝트"}/>
|
||||
|
||||
<div className="flex gap-2 items-center">
|
||||
<div className="flex flex-1 items-center gap-2">
|
||||
<Input
|
||||
placeholder="프로젝트 코드 Or 프로젝트 명"
|
||||
className="w-120 h-9 bg-white"
|
||||
value={searchText}
|
||||
onChange={(e) => setSearchText(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
handleSearchClick();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{
|
||||
userRole < FW_USER_ROLE &&
|
||||
<KriMultiSelect
|
||||
items={statusArray}
|
||||
value={searchStatus}
|
||||
onChange={setSearchStatus}
|
||||
getValue={(item) => item.value}
|
||||
getLabel={(item) => item.label}
|
||||
placeholder="진행 상태"
|
||||
widthClassName="w-60"
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
}
|
||||
<KriMultiSelect
|
||||
items={deptArray}
|
||||
value={searchDept}
|
||||
onChange={setSearchDept}
|
||||
placeholder="담당 그룹"
|
||||
widthClassName="w-60"
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
<KriMultiSelect
|
||||
items={fwArray}
|
||||
value={searchFw}
|
||||
onChange={setSearchFw}
|
||||
placeholder="담당 실사"
|
||||
widthClassName="w-60"
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
<Button
|
||||
className="content-text-lg"
|
||||
onClick={handleSearchClick}
|
||||
>
|
||||
검색
|
||||
</Button>
|
||||
</div>
|
||||
<Button
|
||||
className="content-text-lg"
|
||||
onClick={handleCreateClick}
|
||||
>
|
||||
프로젝트 등록
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-lg border border-gray-200 overflow-hidden">
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={viewList}
|
||||
isClient={false}
|
||||
pageCount={pageCount}
|
||||
totalCount={totalCount}
|
||||
onPaginationChange={setPagination}
|
||||
onSortingChange={setSorting}
|
||||
selectMode='click-event'
|
||||
onRowClick={handleClick}
|
||||
pageSizeOptions={[10, 20, 30, 50]}
|
||||
getRowId={(row) => row.prjctCd} // row.id = userId
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ProjectCreateDialog
|
||||
users={users}
|
||||
ownerFw={userId}
|
||||
onSubmit={handleSubmit}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default MainPage;
|
||||
@@ -1,8 +1,480 @@
|
||||
const ProjectInfoPage = () => {
|
||||
//const url = buildUrlWithParams("/login", searchParams, { ref: "root" });
|
||||
//redirect(url);
|
||||
'use client'
|
||||
|
||||
return (<div>This is Project Info Page</div>)
|
||||
import {useEffect, useState} from 'react'
|
||||
import BodyTitle from '@/components/layout/BodyTitle'
|
||||
import {Button} from '@/components/ui/button'
|
||||
import {Input} from '@/components/ui/input'
|
||||
import {Label} from '@/components/ui/label'
|
||||
import {RadioGroup, RadioGroupItem} from '@/components/ui/radio-group'
|
||||
import {Checkbox} from '@/components/ui/checkbox'
|
||||
import {Tabs, TabsContent, TabsList, TabsTrigger} from '@/components/ui/tabs'
|
||||
import {KriMultiSelect, KriSingleSelect} from '@/components/common/KriAutoComplete'
|
||||
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 {
|
||||
PROJECT_STATUS_LABEL,
|
||||
PROJECT_STATUS_ORDER,
|
||||
ProjectStatus,
|
||||
SURVEY_TYPE_LABEL,
|
||||
SURVEY_TYPE_ORDER,
|
||||
SurveyType
|
||||
} from "@/const/projectConst";
|
||||
import {MultiSelectOption} from "@/components/ui/multi-select";
|
||||
import {FW_TEAM} from "@/const/userConst";
|
||||
import {useItrntUserList} from "@/hooks/useItrntUserList";
|
||||
import {nextApi} from "@/lib/http-client";
|
||||
import {useSelectedProject} from "@/hooks/useSelectedProject";
|
||||
import {UserInfo} from "@/types/user";
|
||||
import {useDebouncedValue} from "@/hooks/useDebouncedValue";
|
||||
import {useAuth} from "@/hooks/useAuth";
|
||||
import {KriEditor} from "@/components/kri-editor";
|
||||
|
||||
|
||||
const defaultProjectInfo: Partial<ProjectInfo> = {
|
||||
prjctCd: '',
|
||||
prjctName: '',
|
||||
prjctStatus: 0,
|
||||
ownerDept: '',
|
||||
ownerFw: '',
|
||||
surveyTy: 0,
|
||||
surveyPrjctCd: '',
|
||||
surveyUrl: '',
|
||||
ff: false,
|
||||
useContactSenario: false,
|
||||
contactSenario: '',
|
||||
}
|
||||
|
||||
export default ProjectInfoPage;
|
||||
type ExternalTab = 'redirect' | 'api'
|
||||
|
||||
const ProjectInfoPage = () => {
|
||||
const mounted = useMounted();
|
||||
const { selectedProject } = useSelectedProject();
|
||||
const { isDialogOpen, showDialog, hideDialog } = useDialog();
|
||||
const { users, isLoading } = useItrntUserList();
|
||||
const { auth } = useAuth();
|
||||
|
||||
const [projectInfo, setProjectInfo] = useState<Partial<ProjectInfo>>(defaultProjectInfo);
|
||||
const [outsourceUserArray, setOutsourceUserArray] = useState<string[]>([]);
|
||||
|
||||
const [outsourceOptionArray, setOutsourceOptionArray] = useState<MultiSelectOption[]>([]);
|
||||
const [deptArray, setDeptArray] = useState<string[]>([]);
|
||||
const [fwArray, setFwArray] = useState<MultiSelectOption[]>([]);
|
||||
|
||||
const [surveyKeyword, setSurveyKeyword] = useState('');
|
||||
const debouncedKeyword = useDebouncedValue(surveyKeyword, 500);
|
||||
const [surveyProjectArray, setSurveyProjectArray] = useState<KonKiwiProjectInfo[]>([]);
|
||||
|
||||
const [externalTab, setExternalTab] = useState<ExternalTab>('redirect')
|
||||
|
||||
const internalSurvey = [SurveyType.KON, SurveyType.KIWI];
|
||||
const baseUrl = 'https://kcont.kric.com'
|
||||
const sidParam = 'sid=${$SID}'
|
||||
|
||||
const externalUrls = {
|
||||
redirect: {
|
||||
start: `${baseUrl}/redirect/start?${sidParam}`,
|
||||
complete: `${baseUrl}/redirect/complete?${sidParam}`,
|
||||
screen: `${baseUrl}/redirect/screen?${sidParam}`,
|
||||
quota: `${baseUrl}/redirect/quota?${sidParam}`,
|
||||
},
|
||||
api: {
|
||||
start: `${baseUrl}/api/external/start?${sidParam}`,
|
||||
complete: `${baseUrl}/api/external/complete?${sidParam}`,
|
||||
screen: `${baseUrl}/api/external/screen?${sidParam}`,
|
||||
quota: `${baseUrl}/api/external/quota?${sidParam}`,
|
||||
},
|
||||
} as const
|
||||
|
||||
const userTeam = auth.user?.userTeam ?? "";
|
||||
|
||||
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[]>(
|
||||
`/kart/project-list/${projectInfo.itrntPrjctCd}/${userTeam}/${isKiwi}`,
|
||||
{ query: keyword ? { keyword } : {} }
|
||||
);
|
||||
|
||||
setSurveyProjectArray(res);
|
||||
}
|
||||
}
|
||||
|
||||
const handleChange = (field: keyof ProjectInfo, value: any) => {
|
||||
setProjectInfo((prev) => ({ ...prev, [field]: value }))
|
||||
}
|
||||
|
||||
const handleResultCodeClick = () => {
|
||||
showDialog('resultCodeDialog')
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!projectInfo.prjctName) {
|
||||
alert('프로젝트명을 입력해주세요.')
|
||||
return
|
||||
}
|
||||
// TODO: 저장 API
|
||||
}
|
||||
|
||||
const handleDeleteClick = async () => {
|
||||
if (confirm('복구 할 수 없습니다. 정말 삭제 하시겠습니까?')) {
|
||||
if(!selectedProject){
|
||||
alert("옳지 않은 요청입니다.");
|
||||
}
|
||||
else{
|
||||
await nextApi.del(`/project/${selectedProject.prjctIdx}`)
|
||||
}
|
||||
|
||||
window.location.href = `/`;
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if(selectedProject){
|
||||
nextApi.get<ProjectInfo>(`/project/info/${selectedProject.prjctIdx}`)
|
||||
.then((res) => { setProjectInfo(res)});
|
||||
|
||||
nextApi.get<UserInfo[]>(`/user/outsource`)
|
||||
.then((res) => {
|
||||
const outsourceOptions: MultiSelectOption[] = res
|
||||
.map(u => ({
|
||||
value: u.userId,
|
||||
label: `${u.userCmpn} / ${u.userName}(${u.userId})`,
|
||||
}));
|
||||
setOutsourceOptionArray(outsourceOptions)
|
||||
});
|
||||
|
||||
nextApi.get<string[]>(`/assign/prjct-outsource/${selectedProject.prjctIdx}`)
|
||||
.then((res) => setOutsourceUserArray(res));
|
||||
}
|
||||
}, [selectedProject])
|
||||
|
||||
useEffect(() => {
|
||||
if (projectInfo.surveyTy !== SurveyType.EXTERNAL) {
|
||||
setExternalTab('redirect')
|
||||
|
||||
if(projectInfo.surveyPrjctCd && internalSurvey.includes(projectInfo.surveyTy || SurveyType.NONE)){
|
||||
let surveyUrl = `/project/${projectInfo.surveyPrjctCd}/INDEX.asp?${sidParam}`;
|
||||
if(projectInfo.surveyTy === SurveyType.KON){
|
||||
surveyUrl = `https://kon.kric.com` + surveyUrl
|
||||
}
|
||||
else if(projectInfo.surveyTy === SurveyType.KIWI){
|
||||
surveyUrl = `https://kon.kiwisurvey.kr` + surveyUrl
|
||||
}
|
||||
|
||||
handleChange('surveyUrl', surveyUrl)
|
||||
}
|
||||
}
|
||||
}, [projectInfo.surveyTy, projectInfo.surveyPrjctCd])
|
||||
|
||||
useEffect(() => {
|
||||
let userTeams = Array.from(new Set(users.map(u => u.userTeam)));
|
||||
if(!userTeams.includes("T900")){ //TFT
|
||||
userTeams.push("T900");
|
||||
}
|
||||
userTeams = userTeams.sort((a, b) => a.localeCompare(b, "ko"));
|
||||
setDeptArray(userTeams);
|
||||
}, [users]);
|
||||
|
||||
useEffect(() => {
|
||||
const userOptions: MultiSelectOption[] = users
|
||||
.filter(u => u.userId == projectInfo.ownerFw || u.userTeam == FW_TEAM)
|
||||
.map(u => ({
|
||||
value: u.userId,
|
||||
label: u.userNm,
|
||||
}));
|
||||
setFwArray(userOptions);
|
||||
}, [users, projectInfo.ownerFw]);
|
||||
|
||||
useEffect(() => {
|
||||
const keyword = debouncedKeyword.trim();
|
||||
searchKonKiwiPrjct(keyword).then();
|
||||
}, [debouncedKeyword, projectInfo.surveyTy, userTeam]);
|
||||
|
||||
|
||||
if (!mounted) return <LoadingOverlay force />
|
||||
|
||||
return (
|
||||
<div className="min-h-full">
|
||||
<div className="space-y-6 pb-24 px-6">
|
||||
<div className="max-w-[900px]">
|
||||
<BodyTitle titleText="프로젝트 정보" />
|
||||
|
||||
{/* 1. 기본 정보 */}
|
||||
<div className="border rounded-lg p-6 space-y-5 bg-white mt-6">
|
||||
<h3 className="content-text-xl font-semibold">프로젝트 기본 정보</h3>
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label className="content-text-base">프로젝트 코드</Label>
|
||||
<Input value={projectInfo.prjctCd || ''} disabled className="bg-gray-100 h-9" />
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-[1fr_auto] gap-3 items-end">
|
||||
<div className="space-y-2">
|
||||
<Label className="content-text-base">진행 상태</Label>
|
||||
<RadioGroup
|
||||
value={String(projectInfo.prjctStatus ?? ProjectStatus.WAITING)}
|
||||
onValueChange={(v) => handleChange('prjctStatus', Number(v) as ProjectStatus)}
|
||||
className="flex gap-4"
|
||||
>
|
||||
{PROJECT_STATUS_ORDER.map((s) => {
|
||||
const id = `status-${s}`;
|
||||
return (
|
||||
<div key={s} className="flex items-center space-x-2">
|
||||
<RadioGroupItem value={String(s)} id={id} />
|
||||
<Label htmlFor={id} className="font-normal cursor-pointer content-text-base">
|
||||
{PROJECT_STATUS_LABEL[s]}
|
||||
</Label>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</RadioGroup>
|
||||
</div>
|
||||
|
||||
<Button onClick={handleResultCodeClick} className="h-9 content-text-base whitespace-nowrap">
|
||||
결과 코드 설정
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label className="content-text-base">
|
||||
프로젝트 명<span className="text-red-500 ml-1">*</span>
|
||||
</Label>
|
||||
<Input
|
||||
value={projectInfo.prjctName || ''}
|
||||
onChange={(e) => handleChange('prjctName', e.target.value)}
|
||||
placeholder="프로젝트명을 입력하세요"
|
||||
className="h-9"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label className="content-text-base">담당 그룹</Label>
|
||||
<KriSingleSelect
|
||||
items={deptArray}
|
||||
value={projectInfo.ownerDept || ''}
|
||||
onChange={(value) => handleChange('ownerDept', value)}
|
||||
placeholder="담당 그룹을 선택하세요"
|
||||
heightClassName="h-9"
|
||||
widthClassName="w-full"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label className="content-text-base">담당 실사</Label>
|
||||
<KriSingleSelect
|
||||
items={fwArray}
|
||||
value={projectInfo.ownerFw || ''}
|
||||
onChange={(value) => handleChange('ownerFw', value)}
|
||||
getValue={(item) => item.value}
|
||||
getLabel={(item) => item.label}
|
||||
placeholder="담당 실사를 선택하세요"
|
||||
heightClassName="h-9"
|
||||
widthClassName="w-full"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="border rounded-lg p-6 space-y-4 bg-white mt-3">
|
||||
<h3 className="content-text-xl font-semibold">외주사</h3>
|
||||
<KriMultiSelect
|
||||
items={outsourceOptionArray}
|
||||
value={outsourceUserArray}
|
||||
onChange={(value) => console.log(value)}
|
||||
getValue={(item) => item.value}
|
||||
getLabel={(item) => item.label}
|
||||
placeholder="없음"
|
||||
heightClassName="h-9"
|
||||
widthClassName="w-full"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="border rounded-lg p-6 space-y-4 bg-white mt-3">
|
||||
<h3 className="content-text-xl font-semibold">설문 연동</h3>
|
||||
|
||||
<RadioGroup
|
||||
value={String(projectInfo.surveyTy ?? SurveyType.NONE)}
|
||||
onValueChange={(v) => handleChange('surveyTy', Number(v) as SurveyType)}
|
||||
className="flex gap-4"
|
||||
>
|
||||
{SURVEY_TYPE_ORDER.map((t) => {
|
||||
const id = `survey-${t}`; // 유니크 보장
|
||||
return (
|
||||
<div key={t} className="flex items-center space-x-2">
|
||||
<RadioGroupItem value={String(t)} id={id} />
|
||||
<Label htmlFor={id} className="font-normal cursor-pointer content-text-base">
|
||||
{SURVEY_TYPE_LABEL[t]}
|
||||
</Label>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</RadioGroup>
|
||||
|
||||
{(projectInfo.surveyTy === SurveyType.KON || projectInfo.surveyTy === SurveyType.KIWI) && (
|
||||
<div className="space-y-2">
|
||||
<Label className="content-text-base">{SURVEY_TYPE_LABEL[projectInfo.surveyTy]} 프로젝트</Label>
|
||||
<KriSingleSelect
|
||||
items={surveyProjectArray}
|
||||
value={projectInfo.surveyPrjctCd || ''}
|
||||
onChange={(value) => handleChange('surveyPrjctCd', value)}
|
||||
getValue={(item) => item.pkey}
|
||||
getLabel={(item) => `[${item.pkey}] ${item.title}`}
|
||||
searchMode={"inputOnly"}
|
||||
onSearchValueChange={setSurveyKeyword}
|
||||
placeholder="프로젝트를 선택하세요"
|
||||
heightClassName="h-9"
|
||||
widthClassName="w-full"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{projectInfo.surveyTy !== SurveyType.NONE && (
|
||||
<div className="space-y-2">
|
||||
<Label className="content-text-base">설문 URL</Label>
|
||||
<Input
|
||||
value={projectInfo.surveyUrl || ''}
|
||||
onChange={(e) => handleChange('surveyUrl', 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">
|
||||
<TabsList className="grid w-full grid-cols-2">
|
||||
<TabsTrigger value="redirect">리다이렉트</TabsTrigger>
|
||||
<TabsTrigger value="api">API</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="redirect" className="mt-4">
|
||||
<div className="border rounded-lg p-4 space-y-3 bg-gray-50">
|
||||
<div className="font-semibold">리다이렉트 URL</div>
|
||||
|
||||
<div className="grid gap-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 content-text-base">시작:</Label>
|
||||
<Input value={externalUrls.redirect.start} disabled className="bg-white h-9" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 content-text-base">완료:</Label>
|
||||
<Input value={externalUrls.redirect.complete} disabled className="bg-white h-9" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 content-text-base">스크린 아웃:</Label>
|
||||
<Input value={externalUrls.redirect.screen} disabled className="bg-white h-9" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 content-text-base">쿼터 풀:</Label>
|
||||
<Input value={externalUrls.redirect.quota} disabled className="bg-white h-9" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="api" className="mt-4">
|
||||
<div className="border rounded-lg p-4 space-y-3 bg-gray-50">
|
||||
<div className="font-semibold">API URL</div>
|
||||
|
||||
<div className="grid gap-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 content-text-base">시작 API:</Label>
|
||||
<Input value={externalUrls.api.start} disabled className="bg-white h-9" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 content-text-base">완료 API:</Label>
|
||||
<Input value={externalUrls.api.complete} disabled className="bg-white h-9" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 content-text-base">스크린 API:</Label>
|
||||
<Input value={externalUrls.api.screen} disabled className="bg-white h-9" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 content-text-base">쿼터 API:</Label>
|
||||
<Input value={externalUrls.api.quota} disabled className="bg-white h-9" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p className="text-xs text-muted-foreground">API Method는 Post를 사용하시면 됩니다.</p>
|
||||
</div>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="border rounded-lg p-6 space-y-4 bg-white mt-3">
|
||||
<h3 className="content-text-xl font-semibold">기타 옵션</h3>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
id="ff"
|
||||
checked={projectInfo.ff || false}
|
||||
onCheckedChange={(checked) => handleChange('ff', checked === true)}
|
||||
/>
|
||||
<Label htmlFor="ff" className="font-normal cursor-pointer content-text-base">
|
||||
현장 면접 진행
|
||||
</Label>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
id="useContactSenario"
|
||||
checked={projectInfo.useContactSenario || false}
|
||||
onCheckedChange={(checked) => handleChange('useContactSenario', checked === true)}
|
||||
/>
|
||||
<Label htmlFor="useContactSenario" className="font-normal cursor-pointer content-text-base">
|
||||
컨택 시나리오
|
||||
</Label>
|
||||
</div>
|
||||
|
||||
{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)}}
|
||||
placeholder="컨택 시나리오를 작성해 주세요"
|
||||
className="w-full"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="fixed left-0 right-0 bottom-0 z-[20] border-t bg-white/80 backdrop-blur shadow-sm">
|
||||
<div className="px-6 py-3">
|
||||
<div className="max-w-[836px] ml-0">
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button
|
||||
variant="destructive"
|
||||
className="w-32 h-10 content-text-base"
|
||||
onClick={handleDeleteClick}
|
||||
>
|
||||
삭제
|
||||
</Button>
|
||||
<Button onClick={handleSubmit} className="w-32 h-10 content-text-base">
|
||||
저장
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ResultCodeDialog
|
||||
open={isDialogOpen('resultCodeDialog')}
|
||||
onOpenChange={(open) => (open ? showDialog('resultCodeDialog') : hideDialog('resultCodeDialog'))}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ProjectInfoPage
|
||||
|
||||
@@ -5,7 +5,7 @@ import {Button} from "@/components/ui/button";
|
||||
import {Card, CardContent, CardHeader} from "@/components/ui/card";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import React, {useEffect, useRef, useState} from "react";
|
||||
import {HttpError, nextApi} from "@/lib/http-client";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import {useRouter, useSearchParams} from "next/navigation";
|
||||
import {LoginUser} from "@/types/auth";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
@@ -13,7 +13,7 @@ import { useLoading } from "@/hooks/useLoading";
|
||||
import { useStorage } from "@/hooks/useStorage"
|
||||
import { StorageKeys } from "@/store/storage/storage-keys";
|
||||
import {apiError} from "@/lib/http-util";
|
||||
import commonConst from "@/config/commonConst";
|
||||
import {NONE_HTTP_ERROR} from "@/const/commonConst";
|
||||
|
||||
const LoginPage = () => {
|
||||
const router = useRouter();
|
||||
@@ -71,7 +71,7 @@ const LoginPage = () => {
|
||||
if (err.status === 401 || err.status === 403) {
|
||||
setError("아이디 또는 비밀번호를 다시 확인해주세요.");
|
||||
}
|
||||
else if(err.code === commonConst.noneHttpError) {
|
||||
else if(err.code === NONE_HTTP_ERROR) {
|
||||
setError("알 수 없는 오류가 발생했습니다. 잠시 후 다시 시도해주세요.");
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -24,7 +24,10 @@ const LogoutPage = () => {
|
||||
logout();
|
||||
|
||||
try {
|
||||
await nextApi.post(`/logout/${userId}`);
|
||||
if(userId !== ""){
|
||||
const logoutRequestOptions = {autoLogoutOnAuthError: false};
|
||||
await nextApi.post(`/logout/${userId}`, null, logoutRequestOptions);
|
||||
}
|
||||
} catch (e) {
|
||||
const err = apiError(e);
|
||||
console.error(err.status, err.code, err.message);
|
||||
|
||||
46
src/app/api/assign/[[...slug]]/route.ts
Normal file
46
src/app/api/assign/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {DataVerification, RouteContext} from "@/types/common";
|
||||
import {createContactApi} from "@/lib/server-api";
|
||||
import {UserInfo, UserUploadResponse} from "@/types/user";
|
||||
import {errorToResponse} from "@/lib/http-util";
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (action === "prjct-outsource") {
|
||||
const result = await contactApi.get<string[]>(`/assign/prjct-outsource/${slug[1]}`);
|
||||
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 { 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);
|
||||
}
|
||||
}
|
||||
1
src/app/api/external/[[...slug]]/route.ts
vendored
Normal file
1
src/app/api/external/[[...slug]]/route.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
//외부 설문에 뎐동 되는 API
|
||||
35
src/app/api/intranet/[[...slug]]/route.ts
Normal file
35
src/app/api/intranet/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createContactApi, createIntranetApi} from "@/lib/server-api";
|
||||
import {IntranetProjectSearchResponse, ProjectInfo, ProjectOwnerResponse} from "@/types/project";
|
||||
import {errorToResponse} from "@/lib/http-util";
|
||||
import {ItrntUserInfo} from "@/types/user";
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const {slug = []} = await context.params;
|
||||
const [action] = slug;
|
||||
const itrntApi = await createIntranetApi();
|
||||
|
||||
if(action === "project"){
|
||||
const keyword = (searchParams.get("keyword") ?? "").trim();
|
||||
const result = await itrntApi.get<IntranetProjectSearchResponse[]>(
|
||||
`/project/search/top10`,
|
||||
{ query: keyword ? { keyword } : {} }
|
||||
);
|
||||
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "user-list"){
|
||||
const result = await itrntApi.get<ItrntUserInfo[]>(`/user/list`);
|
||||
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
28
src/app/api/kart/[[...slug]]/route.ts
Normal file
28
src/app/api/kart/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createKartApi} from "@/lib/server-api";
|
||||
import {KonKiwiProjectInfo} 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 kartApi = await createKartApi();
|
||||
|
||||
if(action === "project-list" && slug.length === 4){
|
||||
const keyword = (searchParams.get("keyword") ?? "").trim();
|
||||
const result = await kartApi.get<KonKiwiProjectInfo[]>(
|
||||
`/project/list/${slug[1]}/${slug[2]}/${slug[3]}`,
|
||||
{ query: keyword ? { keyword } : {} }
|
||||
);
|
||||
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
@@ -19,7 +19,6 @@ export async function POST(
|
||||
: "/auth/logout/";
|
||||
|
||||
await contactApi.post<boolean>(url);
|
||||
|
||||
const res = NextResponse.json({ ok: true });
|
||||
|
||||
res.cookies.set("access_token", "", {
|
||||
|
||||
@@ -1,15 +1,38 @@
|
||||
import {NextRequest} from "next/server";
|
||||
import {createContactApi} from "@/lib/server-api";
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {createContactApi, createIntranetApi} from "@/lib/server-api";
|
||||
import {errorToResponse} from "@/lib/http-util";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {PageResponse, RouteContext} from "@/types/common";
|
||||
import {IntranetProjectSearchResponse, ProjectInfo, ProjectOwnerResponse} from "@/types/project";
|
||||
|
||||
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(action === "owner-list"){
|
||||
const result = await contactApi.get<ProjectOwnerResponse>("/project/owner-list");
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "top"){
|
||||
const keyword = (searchParams.get("keyword") ?? "").trim();
|
||||
const result = await contactApi.get<ProjectInfo[]>(
|
||||
`/project/top/${slug[1]}`,
|
||||
{ query: keyword ? { keyword } : {} }
|
||||
);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "info"){
|
||||
const result = await contactApi.get<ProjectInfo>(
|
||||
`/project/${slug[1]}`,
|
||||
);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
@@ -21,7 +44,20 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if(action === "list"){
|
||||
const body = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json(
|
||||
{ message: "요청 바디가 없습니다." },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
const result = await contactApi.post<PageResponse<ProjectInfo>>("/project/list", body);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
@@ -33,7 +69,20 @@ export const PUT = async (req: NextRequest, context: RouteContext) => {
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if(!action){
|
||||
const body = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json(
|
||||
{ message: "요청 바디가 없습니다." },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
const result = await contactApi.put("/project", body);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
@@ -45,7 +94,7 @@ export const PATCH = async (req: NextRequest, context: RouteContext) => {
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
@@ -57,7 +106,12 @@ export const DELETE = async (req: NextRequest, context: RouteContext) => {
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if(slug.length === 1){
|
||||
await contactApi.del<void>(`/project/${slug[0]}`);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (!action) {
|
||||
const result = await contactApi.get<UserInfo[]>("/user");
|
||||
if(action === "outsource"){
|
||||
const result = await contactApi.get<UserInfo[]>("/user/outsource");
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
@@ -41,6 +41,11 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (!action) {
|
||||
const result = await contactApi.get<UserInfo[]>("/user");
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
|
||||
import {Geist, Geist_Mono} from "next/font/google";
|
||||
import { AppProvider } from "@/components/providers/AppProvider";
|
||||
import "./globals.css";
|
||||
import {Toaster} from "sonner";
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
@@ -25,6 +26,7 @@ const RootLayout = ({ children }: { children: React.ReactNode}) => {
|
||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||
>
|
||||
<AppProvider>{children}</AppProvider>
|
||||
<Toaster />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user