11import React , { useState } from 'react' ;
2- import { Table , Input , Button , Modal , Tooltip , Space , Badge , Spin } from 'antd' ;
3- import { DeleteOutlined , CopyOutlined , SearchOutlined , FlagOutlined } from '@ant-design/icons' ;
2+ import { Button , Modal , Tooltip , Space , Spin , TableColumnsType , Table } from 'antd' ;
3+ import { DeleteOutlined , CopyOutlined , SearchOutlined } from '@ant-design/icons' ;
44import { BlockedPubkey } from '@app/api/blockedPubkeys.api' ;
55import { useModerationStats } from '@app/hooks/useModerationStats' ;
66import * as S from '../BlockedPubkeys.styles' ;
7+ import { createStyledTable } from '../BlockedPubkeys' ;
78
89interface BlockedPubkeysTableProps {
910 blockedPubkeys : BlockedPubkey [ ] ;
1011 loading : boolean ;
1112 onUnblock : ( pubkey : string ) => Promise < void > ;
1213}
13-
14- export const BlockedPubkeysTable : React . FC < BlockedPubkeysTableProps > = ( {
15- blockedPubkeys,
16- loading,
17- onUnblock,
18- } ) => {
14+ const TableRoot = createStyledTable < BlockedPubkey > ( ) ;
15+ export const BlockedPubkeysTable : React . FC < BlockedPubkeysTableProps > = ( { blockedPubkeys, loading, onUnblock } ) => {
1916 const [ searchText , setSearchText ] = useState ( '' ) ;
2017 const [ confirmModalVisible , setConfirmModalVisible ] = useState ( false ) ;
2118 const [ currentPubkey , setCurrentPubkey ] = useState ( '' ) ;
2219 const { getFlagCountsForPubkeys, loading : statsLoading } = useModerationStats ( ) ;
23-
20+
2421 // Get flag counts for all pubkeys in the table
25- const pubkeyFlagCounts = getFlagCountsForPubkeys ( blockedPubkeys . map ( bp => bp . pubkey ) ) ;
22+ const pubkeyFlagCounts = getFlagCountsForPubkeys ( blockedPubkeys . map ( ( bp ) => bp . pubkey ) ) ;
2623
2724 // Handle pubkey copy
2825 const handleCopy = ( pubkey : string ) => {
@@ -43,9 +40,10 @@ export const BlockedPubkeysTable: React.FC<BlockedPubkeysTableProps> = ({
4340 } ;
4441
4542 // Filter pubkeys based on search
46- const filteredPubkeys = blockedPubkeys . filter ( item =>
47- item . pubkey . toLowerCase ( ) . includes ( searchText . toLowerCase ( ) ) ||
48- ( item . reason && item . reason . toLowerCase ( ) . includes ( searchText . toLowerCase ( ) ) )
43+ const filteredPubkeys = blockedPubkeys . filter (
44+ ( item ) =>
45+ item . pubkey . toLowerCase ( ) . includes ( searchText . toLowerCase ( ) ) ||
46+ ( item . reason && item . reason . toLowerCase ( ) . includes ( searchText . toLowerCase ( ) ) ) ,
4947 ) ;
5048
5149 // Format pubkey for display (truncate)
@@ -56,7 +54,7 @@ export const BlockedPubkeysTable: React.FC<BlockedPubkeysTableProps> = ({
5654 return `${ cleanPubkey . substring ( 0 , 6 ) } ...${ cleanPubkey . substring ( cleanPubkey . length - 6 ) } ` ;
5755 } ;
5856
59- const columns = [
57+ const columns : TableColumnsType < BlockedPubkey > = [
6058 {
6159 title : 'Pubkey' ,
6260 dataIndex : 'pubkey' ,
@@ -65,12 +63,7 @@ export const BlockedPubkeysTable: React.FC<BlockedPubkeysTableProps> = ({
6563 < Space >
6664 { formatPubkey ( pubkey ) }
6765 < Tooltip title = "Copy full pubkey" >
68- < Button
69- icon = { < CopyOutlined /> }
70- type = "text"
71- size = "small"
72- onClick = { ( ) => handleCopy ( pubkey ) }
73- />
66+ < Button icon = { < CopyOutlined /> } type = "text" size = "small" onClick = { ( ) => handleCopy ( pubkey ) } />
7467 </ Tooltip >
7568 </ Space >
7669 ) ,
@@ -96,7 +89,7 @@ export const BlockedPubkeysTable: React.FC<BlockedPubkeysTableProps> = ({
9689 { statsLoading ? (
9790 < Spin size = "small" />
9891 ) : (
99- < S . CircularBadge
92+ < S . CircularBadge
10093 color = { count > 10 ? 'var(--error-color)' : count > 5 ? 'var(--warning-color)' : 'var(--primary-color)' }
10194 >
10295 { count }
@@ -105,19 +98,15 @@ export const BlockedPubkeysTable: React.FC<BlockedPubkeysTableProps> = ({
10598 </ S . FlagCountContainer >
10699 ) ;
107100 } ,
108- sorter : ( a : BlockedPubkey , b : BlockedPubkey ) =>
101+ sorter : ( a : BlockedPubkey , b : BlockedPubkey ) =>
109102 ( pubkeyFlagCounts [ a . pubkey ] || 0 ) - ( pubkeyFlagCounts [ b . pubkey ] || 0 ) ,
110103 defaultSortOrder : 'descend' as const ,
111104 } ,
112105 {
113106 title : 'Actions' ,
114107 key : 'actions' ,
115108 render : ( _ : any , record : BlockedPubkey ) => (
116- < Button
117- danger
118- icon = { < DeleteOutlined /> }
119- onClick = { ( ) => showConfirmModal ( record . pubkey ) }
120- >
109+ < Button danger icon = { < DeleteOutlined /> } onClick = { ( ) => showConfirmModal ( record . pubkey ) } >
121110 Unblock
122111 </ Button >
123112 ) ,
@@ -130,14 +119,14 @@ export const BlockedPubkeysTable: React.FC<BlockedPubkeysTableProps> = ({
130119 < S . InputRoot
131120 placeholder = "Search pubkeys or reasons"
132121 value = { searchText }
133- onChange = { e => setSearchText ( e . target . value ) }
122+ onChange = { ( e ) => setSearchText ( e . target . value ) }
134123 prefix = { < SearchOutlined /> }
135124 allowClear
136125 />
137126 </ div >
138127
139128 < S . TableContainer >
140- < S . TableRoot
129+ < TableRoot
141130 dataSource = { filteredPubkeys }
142131 columns = { columns }
143132 rowKey = "pubkey"
@@ -160,7 +149,9 @@ export const BlockedPubkeysTable: React.FC<BlockedPubkeysTableProps> = ({
160149 okButtonProps = { { danger : true } }
161150 >
162151 < p > Are you sure you want to unblock this pubkey?</ p >
163- < p > < strong > { currentPubkey . replace ( 'blocked_pubkey:' , '' ) } </ strong > </ p >
152+ < p >
153+ < strong > { currentPubkey . replace ( 'blocked_pubkey:' , '' ) } </ strong >
154+ </ p >
164155 </ Modal >
165156 </ >
166157 ) ;
0 commit comments