Skip to content

Commit

Permalink
Check valid referral code
Browse files Browse the repository at this point in the history
  • Loading branch information
thi-investax committed Jan 16, 2025
1 parent fa17647 commit 5c0ef9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pages/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { setJumpTaskState } from 'state/jumpTask'
import { CHAINS } from 'components/Web3Provider/constants'
const Launchpad = lazy(() => import('pages/Launchpad'))
import KYC from 'pages/KYC'
import { isLineLiff } from 'utils'
import { isLineLiff, isValidReferralCode } from 'utils'
import { useLiff } from './LiffProvider'
import TaskSuccessModal from 'components/Rewards/TaskSuccessModal'
import { useLineReward } from 'providers/LineRewardProvider'
Expand Down Expand Up @@ -259,6 +259,11 @@ export default function App() {
if (!code) {
return
}

if (!isValidReferralCode(code)) {
return
}

const storedReferralCode = localStorage.getItem('referralCode')
if (!storedReferralCode) {
localStorage.setItem('referralCode', code)
Expand Down
6 changes: 6 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,9 @@ export function tryClearIndexedDB() {

export const isLineLiff =
window.location.hostname.includes('line-liff.ixswap.io') || window.location.hostname.includes('localhost')

export const isValidReferralCode = (code: string) => {
// Define the regex pattern for 6 characters, only alphabets and digits
const pattern = /^[A-Za-z0-9]{6}$/
return pattern.test(code)
}

0 comments on commit 5c0ef9f

Please sign in to comment.