import Layout from '@/components/layout' import { Form, Input, SubmitButton } from '@/components/form' import InputGroup from 'react-bootstrap/InputGroup' import { gql, useMutation, useQuery } from '@apollo/client' import { INVITE_FIELDS } from '@/fragments/invites' import AccordianItem from '@/components/accordian-item' import styles from '@/styles/invites.module.css' import Invite from '@/components/invite' import { inviteSchema } from '@/lib/validate' import { SSR } from '@/lib/constants' import { getGetServerSideProps } from '@/api/ssrApollo' import Info from '@/components/info' import Text from '@/components/text' // force SSR to include CSP nonces export const getServerSideProps = getGetServerSideProps({ query: null }) function InviteForm () { const [createInvite] = useMutation( gql` ${INVITE_FIELDS} mutation createInvite($id: String, $gift: Int!, $limit: Int!, $description: String) { createInvite(id: $id, gift: $gift, limit: $limit, description: $description) { ...InviteFields } }`, { update (cache, { data: { createInvite } }) { cache.modify({ fields: { invites (existingInviteRefs = []) { const newInviteRef = cache.writeFragment({ fragmentName: 'InviteFields', data: createInvite, fragment: INVITE_FIELDS }) return [newInviteRef, ...existingInviteRefs] } } }) } } ) const initialValues = { id: '', gift: 1000, limit: 1, description: '' } return (
) } function InviteList ({ name, invites }) { return (