Merge pull request '260724_01_ENH: 테이블 스타일 통일, 일부 버그 수정' (#9) from develop into master

Reviewed-on: #9
This commit is contained in:
2026-07-24 14:04:07 +09:00
8 changed files with 224 additions and 190 deletions

View File

@@ -179,11 +179,12 @@ const ProjectAssignPage = () => {
]);
const assignInfoString = useMemo(() => {
const cmpnAssign = companyFilter ? originAssign.filter(u => u.userCmpn === companyFilter) : originAssign;
return roleArray.map(role => {
const cnt = originAssign.filter(u => String(u.userRole) === role.value).length;
const cnt = cmpnAssign.filter(u => String(u.userRole) === role.value).length;
return `${role.label} : ${cnt}`;
}).join(' / ');
}, [roleArray, originAssign]);
}, [roleArray, originAssign, companyFilter]);
const handleAssign = () => {
const toAssign = ableView.filter(u => selectedAbleUser.includes(u.userId));
@@ -216,14 +217,14 @@ const ProjectAssignPage = () => {
// 로그인 계정의 소속 회사를 기본 선택하되, 매치되는 게 없으면 자사(ownCmpn) 중 가장 상단 1개로 대체한다.
useEffect(() => {
const cmpn = auth.user?.userCmpn ?? "";
if (cmpn && companyArray.some((company) => company.cmpnId === cmpn)) {
setCompanyFilter(cmpn);
// 이미 유효한 값이 선택돼 있으면(사용자가 직접 고른 값 포함) 그대로 둔다.
if (companyFilter && companyArray.some((company) => company.cmpnId === companyFilter)) {
return;
}
// 이미 유효한 값이 선택돼 있으면(사용자가 직접 고른 값 포함) 그대로 둔다.
if (companyFilter && companyArray.some((company) => company.cmpnId === companyFilter)) {
const cmpn = auth.user?.userCmpn ?? "";
if (cmpn && companyArray.some((company) => company.cmpnId === cmpn)) {
setCompanyFilter(cmpn);
return;
}

View File

@@ -106,7 +106,7 @@ const MessageProgressPage = () => {
<div className="rounded-md border overflow-hidden">
<table className="w-full text-sm">
<thead className="bg-blue-50">
<thead className="bg-primary text-primary-foreground">
<tr>
<th className="h-10 px-3 text-center font-semibold border-b">유형</th>
<th className="h-10 px-3 text-center font-semibold border-b">단가</th>

View File

@@ -24,6 +24,8 @@ export interface KriAutoCompleteBaseProps<T> {
getLabel?: (item: T) => string
withInfo?: boolean
disabled?: boolean
/** Dialog 안에서 사용될 때 팝오버 스크롤이 막히지 않도록 기본 true (Radix Dialog + non-modal Popover 중첩 스크롤락 이슈 우회) */
modalPopover?: boolean
'aria-invalid'?: boolean
}
@@ -74,6 +76,7 @@ export function KriMultiSelect<T = unknown>({
onItemsChange,
onOptionsChange,
disabled,
modalPopover = true,
'aria-invalid': ariaInvalid,
}: KriMultiSelectProps<T>) {
const options = React.useMemo(
@@ -105,6 +108,7 @@ export function KriMultiSelect<T = unknown>({
resetOnDefaultValueChange
deduplicateOptions
disabled={disabled}
modalPopover={modalPopover}
aria-invalid={ariaInvalid}
/>
</div>
@@ -152,6 +156,7 @@ function KriSingleSelectInner<T>(
clearLabel = '선택 해제',
clearValue = '__CLEAR__',
disabled,
modalPopover = true,
'aria-invalid': ariaInvalid,
}: KriSingleSelectProps<T>,
forwardedRef: React.ForwardedRef<MultiSelectRef>,
@@ -221,6 +226,7 @@ function KriSingleSelectInner<T>(
resetOnDefaultValueChange
deduplicateOptions
disabled={disabled}
modalPopover={modalPopover}
title={showSelectedTooltip ? selectedLabel ?? value : undefined}
aria-invalid={ariaInvalid}
/>

View File

@@ -1,7 +1,7 @@
'use client'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import type { OnChangeFn, PaginationState, Row, RowSelectionState, SortingState } from '@tanstack/react-table'
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
import type { OnChangeFn, PaginationState, Row, RowPinningState, RowSelectionState, SortingState } from '@tanstack/react-table'
import { flexRender, getCoreRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table'
import { ArrowDown, ArrowUp, ArrowUpDown } from 'lucide-react'
import { Button } from '@/components/ui/button'
@@ -12,6 +12,8 @@ import type { DataTableColumn, DataTableProps } from './DataTable.type'
import { DataTablePagination } from './DataTablePagination'
import { usePreventClickOnDrag } from './hooks/usePreventClickOnDrag'
const EMPTY_PINNED_ROWS: never[] = []
export function DataTable<TData, TValue = unknown>({
columns,
data,
@@ -34,11 +36,14 @@ export function DataTable<TData, TValue = unknown>({
emptyText = '데이터가 없습니다.',
className,
maxBodyHeight,
disablePagination = false,
topPinnedRows = EMPTY_PINNED_ROWS,
bottomPinnedRows = EMPTY_PINNED_ROWS,
}: Readonly<DataTableProps<TData, TValue>>) {
const [internalPagination, setInternalPagination] = useState<PaginationState>({ pageIndex: 0, pageSize: defaultPageSize })
const [sorting, setSorting] = useState<SortingState>([])
const [rowSelection, setRowSelection] = useState<RowSelectionState>({})
const containerRef = useRef<HTMLDivElement>(null)
const scrollContainerRef = useRef<HTMLDivElement>(null)
const drag = usePreventClickOnDrag()
const selectionEnabled = selectMode === 'single' || selectMode === 'multi'
@@ -54,7 +59,7 @@ export function DataTable<TData, TValue = unknown>({
aria-label="전체 선택"
/>
) : null,
cell: ({ row }) => (
cell: ({ row }) => row.getIsPinned() ? null : (
<Checkbox
checked={row.getIsSelected()}
onCheckedChange={(value) => {
@@ -95,22 +100,43 @@ export function DataTable<TData, TValue = unknown>({
[isClient, onServerPaginationChange],
)
const combinedData = useMemo(
() => [...topPinnedRows, ...data, ...bottomPinnedRows],
[topPinnedRows, data, bottomPinnedRows],
)
const internalGetRowId = useCallback((row: TData, index: number) => {
if (index < topPinnedRows.length) return `__top-pinned-${index}`
if (index >= topPinnedRows.length + data.length) {
return `__bottom-pinned-${index - topPinnedRows.length - data.length}`
}
const originalIndex = index - topPinnedRows.length
return getRowId ? getRowId(data[originalIndex], originalIndex) : String(originalIndex)
}, [topPinnedRows.length, data, getRowId])
const rowPinning = useMemo<RowPinningState>(() => ({
top: topPinnedRows.map((_, i) => `__top-pinned-${i}`),
bottom: bottomPinnedRows.map((_, i) => `__bottom-pinned-${i}`),
}), [topPinnedRows, bottomPinnedRows])
const table = useReactTable({
data,
data: combinedData,
columns: enhancedColumns,
pageCount: isClient ? undefined : serverPageCount,
state: { sorting, pagination, rowSelection },
enableRowSelection: selectionEnabled,
state: { sorting, pagination, rowSelection, rowPinning },
enableRowSelection: (row) => selectionEnabled && !row.getIsPinned(),
enableRowPinning: true,
keepPinnedRows: true,
onRowSelectionChange: setRowSelection,
onSortingChange: setSorting,
onPaginationChange: handlePaginationChange,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: isClient ? getSortedRowModel() : undefined,
getPaginationRowModel: isClient ? getPaginationRowModel() : undefined,
getPaginationRowModel: isClient && !disablePagination ? getPaginationRowModel() : undefined,
manualPagination: !isClient,
manualSorting: !isClient,
enableSortingRemoval: false,
...(getRowId ? { getRowId } : {}),
getRowId: internalGetRowId,
})
useEffect(() => {
@@ -124,7 +150,7 @@ export function DataTable<TData, TValue = unknown>({
useEffect(() => {
if (!focusRowId) return
const target = containerRef.current?.querySelector<HTMLElement>(`[data-row-id="${CSS.escape(focusRowId)}"]`)
const target = scrollContainerRef.current?.querySelector<HTMLElement>(`[data-row-id="${CSS.escape(focusRowId)}"]`)
target?.scrollIntoView({ behavior: 'smooth', block: 'center' })
}, [focusRowId, data])
@@ -150,15 +176,48 @@ export function DataTable<TData, TValue = unknown>({
const totalCount = isClient ? data.length : (serverTotalCount ?? 0)
const topRows = table.getTopRows()
const centerRows = table.getCenterRows()
const bottomRows = table.getBottomRows()
const [topOffsets, setTopOffsets] = useState<number[]>([])
const [bottomOffsets, setBottomOffsets] = useState<number[]>([])
useLayoutEffect(() => {
if (!maxBodyHeight) return
const container = scrollContainerRef.current
if (!container) return
const headerHeight = container.querySelector('thead')?.getBoundingClientRect().height ?? 0
const bodyRows = Array.from(container.querySelectorAll('tbody > tr'))
const topRowEls = bodyRows.slice(0, topRows.length)
const bottomRowEls = bottomRows.length ? bodyRows.slice(-bottomRows.length) : []
let topAcc = headerHeight
setTopOffsets(topRowEls.map((element) => {
const offset = topAcc
topAcc += element.getBoundingClientRect().height
return offset
}))
let bottomAcc = 0
const offsets: number[] = []
for (let index = bottomRowEls.length - 1; index >= 0; index -= 1) {
offsets[index] = bottomAcc
bottomAcc += bottomRowEls[index].getBoundingClientRect().height
}
setBottomOffsets(offsets)
}, [maxBodyHeight, topRows.length, bottomRows.length, centerRows.length])
return (
<div className={cn('w-full space-y-4', className)}>
<div
ref={containerRef}
ref={scrollContainerRef}
className={cn('relative w-full overflow-x-auto rounded-md border', maxBodyHeight && 'overflow-y-auto')}
style={maxBodyHeight ? { maxHeight: maxBodyHeight } : undefined}
>
<table className="w-full caption-bottom text-sm">
<TableHeader className={cn(maxBodyHeight && 'sticky top-0 z-10 bg-background')}>
<TableHeader className={cn(maxBodyHeight && 'sticky top-0 z-20 bg-background')}>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id} className="hover:bg-transparent">
{headerGroup.headers.map((header) => {
@@ -171,7 +230,7 @@ export function DataTable<TData, TValue = unknown>({
<TableHead
key={header.id}
className={cn(
'text-base font-semibold text-foreground',
'text-base font-semibold bg-primary text-primary-foreground',
column.id === 'actions' && 'w-[140px] text-center',
maxWidth && 'overflow-hidden text-ellipsis',
)}
@@ -181,9 +240,16 @@ export function DataTable<TData, TValue = unknown>({
}}
>
{!header.isPlaceholder && column.getCanSort() ? (
<Button type="button" variant="ghost" className="flex gap-1 px-0 text-base font-semibold" onClick={column.getToggleSortingHandler()}>
<Button
type="button"
variant="ghost"
className={cn(
"flex gap-1 px-0 text-base font-semibold",
)}
onClick={column.getToggleSortingHandler()}
>
<span>{content}</span>
{sorted === 'asc' ? <ArrowUp className="size-3" /> : sorted === 'desc' ? <ArrowDown className="size-3" /> : <ArrowUpDown className="text-muted-foreground size-3" />}
{sorted === 'asc' ? <ArrowUp className="size-3" /> : sorted === 'desc' ? <ArrowDown className="size-3" /> : <ArrowUpDown className="size-3" />}
</Button>
) : content}
</TableHead>
@@ -193,7 +259,19 @@ export function DataTable<TData, TValue = unknown>({
))}
</TableHeader>
<TableBody>
{table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => (
{topRows.map((row, index) => (
<TableRow
key={row.id}
className={cn(
'bg-muted text-base font-semibold [&>td]:px-2 [&>td]:py-1.5',
maxBodyHeight && 'sticky z-10',
)}
style={maxBodyHeight ? { top: topOffsets[index] ?? 0 } : undefined}
>
{row.getVisibleCells().map((cell) => <TableCell key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</TableCell>)}
</TableRow>
))}
{centerRows.length ? centerRows.map((row) => (
<TableRow
key={row.id}
data-row-id={row.id}
@@ -228,17 +306,31 @@ export function DataTable<TData, TValue = unknown>({
)) : (
<TableRow><TableCell colSpan={enhancedColumns.length} className="h-24 text-center">{emptyText}</TableCell></TableRow>
)}
{bottomRows.map((row, index) => (
<TableRow
key={row.id}
className={cn(
'bg-muted text-base font-semibold [&>td]:px-2 [&>td]:py-1.5',
maxBodyHeight && 'sticky z-10',
)}
style={maxBodyHeight ? { bottom: bottomOffsets[index] ?? 0 } : undefined}
>
{row.getVisibleCells().map((cell) => <TableCell key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</TableCell>)}
</TableRow>
))}
</TableBody>
</table>
</div>
<DataTablePagination
table={table}
isClient={isClient}
totalCount={totalCount}
pageSizeOptions={pageSizeOptions}
paginationItemsToDisplay={paginationItemsToDisplay}
/>
{!disablePagination && (
<DataTablePagination
table={table}
isClient={isClient}
totalCount={totalCount}
pageSizeOptions={pageSizeOptions}
paginationItemsToDisplay={paginationItemsToDisplay}
/>
)}
</div>
)
}

View File

@@ -44,4 +44,7 @@ export interface DataTableProps<TData, TValue = unknown> {
emptyText?: string
className?: string
maxBodyHeight?: string
disablePagination?: boolean
topPinnedRows?: TData[]
bottomPinnedRows?: TData[]
}

View File

@@ -191,7 +191,7 @@ const ListHeaderManageDialog = ({
useEffect(() => {
if (!resolvedOpen) return
setLocalRows(rows.map((row) => ({ ...row })))
setLocalRows([...rows].sort((a, b) => a.listHderOrder - b.listHderOrder).map((row) => ({ ...row })))
}, [resolvedOpen, rows])
const handleOpenChange = (nextOpen: boolean) => {

View File

@@ -2,6 +2,8 @@
import { useMemo } from 'react'
import { KriLineChart } from '@/components/chart'
import { DataTable } from '@/components/data-table/DataTable'
import type { DataTableColumn } from '@/components/data-table/DataTable.type'
import type { ProgressDateResponse } from '@/types/progress'
import type { ResultCodeColumn } from './resultCodeColumns'
@@ -35,6 +37,39 @@ export function DateProgressSection({ title, subtitle, rows, resultCodeColumns }
return [totalSeries, ...resultSeries]
}, [sortedRows, resultCodeColumns])
const columns = useMemo<DataTableColumn<ProgressDateResponse>[]>(() => [
{
id: 'contactDate',
header: '일자',
accessorFn: (row) => row.contactDate ?? '-',
cell: ({ getValue }) => <div className="text-center">{getValue<string>()}</div>,
},
{
id: 'startTime',
header: '시작',
accessorFn: (row) => row.startTime ?? '-',
cell: ({ getValue }) => <div className="text-center">{getValue<string>()}</div>,
},
{
id: 'endTime',
header: '종료',
accessorFn: (row) => row.endTime ?? '-',
cell: ({ getValue }) => <div className="text-center">{getValue<string>()}</div>,
},
{
id: 'totalCount',
header: 'Total',
accessorFn: (row) => row.totalCount ?? 0,
cell: ({ getValue }) => <div className="text-center">{getValue<number>().toLocaleString()}</div>,
},
...resultCodeColumns.map(({ resultCd, label }): DataTableColumn<ProgressDateResponse> => ({
id: `rc-${resultCd}`,
header: label,
accessorFn: (row) => row.resultCodeCountMap?.[resultCd] ?? 0,
cell: ({ getValue }) => <div className="text-center">{getValue<number>().toLocaleString()}</div>,
})),
], [resultCodeColumns])
return (
<div className="space-y-3">
<div>
@@ -46,45 +81,13 @@ export function DateProgressSection({ title, subtitle, rows, resultCodeColumns }
<KriLineChart categories={categories} series={series} height={320} />
</div>
<div className="rounded-md border overflow-auto max-h-[320px]">
<table className="w-full text-sm whitespace-nowrap">
<thead className="sticky top-0 z-10 bg-blue-50">
<tr>
<th className="h-9 px-3 text-center font-semibold border-b">일자</th>
<th className="h-9 px-3 text-center font-semibold border-b">시작</th>
<th className="h-9 px-3 text-center font-semibold border-b">종료</th>
<th className="h-9 px-3 text-center font-semibold border-b">Total</th>
{resultCodeColumns.map(({ resultCd, label }) => (
<th key={resultCd} className="h-9 px-3 text-center font-semibold border-b">
{label}
</th>
))}
</tr>
</thead>
<tbody>
{sortedRows.length === 0 && (
<tr>
<td colSpan={4 + resultCodeColumns.length} className="h-16 text-center text-muted-foreground">
데이터가 없습니다.
</td>
</tr>
)}
{sortedRows.map((row, index) => (
<tr key={`${row.contactDate}-${index}`} className="border-b last:border-b-0">
<td className="h-9 px-3 text-center">{row.contactDate ?? '-'}</td>
<td className="h-9 px-3 text-center">{row.startTime ?? '-'}</td>
<td className="h-9 px-3 text-center">{row.endTime ?? '-'}</td>
<td className="h-9 px-3 text-center">{(row.totalCount ?? 0).toLocaleString()}</td>
{resultCodeColumns.map(({ resultCd }) => (
<td key={resultCd} className="h-9 px-3 text-center">
{(row.resultCodeCountMap?.[resultCd] ?? 0).toLocaleString()}
</td>
))}
</tr>
))}
</tbody>
</table>
</div>
<DataTable<ProgressDateResponse>
columns={columns}
data={sortedRows}
getRowId={(row, index) => `${row.contactDate ?? ''}-${index}`}
disablePagination
maxBodyHeight="320px"
/>
</div>
)
}

View File

@@ -1,8 +1,8 @@
'use client'
import { useMemo, useState } from 'react'
import { ArrowDown, ArrowUp, ArrowUpDown } from 'lucide-react'
import { cn } from '@/lib/utils'
import { useMemo } from 'react'
import { DataTable } from '@/components/data-table/DataTable'
import type { DataTableColumn } from '@/components/data-table/DataTable.type'
import type { ProgressUserResponse } from '@/types/progress'
import type { ResultCodeColumn } from './resultCodeColumns'
@@ -14,23 +14,8 @@ export type UserProgressTableProps = {
onSelectUser: (userId: string | null) => void
}
type SortKey = 'userId' | 'totalCount' | `rc-${number}`
type SortState = { key: SortKey; dir: 'asc' | 'desc' } | null
const getSortValue = (row: ProgressUserResponse, key: SortKey, userNameMap: Record<string, string>) => {
if (key === 'userId') return userNameMap[row.userId ?? ''] ?? row.userId ?? ''
if (key === 'totalCount') return row.totalCount ?? 0
const resultCd = Number(key.slice(3))
return row.resultCodeCountMap?.[resultCd] ?? 0
}
const pct = (count: number, total: number) => (total > 0 ? `(${((count / total) * 100).toFixed(1)})` : '(0.0)')
const SortIcon = ({ column, sort }: { column: SortKey; sort: SortState }) => {
if (!sort || sort.key !== column) return <ArrowUpDown className="size-3 text-muted-foreground" />
return sort.dir === 'asc' ? <ArrowUp className="size-3" /> : <ArrowDown className="size-3" />
}
export function UserProgressTable({
rows,
resultCodeColumns,
@@ -38,114 +23,58 @@ export function UserProgressTable({
selectedUserId,
onSelectUser,
}: UserProgressTableProps) {
const [sort, setSort] = useState<SortState>(null)
const total = useMemo(() => {
const totalCount = rows.reduce((acc, row) => acc + (row.totalCount ?? 0), 0)
const resultCodeCountMap: Record<number, number> = {}
const totalRow = useMemo<ProgressUserResponse>(() => {
const resultCodeCountMap: Record<string, number> = {}
resultCodeColumns.forEach(({ resultCd }) => {
resultCodeCountMap[resultCd] = rows.reduce((acc, row) => acc + (row.resultCodeCountMap?.[resultCd] ?? 0), 0)
})
return { totalCount, resultCodeCountMap }
return {
totalCount: rows.reduce((acc, row) => acc + (row.totalCount ?? 0), 0),
resultCodeCountMap,
}
}, [rows, resultCodeColumns])
const sortedRows = useMemo(() => {
if (!sort) return rows
const list = [...rows]
list.sort((a, b) => {
const av = getSortValue(a, sort.key, userNameMap)
const bv = getSortValue(b, sort.key, userNameMap)
const compared = typeof av === 'string' && typeof bv === 'string' ? av.localeCompare(bv, 'ko') : Number(av) - Number(bv)
return sort.dir === 'asc' ? compared : -compared
})
return list
}, [rows, sort, userNameMap])
const toggleSort = (key: SortKey) => {
setSort((prev) => {
if (!prev || prev.key !== key) return { key, dir: 'asc' }
if (prev.dir === 'asc') return { key, dir: 'desc' }
return null
})
}
const headerButtonClass = 'flex items-center gap-1 mx-auto cursor-pointer select-none'
const columns = useMemo<DataTableColumn<ProgressUserResponse>[]>(() => [
{
id: 'userId',
header: '담당자',
accessorFn: (row) => userNameMap[row.userId ?? ''] ?? row.userId ?? '',
cell: ({ row }) => (
<div className="text-center">
{row.getIsPinned() ? 'Total' : (userNameMap[row.original.userId ?? ''] ?? row.original.userId ?? '')}
</div>
),
},
{
id: 'totalCount',
header: 'Total',
accessorFn: (row) => row.totalCount ?? 0,
cell: ({ row }) => <div className="text-center">{(row.original.totalCount ?? 0).toLocaleString()}</div>,
},
...resultCodeColumns.map(({ resultCd, label }): DataTableColumn<ProgressUserResponse> => ({
id: `rc-${resultCd}`,
header: label,
accessorFn: (row) => row.resultCodeCountMap?.[resultCd] ?? 0,
cell: ({ row }) => {
const count = row.original.resultCodeCountMap?.[resultCd] ?? 0
const rowTotal = row.original.totalCount ?? 0
return <div className="text-center">{count.toLocaleString()} {pct(count, rowTotal)}</div>
},
})),
], [resultCodeColumns, userNameMap])
return (
<div className="rounded-md border overflow-auto max-h-[420px]">
<table className="w-full text-sm whitespace-nowrap">
<thead className="sticky top-0 z-20 bg-blue-50">
<tr>
<th className="h-9 px-3 text-center font-semibold border-b">
<button type="button" className={headerButtonClass} onClick={() => toggleSort('userId')}>
담당자 <SortIcon column="userId" sort={sort} />
</button>
</th>
<th className="h-9 px-3 text-center font-semibold border-b">
<button type="button" className={headerButtonClass} onClick={() => toggleSort('totalCount')}>
Total <SortIcon column="totalCount" sort={sort} />
</button>
</th>
{resultCodeColumns.map(({ resultCd, label }) => (
<th key={resultCd} className="h-9 px-3 text-center font-semibold border-b">
<button type="button" className={headerButtonClass} onClick={() => toggleSort(`rc-${resultCd}`)}>
{label} <SortIcon column={`rc-${resultCd}`} sort={sort} />
</button>
</th>
))}
</tr>
</thead>
<tbody>
<tr className="sticky top-9 z-10 bg-gray-100 font-semibold border-b">
<td className="h-9 px-3 text-center">Total</td>
<td className="h-9 px-3 text-center">{total.totalCount.toLocaleString()}</td>
{resultCodeColumns.map(({ resultCd }) => {
const count = total.resultCodeCountMap[resultCd] ?? 0
return (
<td key={resultCd} className="h-9 px-3 text-center">
{count.toLocaleString()} {pct(count, total.totalCount)}
</td>
)
})}
</tr>
{sortedRows.length === 0 && (
<tr>
<td colSpan={2 + resultCodeColumns.length} className="h-16 text-center text-muted-foreground">
데이터가 없습니다.
</td>
</tr>
)}
{sortedRows.map((row) => {
const userId = row.userId ?? ''
const rowTotal = row.totalCount ?? 0
const selected = selectedUserId === userId
return (
<tr
key={userId}
className={cn(
'border-b last:border-b-0 cursor-pointer hover:bg-muted/50',
selected && 'bg-muted font-semibold',
)}
onClick={() => onSelectUser(selected ? null : userId)}
>
<td className="h-9 px-3 text-center">{userNameMap[userId] ?? userId}</td>
<td className="h-9 px-3 text-center">{rowTotal.toLocaleString()}</td>
{resultCodeColumns.map(({ resultCd }) => {
const count = row.resultCodeCountMap?.[resultCd] ?? 0
return (
<td key={resultCd} className="h-9 px-3 text-center">
{count.toLocaleString()} {pct(count, rowTotal)}
</td>
)
})}
</tr>
)
})}
</tbody>
</table>
</div>
<DataTable<ProgressUserResponse>
columns={columns}
data={rows}
getRowId={(row) => row.userId ?? ''}
topPinnedRows={[totalRow]}
disablePagination
maxBodyHeight="420px"
selectMode="click-event"
focusRowId={selectedUserId ?? undefined}
onRowClick={(row) => onSelectUser(selectedUserId === (row.userId ?? '') ? null : (row.userId ?? null))}
/>
)
}