-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from lidofinance/fix/wrap-unwrap-refactor-qa-f…
…eedback Fix/wrap unwrap refactor qa feedback
- Loading branch information
Showing
3 changed files
with
31 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 11 additions & 4 deletions
15
features/wsteth/wrap/wrap-form-controls/form-controller-wrap.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
import { useCallback } from 'react'; | ||
import { FormController } from 'features/wsteth/shared/form-controller/form-controller'; | ||
import { useFormContext } from 'react-hook-form'; | ||
import { WrapFormInputType } from '../wrap-form-context'; | ||
|
||
export const FormControllerWrap: React.FC = ({ children }) => { | ||
const { setValue, clearErrors } = useFormContext(); | ||
const { | ||
reset, | ||
getValues, | ||
formState: { defaultValues }, | ||
} = useFormContext<WrapFormInputType>(); | ||
|
||
const handleReset = useCallback(() => { | ||
setValue('amount', undefined); | ||
clearErrors('amount'); | ||
}, [clearErrors, setValue]); | ||
reset({ | ||
...defaultValues, | ||
token: getValues('token'), | ||
}); | ||
}, [defaultValues, getValues, reset]); | ||
|
||
return <FormController reset={handleReset}>{children}</FormController>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters