2021-09-06 22:36:08 +00:00
|
|
|
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'
|
2021-08-17 23:07:52 +00:00
|
|
|
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 }) {
|
2021-09-06 22:36:08 +00:00
|
|
|
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>
|
|
|
|
)
|
|
|
|
}
|