260714_01_ENH: 테스트 서버에서 기동 후 중간 테스트를 위한 커밋
This commit is contained in:
61
src/components/list-contact/ListUpdateHistoryPanel.tsx
Normal file
61
src/components/list-contact/ListUpdateHistoryPanel.tsx
Normal file
@@ -0,0 +1,61 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo } from 'react'
|
||||
import { useListUpdateHistoryQuery } from '@/query/list'
|
||||
import type { listHeader } from '@/types/list'
|
||||
import CollapsibleHistorySection from '@/components/list-contact/CollapsibleHistorySection'
|
||||
import { formatKst } from '@kri/common'
|
||||
|
||||
export type ListUpdateHistoryPanelProps = {
|
||||
prjctIdx: number
|
||||
sid: string
|
||||
listHeaders: listHeader[]
|
||||
}
|
||||
|
||||
const ListUpdateHistoryPanel = ({ prjctIdx, sid, listHeaders }: ListUpdateHistoryPanelProps) => {
|
||||
const headerNameById = useMemo(
|
||||
() => new Map(listHeaders.map((header) => [header.listHderId, header.listHderNm])),
|
||||
[listHeaders],
|
||||
)
|
||||
const historyQuery = useListUpdateHistoryQuery(prjctIdx, sid, true)
|
||||
const history = historyQuery.data ?? []
|
||||
|
||||
return (
|
||||
<div className="space-y-2 rounded-lg border bg-white p-4">
|
||||
<CollapsibleHistorySection title="수정 이력" showDivider={false}>
|
||||
{historyQuery.isLoading ? (
|
||||
<div className="rounded-md border p-4 text-center text-sm text-muted-foreground">불러오는 중...</div>
|
||||
) : history.length === 0 ? (
|
||||
<div className="rounded-md border p-4 text-center text-sm text-muted-foreground">수정 이력이 없습니다.</div>
|
||||
) : (
|
||||
<div className="max-h-60 overflow-y-auto rounded-md border">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="sticky top-0 bg-muted">
|
||||
<tr>
|
||||
<th className="p-2 text-left">항목</th>
|
||||
<th className="p-2 text-left">변경 전</th>
|
||||
<th className="p-2 text-left">변경 후</th>
|
||||
<th className="p-2 text-left">수정자</th>
|
||||
<th className="p-2 text-left">일시</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{history.map((item) => (
|
||||
<tr key={item.listUpdateHistIdx} className="border-t">
|
||||
<td className="p-2">{headerNameById.get(item.listHderId) ?? item.listHderId}</td>
|
||||
<td className="p-2">{item.beforeVal || '-'}</td>
|
||||
<td className="p-2">{item.afterVal || '-'}</td>
|
||||
<td className="p-2">{item.regUser}</td>
|
||||
<td className="p-2">{formatKst(item.regDt, 'dateHourMin')}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</CollapsibleHistorySection>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ListUpdateHistoryPanel
|
||||
Reference in New Issue
Block a user