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