From 949cd39e5ec92543d0f9f722f90dad7b2dbebc1d Mon Sep 17 00:00:00 2001 From: dominictb Date: Fri, 11 Oct 2024 16:25:48 +0700 Subject: [PATCH 1/3] fix: tap gesture does not work when keyboard is visible in default spend category page --- .../workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx index 53c1fe14237c..6bfda5f60e29 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx @@ -97,7 +97,7 @@ function PolicyDistanceRatesSettingsPage({policy, policyCategories, route}: Poli > - + {defaultUnit && ( Date: Fri, 11 Oct 2024 16:31:25 +0700 Subject: [PATCH 2/3] prettier --- .../distanceRates/PolicyDistanceRatesSettingsPage.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx index 6bfda5f60e29..124d505c51d3 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx @@ -97,7 +97,10 @@ function PolicyDistanceRatesSettingsPage({policy, policyCategories, route}: Poli > - + {defaultUnit && ( Date: Wed, 16 Oct 2024 07:20:06 +0700 Subject: [PATCH 3/3] migrate to useOnyx --- .../PolicyDistanceRatesSettingsPage.tsx | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx index 124d505c51d3..e7199e61c2dd 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx @@ -1,8 +1,7 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useState} from 'react'; import {View} from 'react-native'; -import type {OnyxEntry} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; @@ -27,26 +26,20 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -import type * as OnyxTypes from '@src/types/onyx'; import type {CustomUnit} from '@src/types/onyx/Policy'; import CategorySelector from './CategorySelector'; import UnitSelector from './UnitSelector'; -type PolicyDistanceRatesSettingsPageOnyxProps = { - /** Policy details */ - policy: OnyxEntry; +type PolicyDistanceRatesSettingsPageProps = StackScreenProps; - /** Policy categories */ - policyCategories: OnyxEntry; -}; - -type PolicyDistanceRatesSettingsPageProps = PolicyDistanceRatesSettingsPageOnyxProps & StackScreenProps; +function PolicyDistanceRatesSettingsPage({route}: PolicyDistanceRatesSettingsPageProps) { + const policyID = route.params.policyID; + const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); + const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`); -function PolicyDistanceRatesSettingsPage({policy, policyCategories, route}: PolicyDistanceRatesSettingsPageProps) { const styles = useThemeStyles(); const [isCategoryPickerVisible, setIsCategoryPickerVisible] = useState(false); const {translate} = useLocalize(); - const policyID = route.params.policyID; const customUnits = policy?.customUnits ?? {}; const customUnit = customUnits[Object.keys(customUnits)[0]]; const customUnitID = customUnit?.customUnitID ?? ''; @@ -179,11 +172,4 @@ function PolicyDistanceRatesSettingsPage({policy, policyCategories, route}: Poli PolicyDistanceRatesSettingsPage.displayName = 'PolicyDistanceRatesSettingsPage'; -export default withOnyx({ - policy: { - key: ({route}) => `${ONYXKEYS.COLLECTION.POLICY}${route.params.policyID}`, - }, - policyCategories: { - key: ({route}) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${route.params.policyID}`, - }, -})(PolicyDistanceRatesSettingsPage); +export default PolicyDistanceRatesSettingsPage;