251210_01_ENH : 프로젝트 수정, 에디터 구현중
This commit is contained in:
@@ -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]}
|
||||
|
||||
Reference in New Issue
Block a user