Skip to content

Commit

Permalink
Merge branch 'main' into wave8/WorkspaceTaxesSettings-customNameValid…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
filip-solecki committed Mar 20, 2024
2 parents 889975b + 8707d29 commit fa90c4f
Show file tree
Hide file tree
Showing 71 changed files with 1,986 additions and 688 deletions.
5 changes: 5 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,11 @@ const CONST = {
DISABLE: 'disable',
ENABLE: 'enable',
},
TAX_RATES_BULK_ACTION_TYPES: {
DELETE: 'delete',
DISABLE: 'disable',
ENABLE: 'enable',
},
},

CUSTOM_UNITS: {
Expand Down
67 changes: 42 additions & 25 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ const ONYXKEYS = {
/** Holds the reportID for the report between the user and their account manager */
ACCOUNT_MANAGER_REPORT_ID: 'accountManagerReportID',

/** Boolean flag only true when first set */
NVP_IS_FIRST_TIME_NEW_EXPENSIFY_USER: 'isFirstTimeNewExpensifyUser',

/** Holds an array of client IDs which is used for multi-tabs on web in order to know
* which tab is the leader, and which ones are the followers */
ACTIVE_CLIENTS: 'activeClients',
Expand Down Expand Up @@ -106,27 +103,52 @@ const ONYXKEYS = {
STASHED_SESSION: 'stashedSession',
BETAS: 'betas',

/** NVP keys
/** NVP keys */

/** Boolean flag only true when first set */
NVP_IS_FIRST_TIME_NEW_EXPENSIFY_USER: 'nvp_isFirstTimeNewExpensifyUser',

/** Contains the user preference for the LHN priority mode */
NVP_PRIORITY_MODE: 'nvp_priorityMode',

/** Contains the users's block expiration (if they have one) */
NVP_BLOCKED_FROM_CONCIERGE: 'private_blockedFromConcierge',
NVP_BLOCKED_FROM_CONCIERGE: 'nvp_private_blockedFromConcierge',

/** A unique identifier that each user has that's used to send notifications */
NVP_PRIVATE_PUSH_NOTIFICATION_ID: 'private_pushNotificationID',
NVP_PRIVATE_PUSH_NOTIFICATION_ID: 'nvp_private_pushNotificationID',

/** The NVP with the last payment method used per policy */
NVP_LAST_PAYMENT_METHOD: 'nvp_lastPaymentMethod',
NVP_LAST_PAYMENT_METHOD: 'nvp_private_lastPaymentMethod',

/** This NVP holds to most recent waypoints that a person has used when creating a distance request */
NVP_RECENT_WAYPOINTS: 'expensify_recentWaypoints',

/** This NVP will be `true` if the user has ever dismissed the engagement modal on either OldDot or NewDot. If it becomes true it should stay true forever. */
NVP_HAS_DISMISSED_IDLE_PANEL: 'hasDismissedIdlePanel',
NVP_HAS_DISMISSED_IDLE_PANEL: 'nvp_hasDismissedIdlePanel',

/** This NVP contains the choice that the user made on the engagement modal */
NVP_INTRO_SELECTED: 'introSelected',
NVP_INTRO_SELECTED: 'nvp_introSelected',

/** This NVP contains the active policyID */
NVP_ACTIVE_POLICY_ID: 'nvp_expensify_activePolicyID',

/** This NVP contains the referral banners the user dismissed */
NVP_DISMISSED_REFERRAL_BANNERS: 'nvp_dismissedReferralBanners',

/** Indicates which locale should be used */
NVP_PREFERRED_LOCALE: 'nvp_preferredLocale',

/** Whether the user has tried focus mode yet */
NVP_TRY_FOCUS_MODE: 'nvp_tryFocusMode',

/** Whether the user has been shown the hold educational interstitial yet */
NVP_HOLD_USE_EXPLAINED: 'holdUseExplained',

/** Store preferred skintone for emoji */
PREFERRED_EMOJI_SKIN_TONE: 'nvp_expensify_preferredEmojiSkinTone',

/** Store frequently used emojis for this user */
FREQUENTLY_USED_EMOJIS: 'nvp_expensify_frequentlyUsedEmojis',

/** The NVP with the last distance rate used per policy */
NVP_LAST_SELECTED_DISTANCE_RATES: 'lastSelectedDistanceRates',
Expand All @@ -153,9 +175,6 @@ const ONYXKEYS = {
ONFIDO_TOKEN: 'onfidoToken',
ONFIDO_APPLICANT_ID: 'onfidoApplicantID',

/** Indicates which locale should be used */
NVP_PREFERRED_LOCALE: 'preferredLocale',

/** User's Expensify Wallet */
USER_WALLET: 'userWallet',

Expand All @@ -177,12 +196,6 @@ const ONYXKEYS = {
/** The user's cash card and imported cards (including the Expensify Card) */
CARD_LIST: 'cardList',

/** Whether the user has tried focus mode yet */
NVP_TRY_FOCUS_MODE: 'tryFocusMode',

/** Whether the user has been shown the hold educational interstitial yet */
NVP_HOLD_USE_EXPLAINED: 'holdUseExplained',

/** Boolean flag used to display the focus mode notification */
FOCUS_MODE_NOTIFICATION: 'focusModeNotification',

Expand All @@ -195,12 +208,6 @@ const ONYXKEYS = {
/** Stores information about the active reimbursement account being set up */
REIMBURSEMENT_ACCOUNT: 'reimbursementAccount',

/** Store preferred skintone for emoji */
PREFERRED_EMOJI_SKIN_TONE: 'preferredEmojiSkinTone',

/** Store frequently used emojis for this user */
FREQUENTLY_USED_EMOJIS: 'frequentlyUsedEmojis',

/** Stores Workspace ID that will be tied to reimbursement account during setup */
REIMBURSEMENT_ACCOUNT_WORKSPACE_ID: 'reimbursementAccountWorkspaceID',

Expand Down Expand Up @@ -294,7 +301,8 @@ const ONYXKEYS = {
POLICY_CATEGORIES: 'policyCategories_',
POLICY_RECENTLY_USED_CATEGORIES: 'policyRecentlyUsedCategories_',
POLICY_TAGS: 'policyTags_',
POLICY_RECENTLY_USED_TAGS: 'policyRecentlyUsedTags_',
POLICY_RECENTLY_USED_TAGS: 'nvp_recentlyUsedTags_',
OLD_POLICY_RECENTLY_USED_TAGS: 'policyRecentlyUsedTags_',
POLICY_REPORT_FIELDS: 'policyReportFields_',
WORKSPACE_INVITE_MEMBERS_DRAFT: 'workspaceInviteMembersDraft_',
WORKSPACE_INVITE_MESSAGE_DRAFT: 'workspaceInviteMessageDraft_',
Expand Down Expand Up @@ -420,6 +428,10 @@ const ONYXKEYS = {
POLICY_TAG_NAME_FORM_DRAFT: 'policyTagNameFormDraft',
WORKSPACE_NEW_TAX_FORM: 'workspaceNewTaxForm',
WORKSPACE_NEW_TAX_FORM_DRAFT: 'workspaceNewTaxFormDraft',
WORKSPACE_TAX_NAME_FORM: 'workspaceTaxNameForm',
WORKSPACE_TAX_NAME_FORM_DRAFT: 'workspaceTaxNameFormDraft',
WORKSPACE_TAX_VALUE_FORM: 'workspaceTaxValueForm',
WORKSPACE_TAX_VALUE_FORM_DRAFT: 'workspaceTaxValueFormDraft',
},
} as const;

Expand Down Expand Up @@ -471,6 +483,8 @@ type OnyxFormValuesMapping = {
[ONYXKEYS.FORMS.POLICY_TAG_NAME_FORM]: FormTypes.PolicyTagNameForm;
[ONYXKEYS.FORMS.WORKSPACE_NEW_TAX_FORM]: FormTypes.WorkspaceNewTaxForm;
[ONYXKEYS.FORMS.POLICY_CREATE_DISTANCE_RATE_FORM]: FormTypes.PolicyCreateDistanceRateForm;
[ONYXKEYS.FORMS.WORKSPACE_TAX_NAME_FORM]: FormTypes.WorkspaceTaxNameForm;
[ONYXKEYS.FORMS.WORKSPACE_TAX_VALUE_FORM]: FormTypes.WorkspaceTaxValueForm;
};

type OnyxFormDraftValuesMapping = {
Expand Down Expand Up @@ -506,6 +520,7 @@ type OnyxCollectionValuesMapping = {
[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS]: OnyxTypes.TransactionViolations;
[ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT]: OnyxTypes.Transaction;
[ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS]: OnyxTypes.RecentlyUsedTags;
[ONYXKEYS.COLLECTION.OLD_POLICY_RECENTLY_USED_TAGS]: OnyxTypes.RecentlyUsedTags;
[ONYXKEYS.COLLECTION.SELECTED_TAB]: string;
[ONYXKEYS.COLLECTION.PRIVATE_NOTES_DRAFT]: string;
[ONYXKEYS.COLLECTION.NEXT_STEP]: OnyxTypes.ReportNextStep;
Expand Down Expand Up @@ -561,6 +576,8 @@ type OnyxValuesMapping = {
[ONYXKEYS.ONFIDO_TOKEN]: string;
[ONYXKEYS.ONFIDO_APPLICANT_ID]: string;
[ONYXKEYS.NVP_PREFERRED_LOCALE]: OnyxTypes.Locale;
[ONYXKEYS.NVP_ACTIVE_POLICY_ID]: string;
[ONYXKEYS.NVP_DISMISSED_REFERRAL_BANNERS]: OnyxTypes.DismissedReferralBanners;
[ONYXKEYS.USER_WALLET]: OnyxTypes.UserWallet;
[ONYXKEYS.WALLET_ONFIDO]: OnyxTypes.WalletOnfido;
[ONYXKEYS.WALLET_ADDITIONAL_DETAILS]: OnyxTypes.WalletAdditionalDetails;
Expand Down
12 changes: 12 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,18 @@ const ROUTES = {
route: 'settings/workspaces/:policyID/taxes/new',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/taxes/new` as const,
},
WORKSPACE_TAX_EDIT: {
route: 'settings/workspaces/:policyID/tax/:taxID',
getRoute: (policyID: string, taxID: string) => `settings/workspaces/${policyID}/tax/${encodeURI(taxID)}` as const,
},
WORKSPACE_TAX_NAME: {
route: 'settings/workspaces/:policyID/tax/:taxID/name',
getRoute: (policyID: string, taxID: string) => `settings/workspaces/${policyID}/tax/${encodeURI(taxID)}/name` as const,
},
WORKSPACE_TAX_VALUE: {
route: 'settings/workspaces/:policyID/tax/:taxID/value',
getRoute: (policyID: string, taxID: string) => `settings/workspaces/${policyID}/tax/${encodeURI(taxID)}/value` as const,
},
WORKSPACE_DISTANCE_RATES: {
route: 'settings/workspaces/:policyID/distance-rates',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/distance-rates` as const,
Expand Down
3 changes: 3 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ const SCREENS = {
TAGS_EDIT: 'Tags_Edit',
TAG_EDIT: 'Tag_Edit',
TAXES: 'Workspace_Taxes',
TAX_EDIT: 'Workspace_Tax_Edit',
TAX_NAME: 'Workspace_Tax_Name',
TAX_VALUE: 'Workspace_Tax_Value',
TAXES_SETTINGS: 'Workspace_Taxes_Settings',
TAXES_SETTINGS_CUSTOM_TAX_NAME: 'Workspace_Taxes_Settings_CustomTaxName',
TAXES_SETTINGS_WORKSPACE_CURRENCY_DEFAULT: 'Workspace_Taxes_Settings_WorkspaceCurrency',
Expand Down
3 changes: 2 additions & 1 deletion src/components/AmountPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ function AmountPicker({value, description, title, errorText = '', onInputChange,

const updateInput = (updatedValue: string) => {
if (updatedValue !== value) {
onInputChange?.(updatedValue);
// We cast the updatedValue to a number and then back to a string to remove any leading zeros and separating commas
onInputChange?.(String(Number(updatedValue)));
}
hidePickerModal();
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/AvatarSkeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import SkeletonViewContentLoader from './SkeletonViewContentLoader';

function AvatarSkeleton() {
const theme = useTheme();
const skeletonCircleRadius = variables.componentSizeSmall / 2;
const skeletonCircleRadius = variables.sidebarAvatarSize / 2;

return (
<SkeletonViewContentLoader
animate
height={variables.componentSizeSmall}
height={variables.sidebarAvatarSize}
backgroundColor={theme.skeletonLHNIn}
foregroundColor={theme.skeletonLHNOut}
>
Expand Down
4 changes: 3 additions & 1 deletion src/components/ButtonWithDropdownMenu/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type WorkspaceMemberBulkActionType = DeepValueOf<typeof CONST.POLICY.MEMBERS_BUL

type WorkspaceDistanceRatesBulkActionType = DeepValueOf<typeof CONST.POLICY.DISTANCE_RATES_BULK_ACTION_TYPES>;

type WorkspaceTaxRatesBulkActionType = DeepValueOf<typeof CONST.POLICY.TAX_RATES_BULK_ACTION_TYPES>;

type DropdownOption<TValueType> = {
value: TValueType;
text: string;
Expand Down Expand Up @@ -73,4 +75,4 @@ type ButtonWithDropdownMenuProps<TValueType> = {
wrapperStyle?: StyleProp<ViewStyle>;
};

export type {PaymentType, WorkspaceMemberBulkActionType, WorkspaceDistanceRatesBulkActionType, DropdownOption, ButtonWithDropdownMenuProps};
export type {PaymentType, WorkspaceMemberBulkActionType, WorkspaceDistanceRatesBulkActionType, DropdownOption, ButtonWithDropdownMenuProps, WorkspaceTaxRatesBulkActionType};
2 changes: 2 additions & 0 deletions src/components/CheckboxWithLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,5 @@ function CheckboxWithLabel(
CheckboxWithLabel.displayName = 'CheckboxWithLabel';

export default React.forwardRef(CheckboxWithLabel);

export type {CheckboxWithLabelProps};
8 changes: 0 additions & 8 deletions src/components/MapView/responder/index.android.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/components/OptionRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,5 @@ export default React.memo(
prevProps.option.pendingAction === nextProps.option.pendingAction &&
prevProps.option.customIcon === nextProps.option.customIcon,
);

export type {OptionRowProps};
2 changes: 1 addition & 1 deletion src/components/PopoverMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,4 @@ function PopoverMenu({
PopoverMenu.displayName = 'PopoverMenu';

export default React.memo(PopoverMenu);
export type {PopoverMenuItem};
export type {PopoverMenuItem, PopoverMenuProps};
10 changes: 5 additions & 5 deletions src/components/ReferralProgramCTA.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
Expand All @@ -8,15 +9,15 @@ import CONST from '@src/CONST';
import Navigation from '@src/libs/Navigation/Navigation';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {DismissedReferralBanners} from '@src/types/onyx/Account';
import type * as OnyxTypes from '@src/types/onyx';
import Icon from './Icon';
import {Close} from './Icon/Expensicons';
import {PressableWithoutFeedback} from './Pressable';
import Text from './Text';
import Tooltip from './Tooltip';

type ReferralProgramCTAOnyxProps = {
dismissedReferralBanners: DismissedReferralBanners;
dismissedReferralBanners: OnyxEntry<OnyxTypes.DismissedReferralBanners>;
};

type ReferralProgramCTAProps = ReferralProgramCTAOnyxProps & {
Expand All @@ -36,7 +37,7 @@ function ReferralProgramCTA({referralContentType, dismissedReferralBanners}: Ref
User.dismissReferralBanner(referralContentType);
};

if (!referralContentType || dismissedReferralBanners[referralContentType]) {
if (!referralContentType || dismissedReferralBanners?.[referralContentType]) {
return null;
}

Expand Down Expand Up @@ -82,7 +83,6 @@ function ReferralProgramCTA({referralContentType, dismissedReferralBanners}: Ref

export default withOnyx<ReferralProgramCTAProps, ReferralProgramCTAOnyxProps>({
dismissedReferralBanners: {
key: ONYXKEYS.ACCOUNT,
selector: (data) => data?.dismissedReferralBanners ?? {},
key: ONYXKEYS.NVP_DISMISSED_REFERRAL_BANNERS,
},
})(ReferralProgramCTA);
2 changes: 1 addition & 1 deletion src/components/SelectionList/BaseListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function BaseListItem<TItem extends ListItem>({
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
disabled={isDisabled || item.isDisabledCheckbox}
onPress={handleCheckboxPress}
style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), item.isDisabledCheckbox && styles.cursorDisabled]}
style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), item.isDisabledCheckbox && styles.cursorDisabled, styles.mr3]}
>
<View style={selectMultipleStyle}>
{item.isSelected && (
Expand Down
37 changes: 25 additions & 12 deletions src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Button from '@components/Button';
import Checkbox from '@components/Checkbox';
import FixedFooter from '@components/FixedFooter';
import OptionsListSkeletonView from '@components/OptionsListSkeletonView';
import {PressableWithFeedback} from '@components/Pressable';
import SafeAreaConsumer from '@components/SafeAreaConsumer';
import SectionList from '@components/SectionList';
import ShowMoreButton from '@components/ShowMoreButton';
Expand Down Expand Up @@ -512,18 +513,30 @@ function BaseSelectionList<TItem extends ListItem>(
) : (
<>
{!headerMessage && canSelectMultiple && shouldShowSelectAll && (
<View style={[styles.peopleRow, styles.userSelectNone, styles.ph4, styles.pb3, listHeaderWrapperStyle]}>
<Checkbox
isChecked={flattenedSections.allSelected}
onPress={selectAllRow}
disabled={flattenedSections.allOptions.length === flattenedSections.disabledOptionsIndexes.length}
accessibilityLabel={translate('workspace.people.selectAll')}
/>
{customListHeader ?? (
<View style={[styles.flex1]}>
<Text style={[styles.textStrong, styles.ph3]}>{translate('workspace.people.selectAll')}</Text>
</View>
)}
<View style={[styles.userSelectNone, styles.peopleRow, styles.ph5, styles.pb3, listHeaderWrapperStyle]}>
<View style={[styles.flexRow, styles.alignItemsCenter]}>
<Checkbox
accessibilityLabel={translate('workspace.people.selectAll')}
isChecked={flattenedSections.allSelected}
onPress={selectAllRow}
disabled={flattenedSections.allOptions.length === flattenedSections.disabledOptionsIndexes.length}
/>
{!customListHeader && (
<PressableWithFeedback
style={[styles.userSelectNone, styles.flexRow, styles.alignItemsCenter]}
onPress={selectAllRow}
accessibilityLabel={translate('workspace.people.selectAll')}
role="button"
accessibilityState={{checked: flattenedSections.allSelected}}
disabled={flattenedSections.allOptions.length === flattenedSections.disabledOptionsIndexes.length}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
onMouseDown={shouldPreventDefaultFocusOnSelectRow ? (e) => e.preventDefault() : undefined}
>
<Text style={[styles.textStrong, styles.ph3]}>{translate('workspace.people.selectAll')}</Text>
</PressableWithFeedback>
)}
</View>
{customListHeader}
</View>
)}
{!headerMessage && !canSelectMultiple && customListHeader}
Expand Down
1 change: 1 addition & 0 deletions src/components/SwipeInterceptPanResponder.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {PanResponder} from 'react-native';

const SwipeInterceptPanResponder = PanResponder.create({
onStartShouldSetPanResponder: () => true,
onMoveShouldSetPanResponder: () => true,
onPanResponderTerminationRequest: () => false,
});
Expand Down
14 changes: 13 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1876,8 +1876,20 @@ export default {
errors: {
taxRateAlreadyExists: 'This tax name is already in use.',
valuePercentageRange: 'Please enter a valid percentage between 0 and 100.',
genericFailureMessage: 'An error occurred while updating the tax rate, please try again.',
customNameRequired: 'Custom tax name is required.',
deleteFailureMessage: 'An error occurred while deleting the tax rate. Please try again or ask Concierge for help.',
updateFailureMessage: 'An error occurred while updating the tax rate. Please try again or ask Concierge for help.',
createFailureMessage: 'An error occurred while creating the tax rate. Please try again or ask Concierge for help.',
},
deleteTaxConfirmation: 'Are you sure you want to delete this tax?',
deleteMultipleTaxConfirmation: ({taxAmount}) => `Are you sure you want to delete ${taxAmount} taxes?`,
actions: {
delete: 'Delete rate',
deleteMultiple: 'Delete rates',
disable: 'Disable rate',
disableMultiple: 'Disable rates',
enable: 'Enable rate',
enableMultiple: 'Enable rates',
},
},
emptyWorkspace: {
Expand Down
Loading

0 comments on commit fa90c4f

Please sign in to comment.