mirror of
https://github.com/acid-info/logos-ordinals-dashboard.git
synced 2025-02-28 12:40:42 +00:00
feat: implement /user/referral
This commit is contained in:
parent
f8018e6b88
commit
0170bf5b68
@ -1,6 +1,7 @@
|
|||||||
import { numberWithCommas, truncateString } from '@/utils/general.utils'
|
import { numberWithCommas, truncateString } from '@/utils/general.utils'
|
||||||
import styled from '@emotion/styled'
|
import styled from '@emotion/styled'
|
||||||
import { useAtom } from 'jotai'
|
import { useAtom } from 'jotai'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
import { userInfoAtom } from '../../../atoms/userInfo'
|
import { userInfoAtom } from '../../../atoms/userInfo'
|
||||||
import { walletAddressAtom } from '../../../atoms/wallet'
|
import { walletAddressAtom } from '../../../atoms/wallet'
|
||||||
@ -23,6 +24,10 @@ const Dropdown: React.FC = () => {
|
|||||||
const [isExpanded, setIsExpanded] = useState(false)
|
const [isExpanded, setIsExpanded] = useState(false)
|
||||||
const [walletAddress, setWalletAddress] = useAtom(walletAddressAtom)
|
const [walletAddress, setWalletAddress] = useAtom(walletAddressAtom)
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
const { referral_code, referral_address, referral_source } = router.query
|
||||||
|
|
||||||
const [userInfo, setUserInfo] = useAtom(userInfoAtom)
|
const [userInfo, setUserInfo] = useAtom(userInfoAtom)
|
||||||
const [showMultiPass, setShowMultiPass] = useState(false)
|
const [showMultiPass, setShowMultiPass] = useState(false)
|
||||||
|
|
||||||
@ -51,20 +56,27 @@ const Dropdown: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { addr: address, sig: signature } = await handler()
|
const { addr: address, sig: signature } = await handler()
|
||||||
setWalletAddress(address)
|
|
||||||
|
|
||||||
const response = await api.post('/token/pair', { address, signature })
|
const response = await api.post('/token/pair', { address, signature })
|
||||||
|
setIsExpanded(false)
|
||||||
|
setWalletAddress(address)
|
||||||
|
|
||||||
const { access, refresh } = response.data.token
|
const { access, refresh } = response.data.token
|
||||||
|
|
||||||
sessionStorage.setItem('accessToken', access)
|
sessionStorage.setItem('accessToken', access)
|
||||||
sessionStorage.setItem('refreshToken', refresh)
|
sessionStorage.setItem('refreshToken', refresh)
|
||||||
sessionStorage.setItem('walletAddress', address)
|
sessionStorage.setItem('walletAddress', address)
|
||||||
|
|
||||||
setIsExpanded(false)
|
if (referral_code?.length && referral_address?.length) {
|
||||||
|
await api.post('/user/referral', {
|
||||||
|
referral_code: referral_code,
|
||||||
|
referral_address,
|
||||||
|
referral_source,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.log('Failed to connect or disconnect wallet:', error)
|
console.log('Failed to connect or disconnect wallet:', error)
|
||||||
alert(error)
|
|
||||||
|
|
||||||
setWalletAddress(null)
|
setWalletAddress(null)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import { breakpoints } from '@/configs/ui.configs'
|
|||||||
import styled from '@emotion/styled'
|
import styled from '@emotion/styled'
|
||||||
import { useAtom, useSetAtom } from 'jotai'
|
import { useAtom, useSetAtom } from 'jotai'
|
||||||
import React, { useEffect } from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import useGetUserXP from '../../../apis/general/useGetUserXP'
|
// import useGetUserXP from '../../../apis/general/useGetUserXP'
|
||||||
import useGetUserInfo from '../../../apis/operators/useGetUserInfo'
|
import useGetUserInfo from '../../../apis/operators/useGetUserInfo'
|
||||||
import { userInfoAtom } from '../../../atoms/userInfo'
|
import { userInfoAtom } from '../../../atoms/userInfo'
|
||||||
import { walletAddressAtom } from '../../../atoms/wallet'
|
import { walletAddressAtom } from '../../../atoms/wallet'
|
||||||
@ -44,11 +44,9 @@ const DashboardContainer: React.FC<DashboardPageProps> = ({
|
|||||||
|
|
||||||
const processedOperators = processMyOperators(userInfoData?.operators)
|
const processedOperators = processMyOperators(userInfoData?.operators)
|
||||||
|
|
||||||
console.log('processedOperators', processedOperators)
|
// const { data: userXP } = useGetUserXP({
|
||||||
|
// enabled: !!walletAddress && walletAddress.length > 0,
|
||||||
const { data: userXP } = useGetUserXP({
|
// })
|
||||||
enabled: !!walletAddress && walletAddress.length > 0,
|
|
||||||
})
|
|
||||||
|
|
||||||
// console.log('userXP', userXP)
|
// console.log('userXP', userXP)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user