260714_01_ENH: 테스트 서버에서 기동 후 중간 테스트를 위한 커밋
This commit is contained in:
92
src/components/progress/DateProgressSection.tsx
Normal file
92
src/components/progress/DateProgressSection.tsx
Normal file
@@ -0,0 +1,92 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo } from 'react'
|
||||
import { KriLineChart } from '@/components/chart'
|
||||
import type { ProgressDateResponse } from '@/types/progress'
|
||||
import type { ResultCodeColumn } from './resultCodeColumns'
|
||||
|
||||
export type DateProgressSectionProps = {
|
||||
title: string
|
||||
subtitle: string
|
||||
rows: ProgressDateResponse[]
|
||||
resultCodeColumns: ResultCodeColumn[]
|
||||
}
|
||||
|
||||
export function DateProgressSection({ title, subtitle, rows, resultCodeColumns }: DateProgressSectionProps) {
|
||||
const sortedRows = useMemo(
|
||||
() => [...rows].sort((a, b) => (a.contactDate ?? '').localeCompare(b.contactDate ?? '')),
|
||||
[rows],
|
||||
)
|
||||
|
||||
const categories = useMemo(() => sortedRows.map((row) => row.contactDate ?? ''), [sortedRows])
|
||||
|
||||
const series = useMemo(() => {
|
||||
const totalSeries = {
|
||||
name: 'Total',
|
||||
data: sortedRows.map((row) => row.totalCount ?? 0),
|
||||
option: { type: 'bar' },
|
||||
}
|
||||
|
||||
const resultSeries = resultCodeColumns.map(({ resultCd, label }) => ({
|
||||
name: label,
|
||||
data: sortedRows.map((row) => row.resultCodeCountMap?.[resultCd] ?? 0),
|
||||
}))
|
||||
|
||||
return [totalSeries, ...resultSeries]
|
||||
}, [sortedRows, resultCodeColumns])
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<p className="text-base font-semibold">{title}</p>
|
||||
<p className="text-xs text-muted-foreground">{subtitle}</p>
|
||||
</div>
|
||||
|
||||
<div className="rounded-md border p-2">
|
||||
<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>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default DateProgressSection
|
||||
Reference in New Issue
Block a user