feat: 增加军团长提现功能
This commit is contained in:
parent
99f6a250cf
commit
46c1c763aa
|
|
@ -35,11 +35,4 @@ export const checkBuyResult = (params) => {
|
|||
})
|
||||
}
|
||||
|
||||
export const inviteReceive = () => {
|
||||
return request.request({
|
||||
url: '/high_city/app/api/invite/reward/receive',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
export default getReferralRewardInfo
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import React from 'react'
|
||||
import React, { useState } from 'react'
|
||||
import styled from 'styled-components'
|
||||
import { useTranslation } from 'contexts/Localization'
|
||||
import useToast from 'hooks/useToast'
|
||||
import { Button, useModal, Text } from '@pancakeswap/uikit'
|
||||
import { inviteReceive } from 'services/referral'
|
||||
import {
|
||||
useReferralNormalConfigInfo,
|
||||
useReferralCommanderConfigInfo,
|
||||
|
|
@ -11,6 +11,7 @@ import {
|
|||
import FlexCom from './FlexCom'
|
||||
import BuyNftModal from './BuyNftModal'
|
||||
import HeaderMain from './HeaderMain'
|
||||
import { useWithdraw } from '../hooks'
|
||||
|
||||
const ButtonDiv = styled(Button)`
|
||||
width: 100%;
|
||||
|
|
@ -57,8 +58,18 @@ const ConnectedCom: React.FC = () => {
|
|||
const referralNormalConfigInfo = useReferralNormalConfigInfo()
|
||||
const referralRewardInfo = useReferralRewardInfo()
|
||||
const referralCommanderConfigInfo = useReferralCommanderConfigInfo()
|
||||
const getInviteReceive = async () => {
|
||||
await inviteReceive()
|
||||
const [loading, setLoading] = useState(false)
|
||||
const withdraw = useWithdraw()
|
||||
const { toastSuccess } = useToast()
|
||||
const handleWithdraw = async () => {
|
||||
setLoading(true)
|
||||
try {
|
||||
await withdraw()
|
||||
setLoading(false)
|
||||
toastSuccess(t('Successfully claimed!'))
|
||||
} catch (error) {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
return (
|
||||
<MainDiv>
|
||||
|
|
@ -74,7 +85,7 @@ const ConnectedCom: React.FC = () => {
|
|||
<FooterBtn>
|
||||
{referralNormalConfigInfo.receiveLimit <=
|
||||
referralRewardInfo.inviteReward - referralRewardInfo.inviteRewardReceive ? (
|
||||
<ButtonGet onClick={getInviteReceive} variant="secondary">
|
||||
<ButtonGet onClick={handleWithdraw} disabled={loading} variant="secondary">
|
||||
{t('Claim now')}
|
||||
</ButtonGet>
|
||||
) : (
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import React from 'react'
|
||||
import React, { useState } from 'react'
|
||||
import styled from 'styled-components'
|
||||
import { useTranslation } from 'contexts/Localization'
|
||||
import { inviteReceive } from 'services/referral'
|
||||
import { useReferralCommanderConfigInfo, useReferralRewardInfo } from 'state/referral/hooks'
|
||||
import { Text, Image, Button, Heading } from '@pancakeswap/uikit'
|
||||
import useToast from 'hooks/useToast'
|
||||
import FlexCom from './FlexCom'
|
||||
import { useWithdraw } from '../hooks'
|
||||
|
||||
const ButtonDiv = styled(Button)`
|
||||
width: 100%;
|
||||
|
|
@ -78,10 +79,19 @@ const HeadingDiv = styled(Heading)`
|
|||
const RegimentalCom: React.FC = () => {
|
||||
const { t } = useTranslation()
|
||||
const referralCommanderConfigInfo = useReferralCommanderConfigInfo()
|
||||
console.log(referralCommanderConfigInfo)
|
||||
const referralRewardInfo = useReferralRewardInfo()
|
||||
const getInviteReceive = async () => {
|
||||
await inviteReceive()
|
||||
const [loading, setLoading] = useState(false)
|
||||
const withdraw = useWithdraw()
|
||||
const { toastSuccess } = useToast()
|
||||
const handleWithdraw = async () => {
|
||||
setLoading(true)
|
||||
try {
|
||||
await withdraw()
|
||||
setLoading(false)
|
||||
toastSuccess(t('Successfully claimed!'))
|
||||
} catch (error) {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
return (
|
||||
<ContentDiv>
|
||||
|
|
@ -130,7 +140,7 @@ const RegimentalCom: React.FC = () => {
|
|||
<FooterBtn>
|
||||
{referralCommanderConfigInfo.receiveLimit <=
|
||||
referralRewardInfo.inviteReward - referralRewardInfo.inviteRewardReceive ? (
|
||||
<ButtonGet variant="secondary" onClick={getInviteReceive}>
|
||||
<ButtonGet variant="secondary" disabled={loading} onClick={handleWithdraw}>
|
||||
{t('Claim now')}
|
||||
</ButtonGet>
|
||||
) : (
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ export const useWithdraw = () => {
|
|||
const data = await getWithdrawRewardParams()
|
||||
const { address, receive, timestamp, sign } = data
|
||||
const params = [address, receive, timestamp, sign]
|
||||
const price = getDecimalAmountNumber(receive)
|
||||
const res = await referralRewardContract.withDrawReward(...params, { value: price })
|
||||
return res
|
||||
const tx = await referralRewardContract.withDrawReward(...params)
|
||||
const receipt = await tx.wait()
|
||||
return receipt
|
||||
}
|
||||
return transaction
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue