From 3784fd952645c368189de9f82769c7ed567e7d55 Mon Sep 17 00:00:00 2001 From: rory Date: Sun, 25 Feb 2024 09:04:51 -0800 Subject: [PATCH 1/3] Fix onImageSelected type --- src/components/AvatarWithImagePicker.tsx | 3 ++- src/pages/workspace/WorkspaceProfilePage.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/AvatarWithImagePicker.tsx b/src/components/AvatarWithImagePicker.tsx index 07c535ccd96c..1dd71408799e 100644 --- a/src/components/AvatarWithImagePicker.tsx +++ b/src/components/AvatarWithImagePicker.tsx @@ -6,6 +6,7 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import * as Browser from '@libs/Browser'; +import type {CustomRNImageManipulatorResult} from '@libs/cropOrRotateImage/types'; import * as FileUtils from '@libs/fileDownload/FileUtils'; import getImageResolution from '@libs/fileDownload/getImageResolution'; import type {AvatarSource} from '@libs/UserUtils'; @@ -54,7 +55,7 @@ type AvatarWithImagePickerProps = { disabledStyle?: StyleProp; /** Executed once an image has been selected */ - onImageSelected?: () => void; + onImageSelected?: (file: File | CustomRNImageManipulatorResult) => void; /** Execute when the user taps "remove" */ onImageRemoved?: () => void; diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index 4ce5822dfaa0..2f41d0bbd3b9 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -102,7 +102,7 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi fallbackIcon={Expensicons.FallbackWorkspaceAvatar} style={[styles.mb3, isSmallScreenWidth ? styles.mtn17 : styles.mtn20, styles.alignItemsStart, styles.sectionMenuItemTopDescription]} isUsingDefaultAvatar={!policy?.avatar ?? null} - onImageSelected={(file: File) => Policy.updateWorkspaceAvatar(policy?.id ?? '', file)} + onImageSelected={(file) => Policy.updateWorkspaceAvatar(policy?.id ?? '', file as File)} onImageRemoved={() => Policy.deleteWorkspaceAvatar(policy?.id ?? '')} editorMaskImage={Expensicons.ImageCropSquareMask} pendingAction={policy?.pendingFields?.avatar ?? null} From 44fe4276ef2fbd155595ddc7db73aac85aba0c49 Mon Sep 17 00:00:00 2001 From: rory Date: Sun, 25 Feb 2024 09:11:45 -0800 Subject: [PATCH 2/3] Fix pendingFields and errors --- src/components/AvatarWithImagePicker.tsx | 2 +- src/pages/workspace/WorkspaceProfilePage.tsx | 11 +++++------ src/types/onyx/Policy.ts | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/AvatarWithImagePicker.tsx b/src/components/AvatarWithImagePicker.tsx index 1dd71408799e..fa8a6d71516f 100644 --- a/src/components/AvatarWithImagePicker.tsx +++ b/src/components/AvatarWithImagePicker.tsx @@ -88,7 +88,7 @@ type AvatarWithImagePickerProps = { pendingAction?: OnyxCommon.PendingAction; /** The errors to display */ - errors?: OnyxCommon.Errors; + errors?: OnyxCommon.Errors | null; /** Title for avatar preview modal */ headerTitle?: string; diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index 2f41d0bbd3b9..48dfe10a2a0e 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -26,7 +26,6 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {CurrencyList} 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'; @@ -105,8 +104,8 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi onImageSelected={(file) => Policy.updateWorkspaceAvatar(policy?.id ?? '', file as File)} onImageRemoved={() => Policy.deleteWorkspaceAvatar(policy?.id ?? '')} editorMaskImage={Expensicons.ImageCropSquareMask} - pendingAction={policy?.pendingFields?.avatar ?? null} - errors={policy?.errorFields?.avatar ?? null} + pendingAction={policy?.pendingFields?.avatar} + errors={policy?.errorFields?.avatar} onErrorClose={() => Policy.clearAvatarErrors(policy?.id ?? '')} previewSource={UserUtils.getFullSizeAvatar(policy?.avatar ?? '')} headerTitle={translate('workspace.common.workspaceAvatar')} @@ -115,7 +114,7 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi disabledStyle={styles.cursorDefault} errorRowStyles={undefined} /> - + {(!StringUtils.isEmptyString(policy?.description ?? '') || !readOnly) && ( - + )} - + ; + pendingFields?: Record; /** Original file name which is used for the policy avatar */ originalFileName?: string; From 1ceaddfd8a1a0fe0611982e9b72783436414e36d Mon Sep 17 00:00:00 2001 From: rory Date: Sun, 25 Feb 2024 09:21:09 -0800 Subject: [PATCH 3/3] Fix lint --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index d1cb3e066d99..fc1ed1d19560 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -20,7 +20,6 @@ import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSection import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import type SCREENS from '@src/SCREENS'; -import type {PendingAction} from '@src/types/onyx/OnyxCommon'; import ToggleSettingOptionRow from './ToggleSettingsOptionRow'; import type {ToggleSettingOptionRowProps} from './ToggleSettingsOptionRow'; @@ -60,7 +59,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { /> ), isActive: policy?.harvesting?.enabled ?? false, - pendingAction: policy?.pendingFields?.isAutoApprovalEnabled as PendingAction, + pendingAction: policy?.pendingFields?.isAutoApprovalEnabled, }, { icon: Illustrations.Approval, @@ -83,7 +82,7 @@ function WorkspaceWorkflowsPage({policy, route}: WorkspaceWorkflowsPageProps) { /> ), isActive: policy?.isAutoApprovalEnabled ?? false, - pendingAction: policy?.pendingFields?.approvalMode as PendingAction, + pendingAction: policy?.pendingFields?.approvalMode, }, { icon: Illustrations.WalletAlt,