Fix flash after new routing
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import { useMutation, useFlash } from '@redwoodjs/web'
|
import { useMutation } from '@redwoodjs/web'
|
||||||
import { navigate, routes } from '@redwoodjs/router'
|
|
||||||
import PartForm from 'src/components/PartForm'
|
import PartForm from 'src/components/PartForm'
|
||||||
|
|
||||||
export const QUERY = gql`
|
export const QUERY = gql`
|
||||||
@@ -26,12 +25,7 @@ const UPDATE_PART_MUTATION = gql`
|
|||||||
export const Loading = () => <div>Loading...</div>
|
export const Loading = () => <div>Loading...</div>
|
||||||
|
|
||||||
export const Success = ({ part }) => {
|
export const Success = ({ part }) => {
|
||||||
const { addMessage } = useFlash()
|
const [updatePart, { loading, error }] = useMutation(UPDATE_PART_MUTATION)
|
||||||
const [updatePart, { loading, error }] = useMutation(UPDATE_PART_MUTATION, {
|
|
||||||
onCompleted: () => {
|
|
||||||
addMessage('Part updated.', { classes: 'rw-flash-success' })
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const onSave = (input, id) => updatePart({ variables: { id, input } })
|
const onSave = (input, id) => updatePart({ variables: { id, input } })
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ import {
|
|||||||
} from '@redwoodjs/forms'
|
} from '@redwoodjs/forms'
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { navigate, routes } from '@redwoodjs/router'
|
import { navigate, routes } from '@redwoodjs/router'
|
||||||
|
import { useFlash } from '@redwoodjs/web'
|
||||||
|
|
||||||
import Editor from "rich-markdown-editor";
|
import Editor from "rich-markdown-editor";
|
||||||
|
|
||||||
const PartForm = (props) => {
|
const PartForm = (props) => {
|
||||||
|
const { addMessage } = useFlash()
|
||||||
const [description, setDescription] = useState(props?.part?.description)
|
const [description, setDescription] = useState(props?.part?.description)
|
||||||
const onSubmit = async (data, e) => {
|
const onSubmit = async (data, e) => {
|
||||||
|
|
||||||
@@ -26,6 +28,7 @@ const PartForm = (props) => {
|
|||||||
} else {
|
} else {
|
||||||
navigate(routes.part({id: props?.part?.id}))
|
navigate(routes.part({id: props?.part?.id}))
|
||||||
}
|
}
|
||||||
|
addMessage('Part updated.', { classes: 'rw-flash-success' })
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user