@@ -3,7 +3,10 @@ import { useEffect, useState } from 'react'
33import { useForm } from 'react-hook-form'
44import { z } from 'zod'
55
6- import { useGetSelectedAccount } from '../../../../hooks/accounts'
6+ import {
7+ useAddAccountUpdateSubmittingState ,
8+ useGetSelectedAccount ,
9+ } from '../../../../hooks/accounts'
710import { useBaseSetupForm } from '../-hooks'
811
912import { toast } from '../../../../lib/notifications'
@@ -15,6 +18,8 @@ const formSchema = z.object({
1518} )
1619
1720export function useSetupForm ( ) {
21+ const { isSubmitting, updateSubmittingState } =
22+ useAddAccountUpdateSubmittingState ( 'exchangeCode' )
1823 const { selected } = useGetSelectedAccount ( )
1924 const form = useForm < z . infer < typeof formSchema > > ( {
2025 resolver : zodResolver ( formSchema ) ,
@@ -25,14 +30,20 @@ export function useSetupForm() {
2530
2631 useBaseSetupForm ( {
2732 fetcher : window . electronAPI . responseAuthWithExchange ,
33+ type : 'exchangeCode' ,
2834 } )
2935
3036 const onSubmit = ( values : z . infer < typeof formSchema > ) => {
37+ if ( isSubmitting ) {
38+ return
39+ }
40+
41+ updateSubmittingState ( true )
3142 window . electronAPI . createAuthWithExchange ( values . code )
3243 form . reset ( )
3344 }
3445
35- return { form, selected, onSubmit }
46+ return { form, isSubmitting , selected, onSubmit }
3647}
3748
3849export function useGenerateHandlers ( ) {
0 commit comments