Skip to content

Commit

Permalink
Revoke invite
Browse files Browse the repository at this point in the history
  • Loading branch information
bone-house committed Sep 9, 2024
1 parent 397b8cf commit 6ede56c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
3 changes: 3 additions & 0 deletions apps/platform/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export const PLATFORM_JACKPOT_FEE = 0.001 // 0.1%
// Referral fee (in %)
export const PLATFORM_REFERRAL_FEE = 0.0025 // 0.25%

/** If the user should be able to revoke an invite after they've accepted an invite */
export const PLATFORM_ALLOW_REFERRER_REMOVAL = true

// Just a helper function
const lp = (tokenMint: PublicKey | string, poolAuthority?: PublicKey | string): PoolToken => ({
token: new PublicKey(tokenMint),
Expand Down
27 changes: 17 additions & 10 deletions apps/platform/src/sections/UserButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useWalletModal } from '@solana/wallet-adapter-react-ui'
import { GambaUi, useReferral } from 'gamba-react-ui-v2'
import React, { useState } from 'react'
import { Modal } from '../components/Modal'
import { PLATFORM_REFERRAL_FEE } from '../constants'
import { PLATFORM_ALLOW_REFERRER_REMOVAL, PLATFORM_REFERRAL_FEE } from '../constants'
import { useToast } from '../hooks/useToast'
import { useUserStore } from '../hooks/useUserStore'
import { truncateString } from '../utils'
Expand Down Expand Up @@ -43,16 +43,23 @@ function UserModal() {
{truncateString(wallet.publicKey?.toString() ?? '', 6, 3)}
</h1>
<div style={{ display: 'flex', gap: '20px', flexDirection: 'column', width: '100%', padding: '0 20px' }}>
<GambaUi.Button onClick={copyInvite}>
💸 Copy Invite
</GambaUi.Button>
<div style={{ opacity: '.8', fontSize: '80%' }}>
Share your link to earn a {(PLATFORM_REFERRAL_FEE * 100)}% fee when players use this platform.
</div>
{referral.recipient && (
<GambaUi.Button disabled={removing} onClick={revokeInvite}>
Revoke invite
<div style={{ display: 'flex', gap: '10px', flexDirection: 'column', width: '100%' }}>
<GambaUi.Button onClick={copyInvite}>
💸 Copy link
</GambaUi.Button>
<div style={{ opacity: '.8', fontSize: '80%' }}>
Share your link to earn a {(PLATFORM_REFERRAL_FEE * 100)}% fee when players use this platform.
</div>
</div>
{PLATFORM_ALLOW_REFERRER_REMOVAL && referral.recipient && (
<div style={{ display: 'flex', gap: '10px', flexDirection: 'column', width: '100%' }}>
<GambaUi.Button disabled={removing} onClick={revokeInvite}>
Revoke invite
</GambaUi.Button>
<div style={{ opacity: '.8', fontSize: '80%' }}>
You were invited by <a target="_blank" href={`https://solscan.io/account/${referral.recipient.toString()}`} rel="noreferrer">{referral.recipient.toString()}</a>
</div>
</div>
)}
<GambaUi.Button onClick={() => wallet.disconnect()}>
Disconnect
Expand Down

0 comments on commit 6ede56c

Please sign in to comment.