Skip to content

Commit ee3509d

Browse files
Use tag for affiliate referral link
1 parent 7f97aa0 commit ee3509d

File tree

5 files changed

+35
-287
lines changed

5 files changed

+35
-287
lines changed

packages/app/features/account/rewards/activity/screen.test.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ jest.mock('app/utils/useChainAddresses', () => ({
5858
useChainAddresses: jest.fn().mockReturnValue({ data: { address: '0x123' } }),
5959
}))
6060
jest.mock('wagmi')
61-
jest.mock('@web3modal/wagmi/react', () => ({
62-
useWeb3Modal: jest.fn().mockReturnValue({ open: jest.fn() }),
63-
}))
61+
6462
jest.mock('@my/wagmi', () => ({
6563
__esModule: true,
6664
...jest.requireActual('@my/wagmi'),

packages/app/features/affiliate/screen.tsx

+5-10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import { useAffiliateReferrals } from './utils/useAffiliateReferrals'
1919
import { Fragment } from 'react'
2020
import { useAffiliateStats } from './utils/useAffiliateStats'
21+
import type { Functions } from '@my/supabase/database.types'
2122

2223
export const AffiliateScreen = () => {
2324
return (
@@ -171,20 +172,14 @@ const ReferralsList = () => {
171172
)
172173
}
173174

174-
const ReferralsListRow = ({ referral }) => {
175+
const ReferralsListRow = ({
176+
referral,
177+
}: { referral: Functions<'get_affiliate_referrals'>[number] }) => {
175178
const date = new Date(referral?.created_at).toLocaleString(undefined, { dateStyle: 'medium' })
176179

177180
return (
178181
<Card bc="$color0" ai="center">
179-
<Link
180-
href={`/profile/${referral.profile?.send_id}`}
181-
f={1}
182-
als="stretch"
183-
px="$5"
184-
py="$3"
185-
w="100%"
186-
h="100%"
187-
>
182+
<Link href={`/${referral.tag}`} f={1} als="stretch" px="$5" py="$3" w="100%" h="100%">
188183
<XStack gap="$5" f={1} ai="center" jc={'space-between'}>
189184
<XStack gap="$3.5" f={1} ai="center">
190185
<Avatar size="$4.5" br="$4" gap="$2">

packages/app/utils/OpenConnectModalWrapper.tsx

-22
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
CREATE OR REPLACE FUNCTION get_affiliate_stats_summary()
2+
RETURNS TABLE(
3+
id uuid,
4+
created_at timestamptz,
5+
user_id uuid,
6+
referral_count bigint)
7+
LANGUAGE plpgsql
8+
SECURITY DEFINER
9+
SET search_path = public
10+
AS $$
11+
BEGIN
12+
RETURN QUERY
13+
SELECT
14+
a.id,
15+
a.created_at,
16+
a.user_id,
17+
COUNT(DISTINCT r.tag)::bigint AS referral_count,
18+
FROM
19+
affiliate_stats a
20+
LEFT JOIN referrals r ON r.referrer_id = a.user_id
21+
WHERE
22+
a.user_id = auth.uid()
23+
GROUP BY
24+
a.id,
25+
a.created_at,
26+
a.user_id;
27+
END;
28+
$$;
29+

supabase/tests/affiliate_stats_test.sql

-252
This file was deleted.

0 commit comments

Comments
 (0)