1
1
import React , { FunctionComponent } from 'react' ;
2
2
import fromnow from 'fromnow' ;
3
- import { FixedSizeList as List } from 'react-window' ;
4
- import AutoSizer from 'react-virtualized-auto-sizer' ;
5
3
6
- import { AwardIcon } from '../../components/ Icons/common' ;
4
+ import { AwardIcon } from '../Icons/common' ;
7
5
import { CampaignWithFundings } from '../../services/airtable' ;
8
6
import { truncateString } from '../../utils' ;
9
7
10
8
interface Props {
11
9
campaign : CampaignWithFundings ;
12
10
}
13
11
14
- const GUTTER_SIZE = 16 ;
15
-
16
12
export const DonorsList : FunctionComponent < Props > = ( { campaign } ) => {
17
13
const { fundings } = campaign ;
18
14
if ( fundings . length === 0 ) {
@@ -26,44 +22,26 @@ export const DonorsList: FunctionComponent<Props> = ({ campaign }) => {
26
22
) ;
27
23
}
28
24
return (
29
- < ul className = "w-full" style = { { height : 500 } } >
30
- < AutoSizer >
31
- { ( { width, height } ) => (
32
- < List height = { height } itemCount = { fundings . length } itemSize = { 70 } width = { width } >
33
- { ( { index, style } ) => {
34
- const item = fundings [ index ] ;
35
- return (
36
- < li
37
- style = { {
38
- ...style ,
39
- position : 'static' ,
40
- top : Number ( style . top ) + GUTTER_SIZE / 2 ,
41
- height : 'unset' ,
42
- } }
43
- className = "flex items-center bg-white shadow my-4 py-2 rounded-lg" >
44
- < div className = "px-4" >
45
- < AwardIcon />
46
- </ div >
47
- < div className = "flex-1" >
48
- < h6 className = "font-medium text-gray-800" title = { item . name } >
49
- { truncateString ( item . name , 15 ) }
50
- </ h6 >
51
- < p className = "text-xs text-gray-600" >
52
- { fromnow ( new Date ( item . created_at ) , { max : 2 , suffix : true } ) }
53
- </ p >
54
- < p className = "text-xs text-gray-600" > { item . message } </ p >
55
- </ div >
56
- < div className = "px-4" >
57
- < span className = "inline-block bg-green-600 text-xs rounded-full px-3 py-1 text-white" >
58
- ₹ { item . donated_amount }
59
- </ span >
60
- </ div >
61
- </ li >
62
- ) ;
63
- } }
64
- </ List >
65
- ) }
66
- </ AutoSizer >
25
+ < ul className = "w-full overflow-y-scroll" style = { { height : 500 } } >
26
+ { fundings . map ( item => (
27
+ < li key = { item . id } className = "flex items-center bg-white shadow my-4 py-2 rounded-lg" >
28
+ < div className = "px-4" >
29
+ < AwardIcon />
30
+ </ div >
31
+ < div className = "flex-1" >
32
+ < h6 className = "font-medium text-gray-800" title = { item . name } >
33
+ { truncateString ( item . name , 15 ) }
34
+ </ h6 >
35
+ < p className = "text-xs text-gray-600" > { fromnow ( new Date ( item . created_at ) , { max : 2 , suffix : true } ) } </ p >
36
+ < p className = "text-xs text-gray-600" > { item . message } </ p >
37
+ </ div >
38
+ < div className = "px-4" >
39
+ < span className = "inline-block bg-green-600 text-xs rounded-full px-3 py-1 text-white" >
40
+ ₹ { item . donated_amount }
41
+ </ span >
42
+ </ div >
43
+ </ li >
44
+ ) ) }
67
45
</ ul >
68
46
) ;
69
47
} ;
0 commit comments