2023-07-24 18:35:05 +00:00
|
|
|
import Button from 'react-bootstrap/Button'
|
2023-07-23 15:08:43 +00:00
|
|
|
import { CenterLayout } from '../components/layout'
|
2023-06-20 01:26:34 +00:00
|
|
|
import Snl from '../components/snl'
|
2023-07-23 15:08:43 +00:00
|
|
|
import { gql } from 'graphql-tag'
|
2023-06-20 01:26:34 +00:00
|
|
|
import { useMutation, useQuery } from '@apollo/client'
|
2024-02-13 22:40:26 +00:00
|
|
|
import { getGetServerSideProps } from '../api/ssrApollo'
|
|
|
|
|
|
|
|
// force SSR to include CSP nonces
|
|
|
|
export const getServerSideProps = getGetServerSideProps({ query: null })
|
2023-06-20 01:26:34 +00:00
|
|
|
|
|
|
|
export default function Index () {
|
|
|
|
const [toggle] = useMutation(
|
|
|
|
gql`
|
|
|
|
mutation onAirToggle {
|
|
|
|
onAirToggle
|
|
|
|
}`, {
|
|
|
|
update (cache, { data: { onAirToggle } }) {
|
|
|
|
cache.modify({
|
|
|
|
id: 'ROOT_QUERY',
|
|
|
|
fields: {
|
|
|
|
snl: () => onAirToggle
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2023-07-23 15:08:43 +00:00
|
|
|
const { data } = useQuery(gql`{ snl }`)
|
2023-06-20 01:26:34 +00:00
|
|
|
|
|
|
|
return (
|
2023-07-23 15:08:43 +00:00
|
|
|
<CenterLayout>
|
2023-06-20 01:26:34 +00:00
|
|
|
<Snl />
|
|
|
|
<Button variant={data?.snl ? 'primary' : 'danger'} onClick={toggle}>go: {data?.snl ? 'off' : 'on'} air</Button>
|
2023-07-23 15:08:43 +00:00
|
|
|
</CenterLayout>
|
2023-06-20 01:26:34 +00:00
|
|
|
)
|
|
|
|
}
|