stacker.news/pages/live.js

33 lines
788 B
JavaScript
Raw Normal View History

2023-07-24 18:35:05 +00:00
import Button from 'react-bootstrap/Button'
import { CenterLayout } from '../components/layout'
2023-06-20 01:26:34 +00:00
import Snl from '../components/snl'
import { gql } from 'graphql-tag'
2023-06-20 01:26:34 +00:00
import { useMutation, useQuery } from '@apollo/client'
export default function Index () {
const [toggle] = useMutation(
gql`
mutation onAirToggle {
onAirToggle
}`, {
update (cache, { data: { onAirToggle } }) {
cache.modify({
id: 'ROOT_QUERY',
fields: {
snl: () => onAirToggle
}
})
}
}
)
const { data } = useQuery(gql`{ snl }`)
2023-06-20 01:26:34 +00:00
return (
<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>
</CenterLayout>
2023-06-20 01:26:34 +00:00
)
}