File tree 5 files changed +31
-9
lines changed
packages/app/features/affiliate
5 files changed +31
-9
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export const Page: NextPageWithLayout = () => {
12
12
< title > Send | Affiliates</ title >
13
13
< meta
14
14
name = "description"
15
- content = "View your network, track your score, and see your referrals activity."
15
+ content = "View your network and track referral activity."
16
16
key = "desc"
17
17
/>
18
18
</ Head >
@@ -21,7 +21,7 @@ export const Page: NextPageWithLayout = () => {
21
21
)
22
22
}
23
23
24
- const subheader = 'View your network, track your score, and see your referrals activity.'
24
+ const subheader = 'View your network and track referral activity.'
25
25
26
26
export const getServerSideProps = userProtectedGetSSP ( )
27
27
Original file line number Diff line number Diff line change @@ -16,10 +16,7 @@ import {
16
16
} from '@my/ui'
17
17
18
18
import { useAffiliateReferrals } from './utils/useAffiliateReferrals'
19
-
20
19
import { Fragment } from 'react'
21
-
22
- import formatAmount from 'app/utils/formatAmount'
23
20
import { useAffiliateStats } from './utils/useAffiliateStats'
24
21
25
22
export const AffiliateScreen = ( ) => {
@@ -136,7 +133,7 @@ const ReferralsList = () => {
136
133
</ Paragraph >
137
134
) }
138
135
{ pages ?. map ( ( referrals ) => {
139
- return referrals ?. map ( ( { referral } ) => {
136
+ return referrals ?. map ( ( referral ) => {
140
137
if ( ! referral ) return null
141
138
return (
142
139
< Fragment key = { `${ referral . referred_id } -${ referral . tag } ` } >
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ export function useAffiliateReferrals({ pageSize = 10 }: { pageSize?: number } =
11
11
async function fetchAffiliateReferrals ( { pageParam } : { pageParam : number } ) {
12
12
const from = pageParam * pageSize
13
13
const to = ( pageParam + 1 ) * pageSize - 1
14
- const request = supabase . from ( 'affiliate_referrals ') . select ( '*' ) . range ( from , to )
14
+ const request = supabase . rpc ( 'get_affiliate_referrals ') . select ( '*' ) . range ( from , to )
15
15
const { data, error } = await request
16
16
throwIf ( error )
17
17
return data
Original file line number Diff line number Diff line change
1
+ import type { Functions } from '@my/supabase/database.types'
1
2
import { useQuery } from '@tanstack/react-query'
2
3
import { useSupabase } from 'app/utils/supabase/useSupabase'
3
4
4
5
export function useAffiliateStats ( ) {
5
6
const supabase = useSupabase ( )
6
- async function fetchAffiliateStats ( ) {
7
- const request = supabase . from ( 'affiliate_stats_summary' ) . select ( '*' ) . single ( )
7
+ async function fetchAffiliateStats ( ) : Promise <
8
+ Functions < 'get_affiliate_stats_summary' > [ number ] | null
9
+ > {
10
+ const request = supabase . rpc ( 'get_affiliate_stats_summary' ) . select ( '*' ) . single ( )
8
11
9
12
const { data, error } = await request
10
13
if ( error ) {
Original file line number Diff line number Diff line change @@ -1256,6 +1256,28 @@ export type Database = {
1256
1256
Args : Record < PropertyKey , never >
1257
1257
Returns : string
1258
1258
}
1259
+ get_affiliate_referrals : {
1260
+ Args : Record < PropertyKey , never >
1261
+ Returns : {
1262
+ referred_id : string
1263
+ send_plus_minus : number
1264
+ avatar_url : string
1265
+ tag : string
1266
+ created_at : string
1267
+ } [ ]
1268
+ }
1269
+ get_affiliate_stats_summary : {
1270
+ Args : Record < PropertyKey , never >
1271
+ Returns : {
1272
+ id : string
1273
+ created_at : string
1274
+ user_id : string
1275
+ send_plus_minus : number
1276
+ referral_count : number
1277
+ network_plus_minus : number
1278
+ affiliate_send_score : number
1279
+ } [ ]
1280
+ }
1259
1281
insert_challenge : {
1260
1282
Args : Record < PropertyKey , never >
1261
1283
Returns : {
You can’t perform that action at this time.
0 commit comments