2023-07-25 20:29:45 +00:00
|
|
|
import { gql, useQuery } from '@apollo/client'
|
2024-03-20 00:37:31 +00:00
|
|
|
import { getGetServerSideProps } from '@/api/ssrApollo'
|
|
|
|
import Layout from '@/components/layout'
|
2023-07-24 18:35:05 +00:00
|
|
|
import Col from 'react-bootstrap/Col'
|
|
|
|
import Row from 'react-bootstrap/Row'
|
2024-03-20 00:37:31 +00:00
|
|
|
import { UsageHeader } from '@/components/usage-header'
|
2023-05-19 23:12:48 +00:00
|
|
|
import { useRouter } from 'next/router'
|
2023-07-25 14:14:45 +00:00
|
|
|
import dynamic from 'next/dynamic'
|
2024-03-20 00:37:31 +00:00
|
|
|
import PageLoading from '@/components/page-loading'
|
2024-03-23 03:47:21 +00:00
|
|
|
import { WhenAreaChartSkeleton, WhenComposedChartSkeleton, WhenLineChartSkeleton } from '@/components/charts-skeletons'
|
2023-07-24 22:50:12 +00:00
|
|
|
|
2024-03-20 00:37:31 +00:00
|
|
|
const WhenAreaChart = dynamic(() => import('@/components/charts').then(mod => mod.WhenAreaChart), {
|
2024-03-23 03:47:21 +00:00
|
|
|
loading: () => <WhenAreaChartSkeleton />
|
2023-07-25 14:14:45 +00:00
|
|
|
})
|
2024-03-20 00:37:31 +00:00
|
|
|
const WhenLineChart = dynamic(() => import('@/components/charts').then(mod => mod.WhenLineChart), {
|
2024-03-23 03:47:21 +00:00
|
|
|
loading: () => <WhenLineChartSkeleton />
|
2023-07-25 14:14:45 +00:00
|
|
|
})
|
2024-03-20 00:37:31 +00:00
|
|
|
const WhenComposedChart = dynamic(() => import('@/components/charts').then(mod => mod.WhenComposedChart), {
|
2024-03-23 03:47:21 +00:00
|
|
|
loading: () => <WhenComposedChartSkeleton />
|
2023-08-14 20:36:54 +00:00
|
|
|
})
|
2023-05-18 23:41:56 +00:00
|
|
|
|
2023-07-25 20:29:45 +00:00
|
|
|
const GROWTH_QUERY = gql`
|
2023-11-09 00:15:36 +00:00
|
|
|
query Growth($when: String!, $from: String, $to: String)
|
2023-07-25 20:29:45 +00:00
|
|
|
{
|
2023-11-09 00:15:36 +00:00
|
|
|
registrationGrowth(when: $when, from: $from, to: $to) {
|
2023-07-25 20:29:45 +00:00
|
|
|
time
|
|
|
|
data {
|
|
|
|
name
|
|
|
|
value
|
2023-05-18 23:41:56 +00:00
|
|
|
}
|
2023-07-25 20:29:45 +00:00
|
|
|
}
|
2023-11-09 00:15:36 +00:00
|
|
|
itemGrowth(when: $when, from: $from, to: $to) {
|
2023-07-25 20:29:45 +00:00
|
|
|
time
|
|
|
|
data {
|
|
|
|
name
|
|
|
|
value
|
2023-05-18 23:41:56 +00:00
|
|
|
}
|
2023-07-25 20:29:45 +00:00
|
|
|
}
|
2023-11-09 00:15:36 +00:00
|
|
|
spendingGrowth(when: $when, from: $from, to: $to) {
|
2023-07-25 20:29:45 +00:00
|
|
|
time
|
|
|
|
data {
|
|
|
|
name
|
|
|
|
value
|
2023-05-18 23:41:56 +00:00
|
|
|
}
|
2023-07-25 20:29:45 +00:00
|
|
|
}
|
2023-11-09 00:15:36 +00:00
|
|
|
spenderGrowth(when: $when, from: $from, to: $to) {
|
2023-07-25 20:29:45 +00:00
|
|
|
time
|
|
|
|
data {
|
|
|
|
name
|
|
|
|
value
|
2023-05-18 23:41:56 +00:00
|
|
|
}
|
2023-07-25 20:29:45 +00:00
|
|
|
}
|
2023-11-09 00:15:36 +00:00
|
|
|
stackingGrowth(when: $when, from: $from, to: $to) {
|
2023-07-25 20:29:45 +00:00
|
|
|
time
|
|
|
|
data {
|
|
|
|
name
|
|
|
|
value
|
2023-05-18 23:41:56 +00:00
|
|
|
}
|
2023-07-25 20:29:45 +00:00
|
|
|
}
|
2023-11-09 00:15:36 +00:00
|
|
|
stackerGrowth(when: $when, from: $from, to: $to) {
|
2023-07-25 20:29:45 +00:00
|
|
|
time
|
|
|
|
data {
|
|
|
|
name
|
|
|
|
value
|
2023-05-18 23:41:56 +00:00
|
|
|
}
|
2023-07-25 20:29:45 +00:00
|
|
|
}
|
|
|
|
}`
|
2023-05-18 23:41:56 +00:00
|
|
|
|
2023-08-28 17:52:15 +00:00
|
|
|
export const getServerSideProps = getGetServerSideProps({ query: GROWTH_QUERY })
|
2023-07-25 20:29:45 +00:00
|
|
|
|
|
|
|
export default function Growth ({ ssrData }) {
|
2023-05-19 23:12:48 +00:00
|
|
|
const router = useRouter()
|
2023-11-09 00:15:36 +00:00
|
|
|
const { when, from, to } = router.query
|
2023-07-24 22:50:12 +00:00
|
|
|
|
2023-11-09 00:15:36 +00:00
|
|
|
const { data } = useQuery(GROWTH_QUERY, { variables: { when, from, to } })
|
2023-07-25 20:29:45 +00:00
|
|
|
if (!data && !ssrData) return <PageLoading />
|
|
|
|
|
|
|
|
const { registrationGrowth, itemGrowth, spendingGrowth, spenderGrowth, stackingGrowth, stackerGrowth } = data || ssrData
|
|
|
|
|
2023-05-18 23:41:56 +00:00
|
|
|
return (
|
|
|
|
<Layout>
|
|
|
|
<UsageHeader />
|
|
|
|
<Row>
|
|
|
|
<Col className='mt-3'>
|
2024-01-19 21:19:26 +00:00
|
|
|
<div className='text-center text-muted fw-bold'>stackers</div>
|
2023-07-25 14:14:45 +00:00
|
|
|
<WhenLineChart data={stackerGrowth} />
|
2023-05-18 23:41:56 +00:00
|
|
|
</Col>
|
|
|
|
<Col className='mt-3'>
|
2023-07-24 18:35:05 +00:00
|
|
|
<div className='text-center text-muted fw-bold'>stacking</div>
|
2023-07-25 14:14:45 +00:00
|
|
|
<WhenAreaChart data={stackingGrowth} />
|
2023-05-18 23:41:56 +00:00
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
<Row>
|
|
|
|
<Col className='mt-3'>
|
2024-01-19 21:19:26 +00:00
|
|
|
<div className='text-center text-muted fw-bold'>spenders</div>
|
2023-07-25 14:14:45 +00:00
|
|
|
<WhenLineChart data={spenderGrowth} />
|
2023-05-18 23:41:56 +00:00
|
|
|
</Col>
|
|
|
|
<Col className='mt-3'>
|
2023-07-24 18:35:05 +00:00
|
|
|
<div className='text-center text-muted fw-bold'>spending</div>
|
2023-07-25 14:14:45 +00:00
|
|
|
<WhenAreaChart data={spendingGrowth} />
|
2023-05-18 23:41:56 +00:00
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
<Row>
|
|
|
|
<Col className='mt-3'>
|
2023-07-24 18:35:05 +00:00
|
|
|
<div className='text-center text-muted fw-bold'>registrations</div>
|
2023-07-25 14:14:45 +00:00
|
|
|
<WhenAreaChart data={registrationGrowth} />
|
2023-05-18 23:41:56 +00:00
|
|
|
</Col>
|
|
|
|
<Col className='mt-3'>
|
2023-07-24 18:35:05 +00:00
|
|
|
<div className='text-center text-muted fw-bold'>items</div>
|
2024-01-19 21:19:26 +00:00
|
|
|
<WhenComposedChart data={itemGrowth} areaNames={['posts', 'comments', 'jobs']} areaAxis='left' lineNames={['comments/posts', 'territories']} lineAxis='right' barNames={['zaps']} />
|
2023-05-18 23:41:56 +00:00
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</Layout>
|
|
|
|
)
|
|
|
|
}
|