From 06fe35d502a63ffc95886fca371e61025b3318dd Mon Sep 17 00:00:00 2001 From: godofoutcasts94 Date: Fri, 16 Feb 2024 15:16:14 +0530 Subject: [PATCH 01/12] Migrated LoadingPage.js to LoadingPage.tsx --- src/pages/{LoadingPage.js => LoadingPage.tsx} | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) rename src/pages/{LoadingPage.js => LoadingPage.tsx} (65%) diff --git a/src/pages/LoadingPage.js b/src/pages/LoadingPage.tsx similarity index 65% rename from src/pages/LoadingPage.js rename to src/pages/LoadingPage.tsx index fc315495619a..4fb16b29827c 100644 --- a/src/pages/LoadingPage.js +++ b/src/pages/LoadingPage.tsx @@ -1,28 +1,25 @@ -import PropTypes from 'prop-types'; import React from 'react'; import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import useThemeStyles from '@hooks/useThemeStyles'; -const propTypes = { +type LoadingPageProps = { /** Method to trigger when pressing back button of the header */ - onBackButtonPress: PropTypes.func, - title: PropTypes.string.isRequired, -}; + onBackButtonPress?: () => void; -const defaultProps = { - onBackButtonPress: undefined, + /** Title of the Loading page */ + title: string; }; -function LoadingPage(props) { +function LoadingPage({onBackButtonPress = undefined, title}: LoadingPageProps) { const styles = useThemeStyles(); return ( @@ -30,7 +27,5 @@ function LoadingPage(props) { } LoadingPage.displayName = 'LoadingPage'; -LoadingPage.propTypes = propTypes; -LoadingPage.defaultProps = defaultProps; export default LoadingPage; From 356341d01de909e8da35a81346b1beaabbcb8765 Mon Sep 17 00:00:00 2001 From: godofoutcasts94 Date: Fri, 16 Feb 2024 15:24:06 +0530 Subject: [PATCH 02/12] Migrated SearchInputManager.js to SearchInputManager.tsx --- .../workspace/{SearchInputManager.js => SearchInputManager.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/pages/workspace/{SearchInputManager.js => SearchInputManager.tsx} (100%) diff --git a/src/pages/workspace/SearchInputManager.js b/src/pages/workspace/SearchInputManager.tsx similarity index 100% rename from src/pages/workspace/SearchInputManager.js rename to src/pages/workspace/SearchInputManager.tsx From dcaf610f63d70be8ff70d44c8e2e930184ecb324 Mon Sep 17 00:00:00 2001 From: godofoutcasts94 Date: Fri, 16 Feb 2024 16:24:12 +0530 Subject: [PATCH 03/12] Migrated ProcessMoneyRequestHoldPage.js to ProcessMoneyRequestHoldPage.tsx --- ...ssMoneyRequestHoldPage.js => ProcessMoneyRequestHoldPage.tsx} | 1 + 1 file changed, 1 insertion(+) rename src/pages/{ProcessMoneyRequestHoldPage.js => ProcessMoneyRequestHoldPage.tsx} (96%) diff --git a/src/pages/ProcessMoneyRequestHoldPage.js b/src/pages/ProcessMoneyRequestHoldPage.tsx similarity index 96% rename from src/pages/ProcessMoneyRequestHoldPage.js rename to src/pages/ProcessMoneyRequestHoldPage.tsx index c9de16f874a2..956471d65643 100644 --- a/src/pages/ProcessMoneyRequestHoldPage.js +++ b/src/pages/ProcessMoneyRequestHoldPage.tsx @@ -31,6 +31,7 @@ function ProcessMoneyRequestHoldPage() { return ( Navigation.goBack()} From 70ba04891e25a4766b6378b31a4343e3c83f5442 Mon Sep 17 00:00:00 2001 From: godofoutcasts94 Date: Wed, 21 Feb 2024 10:28:17 +0530 Subject: [PATCH 04/12] Migrated WorkspaceProfilePage.js to TS --- ...rofilePage.js => WorkspaceProfilePage.tsx} | 107 ++++++++---------- 1 file changed, 49 insertions(+), 58 deletions(-) rename src/pages/workspace/{WorkspaceProfilePage.js => WorkspaceProfilePage.tsx} (72%) diff --git a/src/pages/workspace/WorkspaceProfilePage.js b/src/pages/workspace/WorkspaceProfilePage.tsx similarity index 72% rename from src/pages/workspace/WorkspaceProfilePage.js rename to src/pages/workspace/WorkspaceProfilePage.tsx index 8a611898cbab..94e8d34cba0f 100644 --- a/src/pages/workspace/WorkspaceProfilePage.js +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -1,9 +1,6 @@ -import lodashGet from 'lodash/get'; -import PropTypes from 'prop-types'; import React, {useCallback} from 'react'; -import {Image, ScrollView, StyleSheet, View} from 'react-native'; -import {withOnyx} from 'react-native-onyx'; -import _ from 'underscore'; +import {Image, ScrollView, View} from 'react-native'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import WorkspaceProfile from '@assets/images/workspace-profile.png'; import Avatar from '@components/Avatar'; import AvatarWithImagePicker from '@components/AvatarWithImagePicker'; @@ -16,7 +13,6 @@ import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; -import compose from '@libs/compose'; import Navigation from '@libs/Navigation/Navigation'; import * as PolicyUtils from '@libs/PolicyUtils'; import * as ReportUtils from '@libs/ReportUtils'; @@ -25,48 +21,42 @@ import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import withPolicy, {policyDefaultProps, policyPropTypes} from './withPolicy'; +import type {Currency, Policy as PolicyType} from '@src/types/onyx'; +import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import withPolicy from './withPolicy'; +import type {PolicyRoute, WithPolicyOnyxProps} from './withPolicy'; import WorkspacePageWithSections from './WorkspacePageWithSections'; -const propTypes = { +type CurrencyList = Record; + +type WorkspaceProfilePageOnyxProps = { /** Constant, list of available currencies */ - currencyList: PropTypes.objectOf( - PropTypes.shape({ - /** Symbol of the currency */ - symbol: PropTypes.string.isRequired, - }), - ), + currencyList: OnyxEntry; +}; +type WorkspaceProfilePageProps = WorkspaceProfilePageOnyxProps & { /** The route object passed to this page from the navigator */ - route: PropTypes.shape({ - /** Each parameter passed via the URL */ - params: PropTypes.shape({ - /** The policyID that is being configured */ - policyID: PropTypes.string.isRequired, - }).isRequired, - }).isRequired, + route: PolicyRoute; - ...policyPropTypes, -}; + /** The policy that is being configured */ + policy: OnyxEntry; -const defaultProps = { - currencyList: {}, - ...policyDefaultProps, + title: string; }; -function WorkspaceProfilePage({policy, currencyList, route}) { +function WorkspaceProfilePage({policy, title, currencyList, route}: WorkspaceProfilePageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const {isSmallScreenWidth} = useWindowDimensions(); - const formattedCurrency = !_.isEmpty(policy) && !_.isEmpty(currencyList) && !!policy.outputCurrency ? `${policy.outputCurrency} - ${currencyList[policy.outputCurrency].symbol}` : ''; - - const onPressCurrency = useCallback(() => Navigation.navigate(ROUTES.WORKSPACE_PROFILE_CURRENCY.getRoute(policy.id)), [policy.id]); - const onPressName = useCallback(() => Navigation.navigate(ROUTES.WORKSPACE_PROFILE_NAME.getRoute(policy.id)), [policy.id]); - const onPressDescription = useCallback(() => Navigation.navigate(ROUTES.WORKSPACE_PROFILE_DESCRIPTION.getRoute(policy.id)), [policy.id]); + const formattedCurrency = + !isEmptyObject(policy) && !isEmptyObject(currencyList) && !!policy.outputCurrency ? `${policy.outputCurrency} - ${currencyList[policy.outputCurrency].symbol}` : ''; + const onPressCurrency = useCallback(() => Navigation.navigate(ROUTES.WORKSPACE_PROFILE_CURRENCY.getRoute(policy?.id ?? '')), [policy?.id ?? '']); + const onPressName = useCallback(() => Navigation.navigate(ROUTES.WORKSPACE_PROFILE_NAME.getRoute(policy?.id ?? '')), [policy?.id ?? '']); + const onPressDescription = useCallback(() => Navigation.navigate(ROUTES.WORKSPACE_PROFILE_DESCRIPTION.getRoute(policy?.id ?? '')), [policy?.id ?? '']); - const policyName = lodashGet(policy, 'name', ''); - const policyDescription = lodashGet(policy, 'description', ''); + const policyName = policy?.name ?? ''; + const policyDescription = policy?.description ?? ''; const readOnly = !PolicyUtils.isPolicyAdmin(policy); const imageStyle = isSmallScreenWidth ? [styles.mhv12, styles.mhn5] : [styles.mhv8, styles.mhn8]; @@ -84,15 +74,18 @@ function WorkspaceProfilePage({policy, currencyList, route}) { {(hasVBA) => ( -
+
Navigation.navigate(ROUTES.WORKSPACE_AVATAR.getRoute(policy.id))} - source={lodashGet(policy, 'avatar')} + onViewPhotoPress={() => Navigation.navigate(ROUTES.WORKSPACE_AVATAR.getRoute(policy?.id ?? ''))} + source={policy?.avatar ?? null} size={CONST.AVATAR_SIZE.XLARGE} avatarStyle={styles.avatarXLarge} enablePreview @@ -100,7 +93,7 @@ function WorkspaceProfilePage({policy, currencyList, route}) { Policy.updateWorkspaceAvatar(lodashGet(policy, 'id', ''), file)} - onImageRemoved={() => Policy.deleteWorkspaceAvatar(lodashGet(policy, 'id', ''))} + isUsingDefaultAvatar={!policy?.avatar ?? null} + onImageSelected={(file: File) => Policy.updateWorkspaceAvatar(policy?.id ?? '', file)} + onImageRemoved={() => Policy.deleteWorkspaceAvatar(policy?.id ?? '')} editorMaskImage={Expensicons.ImageCropSquareMask} - pendingAction={lodashGet(policy, 'pendingFields.avatar', null)} - errors={lodashGet(policy, 'errorFields.avatar', null)} - onErrorClose={() => Policy.clearAvatarErrors(policy.id)} - previewSource={UserUtils.getFullSizeAvatar(policy.avatar, '')} + pendingAction={policy?.pendingFields?.avatar ?? null} + errors={policy?.errorFields?.avatar ?? null} + onErrorClose={() => Policy.clearAvatarErrors(policy?.id ?? '')} + previewSource={UserUtils.getFullSizeAvatar(policy?.avatar, 0)} headerTitle={translate('workspace.common.workspaceAvatar')} - originalFileName={policy.originalFileName} + originalFileName={policy?.originalFileName} disabled={readOnly} disabledStyle={styles.cursorDefault} + errorRowStyles={undefined} /> - + - {(!_.isEmpty(policy.description) || !readOnly) && ( - + {(!isEmptyObject(policy?.description) || !readOnly) && ( + )} - + ({ currencyList: {key: ONYXKEYS.CURRENCY_LIST}, - }), -)(WorkspaceProfilePage); + })(WorkspaceProfilePage), +); From 5cc19624a84183d688c9186a784710d11fadd730 Mon Sep 17 00:00:00 2001 From: godofoutcasts94 Date: Thu, 22 Feb 2024 21:58:29 +0530 Subject: [PATCH 05/12] Refactored lint errors in WorkspaceProfilePage.tsx --- src/pages/workspace/WorkspaceProfilePage.tsx | 27 ++++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index 94e8d34cba0f..c12e8f81c5e9 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -21,10 +21,11 @@ import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type {Currency, Policy as PolicyType} from '@src/types/onyx'; +import type {Currency} from '@src/types/onyx'; +import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import withPolicy from './withPolicy'; -import type {PolicyRoute, WithPolicyOnyxProps} from './withPolicy'; +import type {WithPolicyProps} from './withPolicy'; import WorkspacePageWithSections from './WorkspacePageWithSections'; type CurrencyList = Record; @@ -34,17 +35,9 @@ type WorkspaceProfilePageOnyxProps = { currencyList: OnyxEntry; }; -type WorkspaceProfilePageProps = WorkspaceProfilePageOnyxProps & { - /** The route object passed to this page from the navigator */ - route: PolicyRoute; +type WorkspaceProfilePageProps = WithPolicyProps & WorkspaceProfilePageOnyxProps; - /** The policy that is being configured */ - policy: OnyxEntry; - - title: string; -}; - -function WorkspaceProfilePage({policy, title, currencyList, route}: WorkspaceProfilePageProps) { +function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkspaceProfilePageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const {isSmallScreenWidth} = useWindowDimensions(); @@ -75,7 +68,7 @@ function WorkspaceProfilePage({policy, title, currencyList, route}: WorkspacePro
- + {(!isEmptyObject(policy?.description) || !readOnly) && ( - + )} - + ({ + withOnyx({ currencyList: {key: ONYXKEYS.CURRENCY_LIST}, })(WorkspaceProfilePage), ); From f4dc39bc6baccda37598a4c4060338d8b6fed908 Mon Sep 17 00:00:00 2001 From: godofoutcasts94 Date: Thu, 22 Feb 2024 22:08:54 +0530 Subject: [PATCH 06/12] Migrated WorkspaceProfileCurrencyPage.js to TS --- .../WorkspaceProfileCurrencyPage.tsx | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 src/pages/workspace/WorkspaceProfileCurrencyPage.tsx diff --git a/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx b/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx new file mode 100644 index 000000000000..910370039519 --- /dev/null +++ b/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx @@ -0,0 +1,111 @@ +import React, {useState} from 'react'; +import type {OnyxEntry} from 'react-native-onyx'; +import {withOnyx} from 'react-native-onyx'; +import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import SelectionList from '@components/SelectionList'; +import useLocalize from '@hooks/useLocalize'; +import Navigation from '@libs/Navigation/Navigation'; +import * as PolicyUtils from '@libs/PolicyUtils'; +import * as Policy from '@userActions/Policy'; +import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; +import type {Currency, Policy as PolicyType} from '@src/types/onyx'; +import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import type {WithPolicyAndFullscreenLoadingProps} from './withPolicyAndFullscreenLoading'; +import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading'; + +type CurrencyList = Record; + +type WorkspaceProfileCurrencyPageOnyxProps = { + /** Constant, list of available currencies */ + currencyList: OnyxEntry; +}; + +type WorkspaceProfileCurrencyPageProps = WithPolicyAndFullscreenLoadingProps & WorkspaceProfileCurrencyPageOnyxProps; + +type WorkspaceProfileCurrencyPageSectionItem = { + text: string; + keyForList: string; + isSelected: boolean; +}; + +const getDisplayText = (currencyCode: string, currencySymbol: string) => `${currencyCode} - ${currencySymbol}`; + +function WorkspaceProfileCurrencyPage({currencyList, policy, isLoadingReportData = true}: WorkspaceProfileCurrencyPageProps) { + const {translate} = useLocalize(); + const [searchText, setSearchText] = useState(''); + const trimmedText = searchText.trim().toLowerCase(); + const currencyListKeys = Object.keys(currencyList ?? {}); + + const filteredItems = currencyListKeys.filter((currencyCode: string) => { + const currency = currencyList?.[currencyCode]; + return getDisplayText(currencyCode, currency?.symbol ?? '') + .toLowerCase() + .includes(trimmedText); + }); + + let initiallyFocusedOptionKey; + + const currencyItems: WorkspaceProfileCurrencyPageSectionItem[] = filteredItems.map((currencyCode: string) => { + const currency = currencyList?.[currencyCode]; + const isSelected = policy?.outputCurrency === currencyCode; + + if (isSelected) { + initiallyFocusedOptionKey = currencyCode; + } + + return { + text: getDisplayText(currencyCode, currency?.symbol ?? ''), + keyForList: currencyCode, + isSelected, + }; + }); + + const sections = [{data: currencyItems, indexOffset: 0}]; + + const headerMessage = searchText.trim() && !currencyItems.length ? translate('common.noResultsFound') : ''; + + const onSelectCurrency = (item: WorkspaceProfileCurrencyPageSectionItem) => { + Policy.updateGeneralSettings(policy?.id ?? '', policy?.name ?? '', item.keyForList); + Navigation.goBack(); + }; + + return ( + + Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} + shouldShow={(isEmptyObject(policy) && !isLoadingReportData) || !PolicyUtils.isPolicyAdmin(policy) || PolicyUtils.isPendingDeletePolicy(policy)} + subtitleKey={isEmptyObject(policy) ? undefined : 'workspace.common.notAuthorized'} + > + Navigation.goBack()} + /> + + + + + ); +} + +WorkspaceProfileCurrencyPage.displayName = 'WorkspaceProfileCurrencyPage'; + +export default withPolicyAndFullscreenLoading( + withOnyx({ + currencyList: {key: ONYXKEYS.CURRENCY_LIST}, + })(WorkspaceProfileCurrencyPage), +); From ee9d84629b024c5916addf23ec2c2a907f675155 Mon Sep 17 00:00:00 2001 From: godofoutcasts94 Date: Thu, 22 Feb 2024 23:07:41 +0530 Subject: [PATCH 07/12] Refactored typing error --- src/pages/workspace/WorkspaceProfileCurrencyPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx b/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx index 910370039519..0c078bbbd180 100644 --- a/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx +++ b/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx @@ -75,7 +75,7 @@ function WorkspaceProfileCurrencyPage({currencyList, policy, isLoadingReportData return ( Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} From e8aa369dd9ff886f7cc614c1b21d1f4a8fff4459 Mon Sep 17 00:00:00 2001 From: godofoutcasts94 <158435970+godofoutcasts94@users.noreply.github.com> Date: Sat, 24 Feb 2024 00:20:48 +0530 Subject: [PATCH 08/12] Removed WorkspaceProfileCurrencyPage.tsx --- .../WorkspaceProfileCurrencyPage.tsx | 111 ------------------ 1 file changed, 111 deletions(-) delete mode 100644 src/pages/workspace/WorkspaceProfileCurrencyPage.tsx diff --git a/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx b/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx deleted file mode 100644 index 0c078bbbd180..000000000000 --- a/src/pages/workspace/WorkspaceProfileCurrencyPage.tsx +++ /dev/null @@ -1,111 +0,0 @@ -import React, {useState} from 'react'; -import type {OnyxEntry} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; -import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; -import SelectionList from '@components/SelectionList'; -import useLocalize from '@hooks/useLocalize'; -import Navigation from '@libs/Navigation/Navigation'; -import * as PolicyUtils from '@libs/PolicyUtils'; -import * as Policy from '@userActions/Policy'; -import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; -import type {Currency, Policy as PolicyType} from '@src/types/onyx'; -import {isEmptyObject} from '@src/types/utils/EmptyObject'; -import type {WithPolicyAndFullscreenLoadingProps} from './withPolicyAndFullscreenLoading'; -import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading'; - -type CurrencyList = Record; - -type WorkspaceProfileCurrencyPageOnyxProps = { - /** Constant, list of available currencies */ - currencyList: OnyxEntry; -}; - -type WorkspaceProfileCurrencyPageProps = WithPolicyAndFullscreenLoadingProps & WorkspaceProfileCurrencyPageOnyxProps; - -type WorkspaceProfileCurrencyPageSectionItem = { - text: string; - keyForList: string; - isSelected: boolean; -}; - -const getDisplayText = (currencyCode: string, currencySymbol: string) => `${currencyCode} - ${currencySymbol}`; - -function WorkspaceProfileCurrencyPage({currencyList, policy, isLoadingReportData = true}: WorkspaceProfileCurrencyPageProps) { - const {translate} = useLocalize(); - const [searchText, setSearchText] = useState(''); - const trimmedText = searchText.trim().toLowerCase(); - const currencyListKeys = Object.keys(currencyList ?? {}); - - const filteredItems = currencyListKeys.filter((currencyCode: string) => { - const currency = currencyList?.[currencyCode]; - return getDisplayText(currencyCode, currency?.symbol ?? '') - .toLowerCase() - .includes(trimmedText); - }); - - let initiallyFocusedOptionKey; - - const currencyItems: WorkspaceProfileCurrencyPageSectionItem[] = filteredItems.map((currencyCode: string) => { - const currency = currencyList?.[currencyCode]; - const isSelected = policy?.outputCurrency === currencyCode; - - if (isSelected) { - initiallyFocusedOptionKey = currencyCode; - } - - return { - text: getDisplayText(currencyCode, currency?.symbol ?? ''), - keyForList: currencyCode, - isSelected, - }; - }); - - const sections = [{data: currencyItems, indexOffset: 0}]; - - const headerMessage = searchText.trim() && !currencyItems.length ? translate('common.noResultsFound') : ''; - - const onSelectCurrency = (item: WorkspaceProfileCurrencyPageSectionItem) => { - Policy.updateGeneralSettings(policy?.id ?? '', policy?.name ?? '', item.keyForList); - Navigation.goBack(); - }; - - return ( - - Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} - shouldShow={(isEmptyObject(policy) && !isLoadingReportData) || !PolicyUtils.isPolicyAdmin(policy) || PolicyUtils.isPendingDeletePolicy(policy)} - subtitleKey={isEmptyObject(policy) ? undefined : 'workspace.common.notAuthorized'} - > - Navigation.goBack()} - /> - - - - - ); -} - -WorkspaceProfileCurrencyPage.displayName = 'WorkspaceProfileCurrencyPage'; - -export default withPolicyAndFullscreenLoading( - withOnyx({ - currencyList: {key: ONYXKEYS.CURRENCY_LIST}, - })(WorkspaceProfileCurrencyPage), -); From dc49637e16d1cfbfc68d00c71543862ed62a9d32 Mon Sep 17 00:00:00 2001 From: godofoutcasts94 <158435970+godofoutcasts94@users.noreply.github.com> Date: Sat, 24 Feb 2024 00:22:08 +0530 Subject: [PATCH 09/12] Removed WorkspaceProfilePage.tsx --- src/pages/workspace/WorkspaceProfilePage.tsx | 172 ------------------- 1 file changed, 172 deletions(-) delete mode 100644 src/pages/workspace/WorkspaceProfilePage.tsx diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx deleted file mode 100644 index c12e8f81c5e9..000000000000 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ /dev/null @@ -1,172 +0,0 @@ -import React, {useCallback} from 'react'; -import {Image, ScrollView, View} from 'react-native'; -import {OnyxEntry, withOnyx} from 'react-native-onyx'; -import WorkspaceProfile from '@assets/images/workspace-profile.png'; -import Avatar from '@components/Avatar'; -import AvatarWithImagePicker from '@components/AvatarWithImagePicker'; -import * as Expensicons from '@components/Icon/Expensicons'; -import * as Illustrations from '@components/Icon/Illustrations'; -import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; -import Section from '@components/Section'; -import Text from '@components/Text'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import useWindowDimensions from '@hooks/useWindowDimensions'; -import Navigation from '@libs/Navigation/Navigation'; -import * as PolicyUtils from '@libs/PolicyUtils'; -import * as ReportUtils from '@libs/ReportUtils'; -import * as UserUtils from '@libs/UserUtils'; -import * as Policy from '@userActions/Policy'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; -import type {Currency} from '@src/types/onyx'; -import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; -import {isEmptyObject} from '@src/types/utils/EmptyObject'; -import withPolicy from './withPolicy'; -import type {WithPolicyProps} from './withPolicy'; -import WorkspacePageWithSections from './WorkspacePageWithSections'; - -type CurrencyList = Record; - -type WorkspaceProfilePageOnyxProps = { - /** Constant, list of available currencies */ - currencyList: OnyxEntry; -}; - -type WorkspaceProfilePageProps = WithPolicyProps & WorkspaceProfilePageOnyxProps; - -function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkspaceProfilePageProps) { - const styles = useThemeStyles(); - const {translate} = useLocalize(); - const {isSmallScreenWidth} = useWindowDimensions(); - - const formattedCurrency = - !isEmptyObject(policy) && !isEmptyObject(currencyList) && !!policy.outputCurrency ? `${policy.outputCurrency} - ${currencyList[policy.outputCurrency].symbol}` : ''; - const onPressCurrency = useCallback(() => Navigation.navigate(ROUTES.WORKSPACE_PROFILE_CURRENCY.getRoute(policy?.id ?? '')), [policy?.id ?? '']); - const onPressName = useCallback(() => Navigation.navigate(ROUTES.WORKSPACE_PROFILE_NAME.getRoute(policy?.id ?? '')), [policy?.id ?? '']); - const onPressDescription = useCallback(() => Navigation.navigate(ROUTES.WORKSPACE_PROFILE_DESCRIPTION.getRoute(policy?.id ?? '')), [policy?.id ?? '']); - - const policyName = policy?.name ?? ''; - const policyDescription = policy?.description ?? ''; - const readOnly = !PolicyUtils.isPolicyAdmin(policy); - const imageStyle = isSmallScreenWidth ? [styles.mhv12, styles.mhn5] : [styles.mhv8, styles.mhn8]; - - return ( - - {(hasVBA) => ( - - -
- - Navigation.navigate(ROUTES.WORKSPACE_AVATAR.getRoute(policy?.id ?? ''))} - source={policy?.avatar ?? null} - size={CONST.AVATAR_SIZE.XLARGE} - avatarStyle={styles.avatarXLarge} - enablePreview - DefaultAvatar={() => ( - - )} - type={CONST.ICON_TYPE_WORKSPACE} - fallbackIcon={Expensicons.FallbackWorkspaceAvatar} - style={[styles.mb3, styles.mtn17, styles.alignItemsStart, styles.sectionMenuItemTopDescription]} - isUsingDefaultAvatar={!policy?.avatar ?? null} - onImageSelected={(file: File) => Policy.updateWorkspaceAvatar(policy?.id ?? '', file)} - onImageRemoved={() => Policy.deleteWorkspaceAvatar(policy?.id ?? '')} - editorMaskImage={Expensicons.ImageCropSquareMask} - pendingAction={policy?.pendingFields?.avatar ?? null} - errors={policy?.errorFields?.avatar ?? null} - onErrorClose={() => Policy.clearAvatarErrors(policy?.id ?? '')} - previewSource={UserUtils.getFullSizeAvatar(policy?.avatar, 0)} - headerTitle={translate('workspace.common.workspaceAvatar')} - originalFileName={policy?.originalFileName} - disabled={readOnly} - disabledStyle={styles.cursorDefault} - errorRowStyles={undefined} - /> - - - - {(!isEmptyObject(policy?.description) || !readOnly) && ( - - - - )} - - - - - {hasVBA ? translate('workspace.editor.currencyInputDisabledText') : translate('workspace.editor.currencyInputHelpText')} - - - -
-
-
- )} -
- ); -} - -WorkspaceProfilePage.displayName = 'WorkspaceProfilePage'; - -export default withPolicy( - withOnyx({ - currencyList: {key: ONYXKEYS.CURRENCY_LIST}, - })(WorkspaceProfilePage), -); From 54aad492536b60bdf7c5f8d7850503d3be224c47 Mon Sep 17 00:00:00 2001 From: godofoutcasts94 Date: Sat, 24 Feb 2024 01:13:03 +0530 Subject: [PATCH 10/12] Removed undefined default value --- src/pages/LoadingPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/LoadingPage.tsx b/src/pages/LoadingPage.tsx index 4fb16b29827c..84182e7a4d60 100644 --- a/src/pages/LoadingPage.tsx +++ b/src/pages/LoadingPage.tsx @@ -12,7 +12,7 @@ type LoadingPageProps = { title: string; }; -function LoadingPage({onBackButtonPress = undefined, title}: LoadingPageProps) { +function LoadingPage({onBackButtonPress, title}: LoadingPageProps) { const styles = useThemeStyles(); return ( From 23740aa4987946e1879a0f0babc85ed2d6ca0c13 Mon Sep 17 00:00:00 2001 From: godofoutcasts94 Date: Tue, 27 Feb 2024 21:41:06 +0530 Subject: [PATCH 11/12] Renamed File to SearchInputManager.ts --- .../workspace/{SearchInputManager.tsx => SearchInputManager.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/pages/workspace/{SearchInputManager.tsx => SearchInputManager.ts} (100%) diff --git a/src/pages/workspace/SearchInputManager.tsx b/src/pages/workspace/SearchInputManager.ts similarity index 100% rename from src/pages/workspace/SearchInputManager.tsx rename to src/pages/workspace/SearchInputManager.ts From 09280712447b84fe77439a86704c428f662c5823 Mon Sep 17 00:00:00 2001 From: godofoutcasts94 Date: Thu, 29 Feb 2024 11:05:26 +0530 Subject: [PATCH 12/12] Removed unnecessary comment --- src/pages/LoadingPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/LoadingPage.tsx b/src/pages/LoadingPage.tsx index 84182e7a4d60..9708aa28eb5e 100644 --- a/src/pages/LoadingPage.tsx +++ b/src/pages/LoadingPage.tsx @@ -8,7 +8,6 @@ type LoadingPageProps = { /** Method to trigger when pressing back button of the header */ onBackButtonPress?: () => void; - /** Title of the Loading page */ title: string; };