swap Flash for Toast
This commit is contained in:
@@ -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' }}
|
||||||
|
|||||||
Reference in New Issue
Block a user