import Layout from '../components/layout' import Button from 'react-bootstrap/Button' import { Form, Input, SubmitButton } from '../components/form' import { useRouter } from 'next/router' import Link from 'next/link' import styles from '../styles/post.module.css' import * as Yup from 'yup' import { gql, useMutation } from '@apollo/client' export const DiscussionSchema = Yup.object({ title: Yup.string().required('required').trim() }) export function DiscussionForm () { const router = useRouter() const [createDiscussion] = useMutation( gql` mutation createDiscussion($title: String!, $text: String) { createDiscussion(title: $title, text: $text) { id } }` ) return (
) } export const LinkSchema = Yup.object({ title: Yup.string().required('required').trim(), url: Yup.string().url('invalid url') }) export function LinkForm () { const router = useRouter() const [createLink] = useMutation( gql` mutation createLink($title: String!, $url: String!) { createLink(title: $title, url: $url) { id } }` ) return ( ) } export function PostForm () { const router = useRouter() if (!router.query.type) { return (