Skip to content
4 changes: 4 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,10 @@ const ROUTES = {
route: 'settings/workspaces/:policyID/expensify-card/:cardID/edit/limit',
getRoute: (policyID: string, cardID: string) => `settings/workspaces/${policyID}/expensify-card/${cardID}/edit/limit` as const,
},
WORKSPACE_EXPENSIFY_CARD_LIMIT_TYPE: {
route: 'settings/workspaces/:policyID/expensify-card/:cardID/edit/limit-type',
getRoute: (policyID: string, cardID: string) => `settings/workspaces/${policyID}/expensify-card/${cardID}/edit/limit-type` as const,
},
WORKSPACE_EXPENSIFY_CARD_ISSUE_NEW: {
route: 'settings/workspaces/:policyID/expensify-card/issue-new',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/expensify-card/issue-new` as const,
Expand Down
1 change: 1 addition & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ const SCREENS = {
EXPENSIFY_CARD_LIMIT: 'Workspace_ExpensifyCard_Limit',
EXPENSIFY_CARD_ISSUE_NEW: 'Workspace_ExpensifyCard_New',
EXPENSIFY_CARD_NAME: 'Workspace_ExpensifyCard_Name',
EXPENSIFY_CARD_LIMIT_TYPE: 'Workspace_ExpensifyCard_LimitType',
EXPENSIFY_CARD_BANK_ACCOUNT: 'Workspace_ExpensifyCard_BankAccount',
BILLS: 'Workspace_Bills',
INVOICES: 'Workspace_Invoices',
Expand Down
12 changes: 10 additions & 2 deletions src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function BaseSelectionList<TItem extends ListItem>(
customListHeaderHeight = 0,
listHeaderWrapperStyle,
isRowMultilineSupported = false,
isAlternateTextMultilineSupported = false,
textInputRef,
headerMessageStyle,
shouldHideListOnInitialRender = true,
Expand All @@ -94,6 +95,7 @@ function BaseSelectionList<TItem extends ListItem>(
updateCellsBatchingPeriod = 50,
removeClippedSubviews = true,
shouldDelayFocus = true,
shouldUpdateFocusedIndex = false,
onLongPressRow,
isMobileSelectionModeActive,
}: BaseSelectionListProps<TItem>,
Expand Down Expand Up @@ -288,8 +290,9 @@ function BaseSelectionList<TItem extends ListItem>(
* Logic to run when a row is selected, either with click/press or keyboard hotkeys.
*
* @param item - the list item
* @param indexToFocus - the list item index to focus
*/
const selectRow = (item: TItem) => {
const selectRow = (item: TItem, indexToFocus?: number) => {
// In single-selection lists we don't care about updating the focused index, because the list is closed after selecting an item
if (canSelectMultiple) {
if (sections.length > 1) {
Expand All @@ -309,6 +312,10 @@ function BaseSelectionList<TItem extends ListItem>(
}
}

if (shouldUpdateFocusedIndex && typeof indexToFocus === 'number') {
setFocusedIndex(indexToFocus);
}

if (shouldDebounceRowSelect) {
debouncedOnSelectRow(item);
} else {
Expand Down Expand Up @@ -452,7 +459,7 @@ function BaseSelectionList<TItem extends ListItem>(
canSelectMultiple={canSelectMultiple}
onLongPressRow={onLongPressRow}
isMobileSelectionModeActive={isMobileSelectionModeActive}
onSelectRow={() => selectRow(item)}
onSelectRow={() => selectRow(item, index)}
onCheckboxPress={handleOnCheckboxPress()}
onDismissError={() => onDismissError?.(item)}
shouldPreventDefaultFocusOnSelectRow={shouldPreventDefaultFocusOnSelectRow}
Expand All @@ -461,6 +468,7 @@ function BaseSelectionList<TItem extends ListItem>(
rightHandSideComponent={rightHandSideComponent}
keyForList={item.keyForList ?? ''}
isMultilineSupported={isRowMultilineSupported}
isAlternateTextMultilineSupported={isAlternateTextMultilineSupported}
onFocus={() => {
if (isDisabled) {
return;
Expand Down
11 changes: 10 additions & 1 deletion src/components/SelectionList/RadioListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import {View} from 'react-native';
import TextWithTooltip from '@components/TextWithTooltip';
import useThemeStyles from '@hooks/useThemeStyles';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import BaseListItem from './BaseListItem';
import type {ListItem, RadioListItemProps} from './types';
Expand All @@ -16,13 +17,15 @@ function RadioListItem<TItem extends ListItem>({
shouldPreventEnterKeySubmit,
rightHandSideComponent,
isMultilineSupported = false,
isAlternateTextMultilineSupported = false,
onFocus,
shouldSyncFocus,
}: RadioListItemProps<TItem>) {
const styles = useThemeStyles();
const fullTitle = isMultilineSupported ? item.text?.trimStart() : item.text;
const indentsLength = (item.text?.length ?? 0) - (fullTitle?.length ?? 0);
const paddingLeft = Math.floor(indentsLength / CONST.INDENTS.length) * styles.ml3.marginLeft;
const alternateTextMaxWidth = variables.sideBarWidth - styles.ph5.paddingHorizontal * 2 - styles.ml3.marginLeft - variables.iconSizeNormal;

return (
<BaseListItem
Expand Down Expand Up @@ -61,7 +64,13 @@ function RadioListItem<TItem extends ListItem>({
<TextWithTooltip
shouldShowTooltip={showTooltip}
text={item.alternateText}
style={[styles.textLabelSupporting, styles.lh16, styles.pre]}
style={[
styles.textLabelSupporting,
styles.lh16,
isAlternateTextMultilineSupported ? styles.preWrap : styles.pre,
isAlternateTextMultilineSupported ? {maxWidth: alternateTextMaxWidth} : null,
]}
numberOfLines={isAlternateTextMultilineSupported ? 2 : 1}
/>
)}
</View>
Expand Down
12 changes: 12 additions & 0 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ type CommonListItemProps<TItem extends ListItem> = {
/** Whether to wrap long text up to 2 lines */
isMultilineSupported?: boolean;

/** Whether to wrap the alternate text up to 2 lines */
isAlternateTextMultilineSupported?: boolean;

/** Handles what to do when the item is focused */
onFocus?: () => void;

Expand Down Expand Up @@ -128,6 +131,9 @@ type ListItem = {
/** Whether to wrap long text up to 2 lines */
isMultilineSupported?: boolean;

/** Whether to wrap the alternate text up to 2 lines */
isAlternateTextMultilineSupported?: boolean;

/** The search value from the selection list */
searchText?: string | null;

Expand Down Expand Up @@ -305,6 +311,9 @@ type BaseSelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {
/** Whether to debounce `onRowSelect` */
shouldDebounceRowSelect?: boolean;

/** Whether to update the focused index on a row select */
shouldUpdateFocusedIndex?: boolean;

/** Optional callback function triggered upon pressing a checkbox. If undefined and the list displays checkboxes, checkbox interactions are managed by onSelectRow, allowing for pressing anywhere on the list. */
onCheckboxPress?: (item: TItem) => void;

Expand Down Expand Up @@ -437,6 +446,9 @@ type BaseSelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {
/** Whether to wrap long text up to 2 lines */
isRowMultilineSupported?: boolean;

/** Whether to wrap the alternate text up to 2 lines */
isAlternateTextMultilineSupported?: boolean;

/** Ref for textInput */
textInputRef?: MutableRefObject<TextInput | null> | ((ref: TextInput | null) => void);

Expand Down
6 changes: 6 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2667,6 +2667,12 @@ export default {
smartLimitWarning: (limit: string) => `If you change this card’s limit to ${limit}, new transactions will be declined until you approve more expenses on the card.`,
monthlyLimitWarning: (limit: string) => `If you change this card’s limit to ${limit}, new transactions will be declined until next month.`,
fixedLimitWarning: (limit: string) => `If you change this card’s limit to ${limit}, new transactions will be declined.`,
changeCardLimitType: 'Change card limit type',
changeLimitType: 'Change limit type',
Comment thread
VickyStash marked this conversation as resolved.
changeCardSmartLimitTypeWarning: (limit: string) =>
`If you change this card's limit type to Smart Limit, new transactions will be declined because the ${limit} unapproved limit has already been reached.`,
changeCardMonthlyLimitTypeWarning: (limit: string) =>
`If you change this card's limit type to Monthly, new transactions will be declined because the ${limit} monthly limit has already been reached.`,
},
categories: {
deleteCategories: 'Delete categories',
Expand Down
6 changes: 6 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2717,6 +2717,12 @@ export default {
`Si cambias el límite de esta tarjeta a ${limit}, las nuevas transacciones serán rechazadas hasta que apruebes antiguos gastos de la tarjeta.`,
monthlyLimitWarning: (limit: string) => `Si cambias el límite de esta tarjeta a ${limit}, las nuevas transacciones serán rechazadas hasta el próximo mes.`,
fixedLimitWarning: (limit: string) => `Si cambias el límite de esta tarjeta a ${limit}, se rechazarán las nuevas transacciones.`,
changeCardLimitType: 'Modificar el tipo de límite de la tarjeta',
changeLimitType: 'Modificar el tipo de límite',
changeCardSmartLimitTypeWarning: (limit: string) =>
`Si cambias el tipo de límite de esta tarjeta a Límite inteligente, las nuevas transacciones serán rechazadas porque ya se ha alcanzado el límite de ${limit} no aprobado.`,
changeCardMonthlyLimitTypeWarning: (limit: string) =>
`Si cambias el tipo de límite de esta tarjeta a Mensual, las nuevas transacciones serán rechazadas porque ya se ha alcanzado el límite de ${limit} mensual.`,
},
categories: {
deleteCategories: 'Eliminar categorías',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
[SCREENS.WORKSPACE.EXPENSIFY_CARD_DETAILS]: () => require<ReactComponentModule>('../../../../pages/workspace/expensifyCard/WorkspaceExpensifyCardDetailsPage').default,
[SCREENS.WORKSPACE.EXPENSIFY_CARD_NAME]: () => require<ReactComponentModule>('../../../../pages/workspace/expensifyCard/WorkspaceEditCardNamePage').default,
[SCREENS.WORKSPACE.EXPENSIFY_CARD_LIMIT]: () => require<ReactComponentModule>('../../../../pages/workspace/expensifyCard/WorkspaceEditCardLimitPage').default,
[SCREENS.WORKSPACE.EXPENSIFY_CARD_LIMIT_TYPE]: () => require<ReactComponentModule>('../../../../pages/workspace/expensifyCard/WorkspaceEditCardLimitTypePage').default,
[SCREENS.SETTINGS.SAVE_THE_WORLD]: () => require<ReactComponentModule>('../../../../pages/TeachersUnite/SaveTheWorldPage').default,
[SCREENS.SETTINGS.SUBSCRIPTION.CHANGE_PAYMENT_CURRENCY]: () => require<ReactComponentModule>('../../../../pages/settings/PaymentCard/ChangeCurrency').default,
[SCREENS.SETTINGS.SUBSCRIPTION.CHANGE_BILLING_CURRENCY]: () => require<ReactComponentModule>('../../../../pages/settings/Subscription/PaymentCard/ChangeBillingCurrency').default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial<Record<FullScreenName, string[]>> = {
SCREENS.WORKSPACE.EXPENSIFY_CARD_DETAILS,
SCREENS.WORKSPACE.EXPENSIFY_CARD_NAME,
SCREENS.WORKSPACE.EXPENSIFY_CARD_LIMIT,
SCREENS.WORKSPACE.EXPENSIFY_CARD_LIMIT_TYPE,
],
};

Expand Down
3 changes: 3 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,9 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.WORKSPACE.EXPENSIFY_CARD_NAME]: {
path: ROUTES.WORKSPACE_EXPENSIFY_CARD_NAME.route,
},
[SCREENS.WORKSPACE.EXPENSIFY_CARD_LIMIT_TYPE]: {
path: ROUTES.WORKSPACE_EXPENSIFY_CARD_LIMIT_TYPE.route,
},
[SCREENS.WORKSPACE.EXPENSIFY_CARD_BANK_ACCOUNT]: {
path: ROUTES.WORKSPACE_EXPENSIFY_CARD_BANK_ACCOUNT.route,
},
Expand Down
4 changes: 4 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,10 @@ type SettingsNavigatorParamList = {
policyID: string;
cardID: string;
};
[SCREENS.WORKSPACE.EXPENSIFY_CARD_LIMIT_TYPE]: {
policyID: string;
cardID: string;
};
} & ReimbursementAccountNavigatorParamList;

type NewChatNavigatorParamList = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import * as Card from '@userActions/Card';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import INPUT_IDS from '@src/types/form/EditExpensifyCardLimitForm';

Expand Down Expand Up @@ -109,7 +110,10 @@ function WorkspaceEditCardLimitPage({route}: WorkspaceEditCardLimitPageProps) {
shouldEnablePickerAvoiding={false}
shouldEnableMaxHeight
>
<HeaderWithBackButton title={translate('workspace.expensifyCard.cardLimit')} />
<HeaderWithBackButton
title={translate('workspace.expensifyCard.cardLimit')}
onBackButtonPress={() => Navigation.goBack(ROUTES.WORKSPACE_EXPENSIFY_CARD_DETAILS.getRoute(policyID, cardID))}
/>
<FormProvider
formID={ONYXKEYS.FORMS.EDIT_EXPENSIFY_CARD_LIMIT_FORM}
submitButtonText={translate('common.save')}
Expand Down
Loading