1
1
import {
2
2
AnimatePresence ,
3
+ Avatar ,
3
4
Button ,
4
5
Card ,
5
6
CardHeader ,
@@ -11,6 +12,7 @@ import {
11
12
Stack ,
12
13
XStack ,
13
14
YStack ,
15
+ Link ,
14
16
} from '@my/ui'
15
17
16
18
import { useAffiliateReferrals } from './utils/useAffiliateReferrals'
@@ -22,7 +24,7 @@ import { useAffiliateStats } from './utils/useAffiliateStats'
22
24
23
25
export const AffiliateScreen = ( ) => {
24
26
return (
25
- < YStack f = { 1 } width = { '100%' } gap = "$4" >
27
+ < YStack width = { '100%' } gap = "$4" pb = "$6 ">
26
28
< XStack alignItems = "center" width = { '100%' } jc = "flex-end" gap = "$6" >
27
29
< LinkableButton href = "/leaderboard" fontWeight = { 'bold' } >
28
30
Check Leaderboard
@@ -57,36 +59,36 @@ const StatsCards = () => {
57
59
< Spinner alignSelf = "flex-start" size = "large" color = "$color12" mt = "auto" p = "$4" />
58
60
) : (
59
61
< >
60
- < Paragraph pl = "$4" pb = "$3" fontWeight = "600" size = { '$12' } lineHeight = { '$10 ' } >
62
+ < Paragraph pl = "$4" pb = "$3" fontWeight = "600" size = { '$12' } lineHeight = { '$11 ' } >
61
63
{ affiliateStats ?. referral_count || 0 }
62
64
</ Paragraph >
63
65
</ >
64
66
) }
65
67
</ Card >
66
68
< Card $gtLg = { { flexShrink : 0 , flexBasis : '32%' } } w = "100%" mih = { 152 } >
67
69
< CardHeader >
68
- < Label color = { '$color10' } > Affiliate Send Score </ Label >
70
+ < Label color = { '$color10' } > Network Rewards Share </ Label >
69
71
</ CardHeader >
70
72
{ isLoading ? (
71
73
< Spinner alignSelf = "flex-start" size = "large" color = "$color12" mt = "auto" p = "$4" />
72
74
) : (
73
75
< >
74
- < Paragraph pl = "$4" pb = "$3" fontWeight = "600" size = { '$12' } lineHeight = { '$10 ' } >
75
- { formatAmount ( affiliateStats ?. affiliate_send_score || 0 , 10 ) }
76
+ < Paragraph pl = "$4" pb = "$3" fontWeight = "600" size = { '$12' } lineHeight = { '$11 ' } >
77
+ { formatAmount ( affiliateStats ?. affiliate_send_score || 0 , 10 , 0 ) }
76
78
</ Paragraph >
77
79
</ >
78
80
) }
79
81
</ Card >
80
82
< Card $gtLg = { { flexShrink : 0 , flexBasis : '32%' } } w = "100%" mih = { 152 } >
81
83
< CardHeader >
82
- < Label color = { '$color10' } > Affiliate Network +/-</ Label >
84
+ < Label color = { '$color10' } > Network +/-</ Label >
83
85
</ CardHeader >
84
86
{ isLoading ? (
85
87
< Spinner alignSelf = "flex-start" size = "large" color = "$color12" mt = "auto" p = "$4" />
86
88
) : (
87
89
< >
88
- < Paragraph pl = "$4" pb = "$3" fontWeight = "600" size = { '$12' } lineHeight = { '$10 ' } >
89
- { affiliateStats ?. send_plus_minus || 0 }
90
+ < Paragraph pl = "$4" pb = "$3" fontWeight = "600" size = { '$12' } lineHeight = { '$11 ' } >
91
+ { formatAmount ( affiliateStats ?. network_plus_minus || 0 , 10 , 0 ) }
90
92
</ Paragraph >
91
93
</ >
92
94
) }
@@ -100,7 +102,7 @@ const StatsCards = () => {
100
102
}
101
103
102
104
const ReferralsList = ( ) => {
103
- const pageSize = 10
105
+ const pageSize = 30
104
106
const result = useAffiliateReferrals ( {
105
107
pageSize,
106
108
} )
@@ -115,13 +117,14 @@ const ReferralsList = () => {
115
117
} = result
116
118
117
119
const { pages } = data ?? { }
120
+
118
121
return (
119
- < YStack f = { 1 } width = { '100%' } space = "$4" >
120
- < XStack alignItems = "center" width = { '100%' } gap = "$3" >
122
+ < YStack space = "$4" >
123
+ < XStack alignItems = "center" gap = "$3" >
121
124
< H3 fontWeight = { 'normal' } > Referrals</ H3 >
122
125
</ XStack >
123
- < YStack f = { 1 } width = { '100%' } p = "$6" bg = "$background" space = "$4" br = "$8" >
124
- < ReferralsHeader / >
126
+
127
+ < Card gap = "$5" p = "$5" w = "100%" fd = "row" flexWrap = "wrap" >
125
128
{ ( ( ) => {
126
129
switch ( true ) {
127
130
case isLoadingReferrals :
@@ -141,19 +144,11 @@ const ReferralsList = () => {
141
144
default : {
142
145
return pages ?. map ( ( referrals ) => {
143
146
return referrals ?. map ( ( { referral } ) => {
147
+ if ( ! referral ) return null
144
148
return (
145
149
< Fragment key = { `${ referral . referred_id } -${ referral . tag } ` } >
146
150
< AnimateEnter >
147
- < XStack gap = "$1" ai = "center" >
148
- < Paragraph w = "12%" f = { 1 } mb = "0" size = "$5" lineHeight = "$4" ta = "center" >
149
- /{ referral . tag }
150
- </ Paragraph >
151
- < XStack f = { 1 } ai = "center" w = "12%" jc = "center" mb = "0" gap = "$2" >
152
- < Paragraph size = "$5" lineHeight = "$4" ta = "center" >
153
- ?
154
- </ Paragraph >
155
- </ XStack >
156
- </ XStack >
151
+ < ReferralsListRow referral = { referral } />
157
152
</ AnimateEnter >
158
153
</ Fragment >
159
154
)
@@ -172,38 +167,78 @@ const ReferralsList = () => {
172
167
fetchNextPage ( )
173
168
} }
174
169
disabled = { isFetchingNextPageReferrals || isFetchingReferrals }
175
- color = "$color"
176
170
width = { 200 }
177
171
mx = "auto"
178
172
mb = "$6"
173
+ bc = "$color3"
179
174
>
180
175
Load More
181
176
</ Button >
182
177
) }
183
178
</ >
184
179
) : null }
185
180
</ AnimateEnter >
186
- </ YStack >
181
+ </ Card >
187
182
</ YStack >
188
183
)
189
184
}
190
185
191
- const ReferralsHeader = ( ) => (
192
- < XStack gap = "$1" ai = "center" >
193
- < Paragraph w = "12%" mb = "0" size = "$5" lineHeight = "$4" >
194
- #
195
- </ Paragraph >
196
- < Paragraph w = "12%" f = { 1 } mb = "0" size = "$5" lineHeight = "$4" ta = "center" >
197
- Sendtag
198
- </ Paragraph >
199
- < Paragraph w = "12%" f = { 1 } mb = "0" size = "$5" lineHeight = "$4" ta = "center" >
200
- Referred Date
201
- </ Paragraph >
202
- </ XStack >
203
- )
186
+ const ReferralsListRow = ( { referral } ) => {
187
+ const date = new Date ( referral ?. created_at ) . toLocaleString ( undefined , { dateStyle : 'medium' } )
188
+
189
+ return (
190
+ < Card bc = "$color0" ai = "center" >
191
+ < Link
192
+ href = { `/profile/${ referral . profile ?. send_id } ` }
193
+ f = { 1 }
194
+ als = "stretch"
195
+ px = "$5"
196
+ py = "$3"
197
+ w = "100%"
198
+ h = "100%"
199
+ >
200
+ < XStack gap = "$5" f = { 1 } ai = "center" jc = { 'space-between' } >
201
+ < XStack gap = "$3.5" f = { 1 } ai = "center" >
202
+ < Avatar size = "$4.5" br = "$4" gap = "$2" >
203
+ < Avatar . Image src = { referral . avatar_url ?? '' } />
204
+ < Avatar . Fallback jc = "center" bc = "$olive" >
205
+ < Avatar size = "$4.5" br = "$4" >
206
+ < Avatar . Image
207
+ src = {
208
+ 'https://ui-avatars.com/api/?name=TODO&size=256&format=png&background=86ad7f'
209
+ }
210
+ />
211
+ </ Avatar >
212
+ </ Avatar . Fallback >
213
+ </ Avatar >
204
214
205
- const ReferralsListRow = ( ) => {
206
- return < YStack f = { 1 } width = { '100%' } space = "$4" />
215
+ < YStack >
216
+ < XStack gap = "$1.5" width = { '100%' } >
217
+ < Paragraph color = "$color12" fontSize = "$5" >
218
+ /{ referral . tag }
219
+ </ Paragraph >
220
+ </ XStack >
221
+
222
+ < Stack >
223
+ < Paragraph color = "$color10" size = { '$3' } >
224
+ { date }
225
+ </ Paragraph >
226
+ </ Stack >
227
+ </ YStack >
228
+ </ XStack >
229
+ < Stack als = "flex-start" >
230
+ < Paragraph
231
+ theme = { referral . send_plus_minus >= 0 ? 'green_active' : 'red_active' }
232
+ size = { '$8' }
233
+ lh = { '$1' }
234
+ >
235
+ { referral . send_plus_minus >= 0 ? '+' : '-' }
236
+ </ Paragraph >
237
+ </ Stack >
238
+ </ XStack >
239
+ </ Link >
240
+ </ Card >
241
+ )
207
242
}
208
243
209
244
function AnimateEnter ( { children } : { children : React . ReactNode } ) {
0 commit comments