@@ -28,7 +28,6 @@ export function ViewContributionHistoryPage() {
28
28
const chainIds = getChains ( ) . map ( ( chain ) => chain . id ) ;
29
29
30
30
const { data : ensResolvedAddress } = useEnsAddress ( {
31
- /* If params.address is actually an address, don't resolve the ens address for it*/
32
31
name : isAddress ( params . address ?? "" ) ? undefined : params . address ,
33
32
chainId : 1 ,
34
33
} ) ;
@@ -92,7 +91,7 @@ function ViewContributionHistoryFetcher(props: {
92
91
} else if ( contributionHistory . type === "error" ) {
93
92
console . error ( "Error" , contributionHistory ) ;
94
93
return (
95
- < ViewContributionHistoryWithoutDonations
94
+ < ViewNoHistory
96
95
address = { props . address }
97
96
addressLogo = { addressLogo }
98
97
breadCrumbs = { breadCrumbs }
@@ -144,66 +143,40 @@ export function ViewContributionHistory(props: {
144
143
return [ totalDonations , totalUniqueContributions , projects . length ] ;
145
144
} , [ props . contributions ] ) ;
146
145
147
- const activeRoundDonations = useMemo ( ( ) => {
146
+ const filteredDonations = useMemo ( ( ) => {
148
147
const now = Date . now ( ) ;
149
-
150
- const filteredRoundDonations = props . contributions . data . filter (
151
- ( contribution ) => {
152
- const formattedRoundEndTime =
153
- Number (
154
- dateToEthereumTimestamp (
155
- new Date ( contribution . round . donationsEndTime )
156
- )
157
- ) * 1000 ;
158
- return (
159
- formattedRoundEndTime >= now &&
160
- contribution . round . strategyName !== "allov2.DirectAllocationStrategy"
161
- ) ;
162
- }
163
- ) ;
164
- if ( filteredRoundDonations . length === 0 ) {
165
- return [ ] ;
166
- }
167
- return filteredRoundDonations ;
168
- } , [ props . contributions ] ) ;
169
-
170
- const pastRoundDonations = useMemo ( ( ) => {
171
- const now = Date . now ( ) ;
172
-
173
- const filteredRoundDonations = props . contributions . data . filter (
174
- ( contribution ) => {
148
+
149
+ const getFilteredDonations = ( type : string ) => {
150
+ return props . contributions . data . filter ( ( contribution ) => {
175
151
const formattedRoundEndTime =
176
152
Number (
177
- dateToEthereumTimestamp (
178
- new Date ( contribution . round . donationsEndTime )
179
- )
153
+ dateToEthereumTimestamp ( new Date ( contribution . round . donationsEndTime ) )
180
154
) * 1000 ;
181
- return (
182
- formattedRoundEndTime < now &&
183
- contribution . round . strategyName !== "allov2.DirectAllocationStrategy"
184
- ) ;
185
- }
186
- ) ;
187
- if ( filteredRoundDonations . length === 0 ) {
188
- return [ ] ;
189
- }
190
-
191
- return filteredRoundDonations ;
192
- } , [ props . contributions ] ) ;
193
-
194
- const directAllocationDonations = useMemo ( ( ) => {
195
- const filteredRoundDonations = props . contributions . data . filter (
196
- ( contribution ) => {
197
- return (
198
- contribution . round . strategyName === "allov2.DirectAllocationStrategy"
199
- ) ;
200
- }
201
- ) ;
202
- if ( filteredRoundDonations . length === 0 ) {
203
- return [ ] ;
204
- }
205
-
206
- return filteredRoundDonations ;
155
+
156
+ switch ( type ) {
157
+ case "active" :
158
+ return (
159
+ formattedRoundEndTime >= now &&
160
+ contribution . round . strategyName !== "allov2.DirectAllocationStrategy"
161
+ ) ;
162
+ case "past" :
163
+ return (
164
+ formattedRoundEndTime < now &&
165
+ contribution . round . strategyName !== "allov2.DirectAllocationStrategy"
166
+ ) ;
167
+ case "direct" :
168
+ return contribution . round . strategyName === "allov2.DirectAllocationStrategy" ;
169
+ default :
170
+ return false ;
171
+ }
172
+ } ) ;
173
+ } ;
174
+
175
+ return {
176
+ activeRoundDonations : getFilteredDonations ( "active" ) ,
177
+ pastRoundDonations : getFilteredDonations ( "past" ) ,
178
+ directAllocationDonations : getFilteredDonations ( "direct" ) ,
179
+ } ;
207
180
} , [ props . contributions ] ) ;
208
181
209
182
return (
@@ -212,10 +185,10 @@ export function ViewContributionHistory(props: {
212
185
< Breadcrumb items = { props . breadCrumbs } />
213
186
</ div >
214
187
< main >
215
- < div className = "border-b pb-2 mb-4 flex flex-row items-center justify-between" >
188
+ < div className = "pb-2 flex flex-row items-center justify-between" >
216
189
< div className = "flex flex-row items-center" >
217
190
< img
218
- className = "w-10 h-10 rounded-full mr-4 mt-2 "
191
+ className = "w-10 h-10 rounded-full mr-4 my-auto "
219
192
src = { props . addressLogo }
220
193
alt = "Address Logo"
221
194
/>
@@ -229,28 +202,14 @@ export function ViewContributionHistory(props: {
229
202
</ div >
230
203
</ div >
231
204
< div className = "flex justify-between items-center" >
232
- { /* todo: removed until site is stable */ }
233
- { /* <Button
234
- className="shadow-sm inline-flex border-gray-300 border-2 bg-gradient-to-br from-[#f6d7caff] via-[#bddce8ff] to-[#ebdfa5ff] font-medium py-2 px-4 rounded-md hover:bg-gradient-to-tr text-black w-30 mr-6"
235
- onClick={() =>
236
- window.open(
237
- `https://gg-your-impact.streamlit.app/?address=${props.address}`,
238
- "_blank"
239
- )
240
- }
241
- >
242
- <span className="font-mono text-black text-opacity-100">
243
- Your Gitcoin Grants Impact
244
- </span>
245
- </Button> */ }
246
205
< CopyToClipboardButton
247
206
textToCopy = { `${ currentOrigin } /#/contributors/${ props . address } ` }
248
- iconStyle = "h-4 w-4 mr-1 mt-1 shadow-sm"
207
+ iconStyle = "w-3.5 mr-1 mt-1 shadow-sm"
249
208
/>
250
209
</ div >
251
210
</ div >
252
- < div className = "mt-8 mb-2 font-sans italic " >
253
- * Please note that your recent transactions may take a short while to
211
+ < div className = "text-sm text-gray-500 mb-4 " >
212
+ Please note that your recent transactions may take a short while to
254
213
reflect in your donation history, as processing times may vary.
255
214
</ div >
256
215
< div className = "text-2xl my-6 font-sans" > Donation Impact</ div >
@@ -274,25 +233,31 @@ export function ViewContributionHistory(props: {
274
233
/>
275
234
</ div >
276
235
</ div >
277
- < div className = "text-2xl my-6 " > Donation History</ div >
278
- < div className = "text-lg bg-grey-75 text- black rounded-2xl pl-4 px-1 py-1 mb-2 font-semibold" >
236
+ < div className = "text-2xl mt-6 mb-10 " > Donation History</ div >
237
+ < div className = "border- black mb-2 px-1 py-1 text-black text-lg border-b font-semibold" >
279
238
Active Rounds
280
239
</ div >
281
240
< DonationsTable
282
- contributions = { activeRoundDonations }
241
+ contributions = { filteredDonations . activeRoundDonations }
283
242
activeRound = { true }
284
243
/>
285
- < div className = "text-lg bg-grey-75 text- black rounded-2xl pl-4 px-1 py-1 mb-2 font-semibold" >
244
+ < div className = "border- black mb-2 px-1 py-1 text-black text-lg border-b font-semibold" >
286
245
Past Rounds
287
246
</ div >
288
247
< DonationsTable
289
- contributions = { pastRoundDonations }
248
+ contributions = { filteredDonations . pastRoundDonations }
290
249
activeRound = { false }
291
250
/>
292
- < div className = "text-lg bg-grey-75 text-black rounded-2xl pl-4 px-1 py-1 mb-2 font-semibold" >
293
- Direct Donations
294
- </ div >
295
- < DirectDonationsTable contributions = { directAllocationDonations } />
251
+ { /* Direct Allocation */ }
252
+ { filteredDonations . directAllocationDonations . length > 0 && (
253
+ < >
254
+ < div className = "border-black mb-2 px-1 py-1 text-black text-lg border-b font-semibold" >
255
+ Direct Donations
256
+ </ div >
257
+ < DirectDonationsTable contributions = { filteredDonations . directAllocationDonations } />
258
+ </ >
259
+ )
260
+ }
296
261
</ main >
297
262
< div className = "mt-24 mb-11 h-11" >
298
263
< Footer />
@@ -301,7 +266,7 @@ export function ViewContributionHistory(props: {
301
266
) ;
302
267
}
303
268
304
- export function ViewContributionHistoryWithoutDonations ( props : {
269
+ export function ViewNoHistory ( props : {
305
270
address : string ;
306
271
addressLogo : string ;
307
272
ensName ?: string ;
0 commit comments