DividendCalendarTable.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. 'use client';
  2. import DataTable, { DataTableColumn } from '@/components/table/DataTable';
  3. import { DividendCalendarRow, DIVIDEND_SORT_LABEL, DIVIDEND_FIX_LABEL, DIVIDEND_SETTLE_LABEL } from '@/types/seibro';
  4. import { codeLabel } from '@/lib/utils/market';
  5. function buildColumns(): DataTableColumn<DividendCalendarRow>[] {
  6. return [
  7. {
  8. key: 'name',
  9. header: '종목명',
  10. align: 'left',
  11. priority: 'high',
  12. cellClassName: 'data-table__cell--name',
  13. cell: (row) => <span className='stock-cell__name'>{row.name}</span>
  14. },
  15. {
  16. key: 'rgtStdDt',
  17. header: '권리기준일',
  18. align: 'center',
  19. priority: 'high',
  20. cell: (row) => row.rgtStdDt
  21. },
  22. {
  23. key: 'xrgtDt',
  24. header: '권리락일',
  25. align: 'center',
  26. priority: 'medium',
  27. cell: (row) => row.xrgtDt ?? '—'
  28. },
  29. {
  30. key: 'sortCode',
  31. header: '배당구분',
  32. align: 'center',
  33. priority: 'high',
  34. cell: (row) => <span className='market__cls-badge'>{codeLabel(row.sortCode, DIVIDEND_SORT_LABEL)}</span>
  35. },
  36. {
  37. key: 'settleType',
  38. header: '결산',
  39. align: 'center',
  40. priority: 'low',
  41. cell: (row) => codeLabel(row.settleType, DIVIDEND_SETTLE_LABEL)
  42. },
  43. {
  44. key: 'fixType',
  45. header: '확정',
  46. align: 'center',
  47. priority: 'low',
  48. cell: (row) => codeLabel(row.fixType, DIVIDEND_FIX_LABEL)
  49. }
  50. ];
  51. }
  52. export default function DividendCalendarTable({ rows }: { rows: DividendCalendarRow[] })
  53. {
  54. return (
  55. <DataTable<DividendCalendarRow>
  56. caption='배당 캘린더 — 종목명, 권리기준일, 권리락일, 배당구분, 결산, 확정'
  57. columns={buildColumns()}
  58. rows={rows}
  59. rowKey={(row, index) => `${row.issucoCustno}-${row.rgtStdDt}-${row.sortCode}-${index}`}
  60. emptyMessage='표시할 배당 일정이 없습니다.'
  61. />
  62. );
  63. }