合并冲突
This commit is contained in:
commit
291d189bdc
|
|
@ -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
|
export default getReferralRewardInfo
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import React from 'react'
|
import React, { useState } from 'react'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import { formatDivNumber } from 'utils/formatBalance'
|
import { formatDivNumber } from 'utils/formatBalance'
|
||||||
import { useTranslation } from 'contexts/Localization'
|
import { useTranslation } from 'contexts/Localization'
|
||||||
|
import useToast from 'hooks/useToast'
|
||||||
import { Button, useModal, Text } from '@pancakeswap/uikit'
|
import { Button, useModal, Text } from '@pancakeswap/uikit'
|
||||||
import { inviteReceive } from 'services/referral'
|
|
||||||
import {
|
import {
|
||||||
useReferralNormalConfigInfo,
|
useReferralNormalConfigInfo,
|
||||||
useReferralCommanderConfigInfo,
|
useReferralCommanderConfigInfo,
|
||||||
|
|
@ -12,6 +12,7 @@ import {
|
||||||
import FlexCom from './FlexCom'
|
import FlexCom from './FlexCom'
|
||||||
import BuyNftModal from './BuyNftModal'
|
import BuyNftModal from './BuyNftModal'
|
||||||
import HeaderMain from './HeaderMain'
|
import HeaderMain from './HeaderMain'
|
||||||
|
import { useWithdraw } from '../hooks'
|
||||||
|
|
||||||
const ButtonDiv = styled(Button)`
|
const ButtonDiv = styled(Button)`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
@ -60,8 +61,18 @@ const ConnectedCom: React.FC = () => {
|
||||||
const referralRewardInfo = useReferralRewardInfo()
|
const referralRewardInfo = useReferralRewardInfo()
|
||||||
console.log('referralRewardInfo:', referralRewardInfo)
|
console.log('referralRewardInfo:', referralRewardInfo)
|
||||||
const referralCommanderConfigInfo = useReferralCommanderConfigInfo()
|
const referralCommanderConfigInfo = useReferralCommanderConfigInfo()
|
||||||
const getInviteReceive = async () => {
|
const [loading, setLoading] = useState(false)
|
||||||
await inviteReceive()
|
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 (
|
return (
|
||||||
<MainDiv>
|
<MainDiv>
|
||||||
|
|
@ -75,9 +86,9 @@ const ConnectedCom: React.FC = () => {
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
<FooterBtn>
|
<FooterBtn>
|
||||||
{referralNormalConfigInfo?.receiveLimit <=
|
{referralNormalConfigInfo.receiveLimit <=
|
||||||
referralRewardInfo?.inviteReward - referralRewardInfo?.inviteRewardReceive ? (
|
referralRewardInfo.inviteReward - referralRewardInfo.inviteRewardReceive ? (
|
||||||
<ButtonGet onClick={getInviteReceive} variant="secondary">
|
<ButtonGet onClick={handleWithdraw} disabled={loading} variant="secondary">
|
||||||
{t('Claim now')}
|
{t('Claim now')}
|
||||||
</ButtonGet>
|
</ButtonGet>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
import React from 'react'
|
import React, { useState } from 'react'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import { formatDivNumber } from 'utils/formatBalance'
|
import { formatDivNumber } from 'utils/formatBalance'
|
||||||
import { useTranslation } from 'contexts/Localization'
|
import { useTranslation } from 'contexts/Localization'
|
||||||
import { inviteReceive } from 'services/referral'
|
|
||||||
import { useReferralCommanderConfigInfo, useReferralRewardInfo } from 'state/referral/hooks'
|
import { useReferralCommanderConfigInfo, useReferralRewardInfo } from 'state/referral/hooks'
|
||||||
import { Text, Image, Button, Heading } from '@pancakeswap/uikit'
|
import { Text, Image, Button, Heading } from '@pancakeswap/uikit'
|
||||||
|
import useToast from 'hooks/useToast'
|
||||||
import FlexCom from './FlexCom'
|
import FlexCom from './FlexCom'
|
||||||
|
import { useWithdraw } from '../hooks'
|
||||||
|
|
||||||
const ButtonDiv = styled(Button)`
|
const ButtonDiv = styled(Button)`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
@ -79,10 +80,19 @@ const HeadingDiv = styled(Heading)`
|
||||||
const RegimentalCom: React.FC = () => {
|
const RegimentalCom: React.FC = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const referralCommanderConfigInfo = useReferralCommanderConfigInfo()
|
const referralCommanderConfigInfo = useReferralCommanderConfigInfo()
|
||||||
console.log(referralCommanderConfigInfo)
|
|
||||||
const referralRewardInfo = useReferralRewardInfo()
|
const referralRewardInfo = useReferralRewardInfo()
|
||||||
const getInviteReceive = async () => {
|
const [loading, setLoading] = useState(false)
|
||||||
await inviteReceive()
|
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 (
|
return (
|
||||||
<ContentDiv>
|
<ContentDiv>
|
||||||
|
|
@ -136,7 +146,7 @@ const RegimentalCom: React.FC = () => {
|
||||||
<FooterBtn>
|
<FooterBtn>
|
||||||
{referralCommanderConfigInfo.receiveLimit <=
|
{referralCommanderConfigInfo.receiveLimit <=
|
||||||
referralRewardInfo.inviteReward - referralRewardInfo.inviteRewardReceive ? (
|
referralRewardInfo.inviteReward - referralRewardInfo.inviteRewardReceive ? (
|
||||||
<ButtonGet variant="secondary" onClick={getInviteReceive}>
|
<ButtonGet variant="secondary" disabled={loading} onClick={handleWithdraw}>
|
||||||
{t('Claim now')}
|
{t('Claim now')}
|
||||||
</ButtonGet>
|
</ButtonGet>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@ export const useWithdraw = () => {
|
||||||
const data = await getWithdrawRewardParams()
|
const data = await getWithdrawRewardParams()
|
||||||
const { address, receive, timestamp, sign } = data
|
const { address, receive, timestamp, sign } = data
|
||||||
const params = [address, receive, timestamp, sign]
|
const params = [address, receive, timestamp, sign]
|
||||||
const price = getDecimalAmountNumber(receive)
|
const tx = await referralRewardContract.withDrawReward(...params)
|
||||||
const res = await referralRewardContract.withDrawReward(...params, { value: price })
|
const receipt = await tx.wait()
|
||||||
return res
|
return receipt
|
||||||
}
|
}
|
||||||
return transaction
|
return transaction
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue