-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added new flow for missing personal details #48775
Merged
mountiny
merged 21 commits into
Expensify:main
from
shubham1206agra:missing-personal-details
Sep 12, 2024
Merged
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
7479936
Added new flow for missing personal details
shubham1206agra 3c732d8
Style fixes
shubham1206agra 840a3dc
Added CountryPicker and StatePicker
shubham1206agra 9aa228d
Fixes styling issue
shubham1206agra 41237f0
Fixes page not scrolling
shubham1206agra 70c4609
Added date of birth step
shubham1206agra 038b9e5
Merge branch 'Expensify:main' into missing-personal-details
shubham1206agra 6a3101c
Fix button condition
shubham1206agra baaa455
Fix date range
shubham1206agra 98d277c
Added policyID as a parameter in route
shubham1206agra 745adf1
Added withPolicyAndFullscreenLoading hook to the page
shubham1206agra 68dbc64
Fixed minor bug
shubham1206agra 265376e
Added API command
shubham1206agra 371b4f6
Fix copies
shubham1206agra eae8350
Fix translations
shubham1206agra 358e154
Apply suggestions from code review
shubham1206agra 9f3e94b
Apply suggestions from code review
shubham1206agra 826096c
Fix condition
shubham1206agra bee65db
Merge branch 'Expensify:main' into missing-personal-details
shubham1206agra 040813e
Fix conditions
shubham1206agra 72b265f
Fix phone number parameter
shubham1206agra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,101 @@ | ||
import React, {useMemo} from 'react'; | ||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
import Modal from '@components/Modal'; | ||
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import SelectionList from '@components/SelectionList'; | ||
import RadioListItem from '@components/SelectionList/RadioListItem'; | ||
import useDebouncedState from '@hooks/useDebouncedState'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import searchCountryOptions from '@libs/searchCountryOptions'; | ||
import type {CountryData} from '@libs/searchCountryOptions'; | ||
import StringUtils from '@libs/StringUtils'; | ||
import CONST from '@src/CONST'; | ||
import type {TranslationPaths} from '@src/languages/types'; | ||
|
||
type CountrySelectorModalProps = { | ||
/** Whether the modal is visible */ | ||
isVisible: boolean; | ||
|
||
/** Function to call when the user closes the business type selector modal */ | ||
onClose: () => void; | ||
|
||
/** Label to display on field */ | ||
label: string; | ||
|
||
/** Country selected */ | ||
currentCountry: string; | ||
|
||
/** Function to call when the user selects a country */ | ||
onCountrySelected: (value: CountryData) => void; | ||
|
||
/** Function to call when the user presses on the modal backdrop */ | ||
onBackdropPress?: () => void; | ||
}; | ||
|
||
function CountrySelectorModal({isVisible, currentCountry, onCountrySelected, onClose, label, onBackdropPress}: CountrySelectorModalProps) { | ||
const {translate} = useLocalize(); | ||
const [searchValue, debouncedSearchValue, setSearchValue] = useDebouncedState(''); | ||
|
||
const countries = useMemo( | ||
() => | ||
Object.keys(CONST.ALL_COUNTRIES).map((countryISO) => { | ||
const countryName = translate(`allCountries.${countryISO}` as TranslationPaths); | ||
return { | ||
value: countryISO, | ||
keyForList: countryISO, | ||
text: countryName, | ||
isSelected: currentCountry === countryISO, | ||
searchValue: StringUtils.sanitizeString(`${countryISO}${countryName}`), | ||
}; | ||
}), | ||
[translate, currentCountry], | ||
); | ||
|
||
const searchResults = searchCountryOptions(debouncedSearchValue, countries); | ||
const headerMessage = debouncedSearchValue.trim() && !searchResults.length ? translate('common.noResultsFound') : ''; | ||
|
||
const styles = useThemeStyles(); | ||
|
||
return ( | ||
<Modal | ||
type={CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED} | ||
isVisible={isVisible} | ||
onClose={onClose} | ||
onModalHide={onClose} | ||
hideModalContentWhileAnimating | ||
useNativeDriver | ||
onBackdropPress={onBackdropPress} | ||
> | ||
<ScreenWrapper | ||
style={[styles.pb0]} | ||
includePaddingTop={false} | ||
includeSafeAreaPaddingBottom={false} | ||
testID={CountrySelectorModal.displayName} | ||
> | ||
<HeaderWithBackButton | ||
title={label} | ||
shouldShowBackButton | ||
onBackButtonPress={onClose} | ||
/> | ||
<SelectionList | ||
headerMessage={headerMessage} | ||
sections={[{data: searchResults}]} | ||
textInputValue={searchValue} | ||
textInputLabel={translate('common.search')} | ||
onChangeText={setSearchValue} | ||
onSelectRow={onCountrySelected} | ||
ListItem={RadioListItem} | ||
initiallyFocusedOptionKey={currentCountry} | ||
shouldSingleExecuteRowSelect | ||
shouldStopPropagation | ||
shouldUseDynamicMaxToRenderPerBatch | ||
/> | ||
</ScreenWrapper> | ||
</Modal> | ||
); | ||
} | ||
|
||
CountrySelectorModal.displayName = 'CountrySelectorModal'; | ||
|
||
export default CountrySelectorModal; |
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,57 @@ | ||
import React, {useState} from 'react'; | ||
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import type {CountryData} from '@libs/searchCountryOptions'; | ||
import CONST from '@src/CONST'; | ||
import type {TranslationPaths} from '@src/languages/types'; | ||
import CountrySelectorModal from './CountrySelectorModal'; | ||
|
||
type CountryPickerProps = { | ||
/** Current value of the selected item */ | ||
value?: string; | ||
|
||
/** Callback when the list item is selected */ | ||
onInputChange?: (value: string, key?: string) => void; | ||
|
||
/** Form Error description */ | ||
errorText?: string; | ||
}; | ||
|
||
function CountryPicker({value, errorText, onInputChange = () => {}}: CountryPickerProps) { | ||
const {translate} = useLocalize(); | ||
const [isPickerVisible, setIsPickerVisible] = useState(false); | ||
|
||
const hidePickerModal = () => { | ||
setIsPickerVisible(false); | ||
}; | ||
|
||
const updateInput = (item: CountryData) => { | ||
onInputChange?.(item.value); | ||
hidePickerModal(); | ||
}; | ||
|
||
return ( | ||
<> | ||
<MenuItemWithTopDescription | ||
shouldShowRightIcon | ||
title={value ? translate(`allCountries.${value}` as TranslationPaths) : undefined} | ||
description={translate('common.country')} | ||
onPress={() => setIsPickerVisible(true)} | ||
brickRoadIndicator={errorText ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} | ||
errorText={errorText} | ||
/> | ||
<CountrySelectorModal | ||
isVisible={isPickerVisible} | ||
currentCountry={value ?? ''} | ||
onCountrySelected={updateInput} | ||
onClose={hidePickerModal} | ||
label={translate('common.country')} | ||
onBackdropPress={Navigation.dismissModal} | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
CountryPicker.displayName = 'CountryPicker'; | ||
export default CountryPicker; |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could remove the missing from this url and just leave it as personal details