diff --git a/src/components/SelectionList/BaseSelectionList.tsx b/src/components/SelectionList/BaseSelectionList.tsx index 675438072ce1..48e732d4a182 100644 --- a/src/components/SelectionList/BaseSelectionList.tsx +++ b/src/components/SelectionList/BaseSelectionList.tsx @@ -45,6 +45,7 @@ function BaseSelectionList({ onEndReached, onEndReachedThreshold, confirmButtonOptions, + children, customListHeader, customListHeaderContent, footerContent, @@ -445,6 +446,7 @@ function BaseSelectionList({ } /> + {children} )} diff --git a/src/components/SelectionList/types.ts b/src/components/SelectionList/types.ts index 11af124c21d4..3823399aad25 100644 --- a/src/components/SelectionList/types.ts +++ b/src/components/SelectionList/types.ts @@ -1,9 +1,10 @@ import type {ReactElement, RefObject} from 'react'; import type {GestureResponderEvent, InputModeOptions, StyleProp, TextStyle, ViewStyle} from 'react-native'; import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types'; +import type ChildrenProps from '@src/types/utils/ChildrenProps'; import type {ListItem, ValidListItem} from './ListItem/types'; -type SelectionListProps = { +type SelectionListProps = Partial & { /** Array of items to display in the list */ data: TItem[]; diff --git a/src/pages/workspace/companyCards/addNew/AmexCustomFeed.tsx b/src/pages/workspace/companyCards/addNew/AmexCustomFeed.tsx index 0f1decdf67cf..380b2d7162af 100644 --- a/src/pages/workspace/companyCards/addNew/AmexCustomFeed.tsx +++ b/src/pages/workspace/companyCards/addNew/AmexCustomFeed.tsx @@ -1,47 +1,47 @@ -import React, {useEffect, useState} from 'react'; +import React, {useCallback, useEffect, useMemo, useState} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; import FormHelpMessage from '@components/FormHelpMessage'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import RenderHTML from '@components/RenderHTML'; import ScreenWrapper from '@components/ScreenWrapper'; -import SelectionList from '@components/SelectionListWithSections'; -import RadioListItem from '@components/SelectionListWithSections/RadioListItem'; +import SelectionList from '@components/SelectionList'; +import RadioListItem from '@components/SelectionList/ListItem/RadioListItem'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as CompanyCards from '@userActions/CompanyCards'; +import {setAddNewCompanyCardStepAndData} from '@userActions/CompanyCards'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; function AmexCustomFeed() { const {translate} = useLocalize(); const styles = useThemeStyles(); - const [addNewCard] = useOnyx(ONYXKEYS.ADD_NEW_COMPANY_CARD); + const [addNewCard] = useOnyx(ONYXKEYS.ADD_NEW_COMPANY_CARD, {canBeMissing: true}); const [typeSelected, setTypeSelected] = useState>(); const [hasError, setHasError] = useState(false); - const submit = () => { + const submit = useCallback(() => { if (!typeSelected) { setHasError(true); return; } - CompanyCards.setAddNewCompanyCardStepAndData({ + setAddNewCompanyCardStepAndData({ step: typeSelected === CONST.COMPANY_CARDS.AMEX_CUSTOM_FEED.CORPORATE ? CONST.COMPANY_CARDS.STEP.CARD_INSTRUCTIONS : CONST.COMPANY_CARDS.STEP.BANK_CONNECTION, data: { feedType: CONST.COMPANY_CARD.FEED_BANK_NAME.AMEX, selectedAmexCustomFeed: typeSelected, }, }); - }; + }, [typeSelected]); useEffect(() => { setTypeSelected(addNewCard?.data.selectedAmexCustomFeed); }, [addNewCard?.data.selectedAmexCustomFeed]); const handleBackButtonPress = () => { - CompanyCards.setAddNewCompanyCardStepAndData({step: CONST.COMPANY_CARDS.STEP.SELECT_BANK}); + setAddNewCompanyCardStepAndData({step: CONST.COMPANY_CARDS.STEP.SELECT_BANK}); }; const data = [ @@ -68,6 +68,15 @@ function AmexCustomFeed() { }, ]; + const confirmButtonOptions = useMemo( + () => ({ + showButton: true, + text: translate('common.next'), + onConfirm: submit, + }), + [submit, translate], + ); + return ( { setTypeSelected(value); setHasError(false); }} - sections={[{data}]} + confirmButtonOptions={confirmButtonOptions} shouldSingleExecuteRowSelect - isAlternateTextMultilineSupported - alternateTextNumberOfLines={3} - initiallyFocusedOptionKey={addNewCard?.data.selectedAmexCustomFeed} + alternateNumberOfSupportedLines={3} + initiallyFocusedItemKey={addNewCard?.data.selectedAmexCustomFeed ?? undefined} shouldUpdateFocusedIndex - showConfirmButton - confirmButtonText={translate('common.next')} - onConfirm={submit} addBottomSafeAreaPadding > {hasError && (