Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ const DYNAMIC_ROUTES = {
path: 'imported-members-role',
entryScreens: [SCREENS.WORKSPACE.MEMBERS_IMPORTED_CONFIRMATION],
},
PAYMENT_CARD_CURRENCY_SELECTOR: {
path: 'payment-card-currency',
entryScreens: [SCREENS.SETTINGS.SUBSCRIPTION.CHANGE_BILLING_CURRENCY, SCREENS.SETTINGS.SUBSCRIPTION.ADD_PAYMENT_CARD, SCREENS.WORKSPACE.OWNER_CHANGE_CHECK],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is SCREENS.WORKSPACE.OWNER_CHANGE_CHECK included here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OWNER_CHANGE_CHECK is the screen for the workspace owner-change flow (WorkspaceOwnerChangeWrapperPage). When a billing card is needed to take over ownership, that page renders WorkspaceOwnerPaymentCardForm, which uses the shared PaymentCardFormCurrencySelector. Tapping the currency field there opens this dynamic route, so the screen has to be in entryScreens — otherwise the selector would be blocked from that flow, same as CHANGE_BILLING_CURRENCY and ADD_PAYMENT_CARD.

},
REPORT_SETTINGS_NAME: {
path: 'settings/name',
entryScreens: [SCREENS.REPORT_DETAILS.ROOT],
Expand Down Expand Up @@ -847,7 +851,6 @@ const ROUTES = {

getRoute: (backTo?: string) => getUrlWithBackToParam('settings/profile', backTo),
},
SETTINGS_CHANGE_CURRENCY: 'settings/add-payment-card/change-currency',
SETTINGS_SHARE_CODE: 'settings/shareCode',
SETTINGS_DISPLAY_NAME: 'settings/profile/display-name',
SETTINGS_AVATAR: 'settings/profile/avatar',
Expand All @@ -868,7 +871,6 @@ const ROUTES = {
SETTINGS_SUBSCRIPTION_EXPENSIFY_CODE: 'settings/subscription/details/expensify-code',
SETTINGS_SUBSCRIPTION_ADD_PAYMENT_CARD: 'settings/subscription/add-payment-card',
SETTINGS_SUBSCRIPTION_CHANGE_BILLING_CURRENCY: 'settings/subscription/change-billing-currency',
SETTINGS_SUBSCRIPTION_CHANGE_PAYMENT_CURRENCY: 'settings/subscription/add-payment-card/change-payment-currency',
SETTINGS_SUBSCRIPTION_DISABLE_AUTO_RENEW_SURVEY: 'settings/subscription/disable-auto-renew-survey',
SETTINGS_SUBSCRIPTION_CANCEL_SUBSCRIPTION: 'settings/subscription/cancel-subscription-survey',
SETTINGS_SUBSCRIPTION_DOWNGRADE_BLOCKED: {
Expand Down Expand Up @@ -3290,7 +3292,7 @@ const ROUTES = {

getRoute: (backTo?: string) => getUrlWithBackToParam(`onboarding/workspace-currency`, backTo),
},
CURRENCY_SELECTION: {
WORKSPACE_CURRENCY_SELECTION: {
route: 'workspace/confirmation/currency',

getRoute: (backTo?: string) => getUrlWithBackToParam(`workspace/confirmation/currency`, backTo),
Expand Down
3 changes: 1 addition & 2 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ const SCREENS = {
SAVE_THE_WORLD: 'Settings_TeachersUnite',
APP_DOWNLOAD_LINKS: 'Settings_App_Download_Links',
ADD_DEBIT_CARD: 'Settings_Add_Debit_Card',
ADD_PAYMENT_CARD_CHANGE_CURRENCY: 'Settings_Add_Payment_Card_Change_Currency',
ADD_BANK_ACCOUNT: 'Settings_Add_Bank_Account',
ADD_US_BANK_ACCOUNT: 'Settings_Add_US_Bank_Account',
ADD_US_BANK_ACCOUNT_ENTRY_POINT: 'Settings_Add_US_Bank_Account_Entry_Point',
Expand Down Expand Up @@ -277,7 +276,7 @@ const SCREENS = {
ADD_PAYMENT_CARD: 'Settings_Subscription_Add_Payment_Card',
DISABLE_AUTO_RENEW_SURVEY: 'Settings_Subscription_DisableAutoRenewSurvey',
CHANGE_BILLING_CURRENCY: 'Settings_Subscription_Change_Billing_Currency',
CHANGE_PAYMENT_CURRENCY: 'Settings_Subscription_Change_Payment_Currency',
DYNAMIC_PAYMENT_CARD_CURRENCY_SELECTOR: 'Dynamic_Settings_Subscription_Payment_Card_Currency_Selector',
CANCEL_SUBSCRIPTION: 'Settings_Subscription_CancelSubscription',
SUBSCRIPTION_DOWNGRADE_BLOCKED: 'Settings_Subscription_DowngradeBlocked',
},
Expand Down
147 changes: 0 additions & 147 deletions src/components/AddPaymentCard/PaymentCardChangeCurrencyForm.tsx

This file was deleted.

82 changes: 0 additions & 82 deletions src/components/AddPaymentCard/PaymentCardCurrencyModal.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions src/components/AddPaymentCard/PaymentCardForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ type PaymentCardFormProps = {
footerContent?: ReactNode;
/** Custom content to display in the header before card form */
headerContent?: ReactNode;
/** object to get currency route details from */
currencySelectorRoute?: typeof ROUTES.SETTINGS_SUBSCRIPTION_CHANGE_PAYMENT_CURRENCY;
};

function IAcceptTheLabel() {
Expand Down Expand Up @@ -123,7 +121,6 @@ function PaymentCardForm({
showStateSelector,
footerContent,
headerContent,
currencySelectorRoute,
}: PaymentCardFormProps) {
const styles = useThemeStyles();
const [data, metadata] = useOnyx(ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM);
Expand Down Expand Up @@ -358,7 +355,6 @@ function PaymentCardForm({
{!!showCurrencyField && (
<View style={[styles.mt4, styles.mhn5]}>
<InputWrapper
currencySelectorRoute={currencySelectorRoute}
value={data?.currency ?? CONST.PAYMENT_CARD_CURRENCY.USD}
InputComponent={CurrencySelector}
inputID={INPUT_IDS.CURRENCY}
Expand Down
24 changes: 8 additions & 16 deletions src/components/CurrencySelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import type {View} from 'react-native';
import {useCurrencyListActions} from '@hooks/useCurrencyList';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
import MenuItemWithTopDescription from './MenuItemWithTopDescription';

type CurrencySelectorProps = {
Expand All @@ -27,8 +28,8 @@ type CurrencySelectorProps = {
/** Callback to call when the picker modal is dismissed */
onBlur?: () => void;

/** object to get route details from */
currencySelectorRoute?: typeof ROUTES.SETTINGS_SUBSCRIPTION_CHANGE_PAYMENT_CURRENCY | typeof ROUTES.SETTINGS_CHANGE_CURRENCY | typeof ROUTES.CURRENCY_SELECTION;
/** Optional route override; when omitted the selector opens the dynamic payment-card currency picker. */
currencySelectorRoute?: typeof ROUTES.WORKSPACE_CURRENCY_SELECTION;

/** Label for the input */
label?: string;
Expand All @@ -40,16 +41,7 @@ type CurrencySelectorProps = {
ref: ForwardedRef<View>;
};

function CurrencySelector({
errorText = '',
value: currency,
onInputChange = () => {},
onBlur,
currencySelectorRoute = ROUTES.SETTINGS_CHANGE_CURRENCY,
label,
shouldShowCurrencySymbol = false,
ref,
}: CurrencySelectorProps) {
function CurrencySelector({errorText = '', value: currency, onInputChange = () => {}, onBlur, currencySelectorRoute, label, shouldShowCurrencySymbol = false, ref}: CurrencySelectorProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const {getCurrencySymbol} = useCurrencyListActions();
Expand Down Expand Up @@ -84,11 +76,11 @@ function CurrencySelector({
errorText={errorText}
onPress={() => {
didOpenCurrencySelector.current = true;
if (currencySelectorRoute === ROUTES.CURRENCY_SELECTION) {
if (currencySelectorRoute === ROUTES.WORKSPACE_CURRENCY_SELECTION) {
Navigation.navigate(currencySelectorRoute.getRoute(Navigation.getActiveRoute()));
} else {
Navigation.navigate(currencySelectorRoute as typeof ROUTES.SETTINGS_SUBSCRIPTION_CHANGE_PAYMENT_CURRENCY | typeof ROUTES.SETTINGS_CHANGE_CURRENCY);
return;
}
Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.PAYMENT_CARD_CURRENCY_SELECTOR.path));
}}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/WorkspaceConfirmationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ function WorkspaceConfirmationForm({onSubmit, policyOwnerEmail = '', onBackButto
label={translate('workspace.editor.currencyInputLabel')}
value={userCurrency}
shouldShowCurrencySymbol
currencySelectorRoute={ROUTES.CURRENCY_SELECTION}
currencySelectorRoute={ROUTES.WORKSPACE_CURRENCY_SELECTION}
/>
</View>
{isApprovedAccountant && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ const WorkspaceConfirmationModalStackNavigator = createModalStackNavigator<Works
[SCREENS.WORKSPACE_CONFIRMATION.ROOT]: () => require<ReactComponentModule>('../../../../pages/workspace/WorkspaceConfirmationPage').default,
[SCREENS.WORKSPACE_CONFIRMATION.OWNER_SELECTOR]: () => require<ReactComponentModule>('../../../../pages/workspace/WorkspaceConfirmationOwnerSelectorPage').default,
[SCREENS.WORKSPACE_CONFIRMATION.SUCCESS]: () => require<ReactComponentModule>('../../../../pages/workspace/WorkspaceConfirmationSuccessPage').default,
[SCREENS.CURRENCY.SELECTION]: () => require<ReactComponentModule>('../../../../pages/CurrencySelectionPage').default,
[SCREENS.CURRENCY.SELECTION]: () => require<ReactComponentModule>('../../../../pages/WorkspaceCurrencySelectionPage').default,
});

const WorkspaceDuplicateModalStackNavigator = createModalStackNavigator<WorkspaceDuplicateNavigatorParamList>({
Expand Down Expand Up @@ -953,12 +953,13 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
[SCREENS.WORKSPACE.COMPANY_CARDS_SETTINGS_STATEMENT_CLOSE_DATE]: () =>
require<ReactComponentModule>('../../../../pages/workspace/companyCards/WorkspaceCompanyCardStatementCloseDatePage').default,
[SCREENS.SETTINGS.SAVE_THE_WORLD]: () => require<ReactComponentModule>('../../../../pages/TeachersUnite/SaveTheWorldPage').default,
[SCREENS.SETTINGS.SUBSCRIPTION.CHANGE_PAYMENT_CURRENCY]: withAgentAccessDenied(() => require<ReactComponentModule>('../../../../pages/settings/PaymentCard/ChangeCurrency').default),
[SCREENS.SETTINGS.SUBSCRIPTION.CHANGE_BILLING_CURRENCY]: withAgentAccessDenied(
() => require<ReactComponentModule>('../../../../pages/settings/Subscription/PaymentCard/ChangeBillingCurrency').default,
),
[SCREENS.SETTINGS.SUBSCRIPTION.DYNAMIC_PAYMENT_CARD_CURRENCY_SELECTOR]: withAgentAccessDenied(
() => require<ReactComponentModule>('../../../../pages/settings/Subscription/PaymentCard/DynamicPaymentCardCurrencySelectorPage').default,
),
[SCREENS.SETTINGS.SUBSCRIPTION.ADD_PAYMENT_CARD]: withAgentAccessDenied(() => require<ReactComponentModule>('../../../../pages/settings/Subscription/PaymentCard').default),
[SCREENS.SETTINGS.ADD_PAYMENT_CARD_CHANGE_CURRENCY]: () => require<ReactComponentModule>('../../../../pages/settings/PaymentCard/ChangeCurrency').default,
[SCREENS.WORKSPACE.REPORT_FIELDS_CREATE]: () => require<ReactComponentModule>('../../../../pages/workspace/reports/CreateReportFieldsPage').default,
[SCREENS.WORKSPACE.REPORT_FIELDS_SETTINGS]: () => require<ReactComponentModule>('../../../../pages/workspace/reports/ReportFieldsSettingsPage').default,
[SCREENS.WORKSPACE.REPORT_FIELDS_LIST_VALUES]: () => require<ReactComponentModule>('../../../../pages/workspace/reports/ReportFieldsListValuesPage').default,
Expand Down
Loading
Loading