forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/vbba prevent autosaving in editing mode (Expensify#6)
* feat: added hook for submit step * feat: preventa automatically update values in editing mode in PersonalInfo * fix: changed name of kys array * fix: move\ hook to the main directory * feat: applied to the BankInfo step * feat: applied to the UBO steps * fix: lint fixes * refactorL: standarize variable names
- Loading branch information
Showing
30 changed files
with
334 additions
and
199 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {useCallback} from 'react'; | ||
import * as FormActions from '@userActions/FormActions'; | ||
import type {OnyxFormKeyWithoutDraft} from '@userActions/FormActions'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type {FormValues} from '@src/types/onyx/Form'; | ||
import type {SubStepProps} from './useSubStep/types'; | ||
|
||
type UseReimbursementAccountStepFormSubmitParams = Pick<SubStepProps, 'isEditing' | 'onNext'> & { | ||
formId?: OnyxFormKeyWithoutDraft; | ||
fieldIds: Array<keyof FormValues>; | ||
}; | ||
|
||
export default function useReimbursementAccountStepFormSubmit({formId = ONYXKEYS.REIMBURSEMENT_ACCOUNT, isEditing, onNext, fieldIds}: UseReimbursementAccountStepFormSubmitParams) { | ||
return useCallback( | ||
(values: FormValues) => { | ||
if (isEditing) { | ||
const stepValues = fieldIds.reduce( | ||
(acc, key) => ({ | ||
...acc, | ||
[key]: values[key], | ||
}), | ||
{}, | ||
); | ||
|
||
FormActions.setDraftValues(formId, stepValues); | ||
} | ||
|
||
onNext(); | ||
}, | ||
[isEditing, onNext, formId, fieldIds], | ||
); | ||
} |
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
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
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
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
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
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
Oops, something went wrong.