import { gql } from 'graphql-tag' import Link from 'next/link' import { useRouter } from 'next/router' import { getGetServerSideProps } from '../../api/ssrApollo' import { CopyInput, Select } from '../../components/form' import { CenterLayout } from '../../components/layout' import { useMe } from '../../components/me' import { useQuery } from '@apollo/client' import PageLoading from '../../components/page-loading' import { WHENS } from '../../lib/constants' import dynamic from 'next/dynamic' import { numWithUnits } from '../../lib/format' const WhenComposedChart = dynamic(() => import('../../components/charts').then(mod => mod.WhenComposedChart), { loading: () =>
Loading...
}) const REFERRALS = gql` query Referrals($when: String!) { referrals(when: $when) { totalSats totalReferrals stats { time data { name value } } } }` export const getServerSideProps = getGetServerSideProps(REFERRALS) export default function Referrals ({ ssrData }) { const router = useRouter() const me = useMe() const { data } = useQuery(REFERRALS, { variables: { when: router.query.when } }) if (!data && !ssrData) return const { referrals: { totalSats, totalReferrals, stats } } = data || ssrData return (

{numWithUnits(totalReferrals, { unitPlural: 'referrals', unitSingular: 'referral' })} & {numWithUnits(totalSats, { abbreviate: false })} in the last