Skip to content

Commit

Permalink
add shuldSaveDraft
Browse files Browse the repository at this point in the history
  • Loading branch information
allgandalf committed Mar 11, 2024
1 parent 1425e82 commit 7c73dc8
Show file tree
Hide file tree
Showing 17 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hooks/useReimbursementAccountStepFormSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {SubStepProps} from './useSubStep/types';
type UseReimbursementAccountStepFormSubmitParams = Pick<SubStepProps, 'onNext'> & {
formId?: OnyxFormKey;
fieldIds: Array<FormOnyxKeys<typeof ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM>>;
shouldSaveDraft?: boolean;
shouldSaveDraft: boolean;
};

/**
Expand All @@ -23,7 +23,7 @@ export default function useReimbursementAccountStepFormSubmit({
formId = ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM,
onNext,
fieldIds,
shouldSaveDraft = true,
shouldSaveDraft,
}: UseReimbursementAccountStepFormSubmitParams) {
return useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function AddressUBO({reimbursementAccountDraft, onNext, isEditing, beneficialOwn
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: stepFields,
onNext,
shouldSaveDraft: isEditing,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function DateOfBirthUBO({reimbursementAccountDraft, onNext, isEditing, beneficia
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: [dobInputID],
onNext,
shouldSaveDraft: isEditing,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function LegalNameUBO({reimbursementAccountDraft, onNext, isEditing, beneficialO
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: stepFields,
onNext,
shouldSaveDraft: isEditing,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function SocialSecurityNumberUBO({reimbursementAccountDraft, onNext, isEditing,
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: stepFields,
onNext,
shouldSaveDraft: isEditing,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function AddressBusiness({reimbursementAccount, onNext, isEditing}: AddressBusin
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: STEP_FIELDS,
onNext,
shouldSaveDraft: isEditing,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function IncorporationDateBusiness({reimbursementAccount, reimbursementAccountDr
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: STEP_FIELDS,
onNext,
shouldSaveDraft: isEditing,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function IncorporationStateBusiness({reimbursementAccount, onNext, isEditing}: I
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: STEP_FIELDS,
onNext,
shouldSaveDraft: isEditing,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function NameBusiness({reimbursementAccount, onNext, isEditing}: NameBusinessPro
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: STEP_FIELDS,
onNext,
shouldSaveDraft: isEditing,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ function PhoneNumberBusiness({reimbursementAccount, onNext, isEditing}: PhoneNum
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: STEP_FIELDS,
onNext,
// We want to remove sanitize user input i.e. remove leading and trailing whitespaces
shouldSaveDraft: true,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function TaxIdBusiness({reimbursementAccount, onNext, isEditing}: TaxIdBusinessP
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: STEP_FIELDS,
onNext,
shouldSaveDraft: isEditing,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function TypeBusiness({reimbursementAccount, onNext, isEditing}: TypeBusinessPro
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: STEP_FIELDS,
onNext,
shouldSaveDraft: isEditing,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function WebsiteBusiness({reimbursementAccount, user, session, onNext, isEditing
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: STEP_FIELDS,
onNext,
shouldSaveDraft: isEditing,
});

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function Address({reimbursementAccount, onNext, isEditing}: AddressProps) {
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: STEP_FIELDS,
onNext,
shouldSaveDraft: isEditing,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function DateOfBirth({reimbursementAccount, reimbursementAccountDraft, onNext, i
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: STEP_FIELDS,
onNext,
shouldSaveDraft: isEditing,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function FullName({reimbursementAccount, onNext, isEditing}: FullNameProps) {
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: STEP_FIELDS,
onNext,
shouldSaveDraft: isEditing,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function SocialSecurityNumber({reimbursementAccount, onNext, isEditing}: SocialS
const handleSubmit = useReimbursementAccountStepFormSubmit({
fieldIds: STEP_FIELDS,
onNext,
shouldSaveDraft: isEditing,
});

return (
Expand Down

0 comments on commit 7c73dc8

Please sign in to comment.