stacker.news/pages/notifications.js

38 lines
938 B
JavaScript
Raw Normal View History

import { useRouter } from 'next/router'
2021-09-30 15:46:58 +00:00
import getSSRApolloClient from '../api/ssrApollo'
2021-06-24 23:56:01 +00:00
import Layout from '../components/layout'
import Notifications from '../components/notifications'
2021-09-30 15:46:58 +00:00
import { NOTIFICATIONS } from '../fragments/notifications'
2021-06-24 23:56:01 +00:00
2021-09-30 15:46:58 +00:00
export async function getServerSideProps ({ req }) {
const client = await getSSRApolloClient(req)
const { data } = await client.query({
query: NOTIFICATIONS
})
let notifications, cursor, lastChecked
if (data) {
({ notifications: { notifications, cursor, lastChecked } } = data)
}
return {
props: {
notifications,
cursor,
lastChecked
}
}
}
export default function NotificationPage ({ notifications, cursor, lastChecked }) {
const router = useRouter()
2021-06-24 23:56:01 +00:00
return (
<Layout>
2021-09-30 15:46:58 +00:00
<Notifications
notifications={notifications} cursor={cursor}
lastChecked={lastChecked} key={router.query.key}
/>
2021-06-24 23:56:01 +00:00
</Layout>
)
}