-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Krishna Gupta <belivethatkg@gmail.com>
- Loading branch information
Showing
14 changed files
with
166 additions
and
226 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5084,7 +5084,6 @@ const CONST = { | |
PAYMENT_CARD_CURRENCY: { | ||
USD: 'USD', | ||
AUD: 'AUD', | ||
GBP: 'GBP', | ||
NZD: 'NZD', | ||
}, | ||
|
||
|
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,27 @@ | ||
import {useRoute} from '@react-navigation/native'; | ||
import {CONST as COMMON_CONST} from 'expensify-common'; | ||
import CONST from '@src/CONST'; | ||
|
||
type State = keyof typeof COMMON_CONST.STATES; | ||
type Country = keyof typeof CONST.ALL_COUNTRIES; | ||
type StateAndCountry = {state?: State; country?: Country}; | ||
|
||
/** | ||
* Extracts the 'state' and 'country' query parameters from the route/ url and validates it against COMMON_CONST.STATES and CONST.ALL_COUNTRIES. | ||
* Example 1: Url: https://new.expensify.com/settings/profile/address?state=MO Returns: state=MO | ||
* Example 2: Url: https://new.expensify.com/settings/profile/address?state=ASDF Returns: state=undefined | ||
* Example 3: Url: https://new.expensify.com/settings/profile/address Returns: state=undefined | ||
* Example 4: Url: https://new.expensify.com/settings/profile/address?state=MO-hash-a12341 Returns: state=MO | ||
* Similarly for country parameter. | ||
*/ | ||
export default function useGeographicalStateAndCountryFromRoute(stateParamName = 'state', countryParamName = 'country'): StateAndCountry { | ||
const routeParams = useRoute().params as Record<string, string>; | ||
|
||
const stateFromUrlTemp = routeParams?.[stateParamName] as string | undefined; | ||
const countryFromUrlTemp = routeParams?.[countryParamName] as string | undefined; | ||
|
||
return { | ||
state: COMMON_CONST.STATES[stateFromUrlTemp as State]?.stateISO, | ||
country: Object.keys(CONST.ALL_COUNTRIES).find((country) => country === countryFromUrlTemp) as Country, | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
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.