This commit is contained in:
parent
291d189bdc
commit
153760dc2c
|
|
@ -8,7 +8,7 @@ import { usePollCoreFarmData, useFetchProfile, usePollBlockNumber } from 'state/
|
||||||
import { DatePickerPortal } from 'components/DatePicker'
|
import { DatePickerPortal } from 'components/DatePicker'
|
||||||
import { initAxios } from 'utils/request'
|
import { initAxios } from 'utils/request'
|
||||||
import useToast from 'hooks/useToast'
|
import useToast from 'hooks/useToast'
|
||||||
import { fetchUserInfo, clearUserInfo } from 'state/actions'
|
import { fetchUserInfo, clearUserInfo, fetchOutInfo } from 'state/actions'
|
||||||
import { useAccount } from 'state/userInfo/hooks'
|
import { useAccount } from 'state/userInfo/hooks'
|
||||||
import GlobalStyle from './style/Global'
|
import GlobalStyle from './style/Global'
|
||||||
import Menu from './components/Menu'
|
import Menu from './components/Menu'
|
||||||
|
|
@ -70,6 +70,7 @@ const App: React.FC = () => {
|
||||||
const account = useAccount()
|
const account = useAccount()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// dispatch(fetchOutInfo())
|
||||||
initAxios(() => {
|
initAxios(() => {
|
||||||
dispatch(clearUserInfo)
|
dispatch(clearUserInfo)
|
||||||
}, toast)
|
}, toast)
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,24 @@
|
||||||
import React, { useEffect, useState, useMemo } from 'react'
|
import React, { useEffect, useState, useMemo } from 'react'
|
||||||
import { Menu as UikitMenu, ConnectorNames } from '@pancakeswap/uikit'
|
import { Menu as UikitMenu, ConnectorNames } from '@pancakeswap/uikit'
|
||||||
|
import { useDispatch } from 'react-redux'
|
||||||
import { useWeb3React } from '@web3-react/core'
|
import { useWeb3React } from '@web3-react/core'
|
||||||
import { languageList } from 'config/localization/languages'
|
import { languageList } from 'config/localization/languages'
|
||||||
import { useTranslation } from 'contexts/Localization'
|
import { useTranslation } from 'contexts/Localization'
|
||||||
import useTheme from 'hooks/useTheme'
|
import useTheme from 'hooks/useTheme'
|
||||||
import useAuth from 'hooks/useAuth'
|
import useAuth from 'hooks/useAuth'
|
||||||
import { useDispatch } from 'react-redux'
|
|
||||||
import { usePriceHccUsdt, useProfile } from 'state/hooks'
|
import { usePriceHccUsdt, useProfile } from 'state/hooks'
|
||||||
import { useUnactiveAccount, useSignLogin, useAccount, useUserInfo } from 'state/userInfo/hooks'
|
import { useUnactiveAccount, useSignLogin, useAccount, useUserInfo, useOutLink } from 'state/userInfo/hooks'
|
||||||
import useWeb3Provider from 'hooks/useActiveWeb3React'
|
import useWeb3Provider from 'hooks/useActiveWeb3React'
|
||||||
import { clearUserInfo } from 'state/actions'
|
import { clearUserInfo, fetchOutInfo } from 'state/actions'
|
||||||
|
import { uccnDetail } from 'services/user'
|
||||||
import config from './config'
|
import config from './config'
|
||||||
|
|
||||||
const Menu = (props) => {
|
const Menu = (props) => {
|
||||||
|
// const [detail, setDetail] = useState({ userNumb: 0, tradingVolume: 0, outsideChainVos: [] })
|
||||||
|
// const getDetail = async () => {
|
||||||
|
// const data = await uccnDetail()
|
||||||
|
// setDetail(data)
|
||||||
|
// }
|
||||||
const account = useAccount()
|
const account = useAccount()
|
||||||
const { login, logout } = useAuth()
|
const { login, logout } = useAuth()
|
||||||
const [hasWalletLogin, setHasWalletLogin] = useState(false)
|
const [hasWalletLogin, setHasWalletLogin] = useState(false)
|
||||||
|
|
@ -23,6 +29,8 @@ const Menu = (props) => {
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const { profile } = useProfile()
|
const { profile } = useProfile()
|
||||||
const userInfo = useUserInfo()
|
const userInfo = useUserInfo()
|
||||||
|
// const detail = useOutLink()
|
||||||
|
// console.log(userInfo)
|
||||||
const { currentLanguage, setLanguage, t } = useTranslation()
|
const { currentLanguage, setLanguage, t } = useTranslation()
|
||||||
const inviteUrl = useMemo(() => {
|
const inviteUrl = useMemo(() => {
|
||||||
return userInfo?.inviteCode ? `${window.location.origin}?inviteCode=${userInfo.inviteCode}` : window.location.origin
|
return userInfo?.inviteCode ? `${window.location.origin}?inviteCode=${userInfo.inviteCode}` : window.location.origin
|
||||||
|
|
@ -43,6 +51,18 @@ const Menu = (props) => {
|
||||||
sign()
|
sign()
|
||||||
}
|
}
|
||||||
}, [unActiveAccount, hasWalletLogin, library])
|
}, [unActiveAccount, hasWalletLogin, library])
|
||||||
|
// dispatch(fetchOutInfo())
|
||||||
|
// const detail = useOutLink()
|
||||||
|
// console.log('detail123456:', detail.outsideChainVos)
|
||||||
|
useEffect(() => {
|
||||||
|
// dispatch(fetchOutInfo())
|
||||||
|
// getDetail()
|
||||||
|
// const detail = useOutLink()
|
||||||
|
dispatch(fetchOutInfo())
|
||||||
|
}, [])
|
||||||
|
const detail = useOutLink()
|
||||||
|
console.log(config(t))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UikitMenu
|
<UikitMenu
|
||||||
account={account}
|
account={account}
|
||||||
|
|
@ -56,6 +76,7 @@ const Menu = (props) => {
|
||||||
setLang={setLanguage}
|
setLang={setLanguage}
|
||||||
cakePriceUsd={hccPriceUsdt.toNumber()}
|
cakePriceUsd={hccPriceUsdt.toNumber()}
|
||||||
links={config(t)}
|
links={config(t)}
|
||||||
|
outLink={detail.outsideChainVos}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export {
|
||||||
updateUserPendingReward,
|
updateUserPendingReward,
|
||||||
updateUserStakedBalance,
|
updateUserStakedBalance,
|
||||||
} from './pools'
|
} from './pools'
|
||||||
export { setUserInfo, clearUserInfo, fetchUserInfo } from './userInfo'
|
export { setUserInfo, clearUserInfo, fetchUserInfo, fetchOutInfo } from './userInfo'
|
||||||
export { fetchReferralInfoAsync } from './referral'
|
export { fetchReferralInfoAsync } from './referral'
|
||||||
export { fetchBoardsPublicDataAsync, fetchBoardUserDataAsync } from './boards'
|
export { fetchBoardsPublicDataAsync, fetchBoardUserDataAsync } from './boards'
|
||||||
export { profileFetchStart, profileFetchSucceeded, profileFetchFailed } from './profile'
|
export { profileFetchStart, profileFetchSucceeded, profileFetchFailed } from './profile'
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import {
|
||||||
Team,
|
Team,
|
||||||
BoardConfig,
|
BoardConfig,
|
||||||
} from 'config/constants/types'
|
} from 'config/constants/types'
|
||||||
import { UserInfo } from 'types/user'
|
import { UserInfo, OutLink } from 'types/user'
|
||||||
import { ReferralConfigInfo, ReferralRewardInfo } from 'types/referral'
|
import { ReferralConfigInfo, ReferralRewardInfo } from 'types/referral'
|
||||||
|
|
||||||
export type AppThunk<ReturnType = void> = ThunkAction<ReturnType, State, unknown, AnyAction>
|
export type AppThunk<ReturnType = void> = ThunkAction<ReturnType, State, unknown, AnyAction>
|
||||||
|
|
@ -481,6 +481,7 @@ export interface UserInfoState {
|
||||||
userInfo: UserInfo
|
userInfo: UserInfo
|
||||||
token?: string
|
token?: string
|
||||||
account?: string
|
account?: string
|
||||||
|
outLink?: OutLink
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReferralState {
|
export interface ReferralState {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@ export const useToken = () => {
|
||||||
export const useUserInfo = () => {
|
export const useUserInfo = () => {
|
||||||
return useSelector((state: State) => state.userInfo.userInfo)
|
return useSelector((state: State) => state.userInfo.userInfo)
|
||||||
}
|
}
|
||||||
|
export const useOutLink = () => {
|
||||||
|
return useSelector((state: State) => state.userInfo.outLink)
|
||||||
|
}
|
||||||
|
|
||||||
// 签名登录
|
// 签名登录
|
||||||
export const useSignLogin = () => {
|
export const useSignLogin = () => {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit'
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit'
|
||||||
import { queryUserInfo } from 'services/user'
|
import { queryUserInfo, uccnDetail } from 'services/user'
|
||||||
import { CACHE_TOKEN, CACHE_ACCOUNT, CACHE_USERINFO } from 'config/constants/cacheKey'
|
import { CACHE_TOKEN, CACHE_ACCOUNT, CACHE_USERINFO } from 'config/constants/cacheKey'
|
||||||
import { UserInfo } from 'types/user'
|
import { UserInfo, OutLink } from 'types/user'
|
||||||
import { UserInfoState } from '../types'
|
import { UserInfoState } from '../types'
|
||||||
|
|
||||||
const initialState: UserInfoState = {
|
const initialState: UserInfoState = {
|
||||||
userInfo: {},
|
userInfo: {},
|
||||||
|
outLink: {},
|
||||||
token: localStorage.getItem(CACHE_TOKEN),
|
token: localStorage.getItem(CACHE_TOKEN),
|
||||||
account: localStorage.getItem(CACHE_ACCOUNT),
|
account: localStorage.getItem(CACHE_ACCOUNT),
|
||||||
}
|
}
|
||||||
|
|
@ -15,6 +16,11 @@ export const fetchUserInfo = createAsyncThunk<UserInfo, null>('userInfo/fetchUse
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const fetchOutInfo = createAsyncThunk<OutLink, null>('uccn/detail', async () => {
|
||||||
|
const result = await uccnDetail()
|
||||||
|
return result
|
||||||
|
})
|
||||||
|
|
||||||
export const userInfoSlice = createSlice({
|
export const userInfoSlice = createSlice({
|
||||||
name: 'userInfo',
|
name: 'userInfo',
|
||||||
initialState,
|
initialState,
|
||||||
|
|
@ -22,6 +28,7 @@ export const userInfoSlice = createSlice({
|
||||||
setUserInfo: (state, action) => {
|
setUserInfo: (state, action) => {
|
||||||
const info = action.payload
|
const info = action.payload
|
||||||
state.userInfo = info
|
state.userInfo = info
|
||||||
|
state.outLink = info.outLink
|
||||||
state.account = info.address
|
state.account = info.address
|
||||||
info.token && (state.token = info.token)
|
info.token && (state.token = info.token)
|
||||||
localStorage.setItem(CACHE_TOKEN, state.token)
|
localStorage.setItem(CACHE_TOKEN, state.token)
|
||||||
|
|
@ -36,15 +43,22 @@ export const userInfoSlice = createSlice({
|
||||||
localStorage.removeItem(CACHE_USERINFO)
|
localStorage.removeItem(CACHE_USERINFO)
|
||||||
localStorage.removeItem(CACHE_ACCOUNT)
|
localStorage.removeItem(CACHE_ACCOUNT)
|
||||||
},
|
},
|
||||||
|
setOutLinkInfo: (state, action) => {
|
||||||
|
state.outLink = action.payload.outLink
|
||||||
|
},
|
||||||
},
|
},
|
||||||
extraReducers: (builder) => {
|
extraReducers: (builder) => {
|
||||||
builder.addCase(fetchUserInfo.fulfilled, (state, action) => {
|
builder.addCase(fetchUserInfo.fulfilled, (state, action) => {
|
||||||
state.userInfo = action.payload
|
state.userInfo = action.payload
|
||||||
localStorage.setItem(CACHE_USERINFO, JSON.stringify(state.userInfo))
|
localStorage.setItem(CACHE_USERINFO, JSON.stringify(state.userInfo))
|
||||||
})
|
})
|
||||||
|
builder.addCase(fetchOutInfo.fulfilled, (state, action) => {
|
||||||
|
localStorage.setItem('cs', 'cs')
|
||||||
|
state.outLink = action.payload
|
||||||
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
export const { setUserInfo, clearUserInfo } = userInfoSlice.actions
|
export const { setUserInfo, clearUserInfo, setOutLinkInfo } = userInfoSlice.actions
|
||||||
export default userInfoSlice.reducer
|
export default userInfoSlice.reducer
|
||||||
|
|
|
||||||
|
|
@ -4,3 +4,24 @@ export interface UserInfo {
|
||||||
name?: string
|
name?: string
|
||||||
address?: string
|
address?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface OutLink {
|
||||||
|
outSideChainNumb?: string
|
||||||
|
outsideChainVos?: OUtLinkList[]
|
||||||
|
telegramNumb?: string
|
||||||
|
tradingVolume?: string
|
||||||
|
userNumb?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OUtLinkList {
|
||||||
|
content?: string
|
||||||
|
cover?: string
|
||||||
|
createdAt?: string
|
||||||
|
enabled?: boolean
|
||||||
|
englishName?: string
|
||||||
|
id?: string
|
||||||
|
link?: string
|
||||||
|
name?: string
|
||||||
|
orderNumber?: string
|
||||||
|
updatedAt?: string
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
import React, { useState, useEffect } from 'react'
|
import React, { useState, useEffect } from 'react'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
|
import { useDispatch } from 'react-redux'
|
||||||
|
import { useOutLink } from 'state/userInfo/hooks'
|
||||||
|
import { fetchOutInfo } from 'state/actions'
|
||||||
import { uccnDetail } from 'services/user'
|
import { uccnDetail } from 'services/user'
|
||||||
import { Flex, Heading, Text, Box, Button, Image, Link } from '@pancakeswap/uikit'
|
import { Flex, Heading, Text, Box, Button, Image, Link } from '@pancakeswap/uikit'
|
||||||
import { useTranslation } from 'contexts/Localization'
|
import { useTranslation } from 'contexts/Localization'
|
||||||
|
import { OutLink } from 'types/user'
|
||||||
|
|
||||||
import FlexItemCom from './FlexItemCom'
|
import FlexItemCom from './FlexItemCom'
|
||||||
|
|
||||||
|
|
@ -128,23 +132,22 @@ const ScoreDiv = styled(Flex)`
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
const InfoDiv = styled.div``
|
const InfoDiv = styled.div``
|
||||||
|
|
||||||
const FristCom: React.FC = () => {
|
const FristCom: React.FC = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
const dispatch = useDispatch()
|
||||||
// const [burned, BurnedState] = useState([
|
// const [burned, BurnedState] = useState([
|
||||||
// { id: 'userNumb', name: '持有人数量', value: '0' },
|
// { id: 'userNumb', name: '持有人数量', value: '0' },
|
||||||
// { id: 'tradingVolume', name: '交易量', value: '0' },
|
// { id: 'tradingVolume', name: '交易量', value: '0' },
|
||||||
// { id: 3, name: '市值', value: '62.55%' },
|
// { id: 3, name: '市值', value: '62.55%' },
|
||||||
// ])
|
// ])
|
||||||
const [detail, setDetail] = useState({ userNumb: 0, tradingVolume: 0, outsideChainVos: [] })
|
// const [detail, setDetail] = useState({ userNumb: 0, tradingVolume: 0, outsideChainVos: [] })
|
||||||
const getDetail = async () => {
|
// const getDetail = async () => {
|
||||||
const data = await uccnDetail()
|
// const data = await uccnDetail()
|
||||||
setDetail(data)
|
// setDetail(data)
|
||||||
}
|
// }
|
||||||
|
dispatch(fetchOutInfo())
|
||||||
useEffect(() => {
|
const detail = useOutLink()
|
||||||
getDetail()
|
console.log('detail123:', detail)
|
||||||
}, [])
|
|
||||||
const openLink = (link) => {
|
const openLink = (link) => {
|
||||||
window.open(link)
|
window.open(link)
|
||||||
}
|
}
|
||||||
|
|
@ -167,9 +170,10 @@ const FristCom: React.FC = () => {
|
||||||
</RadiusBtn>
|
</RadiusBtn>
|
||||||
{/* <WhiteBtn variant="secondary">{t('Bazaar')}</WhiteBtn> */}
|
{/* <WhiteBtn variant="secondary">{t('Bazaar')}</WhiteBtn> */}
|
||||||
<Flex>
|
<Flex>
|
||||||
{detail.outsideChainVos.map((item) => {
|
{detail.outsideChainVos?.map((item) => {
|
||||||
return (
|
return (
|
||||||
<BtnImage
|
<BtnImage
|
||||||
|
key={item.id}
|
||||||
style={{ borderRadius: '50%' }}
|
style={{ borderRadius: '50%' }}
|
||||||
src={item.cover}
|
src={item.cover}
|
||||||
alt={item.name}
|
alt={item.name}
|
||||||
|
|
@ -186,8 +190,8 @@ const FristCom: React.FC = () => {
|
||||||
</InfoDiv>
|
</InfoDiv>
|
||||||
</FlexDiv>
|
</FlexDiv>
|
||||||
<ScoreDiv>
|
<ScoreDiv>
|
||||||
<FlexItemCom name={t('Number of holders')} valueNum={detail.userNumb} />
|
<FlexItemCom name={t('Number of holders')} valueNum={detail?.userNumb} />
|
||||||
<FlexItemCom name={t('Your volume')} valueNum={detail.tradingVolume} />
|
<FlexItemCom name={t('Your volume')} valueNum={detail?.tradingVolume} />
|
||||||
<FlexItemCom name={t('market value')} valueNum={0} />
|
<FlexItemCom name={t('market value')} valueNum={0} />
|
||||||
{/* {burned.map((item) => {
|
{/* {burned.map((item) => {
|
||||||
return <FlexItemCom key={item.id} name={item.name} value={item.value} />
|
return <FlexItemCom key={item.id} name={item.name} value={item.value} />
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,8 @@ const ConnectedCom: React.FC = () => {
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
<FooterBtn>
|
<FooterBtn>
|
||||||
{referralNormalConfigInfo.receiveLimit <=
|
{referralNormalConfigInfo?.receiveLimit <=
|
||||||
referralRewardInfo.inviteReward - referralRewardInfo.inviteRewardReceive ? (
|
referralRewardInfo?.inviteReward - referralRewardInfo?.inviteRewardReceive ? (
|
||||||
<ButtonGet onClick={handleWithdraw} disabled={loading} variant="secondary">
|
<ButtonGet onClick={handleWithdraw} disabled={loading} variant="secondary">
|
||||||
{t('Claim now')}
|
{t('Claim now')}
|
||||||
</ButtonGet>
|
</ButtonGet>
|
||||||
|
|
|
||||||
|
|
@ -144,8 +144,8 @@ const RegimentalCom: React.FC = () => {
|
||||||
</>
|
</>
|
||||||
|
|
||||||
<FooterBtn>
|
<FooterBtn>
|
||||||
{referralCommanderConfigInfo.receiveLimit <=
|
{referralCommanderConfigInfo?.receiveLimit <=
|
||||||
referralRewardInfo.inviteReward - referralRewardInfo.inviteRewardReceive ? (
|
referralRewardInfo?.inviteReward - referralRewardInfo?.inviteRewardReceive ? (
|
||||||
<ButtonGet variant="secondary" disabled={loading} onClick={handleWithdraw}>
|
<ButtonGet variant="secondary" disabled={loading} onClick={handleWithdraw}>
|
||||||
{t('Claim now')}
|
{t('Claim now')}
|
||||||
</ButtonGet>
|
</ButtonGet>
|
||||||
|
|
@ -158,7 +158,7 @@ const RegimentalCom: React.FC = () => {
|
||||||
<FooterDiv>
|
<FooterDiv>
|
||||||
<TextDiv>{`${t(
|
<TextDiv>{`${t(
|
||||||
'By using the invitation at the top right of the page, new users can be invited to enter and obtained after users purchase coins',
|
'By using the invitation at the top right of the page, new users can be invited to enter and obtained after users purchase coins',
|
||||||
)}${formatDivNumber(referralCommanderConfigInfo.dividendFirst)}%${t('The commission')}`}</TextDiv>
|
)}${formatDivNumber(referralCommanderConfigInfo?.dividendFirst)}%${t('The commission')}`}</TextDiv>
|
||||||
{/* <TextDiv color="textSubtle">{t('each time')}</TextDiv>
|
{/* <TextDiv color="textSubtle">{t('each time')}</TextDiv>
|
||||||
<TextDiv color="textSubtle">{t('last bid')}</TextDiv>
|
<TextDiv color="textSubtle">{t('last bid')}</TextDiv>
|
||||||
<TextDiv color="textSubtle">{t('commission fee')}</TextDiv> */}
|
<TextDiv color="textSubtle">{t('commission fee')}</TextDiv> */}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue