swap Flash for Toast

This commit is contained in:
David S Price
2021-03-30 22:13:06 -07:00
parent f0ae0690a9
commit e1bbc3f1ce

View File

@@ -7,7 +7,8 @@ import {
Label, Label,
FormError, FormError,
} from '@redwoodjs/forms' } from '@redwoodjs/forms'
import { Flash, useFlash, useMutation } from '@redwoodjs/web' import { useMutation } from '@redwoodjs/web'
import { toast, Toaster } from '@redwoodjs/web/toast'
import { useForm } from 'react-hook-form' import { useForm } from 'react-hook-form'
const CREATE_CONTACT = gql` const CREATE_CONTACT = gql`
@@ -20,13 +21,10 @@ const CREATE_CONTACT = gql`
const ContactPage = () => { const ContactPage = () => {
const formMethods = useForm() const formMethods = useForm()
const { addMessage } = useFlash()
const [create, { loading, error }] = useMutation(CREATE_CONTACT, { const [create, { loading, error }] = useMutation(CREATE_CONTACT, {
onCompleted: () => { onCompleted: () => {
addMessage('Thank you for your submission!', { toast.success('Thank you for your submission!')
style: { backgroundColor: 'green', color: 'white', padding: '1rem' },
})
formMethods.reset() formMethods.reset()
}, },
}) })
@@ -38,7 +36,7 @@ const ContactPage = () => {
return ( return (
<> <>
<Flash timeout={1000} className="bg-green-100 text-green-700" /> <Toaster />
<Form <Form
onSubmit={onSubmit} onSubmit={onSubmit}
validation={{ mode: 'onBlur' }} validation={{ mode: 'onBlur' }}