Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit c801e79

Browse files
Hubert KosterHubert Koster
authored andcommitted
chore: adding reset to the form
1 parent a6284be commit c801e79

File tree

1 file changed

+8
-2
lines changed
  • src/features/dashboard/components/AppForm

1 file changed

+8
-2
lines changed

src/features/dashboard/components/AppForm/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { ReactNode, useMemo } from 'react';
1+
import React, { ReactNode, useCallback, useMemo } from 'react';
22
import { Text } from '@deriv/ui';
33
import { useForm } from 'react-hook-form';
44
import { isNotDemoCurrency } from '@site/src/utils';
@@ -33,6 +33,7 @@ const AppForm = ({
3333
register,
3434
handleSubmit,
3535
formState: { errors },
36+
reset,
3637
} = useForm<IRegisterAppForm>({
3738
mode: 'onBlur',
3839
resolver: yupResolver(is_update_mode ? appEditSchema : appRegisterSchema),
@@ -53,6 +54,11 @@ const AppForm = ({
5354
return admin_check_array.includes(true);
5455
};
5556

57+
const submitAndReset = (e) => {
58+
submit(e);
59+
reset();
60+
};
61+
5662
const disableMarkup = useMemo(() => {
5763
let isDisabled;
5864
isNotDemoCurrency(currentLoginAccount) === 'Demo' ? (isDisabled = true) : (isDisabled = false);
@@ -71,7 +77,7 @@ const AppForm = ({
7177

7278
return (
7379
<React.Fragment>
74-
<form role={'form'} className={styles.apps_form} onSubmit={handleSubmit(submit)}>
80+
<form role={'form'} className={styles.apps_form} onSubmit={handleSubmit(submitAndReset)}>
7581
<div
7682
className={`${styles.formContent} ${
7783
!admin_token && !is_update_mode ? styles.noAdmin : ''

0 commit comments

Comments
 (0)