11import React , { FunctionComponent } from 'react' ;
22import fromnow from 'fromnow' ;
3- import { FixedSizeList as List } from 'react-window' ;
4- import AutoSizer from 'react-virtualized-auto-sizer' ;
53
6- import { AwardIcon } from '../../components/ Icons/common' ;
4+ import { AwardIcon } from '../Icons/common' ;
75import { CampaignWithFundings } from '../../services/airtable' ;
86import { truncateString } from '../../utils' ;
97
108interface Props {
119 campaign : CampaignWithFundings ;
1210}
1311
14- const GUTTER_SIZE = 16 ;
15-
1612export const DonorsList : FunctionComponent < Props > = ( { campaign } ) => {
1713 const { fundings } = campaign ;
1814 if ( fundings . length === 0 ) {
@@ -26,44 +22,26 @@ export const DonorsList: FunctionComponent<Props> = ({ campaign }) => {
2622 ) ;
2723 }
2824 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+ ) ) }
6745 </ ul >
6846 ) ;
6947} ;
0 commit comments