调整代码
This commit is contained in:
parent
6c0f6740b9
commit
ad457846d6
|
|
@ -60,11 +60,7 @@ const Menu = (props) => {
|
|||
const [price, setPrice] = useState(0)
|
||||
useEffect(() => {
|
||||
getDetails()
|
||||
if (hccPriceUsdt.toString() === 'Infinity') {
|
||||
setPrice(0)
|
||||
} else {
|
||||
setPrice(hccPriceUsdt.toNumber())
|
||||
}
|
||||
setPrice(hccPriceUsdt)
|
||||
}, [])
|
||||
return (
|
||||
<UikitMenu
|
||||
|
|
|
|||
|
|
@ -373,9 +373,12 @@ export const usePriceCakeBusd = (): BigNumber => {
|
|||
const cakeBnbFarm = useFarmFromPid(251)
|
||||
return new BigNumber(cakeBnbFarm.token.busdPrice)
|
||||
}
|
||||
export const usePriceHccUsdt = (): BigNumber => {
|
||||
export const usePriceHccUsdt = (): number => {
|
||||
const hccUsdtFarm = useFarmFromPid(1000) // NEED CHANGE
|
||||
return new BigNumber(hccUsdtFarm.token.busdPrice)
|
||||
return new BigNumber(hccUsdtFarm.token.busdPrice).toString() || !hccUsdtFarm.token.busdPrice
|
||||
? 0
|
||||
: new BigNumber(hccUsdtFarm.token.busdPrice).toNumber()
|
||||
// return new BigNumber(hccUsdtFarm.token.busdPrice)
|
||||
}
|
||||
|
||||
// Block
|
||||
|
|
|
|||
|
|
@ -1,51 +1,13 @@
|
|||
import { createSlice } from '@reduxjs/toolkit'
|
||||
import { getReferralRewardInfo, getReferralConfigInfo } from 'services/referral'
|
||||
import { ReferralInfo, ReferralConfigType, ReferralConfigInfo } from 'types/referral'
|
||||
import BigNumber from 'bignumber.js'
|
||||
import erc20ABI from 'config/abi/erc20.json'
|
||||
import multicall from 'utils/multicall'
|
||||
import tokens from 'config/constants/tokens'
|
||||
import { getAddress, getIdoPurchaseAddress } from 'utils/addressHelpers'
|
||||
import { ReferralState } from '../types'
|
||||
|
||||
const initialState: ReferralState = {
|
||||
commanderConfigInfo: {},
|
||||
normalConfigInfo: {},
|
||||
isCommander: false,
|
||||
rewardInfo: {},
|
||||
}
|
||||
const payWayList = {
|
||||
usdt: tokens.usdt,
|
||||
}
|
||||
export const referralSlice = createSlice({
|
||||
name: 'Ido',
|
||||
initialState,
|
||||
reducers: {
|
||||
setReferralInfo: (state, action) => {
|
||||
console.log(action)
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// Actions
|
||||
export const { setReferralInfo } = referralSlice.actions
|
||||
// Thunks
|
||||
// export const fetchReferralInfoAsync = (account) => async (dispatch) => {
|
||||
// if (!account) {
|
||||
// dispatch(setReferralInfo({}))
|
||||
// return
|
||||
// }
|
||||
// const data: ReferralInfo = await getReferralRewardInfo()
|
||||
// const configInfo: ReferralConfigInfo[] = await getReferralConfigInfo()
|
||||
// dispatch(
|
||||
// setReferralInfo({
|
||||
// commanderConfigInfo: configInfo?.find((item) => item.type === ReferralConfigType.COMMANDER) || {},
|
||||
// normalConfigInfo: configInfo?.find((item) => item.type === ReferralConfigType.NORMAL) || {},
|
||||
// isCommander: data.isCommander,
|
||||
// rewardInfo: data.reward || {},
|
||||
// }),
|
||||
// )
|
||||
// }
|
||||
|
||||
export const fetchIdoUserAllowances = async (account: string) => {
|
||||
const calls = Object.values(payWayList).map((payWayItem) => {
|
||||
|
|
@ -63,4 +25,4 @@ export const fetchIdoUserAllowances = async (account: string) => {
|
|||
}
|
||||
}
|
||||
|
||||
export default referralSlice.reducer
|
||||
export default fetchIdoUserAllowances
|
||||
|
|
|
|||
|
|
@ -52,11 +52,7 @@ const CardActions: React.FC<NodeCardActionsProps> = ({ board, account }) => {
|
|||
|
||||
const [price, setPrice] = useState(0)
|
||||
useEffect(() => {
|
||||
if (hccPriceUsdt.toString() === 'Infinity') {
|
||||
setPrice(0)
|
||||
} else {
|
||||
setPrice(Number(hccPriceUsdt.toNumber().toFixed(3)))
|
||||
}
|
||||
setPrice(hccPriceUsdt)
|
||||
}, [])
|
||||
|
||||
const handleApprove = useCallback(async () => {
|
||||
|
|
|
|||
|
|
@ -156,11 +156,7 @@ const FristCom: React.FC = () => {
|
|||
setDetail(data)
|
||||
}
|
||||
useEffect(() => {
|
||||
if (hccPriceUsdt.toString() === 'Infinity') {
|
||||
setPrice(0)
|
||||
} else {
|
||||
setPrice(hccPriceUsdt.toNumber())
|
||||
}
|
||||
setPrice(hccPriceUsdt)
|
||||
getDetail()
|
||||
}, [])
|
||||
const openLink = (link) => {
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@ interface RoundDetailProps {
|
|||
token?: string
|
||||
total?: number
|
||||
}
|
||||
interface Props {
|
||||
interface HeaderStatusProps {
|
||||
status?: string
|
||||
roundDetail?: RoundDetailProps
|
||||
}
|
||||
|
||||
const HeaderStatus: React.FC<Props> = ({ status, roundDetail }) => {
|
||||
const HeaderStatus: React.FC<HeaderStatusProps> = ({ status, roundDetail }) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -19,14 +19,14 @@ const CoinText = styled(Text)`
|
|||
margin-bottom: 20px;
|
||||
`
|
||||
|
||||
interface InputProps {
|
||||
interface ExchangeInputProps {
|
||||
name: string
|
||||
value?: number | string
|
||||
isDisabled?: boolean
|
||||
disabled?: boolean
|
||||
onChange: (e: React.FormEvent<HTMLInputElement>) => void
|
||||
}
|
||||
|
||||
const ExchangeInput: React.FC<InputProps> = ({ name, value, onChange, isDisabled = true }) => {
|
||||
const ExchangeInput: React.FC<ExchangeInputProps> = ({ name, value, onChange, disabled = true }) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
|
|
@ -37,7 +37,7 @@ const ExchangeInput: React.FC<InputProps> = ({ name, value, onChange, isDisabled
|
|||
placeholder={t('Please enter the amount')}
|
||||
onChange={onChange}
|
||||
type="number"
|
||||
disabled={isDisabled}
|
||||
disabled={disabled}
|
||||
/>
|
||||
</PriceContent>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -153,9 +153,9 @@ const ExchangeCard: React.FC<Props> = ({ status, roundDetail, time }) => {
|
|||
<FCard>
|
||||
<HeaderText>{idoInfo?.name}</HeaderText>
|
||||
<HeaderStatus status={status} roundDetail={roundDetail} />
|
||||
<ExchangeInput name="USDT" value={usdtPrice} onChange={handleUsdtChange} isDisabled={status !== 'proceed'} />
|
||||
<ExchangeInput name="USDT" value={usdtPrice} onChange={handleUsdtChange} disabled={status !== 'proceed'} />
|
||||
<RateText status={status} roundDetail={roundDetail} />
|
||||
<ExchangeInput name="HCC" value={hccPrice} onChange={handleHccChange} isDisabled={status !== 'proceed'} />
|
||||
<ExchangeInput name="HCC" value={hccPrice} onChange={handleHccChange} disabled={status !== 'proceed'} />
|
||||
<FooterButton>
|
||||
{account ? (
|
||||
allowanceList.usdt ? (
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ export const useBuyTransaction = () => {
|
|||
const transaction = async (amount) => {
|
||||
const data = await getPurchaseActivity()
|
||||
const { id } = data
|
||||
const params = [id, new BigNumber(amount).times(new BigNumber(10).pow(18)).toString()]
|
||||
const params = [id, getDecimalAmount(amount).toString()]
|
||||
const res = await idoPurchase.purchaseWithLock(...params)
|
||||
return res
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue