stacker.news/components/footer-rewards.js

24 lines
678 B
JavaScript
Raw Normal View History

2023-07-06 17:43:51 +00:00
import { gql, useQuery } from '@apollo/client'
import Link from 'next/link'
import { RewardLine } from '@/pages/rewards'
import { LONG_POLL_INTERVAL, SSR } from '@/lib/constants'
2023-07-06 17:43:51 +00:00
const REWARDS = gql`
{
2023-08-15 17:41:51 +00:00
rewards {
2023-07-06 17:43:51 +00:00
total
time
2023-07-06 17:43:51 +00:00
}
}`
export default function Rewards () {
const { data } = useQuery(REWARDS, SSR ? { ssr: false } : { pollInterval: LONG_POLL_INTERVAL, nextFetchPolicy: 'cache-and-network' })
2023-08-30 00:13:21 +00:00
const total = data?.rewards?.[0]?.total
const time = data?.rewards?.[0]?.time
2023-07-06 17:43:51 +00:00
return (
<Link href='/rewards' className='nav-link p-0 p-0 d-inline-flex'>
{total ? <span><RewardLine total={total} time={time} /></span> : 'rewards'}
2023-07-06 17:43:51 +00:00
</Link>
)
}