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

Hubert / clearing register app form after submitting #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/features/dashboard/components/AppForm/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode, useMemo } from 'react';
import React, { ReactNode, useCallback, useMemo } from 'react';
import { Text } from '@deriv/ui';
import { useForm } from 'react-hook-form';
import { isNotDemoCurrency } from '@site/src/utils';
Expand Down Expand Up @@ -33,6 +33,7 @@ const AppForm = ({
register,
handleSubmit,
formState: { errors },
reset,
} = useForm<IRegisterAppForm>({
mode: 'onBlur',
resolver: yupResolver(is_update_mode ? appEditSchema : appRegisterSchema),
Expand All @@ -53,6 +54,11 @@ const AppForm = ({
return admin_check_array.includes(true);
};

const submitAndReset = (e) => {
submit(e);
reset();
};

const disableMarkup = useMemo(() => {
let isDisabled;
isNotDemoCurrency(currentLoginAccount) === 'Demo' ? (isDisabled = true) : (isDisabled = false);
Expand All @@ -71,7 +77,7 @@ const AppForm = ({

return (
<React.Fragment>
<form role={'form'} className={styles.apps_form} onSubmit={handleSubmit(submit)}>
<form role={'form'} className={styles.apps_form} onSubmit={handleSubmit(submitAndReset)}>
<div
className={`${styles.formContent} ${
!admin_token && !is_update_mode ? styles.noAdmin : ''
Expand Down
Loading