2023-08-06 15:47:58 +00:00
|
|
|
import { useEffect } from 'react'
|
2022-04-21 17:48:27 +00:00
|
|
|
import { getGetServerSideProps } from '../api/ssrApollo'
|
|
|
|
import Layout from '../components/layout'
|
2023-08-03 19:56:59 +00:00
|
|
|
import Notifications, { NotificationAlert } from '../components/notifications'
|
2023-08-06 15:47:58 +00:00
|
|
|
import { HAS_NOTIFICATIONS, NOTIFICATIONS } from '../fragments/notifications'
|
|
|
|
import { useApolloClient } from '@apollo/client'
|
2023-11-09 00:17:01 +00:00
|
|
|
import { clearNotifications } from '../lib/badge'
|
2022-04-20 21:35:07 +00:00
|
|
|
|
2023-08-28 17:52:15 +00:00
|
|
|
export const getServerSideProps = getGetServerSideProps({ query: NOTIFICATIONS, authRequired: true })
|
2022-04-20 21:35:07 +00:00
|
|
|
|
2023-07-23 15:08:43 +00:00
|
|
|
export default function NotificationPage ({ ssrData }) {
|
2023-08-06 15:47:58 +00:00
|
|
|
const client = useApolloClient()
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
client?.writeQuery({
|
|
|
|
query: HAS_NOTIFICATIONS,
|
|
|
|
data: {
|
|
|
|
hasNewNotes: false
|
|
|
|
}
|
|
|
|
})
|
2023-11-09 00:17:01 +00:00
|
|
|
clearNotifications()
|
2023-08-31 01:00:16 +00:00
|
|
|
}, [ssrData])
|
2023-08-06 15:47:58 +00:00
|
|
|
|
2022-04-20 21:35:07 +00:00
|
|
|
return (
|
|
|
|
<Layout>
|
2023-08-03 19:56:59 +00:00
|
|
|
<NotificationAlert />
|
2023-07-23 15:08:43 +00:00
|
|
|
<Notifications ssrData={ssrData} />
|
2022-04-20 21:35:07 +00:00
|
|
|
</Layout>
|
|
|
|
)
|
|
|
|
}
|