From 1d1275b1534894df1f5756633c692014eb4845b3 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Wed, 8 Jan 2025 17:06:28 +0700 Subject: [PATCH 1/4] fix: /bin/zsh doesn't save in the Receipt --- .../workspace/rules/IndividualExpenseRulesSection.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx b/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx index 7b9acc5e6ea0a..62ea0150eedbc 100644 --- a/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx +++ b/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx @@ -88,7 +88,7 @@ function IndividualExpenseRulesSection({policyID}: IndividualExpenseRulesSection const policyCurrency = policy?.outputCurrency ?? CONST.CURRENCY.USD; const maxExpenseAmountNoReceiptText = useMemo(() => { - if (policy?.maxExpenseAmountNoReceipt === CONST.DISABLED_MAX_EXPENSE_VALUE || !policy?.maxExpenseAmountNoReceipt) { + if (policy?.maxExpenseAmountNoReceipt === CONST.DISABLED_MAX_EXPENSE_VALUE) { return ''; } @@ -96,7 +96,7 @@ function IndividualExpenseRulesSection({policyID}: IndividualExpenseRulesSection }, [policy?.maxExpenseAmountNoReceipt, policyCurrency]); const maxExpenseAmountText = useMemo(() => { - if (policy?.maxExpenseAmount === CONST.DISABLED_MAX_EXPENSE_VALUE || !policy?.maxExpenseAmount) { + if (policy?.maxExpenseAmount === CONST.DISABLED_MAX_EXPENSE_VALUE) { return ''; } @@ -104,11 +104,11 @@ function IndividualExpenseRulesSection({policyID}: IndividualExpenseRulesSection }, [policy?.maxExpenseAmount, policyCurrency]); const maxExpenseAgeText = useMemo(() => { - if (policy?.maxExpenseAge === CONST.DISABLED_MAX_EXPENSE_VALUE || !policy?.maxExpenseAge) { + if (policy?.maxExpenseAge === CONST.DISABLED_MAX_EXPENSE_VALUE) { return ''; } - return translate('workspace.rules.individualExpenseRules.maxExpenseAgeDays', {count: policy?.maxExpenseAge}); + return translate('workspace.rules.individualExpenseRules.maxExpenseAgeDays', {count: policy?.maxExpenseAge ?? 0}); }, [policy?.maxExpenseAge, translate]); const billableModeText = translate(`workspace.rules.individualExpenseRules.${policy?.defaultBillable ? 'billable' : 'nonBillable'}`); From be23aa732248adc3a7bf26f38e111782b53656cd Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Wed, 8 Jan 2025 22:37:30 +0700 Subject: [PATCH 2/4] fix lint --- src/pages/workspace/rules/IndividualExpenseRulesSection.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx b/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx index 62ea0150eedbc..365fa083ec6f4 100644 --- a/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx +++ b/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx @@ -39,7 +39,7 @@ type IndividualExpenseRulesMenuItem = { }; function IndividualExpenseRulesSectionSubtitle({policy, translate, styles}: IndividualExpenseRulesSectionSubtitleProps) { - const policyID = policy?.id ?? '-1'; + const policyID = `${policy?.id ?? CONST.DEFAULT_NUMBER_ID}`; const handleOnPressCategoriesLink = () => { if (policy?.areCategoriesEnabled) { From 12285a727a716437b9ff086f970813d2215763d6 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 16 Jan 2025 15:31:27 +0700 Subject: [PATCH 3/4] fix lint --- src/ROUTES.ts | 21 ++++++++++++++++--- .../rules/IndividualExpenseRulesSection.tsx | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 7f8b75f353e18..7fa032082bf57 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -1011,7 +1011,12 @@ const ROUTES = { }, WORKSPACE_CATEGORIES: { route: 'settings/workspaces/:policyID/categories', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/categories` as const, + getRoute: (policyID: string | undefined) => { + if (!policyID) { + Log.warn('Invalid policyID while building route WORKSPACE_CATEGORIES'); + } + return `settings/workspaces/${policyID}/categories` as const; + }, }, WORKSPACE_CATEGORY_SETTINGS: { route: 'settings/workspaces/:policyID/category/:categoryName', @@ -1076,11 +1081,21 @@ const ROUTES = { }, WORKSPACE_MORE_FEATURES: { route: 'settings/workspaces/:policyID/more-features', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/more-features` as const, + getRoute: (policyID: string | undefined) => { + if (!policyID) { + Log.warn('Invalid policyID while building route WORKSPACE_MORE_FEATURES'); + } + return `settings/workspaces/${policyID}/more-features` as const; + }, }, WORKSPACE_TAGS: { route: 'settings/workspaces/:policyID/tags', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/tags` as const, + getRoute: (policyID: string | undefined) => { + if (!policyID) { + Log.warn('Invalid policyID while building route WORKSPACE_TAGS'); + } + return `settings/workspaces/${policyID}/tags` as const; + }, }, WORKSPACE_TAG_CREATE: { route: 'settings/workspaces/:policyID/tags/new', diff --git a/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx b/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx index 365fa083ec6f4..817355cff5b89 100644 --- a/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx +++ b/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx @@ -39,7 +39,7 @@ type IndividualExpenseRulesMenuItem = { }; function IndividualExpenseRulesSectionSubtitle({policy, translate, styles}: IndividualExpenseRulesSectionSubtitleProps) { - const policyID = `${policy?.id ?? CONST.DEFAULT_NUMBER_ID}`; + const policyID = policy?.id; const handleOnPressCategoriesLink = () => { if (policy?.areCategoriesEnabled) { From 81896db9605ede1ce4ad2456938237d431991683 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 16 Jan 2025 16:35:21 +0700 Subject: [PATCH 4/4] fix lint --- .../rules/IndividualExpenseRulesSection.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx b/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx index 817355cff5b89..b41e0fe3ef9f3 100644 --- a/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx +++ b/src/pages/workspace/rules/IndividualExpenseRulesSection.tsx @@ -10,11 +10,11 @@ import TextLink from '@components/TextLink'; import useLocalize from '@hooks/useLocalize'; import usePolicy from '@hooks/usePolicy'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as CurrencyUtils from '@libs/CurrencyUtils'; +import {openExternalLink} from '@libs/actions/Link'; +import {setWorkspaceEReceiptsEnabled} from '@libs/actions/Policy/Policy'; +import {convertToDisplayString} from '@libs/CurrencyUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {ThemeStyles} from '@styles/index'; -import * as Link from '@userActions/Link'; -import * as PolicyActions from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import ROUTES from '@src/ROUTES'; @@ -92,7 +92,7 @@ function IndividualExpenseRulesSection({policyID}: IndividualExpenseRulesSection return ''; } - return CurrencyUtils.convertToDisplayString(policy?.maxExpenseAmountNoReceipt, policyCurrency); + return convertToDisplayString(policy?.maxExpenseAmountNoReceipt, policyCurrency); }, [policy?.maxExpenseAmountNoReceipt, policyCurrency]); const maxExpenseAmountText = useMemo(() => { @@ -100,7 +100,7 @@ function IndividualExpenseRulesSection({policyID}: IndividualExpenseRulesSection return ''; } - return CurrencyUtils.convertToDisplayString(policy?.maxExpenseAmount, policyCurrency); + return convertToDisplayString(policy?.maxExpenseAmount, policyCurrency); }, [policy?.maxExpenseAmount, policyCurrency]); const maxExpenseAgeText = useMemo(() => { @@ -180,7 +180,7 @@ function IndividualExpenseRulesSection({policyID}: IndividualExpenseRulesSection PolicyActions.setWorkspaceEReceiptsEnabled(policyID, !areEReceiptsEnabled)} + onToggle={() => setWorkspaceEReceiptsEnabled(policyID, !areEReceiptsEnabled)} disabled={policyCurrency !== CONST.CURRENCY.USD} /> @@ -189,7 +189,7 @@ function IndividualExpenseRulesSection({policyID}: IndividualExpenseRulesSection {translate('workspace.rules.individualExpenseRules.eReceiptsHint')}{' '} Link.openExternalLink(CONST.DEEP_DIVE_ERECEIPTS)} + onPress={() => openExternalLink(CONST.DEEP_DIVE_ERECEIPTS)} > {translate('workspace.rules.individualExpenseRules.eReceiptsHintLink')}