사용자 변경 이력 조회 구현

This commit is contained in:
dohyeons
2025-08-25 18:30:07 +09:00
parent 3027f2c817
commit b43a88a045
6 changed files with 207 additions and 38 deletions

View File

@@ -33,9 +33,10 @@ export function UserHistoryModal({ isOpen, onClose, userId, userName }: UserHist
const [maxPageSize, setMaxPageSize] = useState(1);
// 페이지네이션 정보 계산
const totalPages = Math.ceil(totalItems / pageSize);
const paginationInfo: PaginationInfo = {
currentPage,
totalPages: maxPageSize,
totalPages: totalPages || 1,
totalItems,
itemsPerPage: pageSize,
startItem: totalItems > 0 ? (currentPage - 1) * pageSize + 1 : 0,
@@ -62,14 +63,16 @@ export function UserHistoryModal({ isOpen, onClose, userId, userName }: UserHist
console.log("📊 백엔드 응답:", response);
if (response && response.success && Array.isArray(response.data)) {
// 원본 JSP처럼 No 컬럼을 RM 값으로 설정
const mappedHistoryList = response.data.map((item) => ({
const responseTotal = response.total || 0;
// No 컬럼을 rowNum 값으로 설정 (페이징 고려)
const mappedHistoryList = response.data.map((item, index) => ({
...item,
no: item.RM || 0, // 원본 JSP에서는 RM을 No로 사용
no: item.rowNum || responseTotal - (pageToLoad - 1) * pageSize - index, // rowNum 우선, 없으면 계산
}));
setHistoryList(mappedHistoryList);
setTotalItems(response.total || 0);
setTotalItems(responseTotal);
setMaxPageSize(response.maxPageSize || 1);
} else if (response && response.success && (!response.data || response.data.length === 0)) {
// 데이터가 비어있는 경우
@@ -202,23 +205,23 @@ export function UserHistoryModal({ isOpen, onClose, userId, userName }: UserHist
historyList.map((history, index) => (
<TableRow key={index}>
<TableCell className="text-center font-mono text-sm">{history.no}</TableCell>
<TableCell className="text-center text-sm">{history.SABUN || "-"}</TableCell>
<TableCell className="text-center text-sm">{history.USER_ID || "-"}</TableCell>
<TableCell className="text-center text-sm">{history.USER_NAME || "-"}</TableCell>
<TableCell className="text-center text-sm">{history.DEPT_NAME || "-"}</TableCell>
<TableCell className="text-center text-sm">{history.sabun || "-"}</TableCell>
<TableCell className="text-center text-sm">{history.userId || "-"}</TableCell>
<TableCell className="text-center text-sm">{history.userName || "-"}</TableCell>
<TableCell className="text-center text-sm">{history.deptName || "-"}</TableCell>
<TableCell className="text-center">
<Badge variant={getStatusBadgeVariant(history.STATUS || "")}>
{getStatusText(history.STATUS || "")}
<Badge variant={getStatusBadgeVariant(history.status || "")}>
{getStatusText(history.status || "")}
</Badge>
</TableCell>
<TableCell className="text-center">
<Badge variant={getChangeTypeBadgeVariant(history.HISTORY_TYPE || "")}>
{history.HISTORY_TYPE || "-"}
<Badge variant={getChangeTypeBadgeVariant(history.historyType || "")}>
{history.historyType || "-"}
</Badge>
</TableCell>
<TableCell className="text-center text-sm">{history.WRITER_NAME || "-"}</TableCell>
<TableCell className="text-center text-sm">{history.writerName || "-"}</TableCell>
<TableCell className="text-center text-sm">
{history.REG_DATE_TITLE || formatDate(history.REGDATE || "")}
{history.regDateTitle || formatDate(history.regDate || "")}
</TableCell>
</TableRow>
))

View File

@@ -81,8 +81,8 @@ export function UserTable({ users, isLoading, paginationInfo, onStatusToggle, on
const handleOpenHistoryModal = (user: User) => {
setHistoryModal({
isOpen: true,
userId: user.user_id,
userName: user.user_name || user.user_id,
userId: user.userId,
userName: user.userName || user.userId,
});
};
@@ -178,7 +178,7 @@ export function UserTable({ users, isLoading, paginationInfo, onStatusToggle, on
</TableHeader>
<TableBody>
{users.map((user, index) => (
<TableRow key={`${user.user_id}-${index}`} className="hover:bg-muted/50">
<TableRow key={`${user.userId}-${index}`} className="hover:bg-muted/50">
<TableCell className="font-mono text-sm font-medium">{getRowNumber(index)}</TableCell>
<TableCell className="font-mono text-sm">{user.sabun || "-"}</TableCell>
<TableCell className="font-medium">{user.companyCode || "-"}</TableCell>
@@ -190,7 +190,7 @@ export function UserTable({ users, isLoading, paginationInfo, onStatusToggle, on
<TableCell className="max-w-[200px] truncate" title={user.email}>
{user.email || "-"}
</TableCell>
<TableCell>{formatDate(user.regDate)}</TableCell>
<TableCell>{formatDate(user.regDate || "")}</TableCell>
<TableCell>
<div className="flex items-center gap-2">
<Switch