260724_01_ENH: 테이블 스타일 통일, 일부 버그 수정
This commit is contained in:
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user