diff --git a/app/forms/instance-create.tsx b/app/forms/instance-create.tsx index b76a5cb19..fa7cd3788 100644 --- a/app/forms/instance-create.tsx +++ b/app/forms/instance-create.tsx @@ -173,7 +173,11 @@ export function CreateInstanceForm() { const { project } = useProjectSelector() const navigate = useNavigate() - const createInstance = useApiMutation('instanceCreate', { + const { + mutateAsync: createInstance, + isPending, + error, + } = useApiMutation('instanceCreate', { onSuccess(instance) { // refetch list of instances queryClient.invalidateQueries('instanceList') @@ -244,10 +248,10 @@ export function CreateInstanceForm() { const imageSizeGiB = image?.size ? Math.ceil(image.size / GiB) : undefined useEffect(() => { - if (createInstance.error) { + if (error) { setIsSubmitting(false) } - }, [createInstance.error]) + }, [error]) // additional form elements for projectImage and siloImage tabs const bootDiskSizeAndName = ( @@ -308,7 +312,7 @@ export function CreateInstanceForm() { ? await readBlobAsBase64(values.userData) : undefined - await createInstance.mutateAsync({ + await createInstance({ query: { project }, body: { name: values.name, @@ -325,8 +329,8 @@ export function CreateInstanceForm() { }, }) }} - loading={createInstance.isPending} - submitError={createInstance.error} + loading={isPending} + submitError={error} > @@ -573,7 +577,7 @@ export function CreateInstanceForm() { siloPools={siloPools.items} /> - Create instance + Create instance navigate(pb.instances({ project }))} />