Skip to content

Commit

Permalink
Fix button on account type step
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham1206agra committed Jan 4, 2025
1 parent a060234 commit 6b982b3
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {useCallback, useMemo, useState} from 'react';
import {View} from 'react-native';
import FormAlertWithSubmitButton from '@components/FormAlertWithSubmitButton';
import SelectionList from '@components/SelectionList';
import RadioListItem from '@components/SelectionList/RadioListItem';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -48,6 +49,19 @@ function AccountType({isEditing, onNext, formValues, fieldsMap}: CustomSubStepPr
[fieldData.valueSet, currentAccountType],
);

const button = useMemo(() => {
const buttonText = isEditing ? translate('common.confirm') : translate('common.next');
return (
<FormAlertWithSubmitButton
isDisabled={fieldData.isRequired && !currentAccountType}
buttonText={buttonText}
onSubmit={onAccountTypeSelected}
containerStyles={[styles.flexReset, styles.flexGrow0, styles.flexShrink0, styles.flexBasisAuto]}
enabledWhenOffline
/>
);
}, [currentAccountType, fieldData.isRequired, isEditing, onAccountTypeSelected, styles.flexBasisAuto, styles.flexGrow0, styles.flexReset, styles.flexShrink0, translate]);

return (
<>
<View style={styles.ph5}>
Expand All @@ -56,15 +70,13 @@ function AccountType({isEditing, onNext, formValues, fieldsMap}: CustomSubStepPr
<SelectionList
sections={[{data: options}]}
onSelectRow={onSelectionChange}
onConfirm={onAccountTypeSelected}
ListItem={RadioListItem}
initiallyFocusedOptionKey={currentAccountType}
footerContent={button}
shouldSingleExecuteRowSelect
shouldStopPropagation
shouldUseDynamicMaxToRenderPerBatch
showConfirmButton
shouldUpdateFocusedIndex
confirmButtonText={isEditing ? translate('common.confirm') : translate('common.next')}
/>
</>
);
Expand Down

0 comments on commit 6b982b3

Please sign in to comment.