@@ -4,7 +4,7 @@ import * as yup from "yup"
4
4
import { Stack , Typography } from "@mui/material"
5
5
import { type FC } from "react"
6
6
import { Link } from "codeforlife/components/router"
7
- import { handleQueryState } from "codeforlife/utils/api"
7
+ import { handleResultState } from "codeforlife/utils/api"
8
8
import { submitForm } from "codeforlife/utils/form"
9
9
import { useParamsRequired } from "codeforlife/hooks"
10
10
@@ -18,24 +18,24 @@ import { paths } from "../../routes"
18
18
export interface FruitDetailProps { }
19
19
20
20
const FruitDetail : FC < FruitDetailProps > = ( ) => {
21
- const [ updateFruit ] = useUpdateFruitMutation ( )
22
21
const [ retrieveFruit , retrieveFruitResult ] = useLazyRetrieveFruitQuery ( )
23
22
24
23
return useParamsRequired ( {
25
24
shape : { id : yup . number ( ) . required ( ) . min ( 1 ) } ,
26
25
children : ( ) =>
27
- handleQueryState ( retrieveFruitResult , fruit => (
26
+ handleResultState ( retrieveFruitResult , fruit => (
28
27
< pages . Page >
29
28
< pages . Section >
30
29
< Typography variant = "h1" > Update fruit</ Typography >
31
30
< forms . Form
32
31
initialValues = { fruit }
33
- onSubmit = { submitForm ( updateFruit , {
32
+ useMutation = { useUpdateFruitMutation }
33
+ submitOptions = { {
34
34
exclude : [ "expires_on" ] ,
35
35
then : ( ) => {
36
36
alert ( "successfully updated fruit" )
37
37
} ,
38
- } ) }
38
+ } }
39
39
>
40
40
< Stack >
41
41
< FruitNameField />
0 commit comments