-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41511 from hungvu193/feat/invoice-collection-acou…
…nt-selector-page Feat: Invoice collection account selector page
- Loading branch information
Showing
15 changed files
with
224 additions
and
13 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import React from 'react'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import type {PolicyAccessVariant} from '@pages/workspace/AccessOrNotFoundWrapper'; | ||
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; | ||
import type {TranslationPaths} from '@src/languages/types'; | ||
import type {PolicyFeatureName} from '@src/types/onyx/Policy'; | ||
import HeaderWithBackButton from './HeaderWithBackButton'; | ||
import ScreenWrapper from './ScreenWrapper'; | ||
import SelectionList from './SelectionList'; | ||
import type RadioListItem from './SelectionList/RadioListItem'; | ||
import type TableListItem from './SelectionList/TableListItem'; | ||
import type {ListItem, SectionListDataType} from './SelectionList/types'; | ||
import type UserListItem from './SelectionList/UserListItem'; | ||
|
||
type SelectorType = ListItem & { | ||
value: string; | ||
}; | ||
|
||
type SelectionScreenProps = { | ||
/** Used to set the testID for tests */ | ||
displayName: string; | ||
|
||
/** Title of the selection component */ | ||
title: TranslationPaths; | ||
|
||
/** Custom content to display in the header */ | ||
headerContent?: React.ReactNode; | ||
|
||
/** Sections for the section list */ | ||
sections: Array<SectionListDataType<SelectorType>>; | ||
|
||
/** Default renderer for every item in the list */ | ||
listItem: typeof RadioListItem | typeof UserListItem | typeof TableListItem; | ||
|
||
/** Item `keyForList` to focus initially */ | ||
initiallyFocusedOptionKey?: string | null | undefined; | ||
|
||
/** Callback to fire when a row is pressed */ | ||
onSelectRow: (selection: SelectorType) => void; | ||
|
||
/** Callback to fire when back button is pressed */ | ||
onBackButtonPress: () => void; | ||
|
||
/** The current policyID */ | ||
policyID: string; | ||
|
||
/** Defines which types of access should be verified */ | ||
accessVariants?: PolicyAccessVariant[]; | ||
|
||
/** The current feature name that the user tries to get access to */ | ||
featureName?: PolicyFeatureName; | ||
|
||
/** Whether or not to block user from accessing the page */ | ||
shouldBeBlocked?: boolean; | ||
}; | ||
|
||
function SelectionScreen({ | ||
displayName, | ||
title, | ||
headerContent, | ||
sections, | ||
listItem, | ||
initiallyFocusedOptionKey, | ||
onSelectRow, | ||
onBackButtonPress, | ||
policyID, | ||
accessVariants, | ||
featureName, | ||
shouldBeBlocked, | ||
}: SelectionScreenProps) { | ||
const {translate} = useLocalize(); | ||
return ( | ||
<AccessOrNotFoundWrapper | ||
policyID={policyID} | ||
accessVariants={accessVariants} | ||
featureName={featureName} | ||
shouldBeBlocked={shouldBeBlocked} | ||
> | ||
<ScreenWrapper | ||
includeSafeAreaPaddingBottom={false} | ||
testID={displayName} | ||
> | ||
<HeaderWithBackButton | ||
title={translate(title)} | ||
onBackButtonPress={onBackButtonPress} | ||
/> | ||
<SelectionList | ||
onSelectRow={onSelectRow} | ||
headerContent={headerContent} | ||
sections={sections} | ||
ListItem={listItem} | ||
showScrollIndicator | ||
shouldShowTooltips={false} | ||
initiallyFocusedOptionKey={initiallyFocusedOptionKey} | ||
/> | ||
</ScreenWrapper> | ||
</AccessOrNotFoundWrapper> | ||
); | ||
} | ||
|
||
export type {SelectorType}; | ||
|
||
SelectionScreen.displayName = 'SelectionScreen'; | ||
export default SelectionScreen; |
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
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.