mirror of
https://github.com/acid-info/logos-ordinals-dashboard.git
synced 2025-01-12 14:44:14 +00:00
chore: misc. ui updates
This commit is contained in:
parent
83dfc50a0f
commit
095fe9b6e7
3
atoms/epochs.ts
Normal file
3
atoms/epochs.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import { atom } from 'jotai'
|
||||||
|
|
||||||
|
export const epochsAtom = atom<any | null>(null)
|
@ -8,6 +8,7 @@ import { usePinOperator } from '../../../../apis/operators/usePinOperator'
|
|||||||
import { useStakeOperator } from '../../../../apis/operators/useStakeOperator'
|
import { useStakeOperator } from '../../../../apis/operators/useStakeOperator'
|
||||||
import { useUnstakeOperator } from '../../../../apis/operators/useUnstakeOperator'
|
import { useUnstakeOperator } from '../../../../apis/operators/useUnstakeOperator'
|
||||||
import { degenModeAtom } from '../../../../atoms/degenMode'
|
import { degenModeAtom } from '../../../../atoms/degenMode'
|
||||||
|
import { epochsAtom } from '../../../../atoms/epochs'
|
||||||
import { userInfoAtom } from '../../../../atoms/userInfo'
|
import { userInfoAtom } from '../../../../atoms/userInfo'
|
||||||
import { walletAddressAtom } from '../../../../atoms/wallet'
|
import { walletAddressAtom } from '../../../../atoms/wallet'
|
||||||
import { ProcessedOperator } from '../../../../types/operators'
|
import { ProcessedOperator } from '../../../../types/operators'
|
||||||
@ -23,6 +24,9 @@ const OperatorCard: React.FC<OperatorCardProps> = ({
|
|||||||
const isDegenMode = useAtomValue(degenModeAtom)
|
const isDegenMode = useAtomValue(degenModeAtom)
|
||||||
|
|
||||||
const [isStaked, setIsStaked] = useState(operator.isStaked)
|
const [isStaked, setIsStaked] = useState(operator.isStaked)
|
||||||
|
const epochs = useAtomValue(epochsAtom)
|
||||||
|
|
||||||
|
const xpPerBlock = epochs?.[0]?.xp_per_block
|
||||||
|
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
@ -95,7 +99,7 @@ const OperatorCard: React.FC<OperatorCardProps> = ({
|
|||||||
<OperatorName>{operator.name}</OperatorName>
|
<OperatorName>{operator.name}</OperatorName>
|
||||||
<PointsPerHour>
|
<PointsPerHour>
|
||||||
<Label>XP/Block</Label>
|
<Label>XP/Block</Label>
|
||||||
<Value>{operator.pointsPerHour} XP</Value>
|
<Value>{xpPerBlock} XP</Value>
|
||||||
</PointsPerHour>
|
</PointsPerHour>
|
||||||
</OperatorInfo>
|
</OperatorInfo>
|
||||||
<Actions>
|
<Actions>
|
||||||
|
@ -61,6 +61,8 @@ const OperatorPanel: React.FC<OperatorPanelProps> = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('user', user)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledPanel>
|
<StyledPanel>
|
||||||
{user?.pinned_operator && (
|
{user?.pinned_operator && (
|
||||||
@ -110,7 +112,7 @@ const OperatorPanel: React.FC<OperatorPanelProps> = () => {
|
|||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow>
|
<InfoRow>
|
||||||
<Label>Role</Label>
|
<Label>Role</Label>
|
||||||
<Value>{user?.id && 'Operator'}</Value>
|
<Value>{user?.role && 'Operator'}</Value>
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow>
|
<InfoRow>
|
||||||
<Label>OP Number</Label>
|
<Label>OP Number</Label>
|
||||||
|
@ -3,7 +3,7 @@ import { numberWithCommas } from '@/utils/general.utils'
|
|||||||
import styled from '@emotion/styled'
|
import styled from '@emotion/styled'
|
||||||
import { useAtomValue } from 'jotai'
|
import { useAtomValue } from 'jotai'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import useGetEpochs from '../../../../apis/general/useGetEpochs'
|
import { epochsAtom } from '../../../../atoms/epochs'
|
||||||
import { userInfoAtom } from '../../../../atoms/userInfo'
|
import { userInfoAtom } from '../../../../atoms/userInfo'
|
||||||
|
|
||||||
interface ProgressBarProps {
|
interface ProgressBarProps {
|
||||||
@ -16,16 +16,19 @@ const ProgressBar: React.FC<ProgressBarProps> = ({
|
|||||||
claimPosition = 76,
|
claimPosition = 76,
|
||||||
}) => {
|
}) => {
|
||||||
const user = useAtomValue(userInfoAtom)
|
const user = useAtomValue(userInfoAtom)
|
||||||
|
const epochs = useAtomValue(epochsAtom)
|
||||||
const { data: epochs } = useGetEpochs({
|
|
||||||
enabled: user?.address?.length > 0,
|
|
||||||
})
|
|
||||||
|
|
||||||
// const { data: currentBlock } = useGetCurrentBTCBlock()
|
// const { data: currentBlock } = useGetCurrentBTCBlock()
|
||||||
// const { data: pillars } = useGetPillars()
|
// const { data: pillars } = useGetPillars()
|
||||||
|
|
||||||
// console.log('currentBlock', currentBlock)
|
// console.log('currentBlock', currentBlock)
|
||||||
// console.log('epochs', epochs)
|
|
||||||
|
// sum up user => operators => staking_xp_per_block
|
||||||
|
const epochXP =
|
||||||
|
user?.operators.reduce(
|
||||||
|
(acc: any, operator: any) => acc + operator.staking_xp_per_block,
|
||||||
|
0,
|
||||||
|
) || 0
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
@ -71,7 +74,7 @@ const ProgressBar: React.FC<ProgressBarProps> = ({
|
|||||||
<EarnedReward>
|
<EarnedReward>
|
||||||
<Label>Epoch 1 XP</Label>
|
<Label>Epoch 1 XP</Label>
|
||||||
<Value color="#F29AE9" backgroundColor="#320430">
|
<Value color="#F29AE9" backgroundColor="#320430">
|
||||||
{`${numberWithCommas(0)}`}
|
{`${numberWithCommas(epochXP)}`}
|
||||||
</Value>
|
</Value>
|
||||||
</EarnedReward>
|
</EarnedReward>
|
||||||
</PointsRow>
|
</PointsRow>
|
||||||
|
@ -47,8 +47,8 @@ const Toast: React.FC = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ToastContainer showTopToast={showTopToast}>
|
<ToastContainer showTopToast={showTopToast}>
|
||||||
{userInfo?.message?.length > 0 ? (
|
{userInfo?.alert_message?.length > 0 ? (
|
||||||
userInfo.message
|
userInfo.alert_message
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
Logos Ordinals Mint Begins November 4, 2024 at 1PM UTC
|
Logos Ordinals Mint Begins November 4, 2024 at 1PM UTC
|
||||||
|
@ -26,8 +26,6 @@ const Dropdown: React.FC = () => {
|
|||||||
const [isExpanded, setIsExpanded] = useState(false)
|
const [isExpanded, setIsExpanded] = useState(false)
|
||||||
const [walletAddress, setWalletAddress] = useAtom(walletAddressAtom)
|
const [walletAddress, setWalletAddress] = useAtom(walletAddressAtom)
|
||||||
|
|
||||||
console.log('walletAddress', walletAddress)
|
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const { referral_code, referral_address, referral_source } = router.query
|
const { referral_code, referral_address, referral_source } = router.query
|
||||||
@ -77,10 +75,10 @@ const Dropdown: React.FC = () => {
|
|||||||
sessionStorage.setItem('refreshToken', refresh)
|
sessionStorage.setItem('refreshToken', refresh)
|
||||||
sessionStorage.setItem('walletAddress', address)
|
sessionStorage.setItem('walletAddress', address)
|
||||||
|
|
||||||
if (referral_code?.length && referral_address?.length) {
|
if (referral_code?.length) {
|
||||||
await api.post('/user/referral', {
|
await api.post('/user/referral', {
|
||||||
referral_code: referral_code,
|
referral_code: referral_code,
|
||||||
referral_address: referral_address,
|
referral_address: walletAddress,
|
||||||
referral_source: referral_source || '',
|
referral_source: referral_source || '',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import styled from '@emotion/styled'
|
import styled from '@emotion/styled'
|
||||||
import { useAtomValue } from 'jotai'
|
|
||||||
import { userInfoAtom } from '../../../../atoms/userInfo'
|
|
||||||
import Collapse from './Collapse'
|
import Collapse from './Collapse'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -8,13 +6,13 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CopyCode = ({ referralCode }: Props) => {
|
const CopyCode = ({ referralCode }: Props) => {
|
||||||
const walletAddress = useAtomValue(userInfoAtom)?.address
|
// const walletAddress = useAtomValue(userInfoAtom)?.address
|
||||||
|
|
||||||
// attach : ?referral_code=${referralCode}&referral_address=${walletAddress}
|
// attach : ?referral_code=${referralCode}&referral_address=${walletAddress}
|
||||||
|
|
||||||
const copyToClipboard = () => {
|
const copyToClipboard = () => {
|
||||||
const currentUrl = window.location.href
|
const currentUrl = window.location.href
|
||||||
const referral = `${currentUrl}?referral_code=${referralCode}&referral_address=${walletAddress}`
|
const referral = `${currentUrl}?referral_code=${referralCode}`
|
||||||
|
|
||||||
navigator.clipboard.writeText(referral || '')
|
navigator.clipboard.writeText(referral || '')
|
||||||
|
|
||||||
|
@ -3,10 +3,12 @@ import { OperatorPanel } from '@/components/Dashboard/OperatorPanel'
|
|||||||
import { ProgressBar } from '@/components/Dashboard/ProgressBar'
|
import { ProgressBar } from '@/components/Dashboard/ProgressBar'
|
||||||
import { breakpoints } from '@/configs/ui.configs'
|
import { breakpoints } from '@/configs/ui.configs'
|
||||||
import styled from '@emotion/styled'
|
import styled from '@emotion/styled'
|
||||||
import { useAtom } 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 useGetEpochs from '../../../apis/general/useGetEpochs'
|
||||||
import useGetUserInfo from '../../../apis/operators/useGetUserInfo'
|
import useGetUserInfo from '../../../apis/operators/useGetUserInfo'
|
||||||
|
import { epochsAtom } from '../../../atoms/epochs'
|
||||||
import { userInfoAtom } from '../../../atoms/userInfo'
|
import { userInfoAtom } from '../../../atoms/userInfo'
|
||||||
import { walletAddressAtom } from '../../../atoms/wallet'
|
import { walletAddressAtom } from '../../../atoms/wallet'
|
||||||
import { processMyOperators } from '../../../utils/operators'
|
import { processMyOperators } from '../../../utils/operators'
|
||||||
@ -29,6 +31,18 @@ const DashboardContainer: React.FC<DashboardPageProps> = ({
|
|||||||
setUserInfo,
|
setUserInfo,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { data: epochsData } = useGetEpochs({
|
||||||
|
enabled: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
const setEpochs = useSetAtom(epochsAtom)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (epochsData) {
|
||||||
|
setEpochs(epochsData)
|
||||||
|
}
|
||||||
|
}, [epochsData, setEpochs])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const walletAddress = sessionStorage.getItem('walletAddress')
|
const walletAddress = sessionStorage.getItem('walletAddress')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user