From feb57aed753c1f464331bafe2b27fda03c217dfe Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 11 Jan 2024 21:12:49 +0700 Subject: [PATCH 001/339] fix: 34120 --- src/components/DistanceEReceipt.js | 1 + src/components/Image/index.js | 10 +++++-- src/components/Image/index.native.js | 26 ++++++++++++++++++- src/components/ImageWithSizeCalculation.tsx | 5 +++- .../MoneyRequestConfirmationList.js | 1 + ...oraryForRefactorRequestConfirmationList.js | 1 + .../ReportActionItem/ReportActionItemImage.js | 12 ++++++--- src/components/ThumbnailImage.tsx | 4 ++- .../Navigation/AppNavigator/AuthScreens.tsx | 2 +- src/pages/ErrorPage/NotFoundPage.js | 1 + 10 files changed, 53 insertions(+), 10 deletions(-) diff --git a/src/components/DistanceEReceipt.js b/src/components/DistanceEReceipt.js index 0241eea44063..5ffece092770 100644 --- a/src/components/DistanceEReceipt.js +++ b/src/components/DistanceEReceipt.js @@ -72,6 +72,7 @@ function DistanceEReceipt({transaction}) { style={[styles.w100, styles.h100]} isAuthTokenRequired shouldDynamicallyResize={false} + objectPositionTop /> )} diff --git a/src/components/Image/index.js b/src/components/Image/index.js index ef1a69e19c12..58b7ec3383a4 100644 --- a/src/components/Image/index.js +++ b/src/components/Image/index.js @@ -1,5 +1,5 @@ import lodashGet from 'lodash/get'; -import React, {useEffect, useMemo} from 'react'; +import React, {useEffect, useMemo, useState} from 'react'; import {Image as RNImage} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; @@ -9,6 +9,7 @@ import RESIZE_MODES from './resizeModes'; function Image(props) { const {source: propsSource, isAuthTokenRequired, onLoad, session} = props; + const [aspectRatio, setAspectRatio] = useState(); /** * Check if the image source is a URL - if so the `encryptedAuthToken` is appended * to the source. @@ -38,8 +39,12 @@ function Image(props) { } RNImage.getSize(source.uri, (width, height) => { onLoad({nativeEvent: {width, height}}); + + if (props.objectPositionTop) { + setAspectRatio(height ? width / height : 'auto'); + } }); - }, [onLoad, source]); + }, [onLoad, source, props.objectPositionTop]); // Omit the props which the underlying RNImage won't use const forwardedProps = _.omit(props, ['source', 'onLoad', 'session', 'isAuthTokenRequired']); @@ -49,6 +54,7 @@ function Image(props) { // eslint-disable-next-line react/jsx-props-no-spreading {...forwardedProps} source={source} + style={[forwardedProps.style, aspectRatio !== undefined && {aspectRatio, height: 'auto'}, props.objectPositionTop && !aspectRatio && {opacity: 0}]} /> ); } diff --git a/src/components/Image/index.native.js b/src/components/Image/index.native.js index f31cfb6936d9..edea86725ae7 100644 --- a/src/components/Image/index.native.js +++ b/src/components/Image/index.native.js @@ -1,11 +1,12 @@ import {Image as ImageComponent} from 'expo-image'; import lodashGet from 'lodash/get'; -import React from 'react'; +import React, {useEffect, useMemo, useState} from 'react'; import {withOnyx} from 'react-native-onyx'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import {defaultProps, imagePropTypes} from './imagePropTypes'; import RESIZE_MODES from './resizeModes'; +import {Image as RNImage} from 'react-native'; const dimensionsCache = new Map(); @@ -16,6 +17,7 @@ function resolveDimensions(key) { function Image(props) { // eslint-disable-next-line react/destructuring-assignment const {source, isAuthTokenRequired, session, ...rest} = props; + const [aspectRatio, setAspectRatio] = useState(); let imageSource = source; if (source && source.uri && typeof source.uri === 'number') { @@ -33,6 +35,27 @@ function Image(props) { }; } + const newSource = useMemo(() => { + if (isAuthTokenRequired) { + const authToken = lodashGet(session, 'encryptedAuthToken', null); + return {uri: `${source.uri}?encryptedAuthToken=${encodeURIComponent(authToken)}`}; + } + return source; + }, [source, isAuthTokenRequired]); + + useEffect(() => { + if (props.onLoad == null) { + return; + } + RNImage.getSize(newSource.uri, (width, height) => { + props.onLoad({nativeEvent: {width, height}}); + + if (props.objectPositionTop) { + setAspectRatio(height ? width / height : 'auto'); + } + }); + }, [props.onLoad, newSource]); + return ( ); } diff --git a/src/components/ImageWithSizeCalculation.tsx b/src/components/ImageWithSizeCalculation.tsx index b13d863d97e1..7ebdd41379c1 100644 --- a/src/components/ImageWithSizeCalculation.tsx +++ b/src/components/ImageWithSizeCalculation.tsx @@ -29,6 +29,8 @@ type ImageWithSizeCalculationProps = { /** Whether the image requires an authToken */ isAuthTokenRequired: boolean; + + objectPositionTop: boolean; }; /** @@ -37,7 +39,7 @@ type ImageWithSizeCalculationProps = { * performing some calculation on a network image after fetching dimensions so * it can be appropriately resized. */ -function ImageWithSizeCalculation({url, style, onMeasure, isAuthTokenRequired}: ImageWithSizeCalculationProps) { +function ImageWithSizeCalculation({url, style, onMeasure, isAuthTokenRequired, objectPositionTop}: ImageWithSizeCalculationProps) { const styles = useThemeStyles(); const isLoadedRef = useRef(null); const [isImageCached, setIsImageCached] = useState(true); @@ -88,6 +90,7 @@ function ImageWithSizeCalculation({url, style, onMeasure, isAuthTokenRequired}: }} onError={onError} onLoad={imageLoadedSuccessfully} + objectPositionTop={objectPositionTop} /> {isLoading && !isImageCached && } diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 13dce9337673..aa33ef87a976 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -612,6 +612,7 @@ function MoneyRequestConfirmationList(props) { // but we don't need it to load the blob:// or file:// image when starting a money request / split bill // So if we have a thumbnail, it means we're retrieving the image from the server isAuthTokenRequired={!_.isEmpty(receiptThumbnail)} + objectPositionTop /> )} {props.shouldShowSmartScanFields && ( diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index 36d424ea28f2..2888f7cf2cdf 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -646,6 +646,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ // but we don't need it to load the blob:// or file:// image when starting a money request / split bill // So if we have a thumbnail, it means we're retrieving the image from the server isAuthTokenRequired={!_.isEmpty(receiptThumbnail)} + objectPositionTop /> )} {shouldShowSmartScanFields && ( diff --git a/src/components/ReportActionItem/ReportActionItemImage.js b/src/components/ReportActionItem/ReportActionItemImage.js index 1495dcbd9111..d8f461aec138 100644 --- a/src/components/ReportActionItem/ReportActionItemImage.js +++ b/src/components/ReportActionItem/ReportActionItemImage.js @@ -72,14 +72,18 @@ function ReportActionItemImage({thumbnail, image, enablePreviewModal, transactio style={[styles.w100, styles.h100]} isAuthTokenRequired shouldDynamicallyResize={false} + objectPositionTop /> ); } else { receiptImageComponent = ( - + + + ); } diff --git a/src/components/ThumbnailImage.tsx b/src/components/ThumbnailImage.tsx index 3c903ee9e78f..b0fecd07093d 100644 --- a/src/components/ThumbnailImage.tsx +++ b/src/components/ThumbnailImage.tsx @@ -26,6 +26,7 @@ type ThumbnailImageProps = { /** Should the image be resized on load or just fit container */ shouldDynamicallyResize?: boolean; + objectPositionTop?: boolean; }; type UpdateImageSizeParams = { @@ -71,7 +72,7 @@ function calculateThumbnailImageSize(width: number, height: number, windowHeight return {thumbnailWidth: Math.max(40, thumbnailScreenWidth), thumbnailHeight: Math.max(40, thumbnailScreenHeight)}; } -function ThumbnailImage({previewSourceURL, style, isAuthTokenRequired, imageWidth = 200, imageHeight = 200, shouldDynamicallyResize = true}: ThumbnailImageProps) { +function ThumbnailImage({previewSourceURL, style, isAuthTokenRequired, imageWidth, imageHeight, shouldDynamicallyResize = true, objectPositionTop = false}: ThumbnailImageProps) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {windowHeight} = useWindowDimensions(); @@ -103,6 +104,7 @@ function ThumbnailImage({previewSourceURL, style, isAuthTokenRequired, imageWidt url={previewSourceURL} onMeasure={updateImageSize} isAuthTokenRequired={isAuthTokenRequired} + objectPositionTop={objectPositionTop} /> diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 7286615e6ba6..caeb65fbaa3a 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -291,7 +291,7 @@ function AuthScreens({lastUpdateIDAppliedToClient, session, lastOpenedPublicRoom Navigation.navigate(ROUTES.HOME)}/>} /> ); From 0eeedc9bca10abc6554bd2eb5e412a35e9bbe835 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 11 Jan 2024 21:19:21 +0700 Subject: [PATCH 002/339] fix: redundant --- src/components/ThumbnailImage.tsx | 2 +- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 2 +- src/pages/ErrorPage/NotFoundPage.js | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/ThumbnailImage.tsx b/src/components/ThumbnailImage.tsx index b0fecd07093d..b04a67fbdc7d 100644 --- a/src/components/ThumbnailImage.tsx +++ b/src/components/ThumbnailImage.tsx @@ -72,7 +72,7 @@ function calculateThumbnailImageSize(width: number, height: number, windowHeight return {thumbnailWidth: Math.max(40, thumbnailScreenWidth), thumbnailHeight: Math.max(40, thumbnailScreenHeight)}; } -function ThumbnailImage({previewSourceURL, style, isAuthTokenRequired, imageWidth, imageHeight, shouldDynamicallyResize = true, objectPositionTop = false}: ThumbnailImageProps) { +function ThumbnailImage({previewSourceURL, style, isAuthTokenRequired, imageWidth = 200, imageHeight = 200, shouldDynamicallyResize = true, objectPositionTop = false}: ThumbnailImageProps) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {windowHeight} = useWindowDimensions(); diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index caeb65fbaa3a..7286615e6ba6 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -291,7 +291,7 @@ function AuthScreens({lastUpdateIDAppliedToClient, session, lastOpenedPublicRoom Navigation.navigate(ROUTES.HOME)}/>} + component={NotFoundPage} /> ); From 5e5adb85b0a05d0d57d4fc3cbc7521d59edc0b59 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 24 Jan 2024 16:17:03 +0700 Subject: [PATCH 003/339] fix lint --- src/components/Image/index.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Image/index.native.js b/src/components/Image/index.native.js index edea86725ae7..1c7b239f6acc 100644 --- a/src/components/Image/index.native.js +++ b/src/components/Image/index.native.js @@ -1,12 +1,12 @@ import {Image as ImageComponent} from 'expo-image'; import lodashGet from 'lodash/get'; import React, {useEffect, useMemo, useState} from 'react'; +import {Image as RNImage} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import {defaultProps, imagePropTypes} from './imagePropTypes'; import RESIZE_MODES from './resizeModes'; -import {Image as RNImage} from 'react-native'; const dimensionsCache = new Map(); From 2e260e62b64f2c0d8601b006a59037b9fbd12fcc Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 24 Jan 2024 17:09:22 +0700 Subject: [PATCH 004/339] fix lint --- src/components/Image/index.native.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Image/index.native.js b/src/components/Image/index.native.js index 1c7b239f6acc..f221a3a15019 100644 --- a/src/components/Image/index.native.js +++ b/src/components/Image/index.native.js @@ -41,7 +41,7 @@ function Image(props) { return {uri: `${source.uri}?encryptedAuthToken=${encodeURIComponent(authToken)}`}; } return source; - }, [source, isAuthTokenRequired]); + }, [source, isAuthTokenRequired, session]); useEffect(() => { if (props.onLoad == null) { @@ -54,7 +54,7 @@ function Image(props) { setAspectRatio(height ? width / height : 'auto'); } }); - }, [props.onLoad, newSource]); + }, [props.onLoad, newSource, props]); return ( Date: Fri, 26 Jan 2024 11:35:09 +0700 Subject: [PATCH 005/339] fix crash bug --- src/components/Image/index.js | 4 ++-- src/components/Image/index.native.js | 26 ++++---------------------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/components/Image/index.js b/src/components/Image/index.js index 58b7ec3383a4..f4962ad9b324 100644 --- a/src/components/Image/index.js +++ b/src/components/Image/index.js @@ -9,7 +9,7 @@ import RESIZE_MODES from './resizeModes'; function Image(props) { const {source: propsSource, isAuthTokenRequired, onLoad, session} = props; - const [aspectRatio, setAspectRatio] = useState(); + const [aspectRatio, setAspectRatio] = useState(null); /** * Check if the image source is a URL - if so the `encryptedAuthToken` is appended * to the source. @@ -54,7 +54,7 @@ function Image(props) { // eslint-disable-next-line react/jsx-props-no-spreading {...forwardedProps} source={source} - style={[forwardedProps.style, aspectRatio !== undefined && {aspectRatio, height: 'auto'}, props.objectPositionTop && !aspectRatio && {opacity: 0}]} + style={[forwardedProps.style, !!aspectRatio && {aspectRatio, height: 'auto'}, props.objectPositionTop && !aspectRatio && {opacity: 0}]} /> ); } diff --git a/src/components/Image/index.native.js b/src/components/Image/index.native.js index f221a3a15019..7da72c34a012 100644 --- a/src/components/Image/index.native.js +++ b/src/components/Image/index.native.js @@ -35,27 +35,6 @@ function Image(props) { }; } - const newSource = useMemo(() => { - if (isAuthTokenRequired) { - const authToken = lodashGet(session, 'encryptedAuthToken', null); - return {uri: `${source.uri}?encryptedAuthToken=${encodeURIComponent(authToken)}`}; - } - return source; - }, [source, isAuthTokenRequired, session]); - - useEffect(() => { - if (props.onLoad == null) { - return; - } - RNImage.getSize(newSource.uri, (width, height) => { - props.onLoad({nativeEvent: {width, height}}); - - if (props.objectPositionTop) { - setAspectRatio(height ? width / height : 'auto'); - } - }); - }, [props.onLoad, newSource, props]); - return ( ); } From 7c9c40ff933a7d2d47a39a5f391101863551aa00 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 26 Jan 2024 17:01:55 +0700 Subject: [PATCH 006/339] fix lint --- src/components/Image/index.native.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/Image/index.native.js b/src/components/Image/index.native.js index 7da72c34a012..862807b909bb 100644 --- a/src/components/Image/index.native.js +++ b/src/components/Image/index.native.js @@ -1,7 +1,6 @@ import {Image as ImageComponent} from 'expo-image'; import lodashGet from 'lodash/get'; -import React, {useEffect, useMemo, useState} from 'react'; -import {Image as RNImage} from 'react-native'; +import React, { useState } from 'react'; import {withOnyx} from 'react-native-onyx'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; From a153e8a46181c676adfd995ce00759e7b4e6b5cb Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 26 Jan 2024 17:41:00 +0700 Subject: [PATCH 007/339] fix lint --- src/components/Image/index.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Image/index.native.js b/src/components/Image/index.native.js index 862807b909bb..2791ea40925d 100644 --- a/src/components/Image/index.native.js +++ b/src/components/Image/index.native.js @@ -1,6 +1,6 @@ import {Image as ImageComponent} from 'expo-image'; import lodashGet from 'lodash/get'; -import React, { useState } from 'react'; +import React, {useState} from 'react'; import {withOnyx} from 'react-native-onyx'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; From 21253021d96298966edad453518aec24aeb0c60f Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 30 Jan 2024 16:29:37 +0700 Subject: [PATCH 008/339] fix the case wide image --- src/components/Image/index.js | 4 ++++ src/components/Image/index.native.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/components/Image/index.js b/src/components/Image/index.js index f4962ad9b324..848e64f60350 100644 --- a/src/components/Image/index.js +++ b/src/components/Image/index.js @@ -41,6 +41,10 @@ function Image(props) { onLoad({nativeEvent: {width, height}}); if (props.objectPositionTop) { + if (width > height) { + setAspectRatio(1); + return; + } setAspectRatio(height ? width / height : 'auto'); } }); diff --git a/src/components/Image/index.native.js b/src/components/Image/index.native.js index 2791ea40925d..b6d5f5b2dcda 100644 --- a/src/components/Image/index.native.js +++ b/src/components/Image/index.native.js @@ -46,6 +46,10 @@ function Image(props) { props.onLoad({nativeEvent: {width, height}}); } if (props.objectPositionTop) { + if (width > height) { + setAspectRatio(1); + return; + } setAspectRatio(height ? width / height : 'auto'); } }} From 00ccc9bd4e75c8a480313f11ecf986725eb6a83e Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 30 Jan 2024 16:34:02 +0700 Subject: [PATCH 009/339] add comment prop --- src/components/Image/imagePropTypes.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/Image/imagePropTypes.js b/src/components/Image/imagePropTypes.js index 78bd48ba47ec..cc4c36e32387 100644 --- a/src/components/Image/imagePropTypes.js +++ b/src/components/Image/imagePropTypes.js @@ -34,6 +34,9 @@ const imagePropTypes = { /** Currently logged in user authToken */ authToken: PropTypes.string, }), + + /** Whether we should show the top of the image */ + objectPositionTop: PropTypes.string }; const defaultProps = { @@ -43,6 +46,7 @@ const defaultProps = { }, isAuthTokenRequired: false, resizeMode: RESIZE_MODES.cover, + objectPositionTop: false, onLoadStart: () => {}, onLoadEnd: () => {}, onLoad: () => {}, From c761e1c17e8795c514904e167f23e42c9fa7aa27 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 30 Jan 2024 18:08:45 +0700 Subject: [PATCH 010/339] merge main --- src/components/Image/imagePropTypes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Image/imagePropTypes.js b/src/components/Image/imagePropTypes.js index cc4c36e32387..5d28b1a9f3f4 100644 --- a/src/components/Image/imagePropTypes.js +++ b/src/components/Image/imagePropTypes.js @@ -36,7 +36,7 @@ const imagePropTypes = { }), /** Whether we should show the top of the image */ - objectPositionTop: PropTypes.string + objectPositionTop: PropTypes.string, }; const defaultProps = { From d09ee205845c7b47eb4b6cdc49c803dc8be43918 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 2 Feb 2024 10:41:02 +0700 Subject: [PATCH 011/339] centralize logic --- src/components/Image/BaseImage.native.tsx | 16 +++------------- src/components/Image/BaseImage.tsx | 16 +++------------- src/components/Image/index.js | 22 ++++++++++++++++++++-- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/components/Image/BaseImage.native.tsx b/src/components/Image/BaseImage.native.tsx index e912bdda9eba..c517efd04515 100644 --- a/src/components/Image/BaseImage.native.tsx +++ b/src/components/Image/BaseImage.native.tsx @@ -1,10 +1,9 @@ import {Image as ExpoImage} from 'expo-image'; import type {ImageProps as ExpoImageProps, ImageLoadEventData} from 'expo-image'; -import {useCallback, useState} from 'react'; +import {useCallback} from 'react'; import type {BaseImageProps} from './types'; -function BaseImage({onLoad, objectPositionTop = false, style, ...props}: ExpoImageProps & BaseImageProps) { - const [aspectRatio, setAspectRatio] = useState(null); +function BaseImage({onLoad, ...props}: ExpoImageProps & BaseImageProps) { const imageLoadedSuccessfully = useCallback( (event: ImageLoadEventData) => { if (!onLoad) { @@ -14,23 +13,14 @@ function BaseImage({onLoad, objectPositionTop = false, style, ...props}: ExpoIma // We override `onLoad`, so both web and native have the same signature const {width, height} = event.source; onLoad({nativeEvent: {width, height}}); - - if (objectPositionTop) { - if (width > height) { - setAspectRatio(1); - return; - } - setAspectRatio(height ? width / height : 'auto'); - } }, - [onLoad, objectPositionTop], + [onLoad], ); return ( diff --git a/src/components/Image/BaseImage.tsx b/src/components/Image/BaseImage.tsx index 9a3f4668647e..ebdd76840267 100644 --- a/src/components/Image/BaseImage.tsx +++ b/src/components/Image/BaseImage.tsx @@ -1,10 +1,9 @@ -import React, {useCallback, useState} from 'react'; +import React, {useCallback} from 'react'; import {Image as RNImage} from 'react-native'; import type {ImageLoadEventData, ImageProps as WebImageProps} from 'react-native'; import type {BaseImageProps} from './types'; -function BaseImage({onLoad, objectPositionTop = false, style, ...props}: WebImageProps & BaseImageProps) { - const [aspectRatio, setAspectRatio] = useState(null); +function BaseImage({onLoad, ...props}: WebImageProps & BaseImageProps) { const imageLoadedSuccessfully = useCallback( (event: {nativeEvent: ImageLoadEventData}) => { if (!onLoad) { @@ -14,23 +13,14 @@ function BaseImage({onLoad, objectPositionTop = false, style, ...props}: WebImag // We override `onLoad`, so both web and native have the same signature const {width, height} = event.nativeEvent.source; onLoad({nativeEvent: {width, height}}); - - if (objectPositionTop) { - if (width > height) { - setAspectRatio(1); - return; - } - setAspectRatio(height ? width / height : 'auto'); - } }, - [onLoad, objectPositionTop], + [onLoad], ); return ( diff --git a/src/components/Image/index.js b/src/components/Image/index.js index 8cee1cf95e14..2788e85895f6 100644 --- a/src/components/Image/index.js +++ b/src/components/Image/index.js @@ -1,5 +1,5 @@ import lodashGet from 'lodash/get'; -import React, {useMemo} from 'react'; +import React, {useCallback, useMemo} from 'react'; import {withOnyx} from 'react-native-onyx'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -7,7 +7,9 @@ import BaseImage from './BaseImage'; import {defaultProps, imagePropTypes} from './imagePropTypes'; import RESIZE_MODES from './resizeModes'; -function Image({source: propsSource, isAuthTokenRequired, session, ...forwardedProps}) { +function Image({source: propsSource, isAuthTokenRequired, session, onLoad, ...forwardedProps}) { + const [aspectRatio, setAspectRatio] = useState(null); + // Update the source to include the auth token if required const source = useMemo(() => { if (typeof lodashGet(propsSource, 'uri') === 'number') { @@ -28,11 +30,27 @@ function Image({source: propsSource, isAuthTokenRequired, session, ...forwardedP // eslint-disable-next-line react-hooks/exhaustive-deps }, [propsSource, isAuthTokenRequired]); + const imageLoadedSuccessfully = useCallback((event) => { + const {width, height} = event.nativeEvent; + + onLoad(event); + + if (objectPositionTop) { + if (width > height) { + setAspectRatio(1); + return; + } + setAspectRatio(height ? width / height : 'auto'); + } + }) + return ( ); } From 7cf8fd81cf99cd3a8cfa869f33be36c271081e65 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 2 Feb 2024 10:56:55 +0700 Subject: [PATCH 012/339] fix lint --- src/components/Image/imagePropTypes.js | 2 +- src/components/Image/index.js | 29 ++++++++++++++------------ src/components/Image/types.ts | 3 --- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/components/Image/imagePropTypes.js b/src/components/Image/imagePropTypes.js index 5d28b1a9f3f4..deb7d75da5ae 100644 --- a/src/components/Image/imagePropTypes.js +++ b/src/components/Image/imagePropTypes.js @@ -36,7 +36,7 @@ const imagePropTypes = { }), /** Whether we should show the top of the image */ - objectPositionTop: PropTypes.string, + objectPositionTop: PropTypes.bool, }; const defaultProps = { diff --git a/src/components/Image/index.js b/src/components/Image/index.js index 2788e85895f6..6851604be8b1 100644 --- a/src/components/Image/index.js +++ b/src/components/Image/index.js @@ -1,5 +1,5 @@ import lodashGet from 'lodash/get'; -import React, {useCallback, useMemo} from 'react'; +import React, {useCallback, useMemo, useState} from 'react'; import {withOnyx} from 'react-native-onyx'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -7,8 +7,8 @@ import BaseImage from './BaseImage'; import {defaultProps, imagePropTypes} from './imagePropTypes'; import RESIZE_MODES from './resizeModes'; -function Image({source: propsSource, isAuthTokenRequired, session, onLoad, ...forwardedProps}) { - const [aspectRatio, setAspectRatio] = useState(null); +function Image({source: propsSource, isAuthTokenRequired, session, onLoad, style, objectPositionTop, ...forwardedProps}) { + const [aspectRatio, setAspectRatio] = useState(null); // Update the source to include the auth token if required const source = useMemo(() => { @@ -30,19 +30,22 @@ function Image({source: propsSource, isAuthTokenRequired, session, onLoad, ...fo // eslint-disable-next-line react-hooks/exhaustive-deps }, [propsSource, isAuthTokenRequired]); - const imageLoadedSuccessfully = useCallback((event) => { - const {width, height} = event.nativeEvent; + const imageLoadedSuccessfully = useCallback( + (event) => { + const {width, height} = event.nativeEvent; - onLoad(event); + onLoad(event); - if (objectPositionTop) { - if (width > height) { - setAspectRatio(1); - return; + if (objectPositionTop) { + if (width > height) { + setAspectRatio(1); + return; + } + setAspectRatio(height ? width / height : 'auto'); } - setAspectRatio(height ? width / height : 'auto'); - } - }) + }, + [onLoad, objectPositionTop], + ); return ( void; - - /** Whether we should show the top of the image */ - objectPositionTop?: boolean; }; export type {BaseImageProps}; From 86190f61d6f9f090ea0714939a15685c57cdc246 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 6 Feb 2024 01:01:01 +0700 Subject: [PATCH 013/339] revert hard code --- .../ReportActionItem/ReportActionItemImage.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/ReportActionItem/ReportActionItemImage.tsx b/src/components/ReportActionItem/ReportActionItemImage.tsx index 7dc4cdf07031..ed46e00c7923 100644 --- a/src/components/ReportActionItem/ReportActionItemImage.tsx +++ b/src/components/ReportActionItem/ReportActionItemImage.tsx @@ -73,13 +73,11 @@ function ReportActionItemImage({thumbnail, image, enablePreviewModal = false, tr ); } else { receiptImageComponent = ( - - - + ); } From 54d0bb9d340926b8997c8b1d584321554d49ecec Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 20 Mar 2024 12:08:37 +0700 Subject: [PATCH 014/339] fix lint --- src/components/Image/index.tsx | 36 +++++++++++++++++++-- src/components/Image/types.ts | 7 ++-- src/components/ImageWithSizeCalculation.tsx | 5 +-- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/components/Image/index.tsx b/src/components/Image/index.tsx index f4e5bf4834e0..c8c78b54de06 100644 --- a/src/components/Image/index.tsx +++ b/src/components/Image/index.tsx @@ -1,11 +1,39 @@ -import React, {useMemo} from 'react'; +import React, {useCallback, useMemo, useState} from 'react'; import {withOnyx} from 'react-native-onyx'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import BaseImage from './BaseImage'; -import type {ImageOnyxProps, ImageOwnProps, ImageProps} from './types'; +import type {ImageOnLoadEvent, ImageOnyxProps, ImageOwnProps, ImageProps} from './types'; -function Image({source: propsSource, isAuthTokenRequired = false, session, ...forwardedProps}: ImageProps) { +function Image({source: propsSource, isAuthTokenRequired = false, session, onLoad, objectPositionTop, style, ...forwardedProps}: ImageProps) { + const [aspectRatio, setAspectRatio] = useState(null); + + const updateAspectRatio = useCallback( + (width: number, height: number) => { + if (!objectPositionTop) { + return; + } + + if (width > height) { + setAspectRatio(1); + return; + } + + setAspectRatio(height ? width / height : 'auto'); + }, + [objectPositionTop], + ); + + const handleLoad = useCallback( + (event: ImageOnLoadEvent) => { + const {width, height} = event.nativeEvent; + + onLoad?.(event); + + updateAspectRatio(width, height); + }, + [onLoad, updateAspectRatio], + ); /** * Check if the image source is a URL - if so the `encryptedAuthToken` is appended * to the source. @@ -34,6 +62,8 @@ function Image({source: propsSource, isAuthTokenRequired = false, session, ...fo ); diff --git a/src/components/Image/types.ts b/src/components/Image/types.ts index 2a5fcbb19324..c2f73e74ee34 100644 --- a/src/components/Image/types.ts +++ b/src/components/Image/types.ts @@ -23,12 +23,12 @@ type BaseImageProps = { /** Event for when the image is fully loaded and returns the natural dimensions of the image */ onLoad?: (event: ImageOnLoadEvent) => void; -}; -type ImageOwnProps = BaseImageProps & { /** Styles for the Image */ style?: StyleProp; +}; +type ImageOwnProps = BaseImageProps & { /** Should an auth token be included in the image request */ isAuthTokenRequired?: boolean; @@ -46,6 +46,9 @@ type ImageOwnProps = BaseImageProps & { /** Progress events while the image is downloading */ onProgress?: () => void; + + /** Whether we should show the top of the image */ + objectPositionTop?: boolean; }; type ImageProps = ImageOnyxProps & ImageOwnProps; diff --git a/src/components/ImageWithSizeCalculation.tsx b/src/components/ImageWithSizeCalculation.tsx index 46e1308692ba..ffa9517299cc 100644 --- a/src/components/ImageWithSizeCalculation.tsx +++ b/src/components/ImageWithSizeCalculation.tsx @@ -33,7 +33,8 @@ type ImageWithSizeCalculationProps = { /** Whether the image requires an authToken */ isAuthTokenRequired: boolean; - objectPositionTop: boolean; + /** Whether we should show the top of the image */ + objectPositionTop?: boolean; }; /** @@ -42,7 +43,7 @@ type ImageWithSizeCalculationProps = { * performing some calculation on a network image after fetching dimensions so * it can be appropriately resized. */ -function ImageWithSizeCalculation({url, style, onMeasure, onLoadFailure, isAuthTokenRequired, objectPositionTop}: ImageWithSizeCalculationProps) { +function ImageWithSizeCalculation({url, style, onMeasure, onLoadFailure, isAuthTokenRequired, objectPositionTop = false}: ImageWithSizeCalculationProps) { const styles = useThemeStyles(); const isLoadedRef = useRef(null); const [isImageCached, setIsImageCached] = useState(true); From 5b1c8835707f9c7c8daf6ed6283a2e97f6d75707 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 21 Mar 2024 17:33:55 +0700 Subject: [PATCH 015/339] replace objectPositionTop with objectPosition --- src/CONST.ts | 5 +++++ src/components/DistanceEReceipt.tsx | 2 +- src/components/Image/index.tsx | 9 +++++---- src/components/Image/types.ts | 10 +++++++--- src/components/ImageWithSizeCalculation.tsx | 10 ++++++---- src/components/MoneyRequestConfirmationList.tsx | 2 +- ...MoneyTemporaryForRefactorRequestConfirmationList.js | 2 +- .../ReportActionItem/ReportActionItemImage.tsx | 4 ++-- src/components/ThumbnailImage.tsx | 10 +++++++--- 9 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index bb191ac5e028..3cd473f2f451 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1095,6 +1095,11 @@ const CONST = { JPEG: 'image/jpeg', }, + IMAGE_OBJECT_POSITION: { + TOP: 'top', + INITIAL: 'initial', + }, + FILE_TYPE_REGEX: { // Image MimeTypes allowed by iOS photos app. IMAGE: /\.(jpg|jpeg|png|webp|gif|tiff|bmp|heic|heif)$/, diff --git a/src/components/DistanceEReceipt.tsx b/src/components/DistanceEReceipt.tsx index 864dc831f74c..03ae1cdef5ad 100644 --- a/src/components/DistanceEReceipt.tsx +++ b/src/components/DistanceEReceipt.tsx @@ -63,7 +63,7 @@ function DistanceEReceipt({transaction}: DistanceEReceiptProps) { style={[styles.w100, styles.h100]} isAuthTokenRequired shouldDynamicallyResize={false} - objectPositionTop + objectPosition /> )} diff --git a/src/components/Image/index.tsx b/src/components/Image/index.tsx index c8c78b54de06..e6cecdc0d5ec 100644 --- a/src/components/Image/index.tsx +++ b/src/components/Image/index.tsx @@ -5,12 +5,13 @@ import ONYXKEYS from '@src/ONYXKEYS'; import BaseImage from './BaseImage'; import type {ImageOnLoadEvent, ImageOnyxProps, ImageOwnProps, ImageProps} from './types'; -function Image({source: propsSource, isAuthTokenRequired = false, session, onLoad, objectPositionTop, style, ...forwardedProps}: ImageProps) { +function Image({source: propsSource, isAuthTokenRequired = false, session, onLoad, objectPosition = CONST.IMAGE_OBJECT_POSITION.INITIAL, style, ...forwardedProps}: ImageProps) { const [aspectRatio, setAspectRatio] = useState(null); + const isObjectPositionTop = objectPosition === CONST.IMAGE_OBJECT_POSITION.TOP; const updateAspectRatio = useCallback( (width: number, height: number) => { - if (!objectPositionTop) { + if (!isObjectPositionTop) { return; } @@ -21,7 +22,7 @@ function Image({source: propsSource, isAuthTokenRequired = false, session, onLoa setAspectRatio(height ? width / height : 'auto'); }, - [objectPositionTop], + [isObjectPositionTop], ); const handleLoad = useCallback( @@ -63,7 +64,7 @@ function Image({source: propsSource, isAuthTokenRequired = false, session, onLoa // eslint-disable-next-line react/jsx-props-no-spreading {...forwardedProps} onLoad={handleLoad} - style={[style, aspectRatio ? {aspectRatio, height: 'auto'} : {}, objectPositionTop && !aspectRatio && {opacity: 0}]} + style={[style, aspectRatio ? {aspectRatio, height: 'auto'} : {}, isObjectPositionTop && !aspectRatio && {opacity: 0}]} source={source} /> ); diff --git a/src/components/Image/types.ts b/src/components/Image/types.ts index c2f73e74ee34..27964d8a6764 100644 --- a/src/components/Image/types.ts +++ b/src/components/Image/types.ts @@ -1,10 +1,14 @@ import type {ImageSource} from 'expo-image'; import type {ImageRequireSource, ImageResizeMode, ImageStyle, ImageURISource, StyleProp} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; +import type {ValueOf} from 'type-fest'; +import type CONST from '@src/CONST'; import type {Session} from '@src/types/onyx'; type ExpoImageSource = ImageSource | number | ImageSource[]; +type ImageObjectPosition = ValueOf; + type ImageOnyxProps = { /** Session info for the currently logged in user. */ session: OnyxEntry; @@ -47,10 +51,10 @@ type ImageOwnProps = BaseImageProps & { /** Progress events while the image is downloading */ onProgress?: () => void; - /** Whether we should show the top of the image */ - objectPositionTop?: boolean; + /** The object position of image */ + objectPosition?: ImageObjectPosition; }; type ImageProps = ImageOnyxProps & ImageOwnProps; -export type {BaseImageProps, ImageOwnProps, ImageOnyxProps, ImageProps, ExpoImageSource, ImageOnLoadEvent}; +export type {BaseImageProps, ImageOwnProps, ImageOnyxProps, ImageProps, ExpoImageSource, ImageOnLoadEvent, ImageObjectPosition}; diff --git a/src/components/ImageWithSizeCalculation.tsx b/src/components/ImageWithSizeCalculation.tsx index ffa9517299cc..eac5c676370b 100644 --- a/src/components/ImageWithSizeCalculation.tsx +++ b/src/components/ImageWithSizeCalculation.tsx @@ -5,9 +5,11 @@ import {View} from 'react-native'; import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; import Log from '@libs/Log'; +import CONST from '@src/CONST'; import FullscreenLoadingIndicator from './FullscreenLoadingIndicator'; import Image from './Image'; import RESIZE_MODES from './Image/resizeModes'; +import type {ImageObjectPosition} from './Image/types'; type OnMeasure = (args: {width: number; height: number}) => void; @@ -33,8 +35,8 @@ type ImageWithSizeCalculationProps = { /** Whether the image requires an authToken */ isAuthTokenRequired: boolean; - /** Whether we should show the top of the image */ - objectPositionTop?: boolean; + /** The object position of image */ + objectPosition?: ImageObjectPosition; }; /** @@ -43,7 +45,7 @@ type ImageWithSizeCalculationProps = { * performing some calculation on a network image after fetching dimensions so * it can be appropriately resized. */ -function ImageWithSizeCalculation({url, style, onMeasure, onLoadFailure, isAuthTokenRequired, objectPositionTop = false}: ImageWithSizeCalculationProps) { +function ImageWithSizeCalculation({url, style, onMeasure, onLoadFailure, isAuthTokenRequired, objectPosition = CONST.IMAGE_OBJECT_POSITION.INITIAL}: ImageWithSizeCalculationProps) { const styles = useThemeStyles(); const isLoadedRef = useRef(null); const [isImageCached, setIsImageCached] = useState(true); @@ -104,7 +106,7 @@ function ImageWithSizeCalculation({url, style, onMeasure, onLoadFailure, isAuthT }} onError={onError} onLoad={imageLoadedSuccessfully} - objectPositionTop={objectPositionTop} + objectPosition={objectPosition} /> {isLoading && !isImageCached && } diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index b2ea75cae8b0..75d156e58eaa 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -614,7 +614,7 @@ function MoneyRequestConfirmationList({ // but we don't need it to load the blob:// or file:// image when starting a money request / split bill // So if we have a thumbnail, it means we're retrieving the image from the server isAuthTokenRequired={!!receiptThumbnail} - objectPositionTop + objectPosition={CONST.IMAGE_OBJECT_POSITION.TOP} /> ) : ( // The empty receipt component should only show for IOU Requests of a paid policy ("Team" or "Corporate") diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index 08957c96128a..c32241d92096 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -906,7 +906,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ // but we don't need it to load the blob:// or file:// image when starting a money request / split bill // So if we have a thumbnail, it means we're retrieving the image from the server isAuthTokenRequired={!_.isEmpty(receiptThumbnail)} - objectPositionTop + objectPosition={CONST.IMAGE_OBJECT_POSITION.TOP} /> ), [receiptFilename, receiptImage, styles, receiptThumbnail, isLocalFile, isAttachmentInvalid], diff --git a/src/components/ReportActionItem/ReportActionItemImage.tsx b/src/components/ReportActionItem/ReportActionItemImage.tsx index b39cabf4e74e..3c6f6e7e2421 100644 --- a/src/components/ReportActionItem/ReportActionItemImage.tsx +++ b/src/components/ReportActionItem/ReportActionItemImage.tsx @@ -85,7 +85,7 @@ function ReportActionItemImage({thumbnail, image, enablePreviewModal = false, tr fallbackIcon={Expensicons.Receipt} fallbackIconSize={isSingleImage ? variables.iconSizeSuperLarge : variables.iconSizeExtraLarge} shouldDynamicallyResize={false} - objectPositionTop + objectPosition={CONST.IMAGE_OBJECT_POSITION.TOP} /> ); } else if (isLocalFile && filename && Str.isPDF(filename) && typeof attachmentModalSource === 'string') { @@ -100,7 +100,7 @@ function ReportActionItemImage({thumbnail, image, enablePreviewModal = false, tr ); } diff --git a/src/components/ThumbnailImage.tsx b/src/components/ThumbnailImage.tsx index d1bdfdf3ca9f..8b8da81c727a 100644 --- a/src/components/ThumbnailImage.tsx +++ b/src/components/ThumbnailImage.tsx @@ -6,9 +6,11 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useThumbnailDimensions from '@hooks/useThumbnailDimensions'; import variables from '@styles/variables'; +import CONST from '@src/CONST'; import type IconAsset from '@src/types/utils/IconAsset'; import Icon from './Icon'; import * as Expensicons from './Icon/Expensicons'; +import type {ImageObjectPosition} from './Image/types'; import ImageWithSizeCalculation from './ImageWithSizeCalculation'; type ThumbnailImageProps = { @@ -35,7 +37,9 @@ type ThumbnailImageProps = { /** Should the image be resized on load or just fit container */ shouldDynamicallyResize?: boolean; - objectPositionTop?: boolean; + + /** The object position of image */ + objectPosition?: ImageObjectPosition; }; type UpdateImageSizeParams = { @@ -52,7 +56,7 @@ function ThumbnailImage({ shouldDynamicallyResize = true, fallbackIcon = Expensicons.Gallery, fallbackIconSize = variables.iconSizeSuperLarge, - objectPositionTop = false, + objectPosition = CONST.IMAGE_OBJECT_POSITION.INITIAL, }: ThumbnailImageProps) { const styles = useThemeStyles(); const theme = useTheme(); @@ -104,7 +108,7 @@ function ThumbnailImage({ onMeasure={updateImageSize} onLoadFailure={() => setFailedToLoad(true)} isAuthTokenRequired={isAuthTokenRequired} - objectPositionTop={objectPositionTop} + objectPosition={objectPosition} /> From 115ec923108600f1ad167783d5acb23417effe5c Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 21 Mar 2024 17:37:50 +0700 Subject: [PATCH 016/339] update objectPosition prop --- src/components/DistanceEReceipt.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/DistanceEReceipt.tsx b/src/components/DistanceEReceipt.tsx index 03ae1cdef5ad..3d2a6a3e57b6 100644 --- a/src/components/DistanceEReceipt.tsx +++ b/src/components/DistanceEReceipt.tsx @@ -18,6 +18,7 @@ import PendingMapView from './MapView/PendingMapView'; import ScrollView from './ScrollView'; import Text from './Text'; import ThumbnailImage from './ThumbnailImage'; +import CONST from '@src/CONST'; type DistanceEReceiptProps = { /** The transaction for the distance request */ @@ -63,7 +64,7 @@ function DistanceEReceipt({transaction}: DistanceEReceiptProps) { style={[styles.w100, styles.h100]} isAuthTokenRequired shouldDynamicallyResize={false} - objectPosition + objectPosition={CONST.IMAGE_OBJECT_POSITION.TOP} /> )} From 1562a88172728730d3ad58cad1abc0e1529f7a28 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 21 Mar 2024 18:05:42 +0700 Subject: [PATCH 017/339] fix order import --- src/components/DistanceEReceipt.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/DistanceEReceipt.tsx b/src/components/DistanceEReceipt.tsx index 3d2a6a3e57b6..2d6e3e56210f 100644 --- a/src/components/DistanceEReceipt.tsx +++ b/src/components/DistanceEReceipt.tsx @@ -8,6 +8,7 @@ import * as ReceiptUtils from '@libs/ReceiptUtils'; import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot'; +import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import type {Transaction} from '@src/types/onyx'; import type {WaypointCollection} from '@src/types/onyx/Transaction'; @@ -18,7 +19,6 @@ import PendingMapView from './MapView/PendingMapView'; import ScrollView from './ScrollView'; import Text from './Text'; import ThumbnailImage from './ThumbnailImage'; -import CONST from '@src/CONST'; type DistanceEReceiptProps = { /** The transaction for the distance request */ From 3e61229cc03c38e5e6c13b7328ee097ffb057a49 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 25 Mar 2024 15:59:38 +0700 Subject: [PATCH 018/339] fix offline case --- .../ReportActionItem/ReportActionItemImage.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/ReportActionItem/ReportActionItemImage.tsx b/src/components/ReportActionItem/ReportActionItemImage.tsx index 3c6f6e7e2421..67efc75f4c24 100644 --- a/src/components/ReportActionItem/ReportActionItemImage.tsx +++ b/src/components/ReportActionItem/ReportActionItemImage.tsx @@ -6,7 +6,6 @@ import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import EReceiptThumbnail from '@components/EReceiptThumbnail'; import * as Expensicons from '@components/Icon/Expensicons'; -import Image from '@components/Image'; import PDFThumbnail from '@components/PDFThumbnail'; import PressableWithoutFocus from '@components/Pressable/PressableWithoutFocus'; import {ShowContextMenuContext} from '@components/ShowContextMenuContext'; @@ -97,9 +96,13 @@ function ReportActionItemImage({thumbnail, image, enablePreviewModal = false, tr ); } else { receiptImageComponent = ( - ); From fa9fa50c819b8527a644043168ce8ee8a9b18b89 Mon Sep 17 00:00:00 2001 From: rory Date: Mon, 25 Mar 2024 09:09:52 -0700 Subject: [PATCH 019/339] Move if from step to job --- .github/workflows/deployExpensifyHelp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deployExpensifyHelp.yml b/.github/workflows/deployExpensifyHelp.yml index d4577e112d59..9f026b3491a9 100644 --- a/.github/workflows/deployExpensifyHelp.yml +++ b/.github/workflows/deployExpensifyHelp.yml @@ -26,6 +26,7 @@ concurrency: jobs: build: + if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork) runs-on: ubuntu-latest steps: - name: Checkout @@ -46,7 +47,6 @@ jobs: - name: Deploy to Cloudflare Pages uses: cloudflare/pages-action@f0a1cd58cd66095dee69bfa18fa5efd1dde93bca id: deploy - if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork) with: apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} From f96096b2c593a5ea6db55a975caf756073f93813 Mon Sep 17 00:00:00 2001 From: rory Date: Mon, 25 Mar 2024 09:15:32 -0700 Subject: [PATCH 020/339] commit benign change to test build --- .../expensify-classic/integrations/HR-integrations/ADP.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/articles/expensify-classic/integrations/HR-integrations/ADP.md b/docs/articles/expensify-classic/integrations/HR-integrations/ADP.md index 47cbd2fdc1f3..d823c6045085 100644 --- a/docs/articles/expensify-classic/integrations/HR-integrations/ADP.md +++ b/docs/articles/expensify-classic/integrations/HR-integrations/ADP.md @@ -13,6 +13,8 @@ Your employee list in ADP can also be imported into Expensify via Expensify’s ## Step 1: Set up the ADP import file +Marco is great! + A basic setup for an ADP import file includes five columns. In order (from left to right), these columns are: - **Company Code** - See “Edit Company” page in ADP From 47219652324d818cf02438ee55ab8239fce71491 Mon Sep 17 00:00:00 2001 From: rory Date: Mon, 25 Mar 2024 09:30:34 -0700 Subject: [PATCH 021/339] Don't skip builds for PRs from forks, just deploys --- .github/workflows/deployExpensifyHelp.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deployExpensifyHelp.yml b/.github/workflows/deployExpensifyHelp.yml index 9f026b3491a9..01b3243bac80 100644 --- a/.github/workflows/deployExpensifyHelp.yml +++ b/.github/workflows/deployExpensifyHelp.yml @@ -26,7 +26,8 @@ concurrency: jobs: build: - if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork) + env: + IS_PR_FROM_FORK: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork) }} runs-on: ubuntu-latest steps: - name: Checkout @@ -47,6 +48,7 @@ jobs: - name: Deploy to Cloudflare Pages uses: cloudflare/pages-action@f0a1cd58cd66095dee69bfa18fa5efd1dde93bca id: deploy + if: env.IS_PR_FROM_FORK != 'true' with: apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} @@ -54,14 +56,17 @@ jobs: directory: ./docs/_site - name: Setup Cloudflare CLI + if: env.IS_PR_FROM_FORK != 'true' run: pip3 install cloudflare==2.19.0 - name: Purge Cloudflare cache + if: env.IS_PR_FROM_FORK != 'true' run: /home/runner/.local/bin/cli4 --verbose --delete hosts=["help.expensify.com"] /zones/:9ee042e6cfc7fd45e74aa7d2f78d617b/purge_cache env: CF_API_KEY: ${{ secrets.CLOUDFLARE_TOKEN }} - name: Leave a comment on the PR + if: env.IS_PR_FROM_FORK != 'true' uses: actions-cool/maintain-one-comment@de04bd2a3750d86b324829a3ff34d47e48e16f4b if: ${{ github.event_name == 'pull_request' }} with: From 7e4445d19860fb4084ac11d0b01abb7e90c3bb79 Mon Sep 17 00:00:00 2001 From: rory Date: Mon, 25 Mar 2024 09:32:43 -0700 Subject: [PATCH 022/339] Fix double if --- .github/workflows/deployExpensifyHelp.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deployExpensifyHelp.yml b/.github/workflows/deployExpensifyHelp.yml index 01b3243bac80..77bc157ef82a 100644 --- a/.github/workflows/deployExpensifyHelp.yml +++ b/.github/workflows/deployExpensifyHelp.yml @@ -66,9 +66,8 @@ jobs: CF_API_KEY: ${{ secrets.CLOUDFLARE_TOKEN }} - name: Leave a comment on the PR - if: env.IS_PR_FROM_FORK != 'true' uses: actions-cool/maintain-one-comment@de04bd2a3750d86b324829a3ff34d47e48e16f4b - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request' && env.IS_PR_FROM_FORK != 'true' }} with: token: ${{ secrets.OS_BOTIFY_TOKEN }} body: ${{ format('A preview of your ExpensifyHelp changes have been deployed to {0} ⚡️', steps.deploy.outputs.alias) }} From b3938df15e0bf8e994a8570f12978a15997b2ec6 Mon Sep 17 00:00:00 2001 From: rory Date: Mon, 25 Mar 2024 09:38:58 -0700 Subject: [PATCH 023/339] Flip IS_PR_FROM_FORK condition --- .github/workflows/deployExpensifyHelp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deployExpensifyHelp.yml b/.github/workflows/deployExpensifyHelp.yml index 77bc157ef82a..1f86072ea3e2 100644 --- a/.github/workflows/deployExpensifyHelp.yml +++ b/.github/workflows/deployExpensifyHelp.yml @@ -27,7 +27,7 @@ concurrency: jobs: build: env: - IS_PR_FROM_FORK: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork) }} + IS_PR_FROM_FORK: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork }} runs-on: ubuntu-latest steps: - name: Checkout From c8ecf02c73f5789baf717f61dc96cff2868ead57 Mon Sep 17 00:00:00 2001 From: rory Date: Mon, 25 Mar 2024 09:41:14 -0700 Subject: [PATCH 024/339] Remove test change --- .../expensify-classic/integrations/HR-integrations/ADP.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/articles/expensify-classic/integrations/HR-integrations/ADP.md b/docs/articles/expensify-classic/integrations/HR-integrations/ADP.md index d823c6045085..47cbd2fdc1f3 100644 --- a/docs/articles/expensify-classic/integrations/HR-integrations/ADP.md +++ b/docs/articles/expensify-classic/integrations/HR-integrations/ADP.md @@ -13,8 +13,6 @@ Your employee list in ADP can also be imported into Expensify via Expensify’s ## Step 1: Set up the ADP import file -Marco is great! - A basic setup for an ADP import file includes five columns. In order (from left to right), these columns are: - **Company Code** - See “Edit Company” page in ADP From c2a0b77e400f1f66e391359a315577e7d05dfc71 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Thu, 28 Mar 2024 18:25:12 +0200 Subject: [PATCH 025/339] Export main page - initial --- src/CONST.ts | 1 + src/ROUTES.ts | 8 ++ src/SCREENS.ts | 2 + src/languages/en.ts | 12 ++ src/languages/es.ts | 12 ++ .../ModalStackNavigators/index.tsx | 2 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 3 + src/libs/Navigation/linkingConfig/config.ts | 4 + src/libs/Navigation/types.ts | 9 ++ .../accounting/WorkspaceAccountingPage.tsx | 21 ++++ .../accounting/qbo/QuickbooksExportPage.tsx | 104 ++++++++++++++++++ 11 files changed, 178 insertions(+) create mode 100644 src/pages/workspace/accounting/WorkspaceAccountingPage.tsx create mode 100644 src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx diff --git a/src/CONST.ts b/src/CONST.ts index c57ac575f7e6..1b8b8cc0b30d 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -534,6 +534,7 @@ const CONST = { CONCIERGE_ICON_URL_2021: `${CLOUDFRONT_URL}/images/icons/concierge_2021.png`, CONCIERGE_ICON_URL: `${CLOUDFRONT_URL}/images/icons/concierge_2022.png`, UPWORK_URL: 'https://github.com/Expensify/App/issues?q=is%3Aopen+is%3Aissue+label%3A%22Help+Wanted%22', + DEEP_DIVE_EXPENSIFY_CARD: 'https://community.expensify.com/discussion/4848/deep-dive-expensify-card-and-quickbooks-online-auto-reconciliation-how-it-works', GITHUB_URL: 'https://github.com/Expensify/App', TERMS_URL: `${USE_EXPENSIFY_URL}/terms`, PRIVACY_URL: `${USE_EXPENSIFY_URL}/privacy`, diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 23bb2ee845ad..8d59c00d9dff 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -452,10 +452,18 @@ const ROUTES = { route: 'settings/workspaces/:policyID/profile', getRoute: (policyID: string) => `settings/workspaces/${policyID}/profile` as const, }, + WORKSPACE_ACCOUNTING: { + route: 'settings/workspaces/:policyID/accounting', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting` as const, + }, WORKSPACE_PROFILE_CURRENCY: { route: 'settings/workspaces/:policyID/profile/currency', getRoute: (policyID: string) => `settings/workspaces/${policyID}/profile/currency` as const, }, + WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export` as const, + }, WORKSPACE_PROFILE_NAME: { route: 'settings/workspaces/:policyID/profile/name', getRoute: (policyID: string) => `settings/workspaces/${policyID}/profile/name` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index ffb18391c980..fd1732fce921 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -208,6 +208,7 @@ const SCREENS = { INVOICES: 'Workspace_Invoices', TRAVEL: 'Workspace_Travel', MEMBERS: 'Workspace_Members', + ACCOUNTING: 'Workspace_Accounting', INVITE: 'Workspace_Invite', INVITE_MESSAGE: 'Workspace_Invite_Message', CATEGORIES: 'Workspace_Categories', @@ -249,6 +250,7 @@ const SCREENS = { CREATE_DISTANCE_RATE: 'Create_Distance_Rate', DISTANCE_RATES_SETTINGS: 'Distance_Rates_Settings', DISTANCE_RATE_DETAILS: 'Distance_Rate_Details', + QUICKBOOKSONLINE_EXPORT: 'Workspace_Accounting_QuickbooksOnline_Export', DISTANCE_RATE_EDIT: 'Distance_Rate_Edit', }, diff --git a/src/languages/en.ts b/src/languages/en.ts index 4badcddbc03d..f2e51b8e3116 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1805,6 +1805,18 @@ export default { control: 'Control', collect: 'Collect', }, + qbo: { + export: 'Export', + exportDescription: 'Configure how data in Expensify gets exported to QuickBooks Online.', + preferredExporter: 'Preferred exporter', + date: 'Date', + exportExpenses: 'Export out-of-pocket expenses as', + exportInvoices: 'Export invoices to', + exportCompany: 'Export company cards as', + exportExpensifyCard: 'Export Expensify Card transactions as', + deepDiveExpensifyCard: 'Expensify Card transactions automatically export to a “Expensify Card Liability Account” created with', + deepDiveExpensifyCardIntegration: 'our integration.', + }, categories: { deleteCategories: 'Delete categories', deleteCategoriesPrompt: 'Are you sure you want to delete these categories?', diff --git a/src/languages/es.ts b/src/languages/es.ts index 8167633c2d64..4e30b0c06e7b 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1827,6 +1827,18 @@ export default { welcomeNote: ({workspaceName}: WelcomeNoteParams) => `¡Has sido invitado a ${workspaceName}! Descargue la aplicación móvil Expensify en use.expensify.com/download para comenzar a rastrear sus gastos.`, }, + qbo: { + export: 'Exportar', + exportDescription: 'Configure cómo se exportan los datos de Expensify a QuickBooks Online.', + preferredExporter: 'Exportador preferido', + date: 'Fecha', + exportExpenses: 'Exportar gastos de bolsillo como', + exportInvoices: 'Exportar facturas a', + exportCompany: 'Exportar tarjetas de empresa como', + exportExpensifyCard: 'Exportar transacciones de la tarjeta Expensify como', + deepDiveExpensifyCard: 'Las transacciones de la Tarjeta Expensify se exportan automáticamente a una "Cuenta de Responsabilidad de la Tarjeta Expensify" creada con', + deepDiveExpensifyCardIntegration: 'nuestra integración.', + }, type: { free: 'Gratis', control: 'Control', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index ef1fc3c2dfb0..de53174ec375 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -194,6 +194,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/settings/Profile/Contacts/ContactMethodDetailsPage').default as React.ComponentType, [SCREENS.SETTINGS.PROFILE.NEW_CONTACT_METHOD]: () => require('../../../../pages/settings/Profile/Contacts/NewContactMethodPage').default as React.ComponentType, [SCREENS.SETTINGS.PREFERENCES.PRIORITY_MODE]: () => require('../../../../pages/settings/Preferences/PriorityModePage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING]: () => require('@pages/workspace/accounting/WorkspaceAccountingPage').default as React.ComponentType, [SCREENS.SETTINGS.PREFERENCES.LANGUAGE]: () => require('../../../../pages/settings/Preferences/LanguagePage').default as React.ComponentType, [SCREENS.SETTINGS.PREFERENCES.THEME]: () => require('../../../../pages/settings/Preferences/ThemePage').default as React.ComponentType, [SCREENS.SETTINGS.CLOSE]: () => require('../../../../pages/settings/Security/CloseAccountPage').default as React.ComponentType, @@ -251,6 +252,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsCustomTaxName').default as React.ComponentType, [SCREENS.WORKSPACE.TAXES_SETTINGS_FOREIGN_CURRENCY_DEFAULT]: () => require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsForeignCurrency').default as React.ComponentType, [SCREENS.WORKSPACE.TAXES_SETTINGS_WORKSPACE_CURRENCY_DEFAULT]: () => require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsWorkspaceCurrency').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportPage').default as React.ComponentType, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType, [SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default as React.ComponentType, [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 1247933701a8..15bc0e88fb44 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -19,6 +19,9 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET, SCREENS.WORKSPACE.WORKFLOWS_PAYER, ], + [SCREENS.WORKSPACE.ACCOUNTING]: [ + SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT, + ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, SCREENS.WORKSPACE.TAX_CREATE, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index c9c5d47a2df3..74d61e20404a 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -232,6 +232,7 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.CURRENCY]: { path: ROUTES.WORKSPACE_PROFILE_CURRENCY.route, }, + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, @@ -617,6 +618,9 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.MEMBERS]: { path: ROUTES.WORKSPACE_MEMBERS.route, }, + [SCREENS.WORKSPACE.ACCOUNTING]: { + path: ROUTES.WORKSPACE_ACCOUNTING.route, + }, [SCREENS.WORKSPACE.CATEGORIES]: { path: ROUTES.WORKSPACE_CATEGORIES.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 60b2ed63ab49..88f4571c0965 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -246,6 +246,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.DISTANCE_RATES_SETTINGS]: { policyID: string; }; + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT]: { + policyID: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; @@ -612,9 +615,15 @@ type WorkspacesCentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.TAXES]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING]: { + policyID: string; + }; [SCREENS.WORKSPACE.DISTANCE_RATES]: { policyID: string; }; + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT]: { + policyID: string; + }; }; type FullScreenNavigatorParamList = { diff --git a/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx b/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx new file mode 100644 index 000000000000..7c2245514839 --- /dev/null +++ b/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import {View} from 'react-native'; +import ScreenWrapper from '@components/ScreenWrapper'; +import withPolicy from '@pages/workspace/withPolicy'; + +// Fake page will be removed after normal on will be merged +function WorkspaceAccountingPage() { + return ( + + + + ); +} + +WorkspaceAccountingPage.displayName = 'WorkspaceAccountingPage'; + +export default withPolicy(WorkspaceAccountingPage); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx new file mode 100644 index 000000000000..4722ac1143d1 --- /dev/null +++ b/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx @@ -0,0 +1,104 @@ +import React from 'react'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@navigation/Navigation'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import * as Link from '@userActions/Link'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +function QuickbooksExportPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const policyID = policy?.id ?? ''; + + const sections = [ + { + description: translate('workspace.qbo.preferredExporter'), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.getRoute(policyID)), + hasError: Boolean(policy?.errors?.enableNewCategories), + title: 'zany@cathyscroissants.com', + }, + { + description: translate('workspace.qbo.date'), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.getRoute(policyID)), + hasError: Boolean(policy?.errors?.syncClasses), + title: 'Date of last expense', + }, + { + description: translate('workspace.qbo.exportExpenses'), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.getRoute(policyID)), + hasError: Boolean(policy?.errors?.syncCustomers), + title: 'Vendor bill', + }, + { + description: translate('workspace.qbo.exportInvoices'), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.getRoute(policyID)), + hasError: Boolean(policy?.errors?.syncLocations), + title: 'Accounts Receivable (A/R)', + }, + { + description: translate('workspace.qbo.exportCompany'), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.getRoute(policyID)), + hasError: Boolean(policy?.errors?.syncTaxes), + title: 'Debit card', + }, + { + description: translate('workspace.qbo.exportExpensifyCard'), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.getRoute(policyID)), + hasError: Boolean(policy?.errors?.syncTaxes), + title: 'Credit card', + interactive: false, + }, + ]; + + return ( + + + + {translate('workspace.qbo.exportDescription')} + {sections.map((section) => ( + + + + ))} + { + Link.openExternalLink(CONST.DEEP_DIVE_EXPENSIFY_CARD); + }} + style={[styles.ph5, styles.pb5]} + accessibilityLabel={translate('workspace.qbo.deepDiveExpensifyCard')} + role={CONST.ROLE.LINK} + > + + {`${translate('workspace.qbo.deepDiveExpensifyCard')} `} + {translate('workspace.qbo.deepDiveExpensifyCardIntegration')} + + + + + ); +} + +QuickbooksExportPage.displayName = 'QuickbooksExportPage'; + +export default withPolicy(QuickbooksExportPage); From 1dfc676edec029d2daf270aef4310705cfecb3ef Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Thu, 28 Mar 2024 18:46:02 +0200 Subject: [PATCH 026/339] prettier --- .../Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 15bc0e88fb44..69da09eb8d23 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -19,9 +19,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET, SCREENS.WORKSPACE.WORKFLOWS_PAYER, ], - [SCREENS.WORKSPACE.ACCOUNTING]: [ - SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT, - ], + [SCREENS.WORKSPACE.ACCOUNTING]: [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, SCREENS.WORKSPACE.TAX_CREATE, From 274343407df3684bd0ed10cdd3e7369947ffc33d Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Fri, 29 Mar 2024 17:23:29 +0200 Subject: [PATCH 027/339] Export date page - initial --- src/CONST.ts | 6 ++ src/ROUTES.ts | 4 ++ src/SCREENS.ts | 1 + src/languages/en.ts | 5 ++ src/languages/es.ts | 5 ++ .../ModalStackNavigators/index.tsx | 1 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 2 +- src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/Navigation/types.ts | 3 + .../qbo/QuickbooksExportDatePage.tsx | 61 +++++++++++++++++++ .../accounting/qbo/QuickbooksExportPage.tsx | 2 +- src/types/onyx/Policy.ts | 2 +- 12 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 src/pages/workspace/accounting/qbo/QuickbooksExportDatePage.tsx diff --git a/src/CONST.ts b/src/CONST.ts index 1b8b8cc0b30d..4ca3884e117d 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -4134,6 +4134,12 @@ const CONST = { }, }, + QUICKBOOKS_EXPORT_DATE: { + LAST_EXPENSE: 'lastExpense', + EXPORTED_DATE: 'exportedDate', + SUBMITTED_DATA: 'submittedData', + }, + SESSION_STORAGE_KEYS: { INITIAL_URL: 'INITIAL_URL', }, diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 8d59c00d9dff..e5e9ec63d648 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -669,6 +669,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/distance-rates/:rateID/edit', getRoute: (policyID: string, rateID: string) => `settings/workspaces/${policyID}/distance-rates/${rateID}/edit` as const, }, + WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT_DATE: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/date', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/date` as const, + }, // Referral program promotion REFERRAL_DETAILS_MODAL: { route: 'referral/:contentType', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index fd1732fce921..664acfbfad66 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -251,6 +251,7 @@ const SCREENS = { DISTANCE_RATES_SETTINGS: 'Distance_Rates_Settings', DISTANCE_RATE_DETAILS: 'Distance_Rate_Details', QUICKBOOKSONLINE_EXPORT: 'Workspace_Accounting_QuickbooksOnline_Export', + QUICKBOOKSONLINE_EXPORT_DATE: 'Workspace_Accounting_QuickbooksOnline_Export_Date', DISTANCE_RATE_EDIT: 'Distance_Rate_Edit', }, diff --git a/src/languages/en.ts b/src/languages/en.ts index f2e51b8e3116..234e76c4ea69 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1816,6 +1816,11 @@ export default { exportExpensifyCard: 'Export Expensify Card transactions as', deepDiveExpensifyCard: 'Expensify Card transactions automatically export to a “Expensify Card Liability Account” created with', deepDiveExpensifyCardIntegration: 'our integration.', + exportDate: 'Export Date', + exportDateDescription: 'Use this date when exporting reports to QuickBooks Online.', + lastExpense: {label: 'Date of last expense', description: 'The date of the most recent expense on the report'}, + exportedDate: {label: 'Export date', description: 'The date the report was exported to QuickBooksOnline'}, + submittedData: {label: 'Submitted data', description: 'The date the report was submitted for approval'}, }, categories: { deleteCategories: 'Delete categories', diff --git a/src/languages/es.ts b/src/languages/es.ts index 4e30b0c06e7b..63968ee7b6f3 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1838,6 +1838,11 @@ export default { exportExpensifyCard: 'Exportar transacciones de la tarjeta Expensify como', deepDiveExpensifyCard: 'Las transacciones de la Tarjeta Expensify se exportan automáticamente a una "Cuenta de Responsabilidad de la Tarjeta Expensify" creada con', deepDiveExpensifyCardIntegration: 'nuestra integración.', + exportDate: 'Fecha de exportación', + exportDateDescription: 'Utilice esta fecha al exportar informes a QuickBooks Online.', + lastExpense: {label: 'Fecha del último gasto', description: 'La fecha del gasto más reciente en el informe.'}, + exportedDate: {label: 'Fecha de exportación', description: 'La fecha en que se exportó el informe a QuickBooks Online'}, + submittedData: {label: 'Datos enviados', description: 'La fecha en que se presentó el informe para su aprobación.'}, }, type: { free: 'Gratis', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index de53174ec375..8425667a39e8 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -253,6 +253,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsForeignCurrency').default as React.ComponentType, [SCREENS.WORKSPACE.TAXES_SETTINGS_WORKSPACE_CURRENCY_DEFAULT]: () => require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsWorkspaceCurrency').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportDatePage').default as React.ComponentType, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType, [SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default as React.ComponentType, [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 69da09eb8d23..cb7cd0492f9a 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -19,7 +19,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET, SCREENS.WORKSPACE.WORKFLOWS_PAYER, ], - [SCREENS.WORKSPACE.ACCOUNTING]: [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT], + [SCREENS.WORKSPACE.ACCOUNTING]: [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT, SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, SCREENS.WORKSPACE.TAX_CREATE, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 74d61e20404a..69287f0ee0b7 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -233,6 +233,7 @@ const config: LinkingOptions['config'] = { path: ROUTES.WORKSPACE_PROFILE_CURRENCY.route, }, [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.route}, + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT_DATE.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 88f4571c0965..9628c7f27680 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -249,6 +249,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT]: { policyID: string; }; + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE]: { + policyID: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportDatePage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksExportDatePage.tsx new file mode 100644 index 000000000000..93f26155fb77 --- /dev/null +++ b/src/pages/workspace/accounting/qbo/QuickbooksExportDatePage.tsx @@ -0,0 +1,61 @@ +import React, {useCallback} from 'react'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import SelectionList from '@components/SelectionList'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@navigation/Navigation'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import CONST from '@src/CONST'; + +function QuickbooksExportDatePage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + // const policyID = policy?.id ?? ''; + const {exportDate} = policy?.connections?.quickbooksOnline?.config ?? {}; + const data = Object.values(CONST.QUICKBOOKS_EXPORT_DATE).map((dateType) => ({ + value: dateType, + text: translate(`workspace.qbo.${dateType}.label`), + alternateText: translate(`workspace.qbo.${dateType}.description`), + keyForList: dateType, + isSelected: exportDate ? CONST.QUICKBOOKS_EXPORT_DATE[exportDate] === dateType : false, + })); + + const updateMode = useCallback( + (mode: {value: string}) => { + if (exportDate && mode.value === CONST.QUICKBOOKS_EXPORT_DATE[exportDate]) { + Navigation.goBack(); + return; + } + // TODO add API call for change + }, + [exportDate], + ); + + return ( + + + + {translate('workspace.qbo.exportDateDescription')} + mode.isSelected)?.keyForList} + /> + + + ); +} + +QuickbooksExportDatePage.displayName = 'QuickbooksExportDatePage'; + +export default withPolicy(QuickbooksExportDatePage); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx index 4722ac1143d1..371da807e3ac 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx @@ -29,7 +29,7 @@ function QuickbooksExportPage({policy}: WithPolicyProps) { }, { description: translate('workspace.qbo.date'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.getRoute(policyID)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT_DATE.getRoute(policyID)), hasError: Boolean(policy?.errors?.syncClasses), title: 'Date of last expense', }, diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 398a0fe0dd28..c3554cad8403 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -165,7 +165,7 @@ type QBOConnectionConfig = { syncClasses: IntegrationEntityMap; syncCustomers: IntegrationEntityMap; syncLocations: IntegrationEntityMap; - exportDate: string; + exportDate: keyof typeof CONST.QUICKBOOKS_EXPORT_DATE; lastConfigurationTime: number; syncTax: boolean; enableNewCategories: boolean; From 4e11125e6862353dfc095b831501988a43d5cc1c Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Sat, 30 Mar 2024 19:00:19 +0300 Subject: [PATCH 028/339] fixed optimistic submitted report action --- src/libs/ReportUtils.ts | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 9fa28535a7a7..cc52ce559d9b 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3283,8 +3283,40 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa * @param paymentType - IOU paymentMethodType. Can be oneOf(Elsewhere, Expensify) * @param isSettlingUp - Whether we are settling up an IOU */ -function getIOUReportActionMessage(iouReportID: string, type: string, total: number, comment: string, currency: string, paymentType = '', isSettlingUp = false): [Message] { +function getIOUReportActionMessage(iouReportID: string, type: string, total: number, comment: string, currency: string, paymentType = '', isSettlingUp = false): Message[] { const report = getReport(iouReportID); + + if (type === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) { + const policy = getPolicy(report?.policyID); + const ownerPersonalDetails = getPersonalDetailsForAccountID(policy?.ownerAccountID ?? 0); + const ownerDisplayName = ownerPersonalDetails?.displayName + ? `${ownerPersonalDetails.displayName} (${ownerPersonalDetails.login})` + : ownerPersonalDetails?.login ?? Localize.translateLocal('common.hidden'); + + return [ + { + type: CONST.REPORT.MESSAGE.TYPE.TEXT, + style: 'strong', + text: 'You', + }, + { + type: CONST.REPORT.MESSAGE.TYPE.TEXT, + style: 'normal', + text: ' submitted this report', + }, + { + type: CONST.REPORT.MESSAGE.TYPE.TEXT, + style: 'normal', + text: ' to ', + }, + { + type: CONST.REPORT.MESSAGE.TYPE.TEXT, + style: 'strong', + text: ownerDisplayName, + }, + ]; + } + const amount = type === CONST.IOU.REPORT_ACTION_TYPE.PAY ? CurrencyUtils.convertToDisplayString(getMoneyRequestSpendBreakdown(!isEmptyObject(report) ? report : null).totalDisplaySpend, currency) @@ -3306,9 +3338,6 @@ function getIOUReportActionMessage(iouReportID: string, type: string, total: num case CONST.REPORT.ACTIONS.TYPE.APPROVED: iouMessage = `approved ${amount}`; break; - case CONST.REPORT.ACTIONS.TYPE.SUBMITTED: - iouMessage = `submitted ${amount}`; - break; case CONST.IOU.REPORT_ACTION_TYPE.CREATE: iouMessage = `requested ${amount}${comment && ` for ${comment}`}`; break; From deb453cda65cc673b73114401e27bd5db2d10403 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Sat, 30 Mar 2024 19:16:22 +0300 Subject: [PATCH 029/339] fixed for no display name case --- src/libs/ReportUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index cc52ce559d9b..8194667baf75 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3290,8 +3290,8 @@ function getIOUReportActionMessage(iouReportID: string, type: string, total: num const policy = getPolicy(report?.policyID); const ownerPersonalDetails = getPersonalDetailsForAccountID(policy?.ownerAccountID ?? 0); const ownerDisplayName = ownerPersonalDetails?.displayName - ? `${ownerPersonalDetails.displayName} (${ownerPersonalDetails.login})` - : ownerPersonalDetails?.login ?? Localize.translateLocal('common.hidden'); + ? `${ownerPersonalDetails.displayName}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}` + : Localize.translateLocal('common.hidden'); return [ { From 22ca301945140408ecf14281b5b540cbbe51c37f Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Sat, 30 Mar 2024 19:49:26 +0300 Subject: [PATCH 030/339] changed to policy submitsTo --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8194667baf75..79fa3a775073 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3288,7 +3288,7 @@ function getIOUReportActionMessage(iouReportID: string, type: string, total: num if (type === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) { const policy = getPolicy(report?.policyID); - const ownerPersonalDetails = getPersonalDetailsForAccountID(policy?.ownerAccountID ?? 0); + const ownerPersonalDetails = getPersonalDetailsForAccountID(policy?.submitsTo ?? 0); const ownerDisplayName = ownerPersonalDetails?.displayName ? `${ownerPersonalDetails.displayName}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}` : Localize.translateLocal('common.hidden'); From fa1a0f8712bf35f0754adcfd91941d216a6f6c14 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Sat, 30 Mar 2024 20:14:06 +0300 Subject: [PATCH 031/339] Add submitted to oneself case --- src/libs/ReportUtils.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 79fa3a775073..7bea7466eae1 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3289,10 +3289,14 @@ function getIOUReportActionMessage(iouReportID: string, type: string, total: num if (type === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) { const policy = getPolicy(report?.policyID); const ownerPersonalDetails = getPersonalDetailsForAccountID(policy?.submitsTo ?? 0); - const ownerDisplayName = ownerPersonalDetails?.displayName - ? `${ownerPersonalDetails.displayName}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}` - : Localize.translateLocal('common.hidden'); - + let ownerDisplayName: string; + if (ownerPersonalDetails?.accountID === currentUserAccountID) { + ownerDisplayName = 'yourself'; + } else { + ownerDisplayName = ownerPersonalDetails?.displayName + ? `${ownerPersonalDetails.displayName}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}` + : 'Hidden'; + } return [ { type: CONST.REPORT.MESSAGE.TYPE.TEXT, From cfc0c8a167cdeb188f9abf0d1f8c07ab0a882e85 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Sat, 30 Mar 2024 20:45:48 +0300 Subject: [PATCH 032/339] changed variable name --- src/libs/ReportUtils.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7bea7466eae1..fbcf6b038f51 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3289,11 +3289,11 @@ function getIOUReportActionMessage(iouReportID: string, type: string, total: num if (type === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) { const policy = getPolicy(report?.policyID); const ownerPersonalDetails = getPersonalDetailsForAccountID(policy?.submitsTo ?? 0); - let ownerDisplayName: string; + let submittedToDisplayName: string; if (ownerPersonalDetails?.accountID === currentUserAccountID) { - ownerDisplayName = 'yourself'; + submittedToDisplayName = 'yourself'; } else { - ownerDisplayName = ownerPersonalDetails?.displayName + submittedToDisplayName = ownerPersonalDetails?.displayName ? `${ownerPersonalDetails.displayName}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}` : 'Hidden'; } @@ -3316,7 +3316,7 @@ function getIOUReportActionMessage(iouReportID: string, type: string, total: num { type: CONST.REPORT.MESSAGE.TYPE.TEXT, style: 'strong', - text: ownerDisplayName, + text: submittedToDisplayName, }, ]; } From 9ce0d6b846d2bf737fc652ace9ca9545dced0d5b Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Tue, 2 Apr 2024 12:33:57 +0300 Subject: [PATCH 033/339] implemented it into separate function --- src/libs/ReportUtils.ts | 68 ++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 0dcf3ab50d7c..ec5165f3f99a 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3275,6 +3275,41 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa return expenseReport; } +function getIOUSubmittedMessage(report: OnyxEntry) { + const policy = getPolicy(report?.policyID); + const ownerPersonalDetails = getPersonalDetailsForAccountID(policy?.submitsTo ?? 0); + let submittedToDisplayName: string; + if (ownerPersonalDetails?.accountID === currentUserAccountID) { + submittedToDisplayName = 'yourself'; + } else { + submittedToDisplayName = ownerPersonalDetails?.displayName + ? `${ownerPersonalDetails.displayName}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}` + : ''; + } + return [ + { + type: CONST.REPORT.MESSAGE.TYPE.TEXT, + style: 'strong', + text: 'You', + }, + { + type: CONST.REPORT.MESSAGE.TYPE.TEXT, + style: 'normal', + text: ' submitted this report', + }, + { + type: CONST.REPORT.MESSAGE.TYPE.TEXT, + style: 'normal', + text: ' to ', + }, + { + type: CONST.REPORT.MESSAGE.TYPE.TEXT, + style: 'strong', + text: submittedToDisplayName, + }, + ]; +} + /** * @param iouReportID - the report ID of the IOU report the action belongs to * @param type - IOUReportAction type. Can be oneOf(create, decline, cancel, pay, split) @@ -3288,38 +3323,7 @@ function getIOUReportActionMessage(iouReportID: string, type: string, total: num const report = getReport(iouReportID); if (type === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) { - const policy = getPolicy(report?.policyID); - const ownerPersonalDetails = getPersonalDetailsForAccountID(policy?.submitsTo ?? 0); - let submittedToDisplayName: string; - if (ownerPersonalDetails?.accountID === currentUserAccountID) { - submittedToDisplayName = 'yourself'; - } else { - submittedToDisplayName = ownerPersonalDetails?.displayName - ? `${ownerPersonalDetails.displayName}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}` - : 'Hidden'; - } - return [ - { - type: CONST.REPORT.MESSAGE.TYPE.TEXT, - style: 'strong', - text: 'You', - }, - { - type: CONST.REPORT.MESSAGE.TYPE.TEXT, - style: 'normal', - text: ' submitted this report', - }, - { - type: CONST.REPORT.MESSAGE.TYPE.TEXT, - style: 'normal', - text: ' to ', - }, - { - type: CONST.REPORT.MESSAGE.TYPE.TEXT, - style: 'strong', - text: submittedToDisplayName, - }, - ]; + return getIOUSubmittedMessage(!isEmptyObject(report) ? report : null); } const amount = From 8103f5a8ab00445cc378b259e821e21fea758d64 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Tue, 2 Apr 2024 13:03:30 +0300 Subject: [PATCH 034/339] avoided double terniary --- src/libs/ReportUtils.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ec5165f3f99a..3c3817659bde 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3281,11 +3281,12 @@ function getIOUSubmittedMessage(report: OnyxEntry) { let submittedToDisplayName: string; if (ownerPersonalDetails?.accountID === currentUserAccountID) { submittedToDisplayName = 'yourself'; + } else if (ownerPersonalDetails?.displayName) { + submittedToDisplayName = `${ownerPersonalDetails.displayName}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}`; } else { - submittedToDisplayName = ownerPersonalDetails?.displayName - ? `${ownerPersonalDetails.displayName}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}` - : ''; + submittedToDisplayName = ''; } + return [ { type: CONST.REPORT.MESSAGE.TYPE.TEXT, From 989ed819c63871a4bebcfac011e719bdf300b1e5 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Tue, 2 Apr 2024 13:49:20 +0300 Subject: [PATCH 035/339] minor fix --- src/libs/ReportUtils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 3c3817659bde..dda853389bb7 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3281,10 +3281,8 @@ function getIOUSubmittedMessage(report: OnyxEntry) { let submittedToDisplayName: string; if (ownerPersonalDetails?.accountID === currentUserAccountID) { submittedToDisplayName = 'yourself'; - } else if (ownerPersonalDetails?.displayName) { - submittedToDisplayName = `${ownerPersonalDetails.displayName}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}`; } else { - submittedToDisplayName = ''; + submittedToDisplayName = `${ownerPersonalDetails.displayName ?? ''}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}`; } return [ From b07c19501f71998ec45784b3172f3d9a31537abf Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Tue, 2 Apr 2024 17:21:17 +0300 Subject: [PATCH 036/339] Export invoice page --- src/ROUTES.ts | 4 ++ src/SCREENS.ts | 1 + src/languages/en.ts | 3 + src/languages/es.ts | 3 + .../WorkspaceSettingsModalStackNavigator.tsx | 5 ++ .../ModalStackNavigators/index.tsx | 1 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 2 +- src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/Navigation/types.ts | 3 + .../qbo/QuickbooksExportInvoicesPage.tsx | 58 +++++++++++++++++++ .../accounting/qbo/QuickbooksExportPage.tsx | 2 +- 11 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 src/pages/workspace/accounting/qbo/QuickbooksExportInvoicesPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 2bd7a47be2aa..27b3cfb04c71 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -458,6 +458,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export` as const, }, + WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_INVOICES: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/invoices', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/invoices` as const, + }, WORKSPACE_PROFILE_NAME: { route: 'settings/workspaces/:policyID/profile/name', getRoute: (policyID: string) => `settings/workspaces/${policyID}/profile/name` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 7543378fb8b5..4bebfbbc5075 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -250,6 +250,7 @@ const SCREENS = { DISTANCE_RATE_DETAILS: 'Distance_Rate_Details', QUICKBOOKSONLINE_EXPORT: 'Workspace_Accounting_QuickbooksOnline_Export', QUICKBOOKSONLINE_EXPORT_DATE: 'Workspace_Accounting_QuickbooksOnline_Export_Date', + QUICKBOOKSONLINE_EXPORT_INVOICES: 'Workspace_Accounting_QuickbooksOnline_Export_Invoices', DISTANCE_RATE_EDIT: 'Distance_Rate_Edit', }, diff --git a/src/languages/en.ts b/src/languages/en.ts index 7a5db95b4a01..2ab722c73340 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1834,6 +1834,9 @@ export default { lastExpense: {label: 'Date of last expense', description: 'The date of the most recent expense on the report'}, exportedDate: {label: 'Export date', description: 'The date the report was exported to QuickBooksOnline'}, submittedData: {label: 'Submitted data', description: 'The date the report was submitted for approval'}, + receivable: 'Accounts receivable', + archive: 'Accounts receivable archive', + exportInvoicesDescription: 'Invoices will be exported to this account in QuickBooks Online.' }, categories: { deleteCategories: 'Delete categories', diff --git a/src/languages/es.ts b/src/languages/es.ts index fb505e1ccd3c..6b3e5260514d 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1856,6 +1856,9 @@ export default { lastExpense: {label: 'Fecha del último gasto', description: 'La fecha del gasto más reciente en el informe.'}, exportedDate: {label: 'Fecha de exportación', description: 'La fecha en que se exportó el informe a QuickBooks Online'}, submittedData: {label: 'Datos enviados', description: 'La fecha en que se presentó el informe para su aprobación.'}, + receivable: 'Cuentas por cobrar', + archive: 'Archivo de cuentas por cobrar', + exportInvoicesDescription: 'Las facturas se exportarán a esta cuenta en QuickBooks Online.' }, type: { free: 'Gratis', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx index 14153809bc86..38b2aec7672a 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx @@ -75,6 +75,11 @@ function WorkspaceSettingsModalStackNavigator() { name={SCREENS.WORKSPACE.DISTANCE_RATES} getComponent={() => require('@pages/workspace/distanceRates/PolicyDistanceRatesPage').default as React.ComponentType} /> + require('@pages/workspace/distanceRates/PolicyDistanceRatesPage').default as React.ComponentType} + /> ); } diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index dce39bd30c45..4ffc09042a42 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -253,6 +253,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsWorkspaceCurrency').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportDatePage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_INVOICES]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportInvoicesPage').default as React.ComponentType, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType, [SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default as React.ComponentType, [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index cb7cd0492f9a..b228b3f9681c 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -19,7 +19,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET, SCREENS.WORKSPACE.WORKFLOWS_PAYER, ], - [SCREENS.WORKSPACE.ACCOUNTING]: [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT, SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE], + [SCREENS.WORKSPACE.ACCOUNTING]: [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT, SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE, SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_INVOICES], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, SCREENS.WORKSPACE.TAX_CREATE, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index d0d4a8336157..c6a0752fa53e 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -234,6 +234,7 @@ const config: LinkingOptions['config'] = { }, [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.route}, [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT_DATE.route}, + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_INVOICES]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_INVOICES.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 82eba60d3d6c..bc75acef5eeb 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -252,6 +252,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE]: { policyID: string; }; + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_INVOICES]: { + policyID: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportInvoicesPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksExportInvoicesPage.tsx new file mode 100644 index 000000000000..2fd407faa8c1 --- /dev/null +++ b/src/pages/workspace/accounting/qbo/QuickbooksExportInvoicesPage.tsx @@ -0,0 +1,58 @@ +import React, {useCallback} from 'react'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import SelectionList from '@components/SelectionList'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; + +function QuickbooksExportInvoicesPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + // const policyID = policy?.id ?? ''; + const data = [ + { + value: 'receivable', + text: translate(`workspace.qbo.receivable`), + keyForList: 'receivable', + isSelected: false, + }, + { + value: 'archive', + text: translate(`workspace.qbo.archive`), + keyForList: 'archive', + isSelected: false, + }, + ]; + + const updateMode = useCallback((mode: {value: string}) => { + // TODO add API call for change + }, []); + + return ( + + + + {translate('workspace.qbo.exportInvoicesDescription')} + mode.isSelected)?.keyForList} + /> + + + ); +} + +QuickbooksExportInvoicesPage.displayName = 'QuickbooksExportInvoicesPage'; + +export default withPolicy(QuickbooksExportInvoicesPage); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx index 371da807e3ac..c35c04445e67 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx @@ -41,7 +41,7 @@ function QuickbooksExportPage({policy}: WithPolicyProps) { }, { description: translate('workspace.qbo.exportInvoices'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.getRoute(policyID)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_INVOICES.getRoute(policyID)), hasError: Boolean(policy?.errors?.syncLocations), title: 'Accounts Receivable (A/R)', }, From 04c7685143a8a002f0c88d5aaad712d3ec33fb3c Mon Sep 17 00:00:00 2001 From: gaber Date: Wed, 3 Apr 2024 04:01:20 +0200 Subject: [PATCH 037/339] remove subscript workspace avatar from expense report --- src/pages/home/report/ReportActionsListItemRenderer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsListItemRenderer.tsx b/src/pages/home/report/ReportActionsListItemRenderer.tsx index 263415d90c39..29908da112f5 100644 --- a/src/pages/home/report/ReportActionsListItemRenderer.tsx +++ b/src/pages/home/report/ReportActionsListItemRenderer.tsx @@ -151,7 +151,7 @@ function ReportActionsListItemRenderer({ displayAsGroup={displayAsGroup} shouldDisplayNewMarker={shouldDisplayNewMarker} shouldShowSubscriptAvatar={ - (ReportUtils.isPolicyExpenseChat(report) || ReportUtils.isExpenseReport(report)) && + ReportUtils.isPolicyExpenseChat(report) && [CONST.REPORT.ACTIONS.TYPE.IOU, CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW, CONST.REPORT.ACTIONS.TYPE.SUBMITTED, CONST.REPORT.ACTIONS.TYPE.APPROVED].some( (type) => type === reportAction.actionName, ) From d0a4ccf4f38db2f5bf0681af7cedcf748f643221 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Wed, 3 Apr 2024 17:36:44 +0300 Subject: [PATCH 038/339] Company card + company card selection screens --- src/ROUTES.ts | 8 +++ src/SCREENS.ts | 2 + src/languages/en.ts | 7 +- src/languages/es.ts | 7 +- .../ModalStackNavigators/index.tsx | 2 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 8 ++- src/libs/Navigation/linkingConfig/config.ts | 2 + src/libs/Navigation/types.ts | 6 ++ .../qbo/QuickbooksExportCompanyCardPage.tsx | 69 +++++++++++++++++++ .../qbo/QuickbooksExportCompanyCardsPage.tsx | 44 ++++++++++++ .../accounting/qbo/QuickbooksExportPage.tsx | 2 +- src/types/onyx/Policy.ts | 2 +- 12 files changed, 154 insertions(+), 5 deletions(-) create mode 100644 src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardPage.tsx create mode 100644 src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 27b3cfb04c71..35c9e41c34df 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -458,6 +458,14 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export` as const, }, + WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_COMPANY_CARDS: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/company-cards', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/company-cards` as const, + }, + WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_COMPANY_CARD: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/company-card', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/company-card` as const, + }, WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_INVOICES: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/invoices', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/invoices` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 4bebfbbc5075..d02288833c4f 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -251,6 +251,8 @@ const SCREENS = { QUICKBOOKSONLINE_EXPORT: 'Workspace_Accounting_QuickbooksOnline_Export', QUICKBOOKSONLINE_EXPORT_DATE: 'Workspace_Accounting_QuickbooksOnline_Export_Date', QUICKBOOKSONLINE_EXPORT_INVOICES: 'Workspace_Accounting_QuickbooksOnline_Export_Invoices', + QUICKBOOKSONLINE_EXPORT_COMPANY_CARDS: 'Workspace_Accounting_QuickbooksOnline_Export_Company_Cards', + QUICKBOOKSONLINE_EXPORT_COMPANY_CARD: 'Workspace_Accounting_QuickbooksOnline_Export_Company_Card', DISTANCE_RATE_EDIT: 'Distance_Rate_Edit', }, diff --git a/src/languages/en.ts b/src/languages/en.ts index 2ab722c73340..c4a5b75105c5 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1820,6 +1820,7 @@ export default { }, qbo: { export: 'Export', + exportAs: 'Export as', exportDescription: 'Configure how data in Expensify gets exported to QuickBooks Online.', preferredExporter: 'Preferred exporter', date: 'Date', @@ -1836,7 +1837,11 @@ export default { submittedData: {label: 'Submitted data', description: 'The date the report was submitted for approval'}, receivable: 'Accounts receivable', archive: 'Accounts receivable archive', - exportInvoicesDescription: 'Invoices will be exported to this account in QuickBooks Online.' + exportInvoicesDescription: 'Invoices will be exported to this account in QuickBooks Online.', + exportCompanyCardsDescription: 'Set how company card purchases export to QuickBooks Online.', + creditCard: 'Credit Card', + debitCard: 'Debit Card', + vendorBill: 'Vendor Bill', }, categories: { deleteCategories: 'Delete categories', diff --git a/src/languages/es.ts b/src/languages/es.ts index 6b3e5260514d..d1104f8c48c1 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1842,6 +1842,7 @@ export default { }, qbo: { export: 'Exportar', + exportAs: 'Exportar cómo', exportDescription: 'Configure cómo se exportan los datos de Expensify a QuickBooks Online.', preferredExporter: 'Exportador preferido', date: 'Fecha', @@ -1858,7 +1859,11 @@ export default { submittedData: {label: 'Datos enviados', description: 'La fecha en que se presentó el informe para su aprobación.'}, receivable: 'Cuentas por cobrar', archive: 'Archivo de cuentas por cobrar', - exportInvoicesDescription: 'Las facturas se exportarán a esta cuenta en QuickBooks Online.' + exportInvoicesDescription: 'Las facturas se exportarán a esta cuenta en QuickBooks Online.', + exportCompanyCardsDescription: 'Establezca cómo se exportan las compras con tarjeta de empresa a QuickBooks Online.', + creditCard: 'Tarjeta de crédito', + debitCard: 'Tarjeta de débito', + vendorBill: 'Factura del proveedor', }, type: { free: 'Gratis', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 4ffc09042a42..8d9cef1eaaaa 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -254,6 +254,8 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/qbo/QuickbooksExportPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportDatePage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_INVOICES]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportInvoicesPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARDS]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARD]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportCompanyCardPage').default as React.ComponentType, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType, [SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default as React.ComponentType, [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index b228b3f9681c..bf9b3b52c9c1 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -19,7 +19,13 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET, SCREENS.WORKSPACE.WORKFLOWS_PAYER, ], - [SCREENS.WORKSPACE.ACCOUNTING]: [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT, SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE, SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_INVOICES], + [SCREENS.WORKSPACE.ACCOUNTING]: [ + SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT, + SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE, + SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_INVOICES, + SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARDS, + SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARD, + ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, SCREENS.WORKSPACE.TAX_CREATE, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index c6a0752fa53e..d2989bd45e5b 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -235,6 +235,8 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.route}, [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT_DATE.route}, [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_INVOICES]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_INVOICES.route}, + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARDS]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_COMPANY_CARDS.route}, + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARD]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_COMPANY_CARD.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index bc75acef5eeb..947a17575640 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -255,6 +255,12 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_INVOICES]: { policyID: string; }; + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARDS]: { + policyID: string; + }; + [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARD]: { + policyID: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardPage.tsx new file mode 100644 index 000000000000..eabdbed2e661 --- /dev/null +++ b/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardPage.tsx @@ -0,0 +1,69 @@ +import React, {useCallback} from 'react'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import SelectionList from '@components/SelectionList'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; + +const CARDS = { + CREDIT_CARD: 'credit_card', + DEBIT_CARD: 'debit_card', + VENDOR_BILL: 'vendor_bill', +}; + +function QuickbooksExportCompanyCardPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const {nonReimbursableExpensesExportDestination} = policy?.connections?.quickbooksOnline?.config ?? {}; + // const policyID = policy?.id ?? ''; + const data = [ + { + value: CARDS.CREDIT_CARD, + text: translate(`workspace.qbo.creditCard`), + keyForList: CARDS.CREDIT_CARD, + isSelected: nonReimbursableExpensesExportDestination === CARDS.CREDIT_CARD, + }, + { + value: CARDS.DEBIT_CARD, + text: translate(`workspace.qbo.debitCard`), + keyForList: CARDS.DEBIT_CARD, + isSelected: nonReimbursableExpensesExportDestination === CARDS.DEBIT_CARD, + }, + { + value: CARDS.VENDOR_BILL, + text: translate(`workspace.qbo.vendorBill`), + keyForList: CARDS.VENDOR_BILL, + isSelected: nonReimbursableExpensesExportDestination === CARDS.VENDOR_BILL, + }, + ]; + + const updateMode = useCallback((mode: {value: string}) => { + // TODO add API call for change + }, []); + + return ( + + + + mode.isSelected)?.keyForList} + /> + + + ); +} + +QuickbooksExportCompanyCardPage.displayName = 'QuickbooksExportCompanyCardPage'; + +export default withPolicy(QuickbooksExportCompanyCardPage); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx new file mode 100644 index 000000000000..318440ee570c --- /dev/null +++ b/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx @@ -0,0 +1,44 @@ +import React from 'react'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@navigation/Navigation'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import ROUTES from '@src/ROUTES'; + +function QuickbooksExportCompanyCardsPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const policyID = policy?.id ?? ''; + + return ( + + + + {translate('workspace.qbo.exportCompanyCardsDescription')} + + Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_COMPANY_CARD.getRoute(policyID))} + brickRoadIndicator={undefined} + /> + + + + ); +} + +QuickbooksExportCompanyCardsPage.displayName = 'QuickbooksExportCompanyCardsPage'; + +export default withPolicy(QuickbooksExportCompanyCardsPage); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx index c35c04445e67..b229c2b23467 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx @@ -47,7 +47,7 @@ function QuickbooksExportPage({policy}: WithPolicyProps) { }, { description: translate('workspace.qbo.exportCompany'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.getRoute(policyID)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_COMPANY_CARDS.getRoute(policyID)), hasError: Boolean(policy?.errors?.syncTaxes), title: 'Debit card', }, diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index abfc88b2bad6..622a547637fb 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -157,7 +157,7 @@ type QBOConnectionConfig = { syncItems: boolean; markChecksToBePrinted: boolean; reimbursableExpensesExportDestination: IntegrationEntityMap; - nonReimbursableExpensesExportDestination: IntegrationEntityMap; + nonReimbursableExpensesExportDestination: string; reimbursableExpensesAccount?: string; nonReimbursableExpensesAccount?: string; From 7fe8f611f8b94b7ff2d5366ef8639f9fbf729250 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 3 Apr 2024 17:53:14 +0300 Subject: [PATCH 039/339] re-shuffled code implementation --- src/libs/ReportUtils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index dda853389bb7..11aff4c3c1d2 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3278,11 +3278,9 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa function getIOUSubmittedMessage(report: OnyxEntry) { const policy = getPolicy(report?.policyID); const ownerPersonalDetails = getPersonalDetailsForAccountID(policy?.submitsTo ?? 0); - let submittedToDisplayName: string; + let submittedToDisplayName = `${ownerPersonalDetails.displayName ?? ''}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}`; if (ownerPersonalDetails?.accountID === currentUserAccountID) { submittedToDisplayName = 'yourself'; - } else { - submittedToDisplayName = `${ownerPersonalDetails.displayName ?? ''}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}`; } return [ From 11c23ffa19c2fbb364b7b1e9cf16e6a03f8eb87a Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Fri, 5 Apr 2024 16:57:09 +0300 Subject: [PATCH 040/339] Export Preferred Exporter screen + sub screen --- src/ROUTES.ts | 18 ++++-- src/SCREENS.ts | 12 ++-- src/languages/en.ts | 2 + src/languages/es.ts | 2 + .../ModalStackNavigators/index.tsx | 12 ++-- .../FULL_SCREEN_TO_RHP_MAPPING.ts | 12 ++-- src/libs/Navigation/linkingConfig/config.ts | 12 ++-- src/libs/Navigation/types.ts | 18 ++++-- .../qbo/QuickBooksExportPreferredExporter.tsx | 47 ++++++++++++++ .../QuickBooksExportPreferredExporterList.tsx | 61 +++++++++++++++++++ .../qbo/QuickbooksExportCompanyCardsPage.tsx | 2 +- .../accounting/qbo/QuickbooksExportPage.tsx | 16 ++--- 12 files changed, 175 insertions(+), 39 deletions(-) create mode 100644 src/pages/workspace/accounting/qbo/QuickBooksExportPreferredExporter.tsx create mode 100644 src/pages/workspace/accounting/qbo/QuickBooksExportPreferredExporterList.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 35c9e41c34df..dd4d63b0de03 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -454,22 +454,30 @@ const ROUTES = { route: 'settings/workspaces/:policyID/profile/currency', getRoute: (policyID: string) => `settings/workspaces/${policyID}/profile/currency` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT: { + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_COMPANY_CARDS: { + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARDS: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/company-cards', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/company-cards` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_COMPANY_CARD: { + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/company-card', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/company-card` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_INVOICES: { + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICES: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/invoices', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/invoices` as const, }, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/preferred-exporter', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/preferred-exporter` as const, + }, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_LIST: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/preferred-exporter-list', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/preferred-exporter-list` as const, + }, WORKSPACE_PROFILE_NAME: { route: 'settings/workspaces/:policyID/profile/name', getRoute: (policyID: string) => `settings/workspaces/${policyID}/profile/name` as const, @@ -675,7 +683,7 @@ const ROUTES = { route: 'settings/workspaces/:policyID/distance-rates/:rateID/edit', getRoute: (policyID: string, rateID: string) => `settings/workspaces/${policyID}/distance-rates/${rateID}/edit` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT_DATE: { + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/date', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/date` as const, }, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index d02288833c4f..59a9a431008a 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -248,11 +248,13 @@ const SCREENS = { CREATE_DISTANCE_RATE: 'Create_Distance_Rate', DISTANCE_RATES_SETTINGS: 'Distance_Rates_Settings', DISTANCE_RATE_DETAILS: 'Distance_Rate_Details', - QUICKBOOKSONLINE_EXPORT: 'Workspace_Accounting_QuickbooksOnline_Export', - QUICKBOOKSONLINE_EXPORT_DATE: 'Workspace_Accounting_QuickbooksOnline_Export_Date', - QUICKBOOKSONLINE_EXPORT_INVOICES: 'Workspace_Accounting_QuickbooksOnline_Export_Invoices', - QUICKBOOKSONLINE_EXPORT_COMPANY_CARDS: 'Workspace_Accounting_QuickbooksOnline_Export_Company_Cards', - QUICKBOOKSONLINE_EXPORT_COMPANY_CARD: 'Workspace_Accounting_QuickbooksOnline_Export_Company_Card', + QUICKBOOKS_ONLINE_EXPORT: 'Workspace_Accounting_Quickbooks_Online_Export', + QUICKBOOKS_ONLINE_EXPORT_DATE: 'Workspace_Accounting_Quickbooks_Online_Export_Date', + QUICKBOOKS_ONLINE_EXPORT_INVOICES: 'Workspace_Accounting_Quickbooks_Online_Export_Invoices', + QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARDS: 'Workspace_Accounting_Quickbooks_Online_Export_Company_Cards', + QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD: 'Workspace_Accounting_Quickbooks_Online_Export_Company_Card', + QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter', + QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_LIST: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter_List', DISTANCE_RATE_EDIT: 'Distance_Rate_Edit', }, diff --git a/src/languages/en.ts b/src/languages/en.ts index c4a5b75105c5..d68efc4e5e7a 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1842,6 +1842,8 @@ export default { creditCard: 'Credit Card', debitCard: 'Debit Card', vendorBill: 'Vendor Bill', + exportPreferredExporterNote: 'This can be any workspace admin, but must be a Domain Admin if you set different export accounts for individual company cards in Domain Settings.', + exportPreferredExporterSubNote: 'Once set, the preferred exporter will see reports for export in their account.', }, categories: { deleteCategories: 'Delete categories', diff --git a/src/languages/es.ts b/src/languages/es.ts index d1104f8c48c1..5d9d58c2f2b4 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1864,6 +1864,8 @@ export default { creditCard: 'Tarjeta de crédito', debitCard: 'Tarjeta de débito', vendorBill: 'Factura del proveedor', + exportPreferredExporterNote: 'Puede ser cualquier administrador del espacio de trabajo, pero debe ser un administrador de dominio si configura diferentes cuentas de exportación para tarjetas de empresa individuales en la configuración del dominio.', + exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en su cuenta.', }, type: { free: 'Gratis', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 8d9cef1eaaaa..0d4446b2a029 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -251,11 +251,13 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsCustomTaxName').default as React.ComponentType, [SCREENS.WORKSPACE.TAXES_SETTINGS_FOREIGN_CURRENCY_DEFAULT]: () => require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsForeignCurrency').default as React.ComponentType, [SCREENS.WORKSPACE.TAXES_SETTINGS_WORKSPACE_CURRENCY_DEFAULT]: () => require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsWorkspaceCurrency').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportDatePage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_INVOICES]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportInvoicesPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARDS]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARD]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportCompanyCardPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportDatePage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICES]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportInvoicesPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARDS]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportCompanyCardPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: () => require('../../../../pages/workspace/accounting/qbo/QuickBooksExportPreferredExporter').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_LIST]: () => require('../../../../pages/workspace/accounting/qbo/QuickBooksExportPreferredExporterList').default as React.ComponentType, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType, [SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default as React.ComponentType, [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index bf9b3b52c9c1..ba4a1cb7cb38 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -20,11 +20,13 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.WORKFLOWS_PAYER, ], [SCREENS.WORKSPACE.ACCOUNTING]: [ - SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT, - SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE, - SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_INVOICES, - SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARDS, - SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARD, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICES, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARDS, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_LIST, ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index d2989bd45e5b..9e700d7f66ca 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -232,11 +232,13 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.CURRENCY]: { path: ROUTES.WORKSPACE_PROFILE_CURRENCY.route, }, - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.route}, - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT_DATE.route}, - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_INVOICES]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_INVOICES.route}, - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARDS]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_COMPANY_CARDS.route}, - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARD]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_COMPANY_CARD.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICES]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICES.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARDS]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARDS.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_LIST]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_LIST.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 947a17575640..89ecb38b66e5 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -246,19 +246,25 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.DISTANCE_RATES_SETTINGS]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT]: { + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_DATE]: { + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_INVOICES]: { + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICES]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARDS]: { + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARDS]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT_COMPANY_CARD]: { + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD]: { + policyID: string; + }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: { + policyID: string; + }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_LIST]: { policyID: string; }; [SCREENS.GET_ASSISTANCE]: { @@ -642,7 +648,7 @@ type WorkspacesCentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.DISTANCE_RATES]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKSONLINE_EXPORT]: { + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: { policyID: string; }; }; diff --git a/src/pages/workspace/accounting/qbo/QuickBooksExportPreferredExporter.tsx b/src/pages/workspace/accounting/qbo/QuickBooksExportPreferredExporter.tsx new file mode 100644 index 000000000000..ffd593591fe2 --- /dev/null +++ b/src/pages/workspace/accounting/qbo/QuickBooksExportPreferredExporter.tsx @@ -0,0 +1,47 @@ +import React from 'react'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@navigation/Navigation'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import ROUTES from '@src/ROUTES'; + +function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const policyID = policy?.id ?? ''; + const policyOwner = policy?.owner ?? ''; + const {exporter} = policy?.connections?.quickbooksOnline?.config?.export ?? {}; + + return ( + + + + {translate('workspace.qbo.exportPreferredExporterNote')} + {translate('workspace.qbo.exportPreferredExporterSubNote')} + + Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_LIST.getRoute(policyID))} + brickRoadIndicator={undefined} + /> + + + + ); +} + +QuickBooksExportPreferredExporterPage.displayName = 'QuickBooksExportPreferredExporterPage'; + +export default withPolicy(QuickBooksExportPreferredExporterPage); diff --git a/src/pages/workspace/accounting/qbo/QuickBooksExportPreferredExporterList.tsx b/src/pages/workspace/accounting/qbo/QuickBooksExportPreferredExporterList.tsx new file mode 100644 index 000000000000..63f4efbe69c0 --- /dev/null +++ b/src/pages/workspace/accounting/qbo/QuickBooksExportPreferredExporterList.tsx @@ -0,0 +1,61 @@ +import React, {useCallback, useMemo} from 'react'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import SelectionList from '@components/SelectionList'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; + +const draft = [ + {name: '+14153166423@expensify.sms', currency: 'USD', id: '94', email: '+14153166423@expensify.sms'}, + {name: 'Account Maintenance Fee', currency: 'USD', id: '141', email: 'alberto@expensify213.com'}, + {name: 'Admin Test', currency: 'USD', id: '119', email: 'admin@qbocard.com'}, + {name: 'Alberto Gonzalez-Cela', currency: 'USD', id: '104', email: 'alberto@expensify.com'}, + {name: 'Aldo test QBO2 QBO2 Last name', currency: 'USD', id: '140', email: 'admin@qbo.com'}, +]; + +function QuickBooksExportPreferredExporterListPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const {data, config} = policy?.connections?.quickbooksOnline ?? {}; + // const policyID = policy?.id ?? ''; + const sections = useMemo( + () => + (data?.vendors ?? draft)?.map((vendor) => ({ + value: vendor.email, + text: vendor.email, + keyForList: vendor.email, + isSelected: config?.export?.exporter === vendor.email, + })) ?? [], + [config?.export?.exporter, data?.vendors], + ); + + const updateMode = useCallback((mode: {value: string}) => { + // TODO add API call for change + }, []); + + return ( + + + + mode.isSelected)?.keyForList} + /> + + + ); +} + +QuickBooksExportPreferredExporterListPage.displayName = 'QuickBooksExportPreferredExporterListPage'; + +export default withPolicy(QuickBooksExportPreferredExporterListPage); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx index 318440ee570c..87c442629c4d 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx @@ -30,7 +30,7 @@ function QuickbooksExportCompanyCardsPage({policy}: WithPolicyProps) { Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_COMPANY_CARD.getRoute(policyID))} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD.getRoute(policyID))} brickRoadIndicator={undefined} /> diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx index b229c2b23467..eb95eb93b06a 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx @@ -19,41 +19,43 @@ function QuickbooksExportPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; + const policyOwner = policy?.owner ?? ''; + const {exporter} = policy?.connections?.quickbooksOnline?.config?.export ?? {}; const sections = [ { description: translate('workspace.qbo.preferredExporter'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.getRoute(policyID)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)), hasError: Boolean(policy?.errors?.enableNewCategories), - title: 'zany@cathyscroissants.com', + title: exporter ?? policyOwner, }, { description: translate('workspace.qbo.date'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT_DATE.getRoute(policyID)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE.getRoute(policyID)), hasError: Boolean(policy?.errors?.syncClasses), title: 'Date of last expense', }, { description: translate('workspace.qbo.exportExpenses'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.getRoute(policyID)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.getRoute(policyID)), hasError: Boolean(policy?.errors?.syncCustomers), title: 'Vendor bill', }, { description: translate('workspace.qbo.exportInvoices'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_INVOICES.getRoute(policyID)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICES.getRoute(policyID)), hasError: Boolean(policy?.errors?.syncLocations), title: 'Accounts Receivable (A/R)', }, { description: translate('workspace.qbo.exportCompany'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_COMPANY_CARDS.getRoute(policyID)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARDS.getRoute(policyID)), hasError: Boolean(policy?.errors?.syncTaxes), title: 'Debit card', }, { description: translate('workspace.qbo.exportExpensifyCard'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKSONLINE_EXPORT.getRoute(policyID)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.getRoute(policyID)), hasError: Boolean(policy?.errors?.syncTaxes), title: 'Credit card', interactive: false, From 1c0d2f3b70c039cc4228f7218989f258097b677e Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Fri, 5 Apr 2024 16:59:25 +0300 Subject: [PATCH 041/339] prettier --- src/languages/es.ts | 3 ++- .../Navigation/AppNavigator/ModalStackNavigators/index.tsx | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 5d9d58c2f2b4..c0a1cf5f0ced 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1864,7 +1864,8 @@ export default { creditCard: 'Tarjeta de crédito', debitCard: 'Tarjeta de débito', vendorBill: 'Factura del proveedor', - exportPreferredExporterNote: 'Puede ser cualquier administrador del espacio de trabajo, pero debe ser un administrador de dominio si configura diferentes cuentas de exportación para tarjetas de empresa individuales en la configuración del dominio.', + exportPreferredExporterNote: + 'Puede ser cualquier administrador del espacio de trabajo, pero debe ser un administrador de dominio si configura diferentes cuentas de exportación para tarjetas de empresa individuales en la configuración del dominio.', exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en su cuenta.', }, type: { diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 0d4446b2a029..f34e9cfa642e 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -256,8 +256,10 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/qbo/QuickbooksExportInvoicesPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARDS]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportCompanyCardPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: () => require('../../../../pages/workspace/accounting/qbo/QuickBooksExportPreferredExporter').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_LIST]: () => require('../../../../pages/workspace/accounting/qbo/QuickBooksExportPreferredExporterList').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: () => + require('../../../../pages/workspace/accounting/qbo/QuickBooksExportPreferredExporter').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_LIST]: () => + require('../../../../pages/workspace/accounting/qbo/QuickBooksExportPreferredExporterList').default as React.ComponentType, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType, [SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default as React.ComponentType, [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default as React.ComponentType, From b7b53dd129075fb0c3165e64d74c23e32b1cfac5 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Fri, 5 Apr 2024 23:44:10 +0300 Subject: [PATCH 042/339] added admin-submit case --- src/libs/ReportUtils.ts | 47 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 0c9197c1796c..2cb8b205061b 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3314,9 +3314,50 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa function getIOUSubmittedMessage(report: OnyxEntry) { const policy = getPolicy(report?.policyID); - const ownerPersonalDetails = getPersonalDetailsForAccountID(policy?.submitsTo ?? 0); - let submittedToDisplayName = `${ownerPersonalDetails.displayName ?? ''}${ownerPersonalDetails.displayName !== ownerPersonalDetails.login ? ` (${ownerPersonalDetails.login})` : ''}`; - if (ownerPersonalDetails?.accountID === currentUserAccountID) { + + if (report?.ownerAccountID !== currentUserAccountID && policy.role === CONST.POLICY.ROLE.ADMIN) { + const ownerPersonalDetail = getPersonalDetailsForAccountID(report?.ownerAccountID ?? 0); + const ownerDisplayName = `${ownerPersonalDetail.displayName ?? ''}${ownerPersonalDetail.displayName !== ownerPersonalDetail.login ? ` (${ownerPersonalDetail.login})` : ''}`; + + return [ + { + style: 'normal', + text: 'You (on behalf of ', + type: CONST.REPORT.MESSAGE.TYPE.TEXT, + }, + { + style: 'strong', + text: ownerDisplayName, + type: CONST.REPORT.MESSAGE.TYPE.TEXT, + }, + { + style: 'normal', + text: ' via admin-submit)', + type: CONST.REPORT.MESSAGE.TYPE.TEXT, + }, + { + style: 'normal', + text: ' submitted this report', + type: CONST.REPORT.MESSAGE.TYPE.TEXT, + }, + { + style: 'normal', + text: ' to ', + type: CONST.REPORT.MESSAGE.TYPE.TEXT, + }, + { + style: 'strong', + text: 'you', + type: CONST.REPORT.MESSAGE.TYPE.TEXT, + }, + ]; + } + + const submittedToPersonalDetail = getPersonalDetailsForAccountID(policy?.submitsTo ?? 0); + let submittedToDisplayName = `${submittedToPersonalDetail.displayName ?? ''}${ + submittedToPersonalDetail.displayName !== submittedToPersonalDetail.login ? ` (${submittedToPersonalDetail.login})` : '' + }`; + if (submittedToPersonalDetail?.accountID === currentUserAccountID) { submittedToDisplayName = 'yourself'; } From 3dee6771460fdd8bb4eca7a80cec64f07a39ef43 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Sun, 7 Apr 2024 01:35:48 +0100 Subject: [PATCH 043/339] add fake accounting page --- .../accounting/WorkspaceAccountingPage.tsx | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/pages/workspace/accounting/WorkspaceAccountingPage.tsx diff --git a/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx b/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx new file mode 100644 index 000000000000..38d711fdcf6a --- /dev/null +++ b/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import {View} from 'react-native'; +import ScreenWrapper from '@components/ScreenWrapper'; +import withPolicy from '@pages/workspace/withPolicy'; + +// Fake page, will be removed after merging with accounting page +function WorkspaceAccountingPage() { + return ( + + + + ); +} + +WorkspaceAccountingPage.displayName = 'WorkspaceAccountingPage'; + +export default withPolicy(WorkspaceAccountingPage); \ No newline at end of file From bf28c9cdf2b13143624074a1d16d76513ca4a9ed Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Sun, 7 Apr 2024 01:36:36 +0100 Subject: [PATCH 044/339] add initial quickbooks advanced page --- .../accounting/qbo/QuickbooksAdvancedPage.tsx | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx diff --git a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx new file mode 100644 index 000000000000..cb1ccab83194 --- /dev/null +++ b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx @@ -0,0 +1,110 @@ +import React from 'react'; +import {View} from 'react-native'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import MenuItem from '@components/MenuItem'; +import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import SpacerView from '@components/SpacerView'; +import useThemeStyles from '@hooks/useThemeStyles'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; + + +function QuickbooksAdvancedPage({policy}: WithPolicyProps) { + const styles = useThemeStyles(); + + return ( + + + + + + + {}} + /> + + + + {}} + /> + + + + {}} + /> + + + + + + + + {}} + /> + + + + + + + + + + + + + + + ); +} + +QuickbooksAdvancedPage.displayName = 'QuickbooksAdvancedPage'; + +export default withPolicy(QuickbooksAdvancedPage); From 80c2e9777c155fd39865fdc382bcae8cae940f30 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Sun, 7 Apr 2024 01:39:13 +0100 Subject: [PATCH 045/339] add qbo advanced screen options --- src/SCREENS.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index fe1b1eac510f..5ea6922e9db7 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -212,6 +212,7 @@ const SCREENS = { INVOICES: 'Workspace_Invoices', TRAVEL: 'Workspace_Travel', MEMBERS: 'Workspace_Members', + ACCOUNTING: 'Workspace_Accounting', INVITE: 'Workspace_Invite', INVITE_MESSAGE: 'Workspace_Invite_Message', CATEGORIES: 'Workspace_Categories', @@ -250,6 +251,7 @@ const SCREENS = { OWNER_CHANGE_SUCCESS: 'Workspace_Owner_Change_Success', OWNER_CHANGE_ERROR: 'Workspace_Owner_Change_Error', DISTANCE_RATES: 'Distance_Rates', + QUICKBOOKS_ONLINE_ADVANCED: 'Workspace_Accounting_Quickbooks_Online_Advanced', CREATE_DISTANCE_RATE: 'Create_Distance_Rate', DISTANCE_RATES_SETTINGS: 'Distance_Rates_Settings', DISTANCE_RATE_DETAILS: 'Distance_Rate_Details', From cc91791576b5bad3db40869f5ce8bf81e133adea Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Sun, 7 Apr 2024 01:39:43 +0100 Subject: [PATCH 046/339] add qbo advanced types --- src/libs/Navigation/types.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index fefad04b9faf..fbc8340fdf57 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -606,6 +606,9 @@ type WorkspacesCentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.TRAVEL]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING]: { + policyID: string; + }; [SCREENS.WORKSPACE.MEMBERS]: { policyID: string; }; @@ -625,6 +628,9 @@ type WorkspacesCentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.DISTANCE_RATES]: { policyID: string; }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED]: { + policyID: string; + }; }; type FullScreenNavigatorParamList = { From 80c4ea0905c32a3f04ccee8db193b3883b68c156 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Sun, 7 Apr 2024 01:40:39 +0100 Subject: [PATCH 047/339] add qbo advanced routes --- src/ROUTES.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 7efc1f676f26..738be5c417bc 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -551,6 +551,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/members', getRoute: (policyID: string) => `settings/workspaces/${policyID}/members` as const, }, + WORKSPACE_ACCOUNTING: { + route: 'settings/workspaces/:policyID/accounting', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting` as const, + }, WORKSPACE_CATEGORIES: { route: 'settings/workspaces/:policyID/categories', getRoute: (policyID: string) => `settings/workspaces/${policyID}/categories` as const, @@ -575,6 +579,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/categories/:categoryName/edit', getRoute: (policyID: string, categoryName: string) => `settings/workspaces/${policyID}/categories/${encodeURIComponent(categoryName)}/edit` as const, }, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ADVANCED: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/advanced', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/advanced` as const, + }, WORKSPACE_TAGS: { route: 'settings/workspaces/:policyID/tags', getRoute: (policyID: string) => `settings/workspaces/${policyID}/tags` as const, From d1012f0e3af09c86856855c351df90b6e955bee9 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Sun, 7 Apr 2024 01:41:39 +0100 Subject: [PATCH 048/339] add qbo advanced to settings modal stack navigator --- src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index e2f51beb5f8f..3c151641e914 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -261,6 +261,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/settings/ExitSurvey/ExitSurveyReasonPage').default as React.ComponentType, [SCREENS.SETTINGS.EXIT_SURVEY.RESPONSE]: () => require('../../../../pages/settings/ExitSurvey/ExitSurveyResponsePage').default as React.ComponentType, [SCREENS.SETTINGS.EXIT_SURVEY.CONFIRM]: () => require('../../../../pages/settings/ExitSurvey/ExitSurveyConfirmPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksAdvancedPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default as React.ComponentType, From c4a7363fb7d4028ee77e370b0e6015dbf3d5c894 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Sun, 7 Apr 2024 01:43:16 +0100 Subject: [PATCH 049/339] add accounting page to modal stack navigator --- .../WorkspaceSettingsModalStackNavigator.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx index 14153809bc86..e65b5b1e0edc 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx @@ -75,6 +75,11 @@ function WorkspaceSettingsModalStackNavigator() { name={SCREENS.WORKSPACE.DISTANCE_RATES} getComponent={() => require('@pages/workspace/distanceRates/PolicyDistanceRatesPage').default as React.ComponentType} /> + require('@pages/workspace/accounting/WorkspaceAccountingPage').default as React.ComponentType} + /> ); } From 03d5cc522dcb4d00068480c4ea2c6b8d6d9e1a2e Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Sun, 7 Apr 2024 01:44:03 +0100 Subject: [PATCH 050/339] match qbo advanced screen to routes --- src/libs/Navigation/linkingConfig/config.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index c9c3efbf2e16..f50701586245 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -262,6 +262,9 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.CURRENCY]: { path: ROUTES.WORKSPACE_PROFILE_CURRENCY.route, }, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED]: { + path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ADVANCED.route, + }, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, @@ -644,6 +647,9 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.INVOICES]: { path: ROUTES.WORKSPACE_INVOICES.route, }, + [SCREENS.WORKSPACE.ACCOUNTING]: { + path: ROUTES.WORKSPACE_ACCOUNTING.route, + }, [SCREENS.WORKSPACE.TRAVEL]: { path: ROUTES.WORKSPACE_TRAVEL.route, }, From 709bf5d47e51863e1bb995c9a3bb775cf03cd020 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Sun, 7 Apr 2024 01:45:09 +0100 Subject: [PATCH 051/339] map qbo advanced screen to accouting --- .../Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 1247933701a8..8ced83fc241e 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -19,6 +19,9 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET, SCREENS.WORKSPACE.WORKFLOWS_PAYER, ], + [SCREENS.WORKSPACE.ACCOUNTING]: [ + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED, + ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, SCREENS.WORKSPACE.TAX_CREATE, From 40a763f8fb9bbae7d1b2f1503110ae07064fdd39 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Sun, 7 Apr 2024 01:46:01 +0100 Subject: [PATCH 052/339] update ToggleSettingOptionRowProps to make icons props optional --- .../workflows/ToggleSettingsOptionRow.tsx | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index da995de1d5d5..ec8cec4aaa20 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -10,7 +10,7 @@ import type IconAsset from '@src/types/utils/IconAsset'; type ToggleSettingOptionRowProps = { /** Icon to be shown for the option */ - icon: IconAsset; + icon?: IconAsset; /** Title of the option */ title: string; /** Subtitle of the option */ @@ -43,14 +43,16 @@ function ToggleSettingOptionRow({icon, title, subtitle, onToggle, subMenuItems, - + {icon && ( + + )} Date: Mon, 8 Apr 2024 14:27:23 +0700 Subject: [PATCH 053/339] fix: app shows full page notfound in ws features page --- .../workspace/AdminPolicyAccessOrNotFoundWrapper.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx b/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx index 5c8456366c6b..0b7e930f001c 100644 --- a/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx +++ b/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx @@ -11,6 +11,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type * as OnyxTypes from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; type AdminAccessOrNotFoundOnyxProps = { /** The report currently being looked at */ @@ -50,6 +51,15 @@ function AdminPolicyAccessOrNotFoundComponent(props: AdminPolicyAccessOrNotFound } if (shouldShowNotFoundPage) { + const isPolicyNotAccessible = isEmptyObject(props.policy) || !props.policy?.id; + + if (isPolicyNotAccessible) { + return Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} + /> + } return Navigation.goBack(ROUTES.WORKSPACE_PROFILE.getRoute(props.policyID))} />; } From 8804b26372646e6358bc6d7a1e7ae04c1f11ee8e Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 9 Apr 2024 00:16:02 +0700 Subject: [PATCH 054/339] fix: lint --- .../AdminPolicyAccessOrNotFoundWrapper.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx b/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx index 0b7e930f001c..5723595b7141 100644 --- a/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx +++ b/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx @@ -2,6 +2,7 @@ import React, {useEffect} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; +import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import Navigation from '@libs/Navigation/Navigation'; import * as PolicyUtils from '@libs/PolicyUtils'; @@ -11,7 +12,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type * as OnyxTypes from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; -import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; type AdminAccessOrNotFoundOnyxProps = { /** The report currently being looked at */ @@ -52,13 +52,15 @@ function AdminPolicyAccessOrNotFoundComponent(props: AdminPolicyAccessOrNotFound if (shouldShowNotFoundPage) { const isPolicyNotAccessible = isEmptyObject(props.policy) || !props.policy?.id; - + if (isPolicyNotAccessible) { - return Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} - /> + return ( + Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} + /> + ); } return Navigation.goBack(ROUTES.WORKSPACE_PROFILE.getRoute(props.policyID))} />; } From 4d8cdeb97d30a8c2cd85c6004bc8d53e37e836c7 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 07:11:29 +0100 Subject: [PATCH 055/339] add qbo online account selecetor page to navigation screens --- src/SCREENS.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 5ea6922e9db7..0e514bb76742 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -252,6 +252,7 @@ const SCREENS = { OWNER_CHANGE_ERROR: 'Workspace_Owner_Change_Error', DISTANCE_RATES: 'Distance_Rates', QUICKBOOKS_ONLINE_ADVANCED: 'Workspace_Accounting_Quickbooks_Online_Advanced', + QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR: 'Policy_Accounting_Quickbooks_Online_Account_Selector', CREATE_DISTANCE_RATE: 'Create_Distance_Rate', DISTANCE_RATES_SETTINGS: 'Distance_Rates_Settings', DISTANCE_RATE_DETAILS: 'Distance_Rate_Details', From ab7fac278c72f7b67c8b333183c86e31bd107bb6 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 07:12:32 +0100 Subject: [PATCH 056/339] add qbo online account selecetor page navigation types --- src/libs/Navigation/types.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index fbc8340fdf57..8a80a7530803 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -631,6 +631,9 @@ type WorkspacesCentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED]: { policyID: string; }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: { + policyID: string; + }; }; type FullScreenNavigatorParamList = { From a17124c8f9a8840e8637e2f6c41f880e26df8460 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 07:13:02 +0100 Subject: [PATCH 057/339] add qbo online account selecetor page route --- src/ROUTES.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 738be5c417bc..e5853315525c 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -583,6 +583,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/advanced', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/advanced` as const, }, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/account-selector', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/account-selector` as const, + }, WORKSPACE_TAGS: { route: 'settings/workspaces/:policyID/tags', getRoute: (policyID: string) => `settings/workspaces/${policyID}/tags` as const, From c1537104dc0e7b7be22a07dfc4033495a094813c Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 07:13:53 +0100 Subject: [PATCH 058/339] add qbo online account selecetor page to stack navigator --- src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 3c151641e914..9c0766e1d84c 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -262,6 +262,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/settings/ExitSurvey/ExitSurveyResponsePage').default as React.ComponentType, [SCREENS.SETTINGS.EXIT_SURVEY.CONFIRM]: () => require('../../../../pages/settings/ExitSurvey/ExitSurveyConfirmPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksAdvancedPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksAccountSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default as React.ComponentType, From cb714f4f0e3358e74f34845e614627f2b3973590 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 07:14:31 +0100 Subject: [PATCH 059/339] match qbo online account selecetor page screen to routes --- src/libs/Navigation/linkingConfig/config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index f50701586245..3e677ff0974e 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -265,6 +265,9 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED]: { path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ADVANCED.route, }, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: { + path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.route, + }, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, From d6a1251bd9dc63c75e2baffa5d5ead52f6d4357e Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 07:15:56 +0100 Subject: [PATCH 060/339] add qbo online account selecetor page to full screen to rhp mapping --- .../Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 8ced83fc241e..74cc415b84ea 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -19,9 +19,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET, SCREENS.WORKSPACE.WORKFLOWS_PAYER, ], - [SCREENS.WORKSPACE.ACCOUNTING]: [ - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED, - ], + [SCREENS.WORKSPACE.ACCOUNTING]: [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, SCREENS.WORKSPACE.TAX_CREATE, From eaf966042b0de24f2579611f871407723fdd0233 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 07:17:13 +0100 Subject: [PATCH 061/339] add qbo online account selecetor page --- .../qbo/QuickbooksAccountSelectPage.tsx | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx diff --git a/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx new file mode 100644 index 000000000000..7828cdb77ee1 --- /dev/null +++ b/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx @@ -0,0 +1,81 @@ +import React, {useCallback, useMemo, useState} from 'react'; +import {View} from 'react-native'; +import type {ValueOf} from 'type-fest'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import Text from '@components/Text'; +import useThemeStyles from '@hooks/useThemeStyles'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; + +const QBO_ONLINE_ACCOUNT_SELECTOR_OPTIONS = { + CROISSANT_CO_PAYROLL_ACCOUNT: 'Croissant Co Payroll Account', + CROISSANT_CO_MONEY_IN_CLEARING: 'Croissant Co Money in Clearing', + CROISSANT_CO_DEBTS_AND_LOANS: 'Croissant Co Debts and Loans', +}; + +type CustomSelectorTypes = ValueOf; + +type SelectorType = { + value: CustomSelectorTypes; + text: string; + keyForList: string; + isSelected: boolean; +}; + +function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { + const styles = useThemeStyles(); + + const [selectedAccount, setSelectedAccount] = useState('Croissant Co Payroll Account'); + + const qboOnlineSelectorOptions = useMemo( + () => + Object.entries(QBO_ONLINE_ACCOUNT_SELECTOR_OPTIONS).map(([key, value]) => ({ + value, + text: value, + keyForList: key, + isSelected: selectedAccount === value, + })), + [selectedAccount], + ); + + const showQBOOnlineSelectorOptions = useCallback( + () => + qboOnlineSelectorOptions.map((item) => ( + + setSelectedAccount(item.value)} + showTooltip={false} + isFocused={item.isSelected} + /> + + )), + [qboOnlineSelectorOptions, setSelectedAccount], + ); + + return ( + + + + + + As you've enabled sync reimbursed reports, you will need select the bank account your reimbursements are coming out of, and we'll create the payment in + QuickBooks. + + + {showQBOOnlineSelectorOptions()} + + ); +} + +QuickbooksAccountSelectPage.displayName = 'QuickbooksAccountSelectPage'; + +export default withPolicy(QuickbooksAccountSelectPage); From 94fbca4c059c9b461befb7797a194a4ea1adc7f4 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 07:17:38 +0100 Subject: [PATCH 062/339] fix lint --- ios/Podfile.lock | 2 +- .../WorkspaceSettingsModalStackNavigator.tsx | 2 +- .../accounting/WorkspaceAccountingPage.tsx | 2 +- .../accounting/qbo/QuickbooksAdvancedPage.tsx | 40 +++++++++---------- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 32a8bca75bcd..94bd6e35f31d 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1921,7 +1921,7 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: 9f26224fce1233ffdad9fa4e56863e3de2190dc0 - Yoga: e64aa65de36c0832d04e8c7bd614396c77a80047 + Yoga: 13c8ef87792450193e117976337b8527b49e8c03 PODFILE CHECKSUM: a431c146e1501391834a2f299a74093bac53b530 diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx index e65b5b1e0edc..bafce9f42128 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx @@ -75,7 +75,7 @@ function WorkspaceSettingsModalStackNavigator() { name={SCREENS.WORKSPACE.DISTANCE_RATES} getComponent={() => require('@pages/workspace/distanceRates/PolicyDistanceRatesPage').default as React.ComponentType} /> - require('@pages/workspace/accounting/WorkspaceAccountingPage').default as React.ComponentType} diff --git a/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx b/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx index 38d711fdcf6a..a96961549c97 100644 --- a/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx +++ b/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx @@ -18,4 +18,4 @@ function WorkspaceAccountingPage() { WorkspaceAccountingPage.displayName = 'WorkspaceAccountingPage'; -export default withPolicy(WorkspaceAccountingPage); \ No newline at end of file +export default withPolicy(WorkspaceAccountingPage); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx index cb1ccab83194..018916428d03 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx @@ -12,7 +12,6 @@ import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; - function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); @@ -22,35 +21,32 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { shouldEnableMaxHeight testID={QuickbooksAdvancedPage.displayName} > - - + {}} /> {}} /> {}} /> @@ -64,17 +60,17 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { {}} /> @@ -87,15 +83,15 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { Date: Tue, 9 Apr 2024 07:35:14 +0100 Subject: [PATCH 063/339] add qbo online invoice account selecetor page to navigation screens --- src/SCREENS.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 0e514bb76742..fbd4d86c89e8 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -253,6 +253,7 @@ const SCREENS = { DISTANCE_RATES: 'Distance_Rates', QUICKBOOKS_ONLINE_ADVANCED: 'Workspace_Accounting_Quickbooks_Online_Advanced', QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR: 'Policy_Accounting_Quickbooks_Online_Account_Selector', + QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR: 'Policy_Accounting_Quickbooks_Online_Invoice_Account_Selector', CREATE_DISTANCE_RATE: 'Create_Distance_Rate', DISTANCE_RATES_SETTINGS: 'Distance_Rates_Settings', DISTANCE_RATE_DETAILS: 'Distance_Rate_Details', From 65f3b501088a69e7f93cc9e6cbbe905e86ecc2d6 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 07:35:51 +0100 Subject: [PATCH 064/339] add qbo online invoice account selecetor page navigation types --- src/libs/Navigation/types.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 8a80a7530803..9aae4fe36010 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -634,6 +634,9 @@ type WorkspacesCentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: { policyID: string; }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR]: { + policyID: string; + }; }; type FullScreenNavigatorParamList = { From 0a8f5b8f8dfea6ba1244a25409cb07e009a09bff Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 07:36:45 +0100 Subject: [PATCH 065/339] add qbo online invoice account selecetor page route --- src/ROUTES.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index e5853315525c..8ff0eadba008 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -587,6 +587,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/account-selector', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/account-selector` as const, }, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/invoice-account-selector', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/invoice-account-selector` as const, + }, WORKSPACE_TAGS: { route: 'settings/workspaces/:policyID/tags', getRoute: (policyID: string) => `settings/workspaces/${policyID}/tags` as const, From b09eea1db24c74d81d9d2c01f1cdd8f7a5a1d531 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 07:37:29 +0100 Subject: [PATCH 066/339] add qbo online invoice account selecetor page to stack navigator --- src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 9c0766e1d84c..6399951add07 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -263,6 +263,8 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/settings/ExitSurvey/ExitSurveyConfirmPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksAdvancedPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksAccountSelectPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR]: () => + require('../../../../pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default as React.ComponentType, From 1502d77730137fe9615408b96b6c493c58bc88e8 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 07:38:07 +0100 Subject: [PATCH 067/339] match qbo online invoice account selecetor page screen to routes --- src/libs/Navigation/linkingConfig/config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 3e677ff0974e..796c671c713e 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -268,6 +268,9 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: { path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.route, }, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR]: { + path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR.route, + }, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, From c4918a9b85f0e5cf6308410fc2051813de499321 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 07:38:43 +0100 Subject: [PATCH 068/339] add qbo online invoice account selecetor page to full screen to rhp mapping --- .../Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 74cc415b84ea..0daf26df9df1 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -19,7 +19,11 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET, SCREENS.WORKSPACE.WORKFLOWS_PAYER, ], - [SCREENS.WORKSPACE.ACCOUNTING]: [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR], + [SCREENS.WORKSPACE.ACCOUNTING]: [ + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR, + ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, SCREENS.WORKSPACE.TAX_CREATE, From 80b7af1ffd029c5b271d25593300d7a148ba4e57 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 07:39:14 +0100 Subject: [PATCH 069/339] add qbo online invoice account selecetor page --- .../QuickbooksInvoiceAccountSelectPage.tsx | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx diff --git a/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx new file mode 100644 index 000000000000..3d7c8ab2f903 --- /dev/null +++ b/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx @@ -0,0 +1,80 @@ +import React, {useCallback, useMemo, useState} from 'react'; +import {View} from 'react-native'; +import type {ValueOf} from 'type-fest'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import Text from '@components/Text'; +import useThemeStyles from '@hooks/useThemeStyles'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; + +const QBO_ONLINE_INVOICE_ACCOUNT_SELECTOR_OPTIONS = { + CROISSANT_CO_PAYROLL_ACCOUNT: 'Croissant Co Payroll Account', + CROISSANT_CO_MONEY_IN_CLEARING: 'Croissant Co Money in Clearing', + CROISSANT_CO_DEBTS_AND_LOANS: 'Croissant Co Debts and Loans', +}; + +type CustomSelectorTypes = ValueOf; + +type SelectorType = { + value: CustomSelectorTypes; + text: string; + keyForList: string; + isSelected: boolean; +}; + +function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { + const styles = useThemeStyles(); + + const [selectedAccount, setSelectedAccount] = useState('Croissant Co Payroll Account'); + + const qboOnlineSelectorOptions = useMemo( + () => + Object.entries(QBO_ONLINE_INVOICE_ACCOUNT_SELECTOR_OPTIONS).map(([key, value]) => ({ + value, + text: value, + keyForList: key, + isSelected: selectedAccount === value, + })), + [selectedAccount], + ); + + const showQBOOnlineSelectorOptions = useCallback( + () => + qboOnlineSelectorOptions.map((item) => ( + + setSelectedAccount(item.value)} + showTooltip={false} + isFocused={item.isSelected} + /> + + )), + [qboOnlineSelectorOptions, setSelectedAccount], + ); + + return ( + + + + + + If you are exporting Invoices from Expensify to Quickbooks Online, this is the account the Invoice will appear against once marked as Paid. + + + {showQBOOnlineSelectorOptions()} + + ); +} + +QuickbooksInvoiceAccountSelectPage.displayName = 'QuickbooksInvoiceAccountSelectPage'; + +export default withPolicy(QuickbooksInvoiceAccountSelectPage); From 20814b7b59814f394773f4db1ac195542ed4dd5f Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Tue, 9 Apr 2024 10:17:31 +0300 Subject: [PATCH 070/339] icon button --- .../accounting/qbo/QuickbooksExportCompanyCardsPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx index 87c442629c4d..3b7f61efef13 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx @@ -32,6 +32,7 @@ function QuickbooksExportCompanyCardsPage({policy}: WithPolicyProps) { description={translate('workspace.qbo.exportAs')} onPress={() => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD.getRoute(policyID))} brickRoadIndicator={undefined} + shouldShowRightIcon /> From 69cfe20b8e6794d1e2ca8dc2c072e6d66ad30446 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 9 Apr 2024 20:43:38 +0700 Subject: [PATCH 071/339] Get correct transaction data in ReportActionItem --- src/pages/home/report/ReportActionItem.tsx | 13 +++++++++---- src/pages/home/report/ReportActionsList.tsx | 6 ++++++ .../home/report/ReportActionsListItemRenderer.tsx | 5 +++++ src/pages/home/report/ReportActionsView.tsx | 11 ++++++++--- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index e3e32f398fb6..5391db6d59ea 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -120,6 +120,11 @@ type ReportActionItemProps = { /** Report action belonging to the report's parent */ parentReportAction: OnyxEntry; + /** The transaction thread report's parentReportAction */ + /** It's used by withOnyx HOC */ + // eslint-disable-next-line react/no-unused-prop-types + parentReportActionForTransactionThread: OnyxEntry; + /** All the data of the action item */ action: OnyxTypes.ReportAction; @@ -939,10 +944,10 @@ export default withOnyx({ key: ONYXKEYS.USER_WALLET, }, transaction: { - key: ({transactionThreadReport, reportActions}) => { - const parentReportActionID = isEmptyObject(transactionThreadReport) ? '0' : transactionThreadReport.parentReportActionID; - const action = reportActions?.find((reportAction) => reportAction.reportActionID === parentReportActionID); - const transactionID = (action as OnyxTypes.OriginalMessageIOU)?.originalMessage.IOUTransactionID ? (action as OnyxTypes.OriginalMessageIOU).originalMessage.IOUTransactionID : 0; + key: ({parentReportActionForTransactionThread}) => { + const transactionID = (parentReportActionForTransactionThread as OnyxTypes.OriginalMessageIOU)?.originalMessage.IOUTransactionID + ? (parentReportActionForTransactionThread as OnyxTypes.OriginalMessageIOU).originalMessage.IOUTransactionID + : 0; return `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`; }, }, diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index d1b9c420b0af..210867100d3c 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -50,6 +50,9 @@ type ReportActionsListProps = WithCurrentUserPersonalDetailsProps & { /** The report's parentReportAction */ parentReportAction: OnyxEntry; + /** The transaction thread report's parentReportAction */ + parentReportActionForTransactionThread: OnyxEntry; + /** Sorted actions prepared for display */ sortedReportActions: OnyxTypes.ReportAction[]; @@ -148,6 +151,7 @@ function ReportActionsList({ listID, onContentSizeChange, shouldEnableAutoScrollToTopThreshold, + parentReportActionForTransactionThread, }: ReportActionsListProps) { const personalDetailsList = usePersonalDetails() || CONST.EMPTY_OBJECT; const styles = useThemeStyles(); @@ -524,6 +528,7 @@ function ReportActionsList({ reportAction={reportAction} reportActions={reportActions} parentReportAction={parentReportAction} + parentReportActionForTransactionThread={parentReportActionForTransactionThread} index={index} report={report} transactionThreadReport={transactionThreadReport} @@ -546,6 +551,7 @@ function ReportActionsList({ parentReportAction, reportActions, transactionThreadReport, + parentReportActionForTransactionThread, ], ); diff --git a/src/pages/home/report/ReportActionsListItemRenderer.tsx b/src/pages/home/report/ReportActionsListItemRenderer.tsx index 263415d90c39..32ca9861d7d0 100644 --- a/src/pages/home/report/ReportActionsListItemRenderer.tsx +++ b/src/pages/home/report/ReportActionsListItemRenderer.tsx @@ -17,6 +17,9 @@ type ReportActionsListItemRendererProps = { /** The report's parentReportAction */ parentReportAction: OnyxEntry; + /** The transaction thread report's parentReportAction */ + parentReportActionForTransactionThread: OnyxEntry; + /** Position index of the report action in the overall report FlatList view */ index: number; @@ -58,6 +61,7 @@ function ReportActionsListItemRenderer({ shouldDisplayNewMarker, linkedReportActionID = '', shouldDisplayReplyDivider, + parentReportActionForTransactionThread, }: ReportActionsListItemRendererProps) { const shouldDisplayParentAction = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED && ReportUtils.isChatThread(report) && !ReportActionsUtils.isTransactionThread(parentReportAction); @@ -145,6 +149,7 @@ function ReportActionsListItemRenderer({ parentReportAction={parentReportAction} report={report} transactionThreadReport={transactionThreadReport} + parentReportActionForTransactionThread={parentReportActionForTransactionThread} action={action} reportActions={reportActions} linkedReportActionID={linkedReportActionID} diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 6040c1e67212..7eb355ef3e85 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -137,20 +137,24 @@ function ReportActionsView({ // Get a sorted array of reportActions for both the current report and the transaction thread report associated with this report (if there is one) // so that we display transaction-level and report-level report actions in order in the one-transaction view - const combinedReportActions = useMemo(() => { + const [combinedReportActions, parentReportActionForTransactionThread] = useMemo(() => { if (isEmptyObject(transactionThreadReportActions)) { - return allReportActions; + return [allReportActions, null]; } // Filter out the created action from the transaction thread report actions, since we already have the parent report's created action in `reportActions` const filteredTransactionThreadReportActions = transactionThreadReportActions?.filter((action) => action.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED); + const moneyRequestAction = allReportActions.find((action) => { + const actionType = (action as OnyxTypes.OriginalMessageIOU).originalMessage?.type ?? ''; + return actionType === CONST.IOU.REPORT_ACTION_TYPE.CREATE || actionType === CONST.IOU.REPORT_ACTION_TYPE.TRACK || !ReportActionsUtils.isSentMoneyReportAction(action); + }); // Filter out the money request actions because we don't want to show any preview actions for one-transaction reports const filteredReportActions = [...allReportActions, ...filteredTransactionThreadReportActions].filter((action) => { const actionType = (action as OnyxTypes.OriginalMessageIOU).originalMessage?.type ?? ''; return actionType !== CONST.IOU.REPORT_ACTION_TYPE.CREATE && actionType !== CONST.IOU.REPORT_ACTION_TYPE.TRACK && !ReportActionsUtils.isSentMoneyReportAction(action); }); - return ReportActionsUtils.getSortedReportActions(filteredReportActions, true); + return [ReportActionsUtils.getSortedReportActions(filteredReportActions, true), moneyRequestAction ?? null]; }, [allReportActions, transactionThreadReportActions]); const indexOfLinkedAction = useMemo(() => { @@ -517,6 +521,7 @@ function ReportActionsView({ transactionThreadReport={transactionThreadReport} reportActions={reportActions} parentReportAction={parentReportAction} + parentReportActionForTransactionThread={parentReportActionForTransactionThread} onLayout={recordTimeToMeasureItemLayout} sortedReportActions={reportActionsToDisplay} mostRecentIOUReportActionID={mostRecentIOUReportActionID} From 05d28691529464ca89d95dd72492469a8c128f84 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Tue, 9 Apr 2024 18:41:01 +0300 Subject: [PATCH 072/339] renaming pages + correct routes + initial Expenses config page --- src/ROUTES.ts | 36 ++++++------ src/SCREENS.ts | 11 ++-- src/languages/en.ts | 3 + src/languages/es.ts | 3 + .../ModalStackNavigators/index.tsx | 21 ++++--- .../FULL_SCREEN_TO_RHP_MAPPING.ts | 11 ++-- src/libs/Navigation/linkingConfig/config.ts | 13 +++-- src/libs/Navigation/types.ts | 13 +++-- ...ksCompanyCardExpenseAccountSelectPage.tsx} | 8 +-- ...ksCompanyCardExpenseConfigurationPage.tsx} | 10 ++-- ... => QuickbooksExportConfigurationPage.tsx} | 16 +++--- ...tsx => QuickbooksExportDateSelectPage.tsx} | 8 +-- ...=> QuickbooksInvoiceAccountSelectPage.tsx} | 8 +-- ...oksOutOfPocketExpenseConfigurationPage.tsx | 55 +++++++++++++++++++ ...oksPreferredExporterConfigurationPage.tsx} | 2 +- ...QuickbooksPreferredExporterSelectPage.tsx} | 0 16 files changed, 148 insertions(+), 70 deletions(-) rename src/pages/workspace/accounting/qbo/{QuickbooksExportCompanyCardPage.tsx => QuickbooksCompanyCardExpenseAccountSelectPage.tsx} (87%) rename src/pages/workspace/accounting/qbo/{QuickbooksExportCompanyCardsPage.tsx => QuickbooksCompanyCardExpenseConfigurationPage.tsx} (79%) rename src/pages/workspace/accounting/qbo/{QuickbooksExportPage.tsx => QuickbooksExportConfigurationPage.tsx} (89%) rename src/pages/workspace/accounting/qbo/{QuickbooksExportDatePage.tsx => QuickbooksExportDateSelectPage.tsx} (89%) rename src/pages/workspace/accounting/qbo/{QuickbooksExportInvoicesPage.tsx => QuickbooksInvoiceAccountSelectPage.tsx} (86%) create mode 100644 src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseConfigurationPage.tsx rename src/pages/workspace/accounting/qbo/{QuickBooksExportPreferredExporter.tsx => QuickbooksPreferredExporterConfigurationPage.tsx} (96%) rename src/pages/workspace/accounting/qbo/{QuickBooksExportPreferredExporterList.tsx => QuickbooksPreferredExporterSelectPage.tsx} (100%) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index dd4d63b0de03..b19be3b0adf3 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -458,25 +458,33 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARDS: { - route: 'settings/workspaces/:policyID/accounting/quickbooks-online/company-cards', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/company-cards` as const, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/company-card-expense', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/company-card-expense` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD: { - route: 'settings/workspaces/:policyID/accounting/quickbooks-online/company-card', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/company-card` as const, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/company-card-expense-account-select', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/company-card-expense-account-select` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICES: { - route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/invoices', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/invoices` as const, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/invoice-account-select', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/invoice-account-select` as const, }, WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/preferred-exporter', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/preferred-exporter` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_LIST: { - route: 'settings/workspaces/:policyID/accounting/quickbooks-online/preferred-exporter-list', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/preferred-exporter-list` as const, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_SELECT: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/preferred-exporter/select', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/preferred-exporter/select` as const, + }, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/out-of-pocket-expense', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/out-of-pocket-expense` as const, + }, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/date-select', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/date-select` as const, }, WORKSPACE_PROFILE_NAME: { route: 'settings/workspaces/:policyID/profile/name', @@ -683,10 +691,6 @@ const ROUTES = { route: 'settings/workspaces/:policyID/distance-rates/:rateID/edit', getRoute: (policyID: string, rateID: string) => `settings/workspaces/${policyID}/distance-rates/${rateID}/edit` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE: { - route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/date', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/date` as const, - }, // Referral program promotion REFERRAL_DETAILS_MODAL: { route: 'referral/:contentType', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 59a9a431008a..0d6694b301b9 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -249,12 +249,13 @@ const SCREENS = { DISTANCE_RATES_SETTINGS: 'Distance_Rates_Settings', DISTANCE_RATE_DETAILS: 'Distance_Rate_Details', QUICKBOOKS_ONLINE_EXPORT: 'Workspace_Accounting_Quickbooks_Online_Export', - QUICKBOOKS_ONLINE_EXPORT_DATE: 'Workspace_Accounting_Quickbooks_Online_Export_Date', - QUICKBOOKS_ONLINE_EXPORT_INVOICES: 'Workspace_Accounting_Quickbooks_Online_Export_Invoices', - QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARDS: 'Workspace_Accounting_Quickbooks_Online_Export_Company_Cards', - QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD: 'Workspace_Accounting_Quickbooks_Online_Export_Company_Card', + QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Date_Select', + QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Invoice_Account_Select', + QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE: 'Workspace_Accounting_Quickbooks_Online_Export_Company_Card_Expense', + QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Company_Card_Expense_Select', QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter', - QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_LIST: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter_List', + QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter_Select', + QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses', DISTANCE_RATE_EDIT: 'Distance_Rate_Edit', }, diff --git a/src/languages/en.ts b/src/languages/en.ts index d68efc4e5e7a..0950a56e355b 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1844,6 +1844,9 @@ export default { vendorBill: 'Vendor Bill', exportPreferredExporterNote: 'This can be any workspace admin, but must be a Domain Admin if you set different export accounts for individual company cards in Domain Settings.', exportPreferredExporterSubNote: 'Once set, the preferred exporter will see reports for export in their account.', + exportOutOfPocketExpensesDescription: 'Set how out-of-pocket expenses export to QuickBooks Online.', + exportVendorBillDescription: + 'We’ll create a single itemized vendor bill for each Expensify report. If the period of the bill is closed, we’ll post to the 1st of the next open period. You can add the vendor bill to your A/P account of choice (below).', }, categories: { deleteCategories: 'Delete categories', diff --git a/src/languages/es.ts b/src/languages/es.ts index c0a1cf5f0ced..f98773c15fdf 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1867,6 +1867,9 @@ export default { exportPreferredExporterNote: 'Puede ser cualquier administrador del espacio de trabajo, pero debe ser un administrador de dominio si configura diferentes cuentas de exportación para tarjetas de empresa individuales en la configuración del dominio.', exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en su cuenta.', + exportOutOfPocketExpensesDescription: 'Establezca cómo se exportan los gastos de bolsillo a QuickBooks Online.', + exportVendorBillDescription: + 'Crearemos una única factura de proveedor detallada para cada informe de Expensify. Si el período de la factura está cerrado, lo publicaremos en el día 1 del próximo período abierto. Puede agregar la factura del proveedor a la cuenta A/P de su elección (a continuación).', }, type: { free: 'Gratis', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index f34e9cfa642e..7229ff3b3a0b 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -251,15 +251,20 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsCustomTaxName').default as React.ComponentType, [SCREENS.WORKSPACE.TAXES_SETTINGS_FOREIGN_CURRENCY_DEFAULT]: () => require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsForeignCurrency').default as React.ComponentType, [SCREENS.WORKSPACE.TAXES_SETTINGS_WORKSPACE_CURRENCY_DEFAULT]: () => require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsWorkspaceCurrency').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportDatePage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICES]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportInvoicesPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARDS]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportCompanyCardPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportDateSelectPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: () => + require('../../../../pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: () => + require('../../../../pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE]: () => + require('../../../../pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: () => + require('../../../../pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseAccountSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: () => - require('../../../../pages/workspace/accounting/qbo/QuickBooksExportPreferredExporter').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_LIST]: () => - require('../../../../pages/workspace/accounting/qbo/QuickBooksExportPreferredExporterList').default as React.ComponentType, + require('../../../../pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT]: () => + require('../../../../pages/workspace/accounting/qbo/QuickbooksPreferredExporterSelectPage').default as React.ComponentType, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType, [SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default as React.ComponentType, [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index ba4a1cb7cb38..2cd1736bb003 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -21,12 +21,13 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { ], [SCREENS.WORKSPACE.ACCOUNTING]: [ SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICES, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARDS, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_LIST, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES, ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 9e700d7f66ca..966f1a065615 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -233,12 +233,15 @@ const config: LinkingOptions['config'] = { path: ROUTES.WORKSPACE_PROFILE_CURRENCY.route, }, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.route}, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE.route}, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICES]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICES.route}, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARDS]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARDS.route}, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: { + path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.route, + }, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.route}, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_LIST]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_LIST.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_SELECT.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 89ecb38b66e5..ebbd5f84867a 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -249,22 +249,25 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE]: { + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICES]: { + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARDS]: { + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD]: { + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE]: { + policyID: string; + }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: { policyID: string; }; [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_LIST]: { + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT]: { policyID: string; }; [SCREENS.GET_ASSISTANCE]: { diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseAccountSelectPage.tsx similarity index 87% rename from src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardPage.tsx rename to src/pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index eabdbed2e661..6925dde83b8c 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -15,7 +15,7 @@ const CARDS = { VENDOR_BILL: 'vendor_bill', }; -function QuickbooksExportCompanyCardPage({policy}: WithPolicyProps) { +function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const {nonReimbursableExpensesExportDestination} = policy?.connections?.quickbooksOnline?.config ?? {}; @@ -49,7 +49,7 @@ function QuickbooksExportCompanyCardPage({policy}: WithPolicyProps) { @@ -64,6 +64,6 @@ function QuickbooksExportCompanyCardPage({policy}: WithPolicyProps) { ); } -QuickbooksExportCompanyCardPage.displayName = 'QuickbooksExportCompanyCardPage'; +QuickbooksCompanyCardExpenseAccountSelectPage.displayName = 'QuickbooksCompanyCardExpenseAccountSelectPage'; -export default withPolicy(QuickbooksExportCompanyCardPage); +export default withPolicy(QuickbooksCompanyCardExpenseAccountSelectPage); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseConfigurationPage.tsx similarity index 79% rename from src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx rename to src/pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseConfigurationPage.tsx index 3b7f61efef13..83b967d99ab0 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksExportCompanyCardsPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseConfigurationPage.tsx @@ -12,7 +12,7 @@ import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import ROUTES from '@src/ROUTES'; -function QuickbooksExportCompanyCardsPage({policy}: WithPolicyProps) { +function QuickbooksCompanyCardExpenseConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; @@ -21,7 +21,7 @@ function QuickbooksExportCompanyCardsPage({policy}: WithPolicyProps) { @@ -30,7 +30,7 @@ function QuickbooksExportCompanyCardsPage({policy}: WithPolicyProps) { Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD.getRoute(policyID))} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID))} brickRoadIndicator={undefined} shouldShowRightIcon /> @@ -40,6 +40,6 @@ function QuickbooksExportCompanyCardsPage({policy}: WithPolicyProps) { ); } -QuickbooksExportCompanyCardsPage.displayName = 'QuickbooksExportCompanyCardsPage'; +QuickbooksCompanyCardExpenseConfigurationPage.displayName = 'QuickbooksCompanyCardExpenseConfigurationPage'; -export default withPolicy(QuickbooksExportCompanyCardsPage); +export default withPolicy(QuickbooksCompanyCardExpenseConfigurationPage); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksExportConfigurationPage.tsx similarity index 89% rename from src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx rename to src/pages/workspace/accounting/qbo/QuickbooksExportConfigurationPage.tsx index eb95eb93b06a..3bf77f4f3500 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksExportPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksExportConfigurationPage.tsx @@ -15,7 +15,7 @@ import * as Link from '@userActions/Link'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; -function QuickbooksExportPage({policy}: WithPolicyProps) { +function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; @@ -31,25 +31,25 @@ function QuickbooksExportPage({policy}: WithPolicyProps) { }, { description: translate('workspace.qbo.date'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE.getRoute(policyID)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.getRoute(policyID)), hasError: Boolean(policy?.errors?.syncClasses), title: 'Date of last expense', }, { description: translate('workspace.qbo.exportExpenses'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.getRoute(policyID)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)), hasError: Boolean(policy?.errors?.syncCustomers), title: 'Vendor bill', }, { description: translate('workspace.qbo.exportInvoices'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICES.getRoute(policyID)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.getRoute(policyID)), hasError: Boolean(policy?.errors?.syncLocations), title: 'Accounts Receivable (A/R)', }, { description: translate('workspace.qbo.exportCompany'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARDS.getRoute(policyID)), + action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE.getRoute(policyID)), hasError: Boolean(policy?.errors?.syncTaxes), title: 'Debit card', }, @@ -66,7 +66,7 @@ function QuickbooksExportPage({policy}: WithPolicyProps) { @@ -101,6 +101,6 @@ function QuickbooksExportPage({policy}: WithPolicyProps) { ); } -QuickbooksExportPage.displayName = 'QuickbooksExportPage'; +QuickbooksExportConfigurationPage.displayName = 'QuickbooksExportConfigurationPage'; -export default withPolicy(QuickbooksExportPage); +export default withPolicy(QuickbooksExportConfigurationPage); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportDatePage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksExportDateSelectPage.tsx similarity index 89% rename from src/pages/workspace/accounting/qbo/QuickbooksExportDatePage.tsx rename to src/pages/workspace/accounting/qbo/QuickbooksExportDateSelectPage.tsx index 93f26155fb77..3c0200ab116e 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksExportDatePage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksExportDateSelectPage.tsx @@ -12,7 +12,7 @@ import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; -function QuickbooksExportDatePage({policy}: WithPolicyProps) { +function QuickbooksExportDateSelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); // const policyID = policy?.id ?? ''; @@ -40,7 +40,7 @@ function QuickbooksExportDatePage({policy}: WithPolicyProps) { @@ -56,6 +56,6 @@ function QuickbooksExportDatePage({policy}: WithPolicyProps) { ); } -QuickbooksExportDatePage.displayName = 'QuickbooksExportDatePage'; +QuickbooksExportDateSelectPage.displayName = 'QuickbooksExportDateSelectPage'; -export default withPolicy(QuickbooksExportDatePage); +export default withPolicy(QuickbooksExportDateSelectPage); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportInvoicesPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx similarity index 86% rename from src/pages/workspace/accounting/qbo/QuickbooksExportInvoicesPage.tsx rename to src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx index 2fd407faa8c1..430c59059676 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksExportInvoicesPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx @@ -10,7 +10,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; -function QuickbooksExportInvoicesPage({policy}: WithPolicyProps) { +function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); // const policyID = policy?.id ?? ''; @@ -37,7 +37,7 @@ function QuickbooksExportInvoicesPage({policy}: WithPolicyProps) { @@ -53,6 +53,6 @@ function QuickbooksExportInvoicesPage({policy}: WithPolicyProps) { ); } -QuickbooksExportInvoicesPage.displayName = 'QuickbooksExportInvoicesPage'; +QuickbooksInvoiceAccountSelectPage.displayName = 'QuickbooksInvoiceAccountSelectPage'; -export default withPolicy(QuickbooksExportInvoicesPage); +export default withPolicy(QuickbooksInvoiceAccountSelectPage); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseConfigurationPage.tsx new file mode 100644 index 000000000000..4d585fe34d31 --- /dev/null +++ b/src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseConfigurationPage.tsx @@ -0,0 +1,55 @@ +import React from 'react'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@navigation/Navigation'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import ROUTES from '@src/ROUTES'; + +const isVendorBill = true; +function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const policyID = policy?.id ?? ''; + + return ( + + + + {translate('workspace.qbo.exportOutOfPocketExpensesDescription')} + + Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID))} + brickRoadIndicator={undefined} + shouldShowRightIcon + /> + + {isVendorBill && {translate('workspace.qbo.exportVendorBillDescription')}} + + Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID))} + brickRoadIndicator={undefined} + shouldShowRightIcon + /> + + + + ); +} + +QuickbooksOutOfPocketExpenseConfigurationPage.displayName = 'QuickbooksExportOutOfPocketExpensesPage'; + +export default withPolicy(QuickbooksOutOfPocketExpenseConfigurationPage); diff --git a/src/pages/workspace/accounting/qbo/QuickBooksExportPreferredExporter.tsx b/src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage.tsx similarity index 96% rename from src/pages/workspace/accounting/qbo/QuickBooksExportPreferredExporter.tsx rename to src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage.tsx index ffd593591fe2..6127a0626e74 100644 --- a/src/pages/workspace/accounting/qbo/QuickBooksExportPreferredExporter.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage.tsx @@ -33,7 +33,7 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_LIST.getRoute(policyID))} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_SELECT.getRoute(policyID))} brickRoadIndicator={undefined} /> diff --git a/src/pages/workspace/accounting/qbo/QuickBooksExportPreferredExporterList.tsx b/src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterSelectPage.tsx similarity index 100% rename from src/pages/workspace/accounting/qbo/QuickBooksExportPreferredExporterList.tsx rename to src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterSelectPage.tsx From 3fbe52e4eaa8d7adf55f9debd8b747c73bbc8f58 Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Tue, 9 Apr 2024 21:31:06 +0530 Subject: [PATCH 073/339] Enable editing of Track expense --- src/components/AttachmentModal.tsx | 9 +++++-- .../ReportActionItem/MoneyRequestView.tsx | 23 +++++++++-------- src/libs/ReportUtils.ts | 12 ++++++--- src/libs/actions/IOU.ts | 25 +++++++++++++++---- src/pages/TransactionReceiptPage.tsx | 2 ++ 5 files changed, 50 insertions(+), 21 deletions(-) diff --git a/src/components/AttachmentModal.tsx b/src/components/AttachmentModal.tsx index c915b2f227aa..eb6178d49cee 100755 --- a/src/components/AttachmentModal.tsx +++ b/src/components/AttachmentModal.tsx @@ -100,6 +100,9 @@ type AttachmentModalProps = AttachmentModalOnyxProps & { /** Determines if download Button should be shown or not */ allowDownload?: boolean; + /** Determines if the receipt comes from track expense action */ + isTrackExpenseAction?: boolean; + /** Title shown in the header of the modal */ headerTitle?: string; @@ -145,6 +148,7 @@ function AttachmentModal({ originalFileName = '', isAuthTokenRequired = false, allowDownload = false, + isTrackExpenseAction = false, report, onModalShow = () => {}, onModalHide = () => {}, @@ -181,6 +185,7 @@ function AttachmentModal({ const nope = useSharedValue(false); const {windowWidth, isSmallScreenWidth} = useWindowDimensions(); const isOverlayModalVisible = (isReceiptAttachment && isDeleteReceiptConfirmModalVisible) || (!isReceiptAttachment && isAttachmentInvalid); + const iouType = useMemo(() => isTrackExpenseAction ? CONST.IOU.TYPE.TRACK_EXPENSE : CONST.IOU.TYPE.REQUEST, [isTrackExpenseAction]); const [file, setFile] = useState( originalFileName @@ -422,7 +427,7 @@ function AttachmentModal({ Navigation.navigate( ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( CONST.IOU.ACTION.EDIT, - CONST.IOU.TYPE.REQUEST, + iouType, transaction?.transactionID ?? '', report?.reportID ?? '', Navigation.getActiveRouteWithoutParams(), @@ -449,7 +454,7 @@ function AttachmentModal({ } return menuItems; // eslint-disable-next-line react-hooks/exhaustive-deps - }, [isReceiptAttachment, parentReport, parentReportActions, policy, transaction, file, sourceState]); + }, [isReceiptAttachment, parentReport, parentReportActions, policy, transaction, file, sourceState, iouType]); // There are a few things that shouldn't be set until we absolutely know if the file is a receipt or an attachment. // props.isReceiptAttachment will be null until its certain what the file is, in which case it will then be true|false. diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index dd34d0ca2540..cd4a1f8d60d7 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -150,6 +150,9 @@ function MoneyRequestView({ const policyTagLists = useMemo(() => PolicyUtils.getTagLists(policyTagList), [policyTagList]); + const isTrackExpense = ReportUtils.isTrackExpenseReport(report); + const iouType = isTrackExpense ? CONST.IOU.TYPE.TRACK_EXPENSE : CONST.IOU.TYPE.REQUEST; + // Flags for showing categories and tags // transactionCategory can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing @@ -297,7 +300,7 @@ function MoneyRequestView({ Navigation.navigate( ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( CONST.IOU.ACTION.EDIT, - CONST.IOU.TYPE.REQUEST, + iouType, transaction?.transactionID ?? '', report.reportID, Navigation.getActiveRouteWithoutParams(), @@ -317,7 +320,7 @@ function MoneyRequestView({ interactive={canEditAmount} shouldShowRightIcon={canEditAmount} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID)) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID)) } brickRoadIndicator={getErrorForField('amount') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} error={getErrorForField('amount')} @@ -333,7 +336,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID), ) } wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]} @@ -352,7 +355,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID), ) } /> @@ -367,7 +370,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID), ) } brickRoadIndicator={getErrorForField('merchant') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} @@ -383,7 +386,7 @@ function MoneyRequestView({ shouldShowRightIcon={canEditDate} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID)) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID)) } brickRoadIndicator={getErrorForField('date') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} error={getErrorForField('date')} @@ -399,7 +402,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID), ) } brickRoadIndicator={getErrorForField('category') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} @@ -421,7 +424,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, index, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.EDIT, iouType, index, transaction?.transactionID ?? '', report.reportID), ) } brickRoadIndicator={getErrorForField('tag', {tagListIndex: index, tagListName: name}) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} @@ -448,7 +451,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID), ) } /> @@ -465,7 +468,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID), ) } /> diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index c9241054e74c..5b685309106b 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2366,9 +2366,9 @@ function canEditMoneyRequest(reportAction: OnyxEntry): boolean { } // TODO: Uncomment this line when BE starts working properly (Editing Track Expense) - // if (reportAction.originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK) { - // return true; - // } + if (reportAction.originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK) { + return true; + } if (reportAction.originalMessage.type !== CONST.IOU.REPORT_ACTION_TYPE.CREATE) { return false; @@ -2946,6 +2946,9 @@ function getChatRoomSubtitle(report: OnyxEntry): string | undefined { if (isChatThread(report)) { return ''; } + if (isSelfDM(report)) { + return Localize.translateLocal('reportActionsView.yourSpace'); + } if (!isDefaultRoom(report) && !isUserCreatedPolicyRoom(report) && !isPolicyExpenseChat(report)) { return ''; } @@ -5734,8 +5737,9 @@ function getOutstandingChildRequest(iouReport: OnyxEntry | EmptyObject): } if (!isExpenseReport(iouReport)) { + const {reimbursableSpend} = getMoneyRequestSpendBreakdown(iouReport); return { - hasOutstandingChildRequest: iouReport.managerID === currentUserAccountID && iouReport.total !== 0, + hasOutstandingChildRequest: iouReport.managerID === currentUserAccountID && reimbursableSpend !== 0, }; } diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 463642cdecbf..05142e8e0a56 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1728,6 +1728,9 @@ function getUpdateMoneyRequestParams( ...iouReport, total: iouReport.total - diff, }; + if (!transaction?.reimbursable && typeof updatedMoneyRequestReport.nonReimbursableTotal === 'number') { + updatedMoneyRequestReport.nonReimbursableTotal -= diff; + } } else { updatedMoneyRequestReport = IOUUtils.updateIOUOwnerAndTotal(iouReport, updatedReportAction.actorAccountID ?? -1, diff, TransactionUtils.getCurrency(transaction), false, true); } @@ -2075,8 +2078,9 @@ function updateMoneyRequestDate( created: value, }; const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`] ?? null; + const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport?.parentReportID}`] ?? null; let data: UpdateMoneyRequestData; - if (ReportUtils.isTrackExpenseReport(transactionThreadReport)) { + if (ReportUtils.isTrackExpenseReport(transactionThreadReport) && ReportUtils.isSelfDM(parentReport)) { data = getUpdateTrackExpenseParams(transactionID, transactionThreadReportID, transactionChanges, true, policy); } else { data = getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, transactionChanges, policy, policyTags, policyCategories, true); @@ -2114,8 +2118,9 @@ function updateMoneyRequestMerchant( merchant: value, }; const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`] ?? null; + const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport?.parentReportID}`] ?? null; let data: UpdateMoneyRequestData; - if (ReportUtils.isTrackExpenseReport(transactionThreadReport)) { + if (ReportUtils.isTrackExpenseReport(transactionThreadReport) && ReportUtils.isSelfDM(parentReport)) { data = getUpdateTrackExpenseParams(transactionID, transactionThreadReportID, transactionChanges, true, policy); } else { data = getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, transactionChanges, policy, policyTagList, policyCategories, true); @@ -2185,8 +2190,9 @@ function updateMoneyRequestDistance( waypoints, }; const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`] ?? null; + const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport?.parentReportID}`] ?? null; let data: UpdateMoneyRequestData; - if (ReportUtils.isTrackExpenseReport(transactionThreadReport)) { + if (ReportUtils.isTrackExpenseReport(transactionThreadReport) && ReportUtils.isSelfDM(parentReport)) { data = getUpdateTrackExpenseParams(transactionID, transactionThreadReportID, transactionChanges, true, policy); } else { data = getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, transactionChanges, policy, policyTagList, policyCategories, true); @@ -2224,8 +2230,9 @@ function updateMoneyRequestDescription( comment, }; const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`] ?? null; + const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport?.parentReportID}`] ?? null; let data: UpdateMoneyRequestData; - if (ReportUtils.isTrackExpenseReport(transactionThreadReport)) { + if (ReportUtils.isTrackExpenseReport(transactionThreadReport) && ReportUtils.isSelfDM(parentReport)) { data = getUpdateTrackExpenseParams(transactionID, transactionThreadReportID, transactionChanges, true, policy); } else { data = getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, transactionChanges, policy, policyTagList, policyCategories, true); @@ -3796,7 +3803,15 @@ function updateMoneyRequestAmountAndCurrency( amount, currency, }; - const {params, onyxData} = getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, transactionChanges, policy, policyTagList, policyCategories, true); + const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`] ?? null; + const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport?.parentReportID}`] ?? null; + let data: UpdateMoneyRequestData; + if (ReportUtils.isTrackExpenseReport(transactionThreadReport) && ReportUtils.isSelfDM(parentReport)) { + data = getUpdateTrackExpenseParams(transactionID, transactionThreadReportID, transactionChanges, true, policy); + } else { + data = getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, transactionChanges, policy, policyTagList, policyCategories, true); + } + const {params, onyxData} = data; API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_AMOUNT_AND_CURRENCY, params, onyxData); } diff --git a/src/pages/TransactionReceiptPage.tsx b/src/pages/TransactionReceiptPage.tsx index 80bda8c0df1b..7a2df49e287a 100644 --- a/src/pages/TransactionReceiptPage.tsx +++ b/src/pages/TransactionReceiptPage.tsx @@ -35,6 +35,7 @@ function TransactionReceipt({transaction, report, reportMetadata = {isLoadingIni const parentReportAction = ReportActionUtils.getReportAction(report?.parentReportID ?? '', report?.parentReportActionID ?? ''); const canEditReceipt = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.RECEIPT); const isEReceipt = transaction && TransactionUtils.hasEReceipt(transaction); + const isTrackExpenseAction = ReportActionUtils.isTrackExpenseAction(parentReportAction); useEffect(() => { if (report && transaction) { @@ -59,6 +60,7 @@ function TransactionReceipt({transaction, report, reportMetadata = {isLoadingIni isReceiptAttachment canEditReceipt={canEditReceipt} allowDownload={!isEReceipt} + isTrackExpenseAction={isTrackExpenseAction} originalFileName={receiptURIs?.filename} defaultOpen onModalClose={() => { From 4a1dbc2596ff1eb573f581d8fec5ca8a7519409a Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Tue, 9 Apr 2024 21:31:59 +0530 Subject: [PATCH 074/339] Fixing lint --- src/components/AttachmentModal.tsx | 2 +- .../ReportActionItem/MoneyRequestView.tsx | 38 +++++-------------- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/src/components/AttachmentModal.tsx b/src/components/AttachmentModal.tsx index eb6178d49cee..71d721572f90 100755 --- a/src/components/AttachmentModal.tsx +++ b/src/components/AttachmentModal.tsx @@ -185,7 +185,7 @@ function AttachmentModal({ const nope = useSharedValue(false); const {windowWidth, isSmallScreenWidth} = useWindowDimensions(); const isOverlayModalVisible = (isReceiptAttachment && isDeleteReceiptConfirmModalVisible) || (!isReceiptAttachment && isAttachmentInvalid); - const iouType = useMemo(() => isTrackExpenseAction ? CONST.IOU.TYPE.TRACK_EXPENSE : CONST.IOU.TYPE.REQUEST, [isTrackExpenseAction]); + const iouType = useMemo(() => (isTrackExpenseAction ? CONST.IOU.TYPE.TRACK_EXPENSE : CONST.IOU.TYPE.REQUEST), [isTrackExpenseAction]); const [file, setFile] = useState( originalFileName diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index cd4a1f8d60d7..fc003c32e1ac 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -319,9 +319,7 @@ function MoneyRequestView({ titleStyle={styles.textHeadlineH2} interactive={canEditAmount} shouldShowRightIcon={canEditAmount} - onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID)) - } + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID))} brickRoadIndicator={getErrorForField('amount') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} error={getErrorForField('amount')} /> @@ -334,11 +332,7 @@ function MoneyRequestView({ interactive={canEdit} shouldShowRightIcon={canEdit} titleStyle={styles.flex1} - onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID), - ) - } + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID))} wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]} brickRoadIndicator={getErrorForField('comment') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} error={getErrorForField('comment')} @@ -354,9 +348,7 @@ function MoneyRequestView({ shouldShowRightIcon={canEditDistance} titleStyle={styles.flex1} onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID), - ) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID)) } /> @@ -369,9 +361,7 @@ function MoneyRequestView({ shouldShowRightIcon={canEditMerchant} titleStyle={styles.flex1} onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID), - ) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID)) } brickRoadIndicator={getErrorForField('merchant') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} error={getErrorForField('merchant')} @@ -385,9 +375,7 @@ function MoneyRequestView({ interactive={canEditDate} shouldShowRightIcon={canEditDate} titleStyle={styles.flex1} - onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID)) - } + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID))} brickRoadIndicator={getErrorForField('date') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} error={getErrorForField('date')} /> @@ -401,9 +389,7 @@ function MoneyRequestView({ shouldShowRightIcon={canEdit} titleStyle={styles.flex1} onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID), - ) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID)) } brickRoadIndicator={getErrorForField('category') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} error={getErrorForField('category')} @@ -423,9 +409,7 @@ function MoneyRequestView({ shouldShowRightIcon={canEdit} titleStyle={styles.flex1} onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.EDIT, iouType, index, transaction?.transactionID ?? '', report.reportID), - ) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.EDIT, iouType, index, transaction?.transactionID ?? '', report.reportID)) } brickRoadIndicator={getErrorForField('tag', {tagListIndex: index, tagListName: name}) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} error={getErrorForField('tag', {tagListIndex: index, tagListName: name})} @@ -450,9 +434,7 @@ function MoneyRequestView({ shouldShowRightIcon={canEdit} titleStyle={styles.flex1} onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID), - ) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID)) } /> @@ -467,9 +449,7 @@ function MoneyRequestView({ shouldShowRightIcon={canEdit} titleStyle={styles.flex1} onPress={() => - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID), - ) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID)) } /> From faec57128745bdd08b58aa64a5c551a8da59d882 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 9 Apr 2024 23:26:55 +0700 Subject: [PATCH 075/339] update correctly filter condition --- src/pages/home/report/ReportActionsView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 7eb355ef3e85..45b58a807877 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -146,7 +146,7 @@ function ReportActionsView({ const filteredTransactionThreadReportActions = transactionThreadReportActions?.filter((action) => action.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED); const moneyRequestAction = allReportActions.find((action) => { const actionType = (action as OnyxTypes.OriginalMessageIOU).originalMessage?.type ?? ''; - return actionType === CONST.IOU.REPORT_ACTION_TYPE.CREATE || actionType === CONST.IOU.REPORT_ACTION_TYPE.TRACK || !ReportActionsUtils.isSentMoneyReportAction(action); + return actionType === CONST.IOU.REPORT_ACTION_TYPE.CREATE || actionType === CONST.IOU.REPORT_ACTION_TYPE.TRACK || ReportActionsUtils.isSentMoneyReportAction(action); }); // Filter out the money request actions because we don't want to show any preview actions for one-transaction reports From e2de27005699da62d4bfcc07c0d897830656b612 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 9 Apr 2024 23:37:27 +0700 Subject: [PATCH 076/339] fix lint --- src/pages/home/report/ReportActionItem.tsx | 2 +- tests/perf-test/ReportActionsList.perf-test.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 5391db6d59ea..298822364f21 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -123,7 +123,7 @@ type ReportActionItemProps = { /** The transaction thread report's parentReportAction */ /** It's used by withOnyx HOC */ // eslint-disable-next-line react/no-unused-prop-types - parentReportActionForTransactionThread: OnyxEntry; + parentReportActionForTransactionThread?: OnyxEntry; /** All the data of the action item */ action: OnyxTypes.ReportAction; diff --git a/tests/perf-test/ReportActionsList.perf-test.tsx b/tests/perf-test/ReportActionsList.perf-test.tsx index a952d149a598..7d45e3e4b45d 100644 --- a/tests/perf-test/ReportActionsList.perf-test.tsx +++ b/tests/perf-test/ReportActionsList.perf-test.tsx @@ -95,6 +95,7 @@ function ReportActionsListWrapper() { Date: Tue, 9 Apr 2024 18:23:43 +0100 Subject: [PATCH 077/339] revert: Podfile lock --- ios/Podfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 94bd6e35f31d..32a8bca75bcd 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1921,7 +1921,7 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: 9f26224fce1233ffdad9fa4e56863e3de2190dc0 - Yoga: 13c8ef87792450193e117976337b8527b49e8c03 + Yoga: e64aa65de36c0832d04e8c7bd614396c77a80047 PODFILE CHECKSUM: a431c146e1501391834a2f299a74093bac53b530 From b6f6c2c9bc73f40622932a7fef0103670768ef5f Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 21:16:23 +0100 Subject: [PATCH 078/339] fix tsc --- src/libs/Navigation/linkingConfig/config.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index f317ed4b98ad..1b371f083a27 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -659,9 +659,6 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.INVOICES]: { path: ROUTES.WORKSPACE_INVOICES.route, }, - [SCREENS.WORKSPACE.ACCOUNTING]: { - path: ROUTES.WORKSPACE_ACCOUNTING.route, - }, [SCREENS.WORKSPACE.TRAVEL]: { path: ROUTES.WORKSPACE_TRAVEL.route, }, From 3df0f4eabd8f17c67e9b396207c1d62abec4995e Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 22:36:45 +0100 Subject: [PATCH 079/339] fix tsc --- src/libs/Navigation/types.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 5f281fab2fd3..45b79a290278 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -604,9 +604,6 @@ type WorkspacesCentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.TRAVEL]: { policyID: string; }; - [SCREENS.WORKSPACE.ACCOUNTING]: { - policyID: string; - }; [SCREENS.WORKSPACE.MEMBERS]: { policyID: string; }; From e9e3550143a2ff00ef5d527728a0d26f8c46c8d6 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 22:41:49 +0100 Subject: [PATCH 080/339] remove duplicate stack navigator --- .../WorkspaceSettingsModalStackNavigator.tsx | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx index 25a140d76079..6eb3f8a885d2 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx @@ -51,12 +51,6 @@ function WorkspaceSettingsModalStackNavigator() { getComponent={() => require('@pages/workspace/WorkspaceMembersPage').default as React.ComponentType} /> - require('@pages/workspace/accounting/WorkspaceAccountingPage').default as React.ComponentType} - /> - require('@pages/workspace/distanceRates/PolicyDistanceRatesPage').default as React.ComponentType} /> - require('@pages/workspace/accounting/WorkspaceAccountingPage').default as React.ComponentType} - /> ); } From 69f1ccfcc5d925864c840c30c09920eab6ee600d Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 22:48:56 +0100 Subject: [PATCH 081/339] put back accounting stack --- .../WorkspaceSettingsModalStackNavigator.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx index 6eb3f8a885d2..2dce4247c7ae 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx @@ -51,6 +51,12 @@ function WorkspaceSettingsModalStackNavigator() { getComponent={() => require('@pages/workspace/WorkspaceMembersPage').default as React.ComponentType} /> + require('@pages/workspace/accounting/WorkspaceAccountingPage').default as React.ComponentType} + /> + Date: Tue, 9 Apr 2024 22:55:09 +0100 Subject: [PATCH 082/339] update first section options --- .../accounting/qbo/QuickbooksAdvancedPage.tsx | 59 +++++++++++-------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx index 018916428d03..1a69c49278de 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx @@ -14,6 +14,26 @@ import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOpt function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); + const qboSyncToggleSettings = [ + { + title: 'Auto-Sync', + subTitle: 'Changes made in Quickbooks will automatically be reflected in Expensify.', + isActive: true, + onToggle: () => {}, + }, + { + title: 'Invite Employees', + subTitle: 'Import Quickbooks Online employee records and invite them to this workspace.', + isActive: true, + onToggle: () => {}, + }, + { + title: 'Automatically Create Entities', + subTitle: 'Expensify will automatically create a vendor in Quickbooks, if one does not exist. Expensify will also automatically create a customer when exporting invoices.', + isActive: true, + onToggle: () => {}, + }, + ]; return ( - - {}} - /> - - - - {}} - /> - - - - {}} - /> - + {qboSyncToggleSettings.map((item) => ( + + + + ))} Date: Tue, 9 Apr 2024 23:11:55 +0100 Subject: [PATCH 083/339] navigate to advanced screen --- .../workspace/accounting/WorkspaceAccountingPage.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx b/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx index 2c87e8803be6..967d09535838 100644 --- a/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx +++ b/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx @@ -16,8 +16,9 @@ import type ThreeDotsMenuProps from '@components/ThreeDotsMenu/types'; import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -// import useWaitForNavigation from '@hooks/useWaitForNavigation'; +import useWaitForNavigation from '@hooks/useWaitForNavigation'; import useWindowDimensions from '@hooks/useWindowDimensions'; +import Navigation from '@libs/Navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper'; @@ -25,13 +26,14 @@ import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import type {AnchorPosition} from '@styles/index'; import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; function WorkspaceAccountingPage({policy}: WithPolicyProps) { const theme = useTheme(); const styles = useThemeStyles(); const {translate} = useLocalize(); // const {environmentURL} = useEnvironment(); - // const waitForNavigate = useWaitForNavigation(); + const waitForNavigate = useWaitForNavigation(); const {isSmallScreenWidth, windowWidth} = useWindowDimensions(); const [threeDotsMenuPosition, setThreeDotsMenuPosition] = useState({horizontal: 0, vertical: 0}); @@ -157,7 +159,7 @@ function WorkspaceAccountingPage({policy}: WithPolicyProps) { shouldShowRightIcon: true, title: translate('workspace.accounting.advanced'), wrapperStyle: [styles.sectionMenuItemTopDescription], - onPress: () => {}, + onPress: waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ADVANCED.getRoute(policyID))), }, ]), ], From f299acb56787d2794e65f96c9a4a54db6d6e456b Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 23:48:31 +0100 Subject: [PATCH 084/339] move QBO_ONLINE_ACCOUNT_SELECTOR_OPTIONS to const --- src/CONST.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/CONST.ts b/src/CONST.ts index 4bef4022af62..4eb683333927 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1200,6 +1200,12 @@ const CONST = { EXPENSIFY_EMAIL_DOMAIN: '@expensify.com', }, + QBO_ONLINE_ACCOUNT_SELECTOR_OPTIONS: { + CROISSANT_CO_PAYROLL_ACCOUNT: 'Croissant Co Payroll Account', + CROISSANT_CO_MONEY_IN_CLEARING: 'Croissant Co Money in Clearing', + CROISSANT_CO_DEBTS_AND_LOANS: 'Croissant Co Debts and Loans', + }, + ACCOUNT_ID: { ACCOUNTING: Number(Config?.EXPENSIFY_ACCOUNT_ID_ACCOUNTING ?? 9645353), ADMIN: Number(Config?.EXPENSIFY_ACCOUNT_ID_ADMIN ?? -1), From 87810f472ebf2877af1c2f85bad69bd3d92c8b1d Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 9 Apr 2024 23:49:00 +0100 Subject: [PATCH 085/339] use QBO_ONLINE_ACCOUNT_SELECTOR_OPTIONS --- .../accounting/qbo/QuickbooksAccountSelectPage.tsx | 11 +++-------- .../qbo/QuickbooksInvoiceAccountSelectPage.tsx | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx index 7828cdb77ee1..e24ce297fdc1 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx @@ -10,14 +10,9 @@ import Text from '@components/Text'; import useThemeStyles from '@hooks/useThemeStyles'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import CONST from '@src/CONST'; -const QBO_ONLINE_ACCOUNT_SELECTOR_OPTIONS = { - CROISSANT_CO_PAYROLL_ACCOUNT: 'Croissant Co Payroll Account', - CROISSANT_CO_MONEY_IN_CLEARING: 'Croissant Co Money in Clearing', - CROISSANT_CO_DEBTS_AND_LOANS: 'Croissant Co Debts and Loans', -}; - -type CustomSelectorTypes = ValueOf; +type CustomSelectorTypes = ValueOf; type SelectorType = { value: CustomSelectorTypes; @@ -33,7 +28,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const qboOnlineSelectorOptions = useMemo( () => - Object.entries(QBO_ONLINE_ACCOUNT_SELECTOR_OPTIONS).map(([key, value]) => ({ + Object.entries(CONST.QBO_ONLINE_ACCOUNT_SELECTOR_OPTIONS).map(([key, value]) => ({ value, text: value, keyForList: key, diff --git a/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx index 3d7c8ab2f903..53b1be0eb7da 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx @@ -10,14 +10,9 @@ import Text from '@components/Text'; import useThemeStyles from '@hooks/useThemeStyles'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import CONST from '@src/CONST'; -const QBO_ONLINE_INVOICE_ACCOUNT_SELECTOR_OPTIONS = { - CROISSANT_CO_PAYROLL_ACCOUNT: 'Croissant Co Payroll Account', - CROISSANT_CO_MONEY_IN_CLEARING: 'Croissant Co Money in Clearing', - CROISSANT_CO_DEBTS_AND_LOANS: 'Croissant Co Debts and Loans', -}; - -type CustomSelectorTypes = ValueOf; +type CustomSelectorTypes = ValueOf; type SelectorType = { value: CustomSelectorTypes; @@ -33,7 +28,7 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const qboOnlineSelectorOptions = useMemo( () => - Object.entries(QBO_ONLINE_INVOICE_ACCOUNT_SELECTOR_OPTIONS).map(([key, value]) => ({ + Object.entries(CONST.QBO_ONLINE_ACCOUNT_SELECTOR_OPTIONS).map(([key, value]) => ({ value, text: value, keyForList: key, From 9e8b4b9e590cba45109704a12a623fabfdb6b2f0 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 00:03:18 +0100 Subject: [PATCH 086/339] navigate to advanced page --- .../workspace/accounting/qbo/QuickbooksAdvancedPage.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx index 1a69c49278de..74dc18669529 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx @@ -8,12 +8,19 @@ import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import SpacerView from '@components/SpacerView'; import useThemeStyles from '@hooks/useThemeStyles'; +import useWaitForNavigation from '@hooks/useWaitForNavigation'; +import Navigation from '@libs/Navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; +import ROUTES from '@src/ROUTES'; function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); + const waitForNavigate = useWaitForNavigation(); + + const policyID = policy?.id ?? ''; + const qboSyncToggleSettings = [ { title: 'Auto-Sync', @@ -79,6 +86,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { title="Croissant Co payroll Account" description="Quickbooks Account" wrapperStyle={[styles.sectionMenuItemTopDescription]} + onPress={waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.getRoute(policyID)))} /> From 448812c1622b11afb23c3ea6bbed7a30f242d966 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 00:12:15 +0100 Subject: [PATCH 087/339] navigate to online invoice account selector page --- src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx index 74dc18669529..9f02b3adc591 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx @@ -110,6 +110,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { shouldShowRightIcon shouldShowBasicTitle wrapperStyle={[styles.sectionMenuItemTopDescription]} + onPress={waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR.getRoute(policyID)))} /> From 6ac5904401fdb2ec372e802bf43dbff859b6b526 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 11:06:01 +0100 Subject: [PATCH 088/339] add to dependency tray --- src/pages/workspace/accounting/WorkspaceAccountingPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx b/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx index ad6e064d4cf7..efcd3e29c641 100644 --- a/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx +++ b/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx @@ -163,7 +163,7 @@ function WorkspaceAccountingPage({policy}: WithPolicyProps) { }, ]), ], - [styles.sectionMenuItemTopDescription, styles.popoverMenuIcon, translate, isSyncInProgress, theme.spinner, overflowMenu, threeDotsMenuPosition, policyID], + [styles.sectionMenuItemTopDescription, styles.popoverMenuIcon, translate, waitForNavigate, isSyncInProgress, theme.spinner, overflowMenu, threeDotsMenuPosition, policyID], ); const headerThreeDotsMenuItems: ThreeDotsMenuProps['menuItems'] = [ From 1127d9d6d32c24f3a444f04aad0deaa6c998ac50 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 11:07:15 +0100 Subject: [PATCH 089/339] add initial advanced config strings for english --- src/languages/en.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 3b670f7b6ebc..f91f1f80ba43 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1872,6 +1872,25 @@ export default { taxesDescription: 'Choose whether to import tax rates and tax defaults from your accounting integration.', locationsAdditionalDescription: 'Locations are imported as Tags. This limits exporting expense reports as Vendor Bills or Checks to QuickBooks Online. To unlock these export options, either disable Locations import or upgrade to the Control Plan to export Locations encoded as a Report Field.', + advancedConfig: { + advanced: 'Advanced', + autoSync: 'Auto-Sync', + autoSyncDescription: 'Changes made in Quickbooks will automatically be reflected in Expensify.', + inviteEmployees: 'Invite Employees', + inviteEmployeesDescription: 'Import Quickbooks Online employee records and invite them to this workspace.', + createEntities: 'Automatically Create Entities', + createEntitiesDescription: + 'Expensify will automatically create a vendor in Quickbooks, if one does not exist. Expensify will also automatically create a customer when exporting invoices.', + reimbursedReports: 'Sync Reimbursed Reports', + reimbursedReportsDescription: 'Any time report is reimbursed using Expensify ACH, the corresponding bill payment will be created in the Quickbooks accounts below.', + qboAccount: 'Quickbooks Account', + collectionAccount: 'Invoice Collection Account', + collectionAccountDescription: 'Once invoices have been Paid, the payment will appear in the account configured below.', + accountSelectDescription: + "As you've enabled sync reimbursed reports, you will need select the bank account your reimbursements are coming out of, and we'll create the payment in QuickBooks.", + invoiceAccountSelectDescription: + 'If you are exporting Invoices from Expensify to Quickbooks Online, this is the account the Invoice will appear against once marked as Paid.', + }, }, type: { free: 'Free', From df300527c8534f22603def08f3c1b23d96e38ada Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 11:07:40 +0100 Subject: [PATCH 090/339] add initial advanced config strings for spanish --- src/languages/es.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/languages/es.ts b/src/languages/es.ts index 5027174b2922..afd63b6a6d25 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1899,6 +1899,25 @@ export default { taxesDescription: 'Elige si quires importar las tasas de impuestos y los impuestos por defecto de tu integración de contaduría.', locationsAdditionalDescription: 'Los lugares son importados como Etiquegas. Esto limita a exportar los informes de gastos como Factura del Proveedor o Cheques a Quicbooks Online. Para desbloquear estas opciones de exportación desactiva la importación de Lugares o cambia al Plan Control para exportar Lugares como Campos de Informes.', + advancedConfig: { + advanced: 'Advanced', + autoSync: 'Auto-Sync', + autoSyncDescription: 'Changes made in Quickbooks will automatically be reflected in Expensify.', + inviteEmployees: 'Invite Employees', + inviteEmployeesDescription: 'Import Quickbooks Online employee records and invite them to this workspace.', + createEntities: 'Automatically Create Entities', + createEntitiesDescription: + 'Expensify will automatically create a vendor in Quickbooks, if one does not exist. Expensify will also automatically create a customer when exporting invoices.', + reimbursedReports: 'Sync Reimbursed Reports', + reimbursedReportsDescription: 'Any time report is reimbursed using Expensify ACH, the corresponding bill payment will be created in the Quickbooks accounts below.', + qboAccount: 'Quickbooks Account', + collectionAccount: 'Invoice Collection Account', + collectionAccountDescription: 'Once invoices have been Paid, the payment will appear in the account configured below.', + accountSelectDescription: + "As you've enabled sync reimbursed reports, you will need select the bank account your reimbursements are coming out of, and we'll create the payment in QuickBooks.", + invoiceAccountSelectDescription: + 'If you are exporting Invoices from Expensify to Quickbooks Online, this is the account the Invoice will appear against once marked as Paid.', + }, }, type: { free: 'Gratis', From 554d75827b89b27d45480845e3d297154bbf8ace Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 11:09:22 +0100 Subject: [PATCH 091/339] use translations for qbo advanced page --- .../accounting/qbo/QuickbooksAdvancedPage.tsx | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx index 9f02b3adc591..3d96842f72ce 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx @@ -7,6 +7,7 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import SpacerView from '@components/SpacerView'; +import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import useWaitForNavigation from '@hooks/useWaitForNavigation'; import Navigation from '@libs/Navigation/Navigation'; @@ -18,25 +19,26 @@ import ROUTES from '@src/ROUTES'; function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const waitForNavigate = useWaitForNavigation(); + const {translate} = useLocalize(); const policyID = policy?.id ?? ''; const qboSyncToggleSettings = [ { - title: 'Auto-Sync', - subTitle: 'Changes made in Quickbooks will automatically be reflected in Expensify.', + title: translate('workspace.qbo.advancedConfig.autoSync'), + subTitle: translate('workspace.qbo.advancedConfig.autoSyncDescription'), isActive: true, onToggle: () => {}, }, { - title: 'Invite Employees', - subTitle: 'Import Quickbooks Online employee records and invite them to this workspace.', + title: translate('workspace.qbo.advancedConfig.inviteEmployees'), + subTitle: translate('workspace.qbo.advancedConfig.inviteEmployeesDescription'), isActive: true, onToggle: () => {}, }, { - title: 'Automatically Create Entities', - subTitle: 'Expensify will automatically create a vendor in Quickbooks, if one does not exist. Expensify will also automatically create a customer when exporting invoices.', + title: translate('workspace.qbo.advancedConfig.createEntities'), + subTitle: translate('workspace.qbo.advancedConfig.createEntitiesDescription'), isActive: true, onToggle: () => {}, }, @@ -48,7 +50,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { shouldEnableMaxHeight testID={QuickbooksAdvancedPage.displayName} > - + {qboSyncToggleSettings.map((item) => ( @@ -74,8 +76,8 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { {}} /> @@ -84,7 +86,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.getRoute(policyID)))} /> @@ -98,8 +100,8 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { Date: Wed, 10 Apr 2024 11:09:51 +0100 Subject: [PATCH 092/339] use translations for qbo account select page --- .../accounting/qbo/QuickbooksAccountSelectPage.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx index e24ce297fdc1..4228b7b01e38 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx @@ -7,6 +7,7 @@ import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import RadioListItem from '@components/SelectionList/RadioListItem'; import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; @@ -23,6 +24,7 @@ type SelectorType = { function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); + const {translate} = useLocalize(); const [selectedAccount, setSelectedAccount] = useState('Croissant Co Payroll Account'); @@ -58,13 +60,10 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { shouldEnableMaxHeight testID={QuickbooksAccountSelectPage.displayName} > - + - - As you've enabled sync reimbursed reports, you will need select the bank account your reimbursements are coming out of, and we'll create the payment in - QuickBooks. - + {translate('workspace.qbo.advancedConfig.accountSelectDescription')} {showQBOOnlineSelectorOptions()} From a96eef4a2107259e816344a6106ee7b57889744f Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 11:10:15 +0100 Subject: [PATCH 093/339] use translations for qbo invoice account select page --- .../accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx index 53b1be0eb7da..68ff143d46a7 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx @@ -7,6 +7,7 @@ import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import RadioListItem from '@components/SelectionList/RadioListItem'; import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; @@ -23,6 +24,7 @@ type SelectorType = { function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); + const {translate} = useLocalize(); const [selectedAccount, setSelectedAccount] = useState('Croissant Co Payroll Account'); @@ -58,12 +60,10 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { shouldEnableMaxHeight testID={QuickbooksInvoiceAccountSelectPage.displayName} > - + - - If you are exporting Invoices from Expensify to Quickbooks Online, this is the account the Invoice will appear against once marked as Paid. - + {translate('workspace.qbo.advancedConfig.invoiceAccountSelectDescription')} {showQBOOnlineSelectorOptions()} From 3bff44201dd83936fb35a119446d5fddfe7a3fd1 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 12:03:17 +0100 Subject: [PATCH 094/339] update to qbo selector options --- src/CONST.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 6324c418d961..53d663314081 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1200,10 +1200,10 @@ const CONST = { EXPENSIFY_EMAIL_DOMAIN: '@expensify.com', }, - QBO_ONLINE_ACCOUNT_SELECTOR_OPTIONS: { - CROISSANT_CO_PAYROLL_ACCOUNT: 'Croissant Co Payroll Account', - CROISSANT_CO_MONEY_IN_CLEARING: 'Croissant Co Money in Clearing', - CROISSANT_CO_DEBTS_AND_LOANS: 'Croissant Co Debts and Loans', + QBO_SELECTOR_OPTIONS: { + CROISSANT_CO_PAYROLL_ACCOUNT: 'CroissantCoPayrollAccount', + CROISSANT_CO_MONEY_IN_CLEARING: 'CroissantCoMoneyInClearing', + CROISSANT_CO_DEBTS_AND_LOANS: 'CroissantCoDebtsAndLoans', }, INTEGRATION_ENTITY_MAP_TYPES: { From bfbb86ff526efc8cbefef1fef9a3faa2bd1d27b9 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 12:04:02 +0100 Subject: [PATCH 095/339] add croissantCo strings for english --- src/languages/en.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index f91f1f80ba43..0301a0fb188a 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1890,6 +1890,11 @@ export default { "As you've enabled sync reimbursed reports, you will need select the bank account your reimbursements are coming out of, and we'll create the payment in QuickBooks.", invoiceAccountSelectDescription: 'If you are exporting Invoices from Expensify to Quickbooks Online, this is the account the Invoice will appear against once marked as Paid.', + croissantCo: { + [CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_PAYROLL_ACCOUNT]: 'Croissant Co Payroll Account', + [CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_MONEY_IN_CLEARING]: 'Croissant Co Money in Clearing', + [CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_DEBTS_AND_LOANS]: 'Croissant Co Debts and Loans', + }, }, }, type: { From 4e78e0c983fee26d4b2660f896ceb6afd28ab3ec Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 12:04:12 +0100 Subject: [PATCH 096/339] add croissantCo strings for spanish --- src/languages/es.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/languages/es.ts b/src/languages/es.ts index afd63b6a6d25..9c0e4dfdedc3 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1917,6 +1917,11 @@ export default { "As you've enabled sync reimbursed reports, you will need select the bank account your reimbursements are coming out of, and we'll create the payment in QuickBooks.", invoiceAccountSelectDescription: 'If you are exporting Invoices from Expensify to Quickbooks Online, this is the account the Invoice will appear against once marked as Paid.', + croissantCo: { + [CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_PAYROLL_ACCOUNT]: 'Croissant Co Payroll Account', + [CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_MONEY_IN_CLEARING]: 'Croissant Co Money in Clearing', + [CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_DEBTS_AND_LOANS]: 'Croissant Co Debts and Loans', + }, }, }, type: { From f1b5671479cec8f6f1459ec1f2a2493baf9875cc Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 12:14:28 +0100 Subject: [PATCH 097/339] use translations for selector options on qbo advanced page --- src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx index 3d96842f72ce..bce9cd7de095 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx @@ -85,7 +85,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.getRoute(policyID)))} @@ -108,7 +108,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { /> Date: Wed, 10 Apr 2024 12:15:50 +0100 Subject: [PATCH 098/339] use translations for selector options on qbo account select page --- .../accounting/qbo/QuickbooksAccountSelectPage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx index 4228b7b01e38..0327ef2a9be5 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx @@ -13,7 +13,7 @@ import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; -type CustomSelectorTypes = ValueOf; +type CustomSelectorTypes = ValueOf; type SelectorType = { value: CustomSelectorTypes; @@ -26,13 +26,13 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const [selectedAccount, setSelectedAccount] = useState('Croissant Co Payroll Account'); + const [selectedAccount, setSelectedAccount] = useState(CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_PAYROLL_ACCOUNT); const qboOnlineSelectorOptions = useMemo( () => - Object.entries(CONST.QBO_ONLINE_ACCOUNT_SELECTOR_OPTIONS).map(([key, value]) => ({ + Object.entries(CONST.QBO_SELECTOR_OPTIONS).map(([key, value]) => ({ value, - text: value, + text: translate(`workspace.qbo.advancedConfig.croissantCo.${value}`), keyForList: key, isSelected: selectedAccount === value, })), From e3b1d1f81781cbbae3ef4d2e00465429fb8c92ee Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 12:16:13 +0100 Subject: [PATCH 099/339] use translations for selector options on qbo invoice account select page --- .../accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx index 68ff143d46a7..02639367ae30 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx @@ -13,7 +13,7 @@ import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; -type CustomSelectorTypes = ValueOf; +type CustomSelectorTypes = ValueOf; type SelectorType = { value: CustomSelectorTypes; @@ -26,13 +26,13 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const [selectedAccount, setSelectedAccount] = useState('Croissant Co Payroll Account'); + const [selectedAccount, setSelectedAccount] = useState(CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_PAYROLL_ACCOUNT); const qboOnlineSelectorOptions = useMemo( () => - Object.entries(CONST.QBO_ONLINE_ACCOUNT_SELECTOR_OPTIONS).map(([key, value]) => ({ + Object.entries(CONST.QBO_SELECTOR_OPTIONS).map(([key, value]) => ({ value, - text: value, + text: translate(`workspace.qbo.advancedConfig.croissantCo.${value}`), keyForList: key, isSelected: selectedAccount === value, })), From 6490db7d51e3c20c8fca860787e71744c1afa00e Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Wed, 10 Apr 2024 14:25:03 +0300 Subject: [PATCH 100/339] resolve conflicts --- .../WorkspaceSettingsModalStackNavigator.tsx | 5 ----- src/libs/Navigation/types.ts | 6 ------ src/pages/workspace/accounting/WorkspaceAccountingPage.tsx | 2 +- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx index 3f572cdf542c..2dce4247c7ae 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/WorkspaceSettingsModalStackNavigator.tsx @@ -82,11 +82,6 @@ function WorkspaceSettingsModalStackNavigator() { name={SCREENS.WORKSPACE.DISTANCE_RATES} getComponent={() => require('@pages/workspace/distanceRates/PolicyDistanceRatesPage').default as React.ComponentType} /> - require('@pages/workspace/distanceRates/PolicyDistanceRatesPage').default as React.ComponentType} - /> ); } diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index df2727b48cb2..f9d0875b1b73 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -668,18 +668,12 @@ type WorkspacesCentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.TAXES]: { policyID: string; }; - [SCREENS.WORKSPACE.ACCOUNTING]: { - policyID: string; - }; [SCREENS.WORKSPACE.DISTANCE_RATES]: { policyID: string; }; [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: { policyID: string; }; - [SCREENS.WORKSPACE.ACCOUNTING]: { - policyID: string; - }; }; type FullScreenNavigatorParamList = { diff --git a/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx b/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx index 6fada466e2bb..775b70bf32eb 100644 --- a/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx +++ b/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx @@ -151,7 +151,7 @@ function WorkspaceAccountingPage({policy}: WithPolicyProps) { shouldShowRightIcon: true, title: translate('workspace.accounting.export'), wrapperStyle: [styles.sectionMenuItemTopDescription], - onPress: () => {}, + onPress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.getRoute(policyID)), }, { icon: Expensicons.Gear, From a1349fceb4c46f4837d3415c7fda7882f08fc1c7 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Wed, 10 Apr 2024 14:33:25 +0300 Subject: [PATCH 101/339] resolve conflicts --- src/ROUTES.ts | 4 ---- src/languages/en.ts | 12 +++++------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 755f9a4e3597..91412066d6f7 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -590,10 +590,6 @@ const ROUTES = { route: 'settings/workspaces/:policyID/members', getRoute: (policyID: string) => `settings/workspaces/${policyID}/members` as const, }, - WORKSPACE_ACCOUNTING: { - route: 'settings/workspaces/:policyID/accounting', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting` as const, - }, WORKSPACE_CATEGORIES: { route: 'settings/workspaces/:policyID/categories', getRoute: (policyID: string) => `settings/workspaces/${policyID}/categories` as const, diff --git a/src/languages/en.ts b/src/languages/en.ts index 46da0550cf93..61627359e5cf 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1872,13 +1872,6 @@ export default { taxesDescription: 'Choose whether to import tax rates and tax defaults from your accounting integration.', locationsAdditionalDescription: 'Locations are imported as Tags. This limits exporting expense reports as Vendor Bills or Checks to QuickBooks Online. To unlock these export options, either disable Locations import or upgrade to the Control Plan to export Locations encoded as a Report Field.', - }, - type: { - free: 'Free', - control: 'Control', - collect: 'Collect', - }, - qbo: { export: 'Export', exportAs: 'Export as', exportDescription: 'Configure how data in Expensify gets exported to QuickBooks Online.', @@ -1908,6 +1901,11 @@ export default { exportVendorBillDescription: 'We’ll create a single itemized vendor bill for each Expensify report. If the period of the bill is closed, we’ll post to the 1st of the next open period. You can add the vendor bill to your A/P account of choice (below).', }, + type: { + free: 'Free', + control: 'Control', + collect: 'Collect', + }, categories: { deleteCategories: 'Delete categories', deleteCategoriesPrompt: 'Are you sure you want to delete these categories?', From fbeca896961162dbc2d6249fc2b9e4d7a055cf7d Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 12:43:04 +0100 Subject: [PATCH 102/339] update select defaults --- src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx | 2 +- .../accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx index bce9cd7de095..0bc4cdff2e12 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx @@ -108,7 +108,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { /> (CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_PAYROLL_ACCOUNT); + const [selectedAccount, setSelectedAccount] = useState(CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_MONEY_IN_CLEARING); const qboOnlineSelectorOptions = useMemo( () => From 5e1f4324b352bd7adb2ae7de04423f768370f4b3 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Wed, 10 Apr 2024 17:20:55 +0300 Subject: [PATCH 103/339] Out of pocket sub page --- src/ROUTES.ts | 4 + src/SCREENS.ts | 1 + src/languages/en.ts | 9 +++ src/languages/es.ts | 10 ++- .../ModalStackNavigators/index.tsx | 2 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 2 +- src/libs/Navigation/linkingConfig/config.ts | 3 + src/libs/Navigation/types.ts | 3 + ...oksOutOfPocketExpenseConfigurationPage.tsx | 33 ++++---- ...ooksOutOfPocketExpenseEntitySelectPage.tsx | 78 +++++++++++++++++++ 10 files changed, 130 insertions(+), 15 deletions(-) create mode 100644 src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 91412066d6f7..b11064a419b0 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -506,6 +506,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/out-of-pocket-expense', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/out-of-pocket-expense` as const, }, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/out-of-pocket-expense/entity-select', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/out-of-pocket-expense/entity-select` as const, + }, WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/date-select', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/date-select` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index e2e9e2ed29aa..f1d4e63d2498 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -268,6 +268,7 @@ const SCREENS = { QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter', QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter_Select', QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses', + QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses_Select', DISTANCE_RATE_EDIT: 'Distance_Rate_Edit', }, diff --git a/src/languages/en.ts b/src/languages/en.ts index 61627359e5cf..f21fdd57c22e 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1900,6 +1900,15 @@ export default { exportOutOfPocketExpensesDescription: 'Set how out-of-pocket expenses export to QuickBooks Online.', exportVendorBillDescription: 'We’ll create a single itemized vendor bill for each Expensify report. If the period of the bill is closed, we’ll post to the 1st of the next open period. You can add the vendor bill to your A/P account of choice (below).', + check: 'Check', + journalEntry: 'Journal Entry', + optionBelow: 'Choose an option below:', + outOfPocketTaxEnabledDescription: + 'Note: QuickBooks Online doesn’t support a field for tax on Journal Entry exports. Because you have tax tracking enabled on your workspace, this export option is unavailable.', + outOfPocketTaxEnabledError: 'Journal entry is not available when taxes enabled. please select a different export option.', + outOfPocketLocationEnabledError: 'Vendor Bills are not available when locations are enabled. Please select a different export option.', + outOfPocketLocationEnabledDescription: + 'Note: QuickBooks Online does not support a field for Locations as Tags on Vendor Bills exports. As you import Locations from, this this export option is unavailable.', }, type: { free: 'Free', diff --git a/src/languages/es.ts b/src/languages/es.ts index 30a7da7b57c8..3d5f0be75fe4 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1928,7 +1928,15 @@ export default { exportOutOfPocketExpensesDescription: 'Establezca cómo se exportan los gastos de bolsillo a QuickBooks Online.', exportVendorBillDescription: 'Crearemos una única factura de proveedor detallada para cada informe de Expensify. Si el período de la factura está cerrado, lo publicaremos en el día 1 del próximo período abierto. Puede agregar la factura del proveedor a la cuenta A/P de su elección (a continuación).', - + check: 'Cheque', + journalEntry: 'Entrada de diario', + optionBelow: 'Elija una opción a continuación:', + outOfPocketTaxEnabledDescription: + 'Nota: QuickBooks Online no admite un campo para impuestos sobre las exportaciones de asientos de diario. Debido a que tiene habilitado el seguimiento de impuestos en su espacio de trabajo, esta opción de exportación no está disponible.', + outOfPocketTaxEnabledError: 'El asiento de diario no está disponible cuando los impuestos están habilitados. seleccione una opción de exportación diferente.', + outOfPocketLocationEnabledError: 'Las facturas de proveedores no están disponibles cuando las ubicaciones están habilitadas. Seleccione una opción de exportación diferente.', + outOfPocketLocationEnabledDescription: + 'Nota: QuickBooks Online no admite un campo para Ubicaciones como etiquetas en las exportaciones de facturas de proveedores. A medida que importa ubicaciones, esta opción de exportación no está disponible.', }, type: { free: 'Gratis', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index bde9d89a058d..c2f180a820ad 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -259,6 +259,8 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: () => + require('../../../../pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseEntitySelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: () => diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 5808d46f0cb0..795f16e5ea35 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -33,7 +33,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES, - + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT, ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 72579852d492..0c94d3c1643c 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -273,6 +273,9 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.route}, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.route}, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: { + path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.route, + }, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE.route}, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: { path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.route, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index f9d0875b1b73..9c003d0d0307 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -271,6 +271,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: { policyID: string; }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: { + policyID: string; + }; [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE]: { policyID: string; }; diff --git a/src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseConfigurationPage.tsx index 4d585fe34d31..a5e02a7c8b42 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseConfigurationPage.tsx @@ -10,6 +10,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; const isVendorBill = true; @@ -17,6 +18,8 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; + const {syncLocations} = policy?.connections?.quickbooksOnline?.config ?? {}; + const isLocationEnabled = Boolean(syncLocations && syncLocations !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); return ( - {translate('workspace.qbo.exportOutOfPocketExpensesDescription')} + {!isLocationEnabled && {translate('workspace.qbo.exportOutOfPocketExpensesDescription')}} Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID))} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.getRoute(policyID))} brickRoadIndicator={undefined} - shouldShowRightIcon - /> - - {isVendorBill && {translate('workspace.qbo.exportVendorBillDescription')}} - - Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID))} - brickRoadIndicator={undefined} - shouldShowRightIcon + shouldShowRightIcon={!isLocationEnabled} + interactive={!isLocationEnabled} /> + {isVendorBill && !isLocationEnabled && {translate('workspace.qbo.exportVendorBillDescription')}} + {isLocationEnabled && {translate('workspace.qbo.outOfPocketLocationEnabledDescription')}} + {!isLocationEnabled && ( + + Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID))} + brickRoadIndicator={undefined} + shouldShowRightIcon + /> + + )} ); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx new file mode 100644 index 000000000000..7069fbc3ffe1 --- /dev/null +++ b/src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx @@ -0,0 +1,78 @@ +import React, {useCallback} from 'react'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import SelectionList from '@components/SelectionList'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import CONST from '@src/CONST'; + +const CARDS = { + CHECK: 'check', + JOURNAL_ENTRY: 'journal_entry', + VENDOR_BILL: 'vendor_bill', +}; + +function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const {nonReimbursableExpensesExportDestination, syncTaxes} = policy?.connections?.quickbooksOnline?.config ?? {}; + const isTaxesEnabled = Boolean(syncTaxes && syncTaxes !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); + + // const policyID = policy?.id ?? ''; + const data = [ + { + value: CARDS.CHECK, + text: translate(`workspace.qbo.check`), + keyForList: CARDS.CHECK, + isSelected: nonReimbursableExpensesExportDestination === CARDS.CHECK, + isShown: true, + }, + { + value: CARDS.JOURNAL_ENTRY, + text: translate(`workspace.qbo.journalEntry`), + keyForList: CARDS.JOURNAL_ENTRY, + isSelected: nonReimbursableExpensesExportDestination === CARDS.JOURNAL_ENTRY, + isShown: !isTaxesEnabled, + }, + { + value: CARDS.VENDOR_BILL, + text: translate(`workspace.qbo.vendorBill`), + keyForList: CARDS.VENDOR_BILL, + isSelected: nonReimbursableExpensesExportDestination === CARDS.VENDOR_BILL, + isShown: true, + }, + ]; + + const updateMode = useCallback((mode: {value: string}) => { + // TODO add API call for change + }, []); + + return ( + + + {translate('workspace.qbo.optionBelow')} + + item.isShown)}]} + ListItem={RadioListItem} + onSelectRow={updateMode} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + /> + {translate('workspace.qbo.outOfPocketTaxEnabledDescription')} + + + ); +} + +QuickbooksOutOfPocketExpenseEntitySelectPage.displayName = 'QuickbooksOutOfPocketExpenseEntitySelectPage'; + +export default withPolicy(QuickbooksOutOfPocketExpenseEntitySelectPage); From 2b874fdec54f844861405ec54fed891a47da1fc7 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 18:02:57 +0100 Subject: [PATCH 104/339] unify all qbo configs and rename to QUICK_BOOKS_CONFIG --- src/CONST.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index 53d663314081..04326b39f833 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1216,7 +1216,10 @@ const CONST = { }, QUICK_BOOKS_ONLINE: 'quickbooksOnline', - QUICK_BOOKS_IMPORTS: { + QUICK_BOOKS_CONFIG: { + AUTO_SYNC: 'autoSync', + SYNCE_PEOPLE: 'syncPeople', + AUTO_CREATE_VENDOR: 'autoCreateVendor', SYNC_CLASSES: 'syncClasses', ENABLE_NEW_CATEGORIES: 'enableNewCategories', SYNC_CUSTOMERS: 'syncCustomers', From b29870847a1a608d8ee9f6005e1ead86ea8f0740 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 18:03:47 +0100 Subject: [PATCH 105/339] update updatePolicyConnectionConfig param types --- src/libs/actions/Policy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index d6ab203e85a4..7f2bca0ec05c 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -3721,7 +3721,7 @@ function openPolicyDistanceRatesPage(policyID?: string) { API.read(READ_COMMANDS.OPEN_POLICY_DISTANCE_RATES_PAGE, params); } -function updatePolicyConnectionConfig(policyID: string, settingName: ValueOf, settingValue: ValueOf) { +function updatePolicyConnectionConfig(policyID: string, settingName: ValueOf, settingValue: ValueOf | boolean) { const parameters = {policyID, connectionName: CONST.QUICK_BOOKS_ONLINE, settingName, settingValue, idempotencyKey: settingName}; const optimisticData: OnyxUpdate[] = [ { From ba34554a08cbd5266fe6ecd5421c48bec8ba88a6 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 18:04:21 +0100 Subject: [PATCH 106/339] update UpdatePolicyConnectionConfigParams types --- src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts index be062435eaa4..319f8b0fdcca 100644 --- a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts +++ b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts @@ -4,8 +4,8 @@ import type CONST from '@src/CONST'; type UpdatePolicyConnectionConfigParams = { policyID: string; connectionName: string; - settingName: ValueOf; - settingValue: ValueOf; + settingName: ValueOf; + settingValue: ValueOf | boolean; idempotencyKey: string; }; From f6f5bf356b6703689806a4429ec81174a14951ad Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 18:06:21 +0100 Subject: [PATCH 107/339] group all qbo advance config pages and use updatePolicyConnectionConfig for toggle switch --- .../QuickbooksAccountSelectPage.tsx | 0 .../{ => advanced}/QuickbooksAdvancedPage.tsx | 27 ++++++++++++++----- .../QuickbooksInvoiceAccountSelectPage.tsx | 0 3 files changed, 21 insertions(+), 6 deletions(-) rename src/pages/workspace/accounting/qbo/{ => advanced}/QuickbooksAccountSelectPage.tsx (100%) rename src/pages/workspace/accounting/qbo/{ => advanced}/QuickbooksAdvancedPage.tsx (85%) rename src/pages/workspace/accounting/qbo/{ => advanced}/QuickbooksInvoiceAccountSelectPage.tsx (100%) diff --git a/src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx similarity index 100% rename from src/pages/workspace/accounting/qbo/QuickbooksAccountSelectPage.tsx rename to src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx diff --git a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx similarity index 85% rename from src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx rename to src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index 0bc4cdff2e12..88ea8ab3dd67 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -14,7 +14,9 @@ import Navigation from '@libs/Navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; +import * as Policy from '@userActions/Policy'; import ROUTES from '@src/ROUTES'; +import CONST from '@src/CONST'; function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); @@ -22,25 +24,38 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? ''; + const {autoSync, syncPeople, autoCreateVendor} = policy?.connections?.quickbooksOnline?.config ?? {}; const qboSyncToggleSettings = [ { title: translate('workspace.qbo.advancedConfig.autoSync'), subTitle: translate('workspace.qbo.advancedConfig.autoSyncDescription'), - isActive: true, - onToggle: () => {}, + isActive: Boolean(autoSync), + onToggle: () => Policy.updatePolicyConnectionConfig( + policyID, + CONST.QUICK_BOOKS_CONFIG.AUTO_SYNC, + !autoSync, + ), }, { title: translate('workspace.qbo.advancedConfig.inviteEmployees'), subTitle: translate('workspace.qbo.advancedConfig.inviteEmployeesDescription'), - isActive: true, - onToggle: () => {}, + isActive: Boolean(syncPeople), + onToggle: () => Policy.updatePolicyConnectionConfig( + policyID, + CONST.QUICK_BOOKS_CONFIG.SYNCE_PEOPLE, + !syncPeople, + ), }, { title: translate('workspace.qbo.advancedConfig.createEntities'), subTitle: translate('workspace.qbo.advancedConfig.createEntitiesDescription'), - isActive: true, - onToggle: () => {}, + isActive: Boolean(autoCreateVendor), + onToggle: () => Policy.updatePolicyConnectionConfig( + policyID, + CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR, + !autoCreateVendor, + ), }, ]; diff --git a/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx similarity index 100% rename from src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx rename to src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx From 42d8dcc82eca4e42035a843b8458ca66f9004308 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 18:07:11 +0100 Subject: [PATCH 108/339] update qbo param list structure --- .../Navigation/AppNavigator/ModalStackNavigators/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 162969bd1810..6c7419447d64 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -260,10 +260,10 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/settings/ExitSurvey/ExitSurveyReasonPage').default as React.ComponentType, [SCREENS.SETTINGS.EXIT_SURVEY.RESPONSE]: () => require('../../../../pages/settings/ExitSurvey/ExitSurveyResponsePage').default as React.ComponentType, [SCREENS.SETTINGS.EXIT_SURVEY.CONFIRM]: () => require('../../../../pages/settings/ExitSurvey/ExitSurveyConfirmPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksAdvancedPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksAccountSelectPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED]: () => require('../../../../pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: () => require('../../../../pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR]: () => - require('../../../../pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage').default as React.ComponentType, + require('../../../../pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_IMPORT]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksImportPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_CHART_OF_ACCOUNTS]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksChartOfAccountsPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_CUSTOMERS]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksCustomersPage').default as React.ComponentType, From 84a3746357bac843e7ddf8cea591acd47976fbcf Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 18:09:45 +0100 Subject: [PATCH 109/339] group all qbo import config pages --- .../{ => import}/QuickbooksChartOfAccountsPage.tsx | 2 +- .../qbo/{ => import}/QuickbooksClassesPage.tsx | 2 +- .../qbo/{ => import}/QuickbooksCustomersPage.tsx | 2 +- .../qbo/{ => import}/QuickbooksImportPage.tsx | 0 .../qbo/{ => import}/QuickbooksLocationsPage.tsx | 2 +- .../qbo/{ => import}/QuickbooksTaxesPage.tsx | 12 ++++++------ 6 files changed, 10 insertions(+), 10 deletions(-) rename src/pages/workspace/accounting/qbo/{ => import}/QuickbooksChartOfAccountsPage.tsx (99%) rename src/pages/workspace/accounting/qbo/{ => import}/QuickbooksClassesPage.tsx (99%) rename src/pages/workspace/accounting/qbo/{ => import}/QuickbooksCustomersPage.tsx (99%) rename src/pages/workspace/accounting/qbo/{ => import}/QuickbooksImportPage.tsx (100%) rename src/pages/workspace/accounting/qbo/{ => import}/QuickbooksLocationsPage.tsx (99%) rename src/pages/workspace/accounting/qbo/{ => import}/QuickbooksTaxesPage.tsx (91%) diff --git a/src/pages/workspace/accounting/qbo/QuickbooksChartOfAccountsPage.tsx b/src/pages/workspace/accounting/qbo/import/QuickbooksChartOfAccountsPage.tsx similarity index 99% rename from src/pages/workspace/accounting/qbo/QuickbooksChartOfAccountsPage.tsx rename to src/pages/workspace/accounting/qbo/import/QuickbooksChartOfAccountsPage.tsx index 593e5f9dc00a..1fee44687592 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksChartOfAccountsPage.tsx +++ b/src/pages/workspace/accounting/qbo/import/QuickbooksChartOfAccountsPage.tsx @@ -49,7 +49,7 @@ function QuickbooksChartOfAccountsPage({policy}: WithPolicyProps) { onToggle={() => Policy.updatePolicyConnectionConfig( policyID, - CONST.QUICK_BOOKS_IMPORTS.ENABLE_NEW_CATEGORIES, + CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } diff --git a/src/pages/workspace/accounting/qbo/QuickbooksClassesPage.tsx b/src/pages/workspace/accounting/qbo/import/QuickbooksClassesPage.tsx similarity index 99% rename from src/pages/workspace/accounting/qbo/QuickbooksClassesPage.tsx rename to src/pages/workspace/accounting/qbo/import/QuickbooksClassesPage.tsx index f8c631b31476..620d86704308 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksClassesPage.tsx +++ b/src/pages/workspace/accounting/qbo/import/QuickbooksClassesPage.tsx @@ -51,7 +51,7 @@ function QuickbooksClassesPage({policy}: WithPolicyProps) { onToggle={() => Policy.updatePolicyConnectionConfig( policyID, - CONST.QUICK_BOOKS_IMPORTS.SYNC_CLASSES, + CONST.QUICK_BOOKS_CONFIG.SYNC_CLASSES, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } diff --git a/src/pages/workspace/accounting/qbo/QuickbooksCustomersPage.tsx b/src/pages/workspace/accounting/qbo/import/QuickbooksCustomersPage.tsx similarity index 99% rename from src/pages/workspace/accounting/qbo/QuickbooksCustomersPage.tsx rename to src/pages/workspace/accounting/qbo/import/QuickbooksCustomersPage.tsx index 27fde14081e7..7dafe1dfd206 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksCustomersPage.tsx +++ b/src/pages/workspace/accounting/qbo/import/QuickbooksCustomersPage.tsx @@ -50,7 +50,7 @@ function QuickbooksCustomersPage({policy}: WithPolicyProps) { onToggle={() => Policy.updatePolicyConnectionConfig( policyID, - CONST.QUICK_BOOKS_IMPORTS.SYNC_CUSTOMERS, + CONST.QUICK_BOOKS_CONFIG.SYNC_CUSTOMERS, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } diff --git a/src/pages/workspace/accounting/qbo/QuickbooksImportPage.tsx b/src/pages/workspace/accounting/qbo/import/QuickbooksImportPage.tsx similarity index 100% rename from src/pages/workspace/accounting/qbo/QuickbooksImportPage.tsx rename to src/pages/workspace/accounting/qbo/import/QuickbooksImportPage.tsx diff --git a/src/pages/workspace/accounting/qbo/QuickbooksLocationsPage.tsx b/src/pages/workspace/accounting/qbo/import/QuickbooksLocationsPage.tsx similarity index 99% rename from src/pages/workspace/accounting/qbo/QuickbooksLocationsPage.tsx rename to src/pages/workspace/accounting/qbo/import/QuickbooksLocationsPage.tsx index 21da79587c0c..0e9150549e64 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksLocationsPage.tsx +++ b/src/pages/workspace/accounting/qbo/import/QuickbooksLocationsPage.tsx @@ -51,7 +51,7 @@ function QuickbooksLocationsPage({policy}: WithPolicyProps) { onToggle={() => Policy.updatePolicyConnectionConfig( policyID, - CONST.QUICK_BOOKS_IMPORTS.SYNC_LOCATIONS, + CONST.QUICK_BOOKS_CONFIG.SYNC_LOCATIONS, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } diff --git a/src/pages/workspace/accounting/qbo/QuickbooksTaxesPage.tsx b/src/pages/workspace/accounting/qbo/import/QuickbooksTaxesPage.tsx similarity index 91% rename from src/pages/workspace/accounting/qbo/QuickbooksTaxesPage.tsx rename to src/pages/workspace/accounting/qbo/import/QuickbooksTaxesPage.tsx index 293d6518baa0..99d16fd1b497 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksTaxesPage.tsx +++ b/src/pages/workspace/accounting/qbo/import/QuickbooksTaxesPage.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import {View} from 'react-native'; +import { View } from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import ScreenWrapper from '@components/ScreenWrapper'; @@ -11,16 +11,16 @@ import useThemeStyles from '@hooks/useThemeStyles'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; -import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import type { WithPolicyProps } from '@pages/workspace/withPolicy'; import variables from '@styles/variables'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; -function QuickbooksTaxesPage({policy}: WithPolicyProps) { - const {translate} = useLocalize(); +function QuickbooksTaxesPage({ policy }: WithPolicyProps) { + const { translate } = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; - const {syncTaxes, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {}; + const { syncTaxes, pendingFields } = policy?.connections?.quickbooksOnline?.config ?? {}; const isSwitchOn = Boolean(syncTaxes && syncTaxes !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); return ( @@ -48,7 +48,7 @@ function QuickbooksTaxesPage({policy}: WithPolicyProps) { onToggle={() => Policy.updatePolicyConnectionConfig( policyID, - CONST.QUICK_BOOKS_IMPORTS.SYNC_TAXES, + CONST.QUICK_BOOKS_CONFIG.SYNC_TAXES, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } From 7ff7d7188930f75990235611c308b92395c6c2e4 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 10 Apr 2024 18:09:57 +0100 Subject: [PATCH 110/339] update qbo param list structure --- .../AppNavigator/ModalStackNavigators/index.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 6c7419447d64..032e817069b7 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -264,12 +264,12 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR]: () => require('../../../../pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_IMPORT]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksImportPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_CHART_OF_ACCOUNTS]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksChartOfAccountsPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_CUSTOMERS]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksCustomersPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_TAXES]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksTaxesPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_LOCATIONS]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksLocationsPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_CLASSES]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksClassesPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_IMPORT]: () => require('../../../../pages/workspace/accounting/qbo/import/QuickbooksImportPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_CHART_OF_ACCOUNTS]: () => require('../../../../pages/workspace/accounting/qbo/import/QuickbooksChartOfAccountsPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_CUSTOMERS]: () => require('../../../../pages/workspace/accounting/qbo/import/QuickbooksCustomersPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_TAXES]: () => require('../../../../pages/workspace/accounting/qbo/import/QuickbooksTaxesPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_LOCATIONS]: () => require('../../../../pages/workspace/accounting/qbo/import/QuickbooksLocationsPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_CLASSES]: () => require('../../../../pages/workspace/accounting/qbo/import/QuickbooksClassesPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default as React.ComponentType, From a2be77e553da0c0be1e517173a0c9e0449b75e65 Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Thu, 11 Apr 2024 06:36:57 +0530 Subject: [PATCH 111/339] Fixing logic for editing --- src/libs/ReportUtils.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 5b685309106b..fdcbe1a058c8 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2365,19 +2365,16 @@ function canEditMoneyRequest(reportAction: OnyxEntry): boolean { return true; } - // TODO: Uncomment this line when BE starts working properly (Editing Track Expense) - if (reportAction.originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK) { - return true; - } + const allowedReportActionType: Array> = [CONST.IOU.REPORT_ACTION_TYPE.TRACK, CONST.IOU.REPORT_ACTION_TYPE.CREATE]; - if (reportAction.originalMessage.type !== CONST.IOU.REPORT_ACTION_TYPE.CREATE) { + if (!allowedReportActionType.includes(reportAction.originalMessage.type)) { return false; } const moneyRequestReportID = reportAction?.originalMessage?.IOUReportID ?? 0; if (!moneyRequestReportID) { - return false; + return reportAction.originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK; } const moneyRequestReport = getReport(String(moneyRequestReportID)); From d140a2a4d939cce101f43ed069aedf63607ffcd7 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Thu, 11 Apr 2024 14:11:26 +0300 Subject: [PATCH 112/339] Re-work on Preferred exporter with new design --- src/ROUTES.ts | 4 -- src/SCREENS.ts | 1 - .../ModalStackNavigators/index.tsx | 2 - .../FULL_SCREEN_TO_RHP_MAPPING.ts | 1 - src/libs/Navigation/linkingConfig/config.ts | 1 - src/libs/Navigation/types.ts | 3 - ...ooksPreferredExporterConfigurationPage.tsx | 49 ++++++++++----- .../QuickbooksPreferredExporterSelectPage.tsx | 61 ------------------- 8 files changed, 33 insertions(+), 89 deletions(-) delete mode 100644 src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterSelectPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index b11064a419b0..6e911472fe94 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -498,10 +498,6 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/preferred-exporter', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/preferred-exporter` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_SELECT: { - route: 'settings/workspaces/:policyID/accounting/quickbooks-online/preferred-exporter/select', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/preferred-exporter/select` as const, - }, WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/out-of-pocket-expense', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/out-of-pocket-expense` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index f1d4e63d2498..d507c0a9475d 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -266,7 +266,6 @@ const SCREENS = { QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE: 'Workspace_Accounting_Quickbooks_Online_Export_Company_Card_Expense', QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Company_Card_Expense_Select', QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter', - QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter_Select', QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses', QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses_Select', DISTANCE_RATE_EDIT: 'Distance_Rate_Edit', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index c2f180a820ad..869d234ff584 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -267,8 +267,6 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT]: () => - require('../../../../pages/workspace/accounting/qbo/QuickbooksPreferredExporterSelectPage').default as React.ComponentType, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType, [SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default as React.ComponentType, [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 795f16e5ea35..787b401d05d3 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -31,7 +31,6 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT, ], diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 0c94d3c1643c..c1a0c8158c83 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -281,7 +281,6 @@ const config: LinkingOptions['config'] = { path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.route, }, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.route}, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_SELECT.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 9c003d0d0307..4aad74491f8f 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -283,9 +283,6 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER_SELECT]: { - policyID: string; - }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; diff --git a/src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage.tsx index 6127a0626e74..23d8a8994ba9 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage.tsx @@ -1,23 +1,42 @@ -import React from 'react'; +import React, {useCallback, useMemo} from 'react'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; +import SelectionList from '@components/SelectionList'; +import RadioListItem from '@components/SelectionList/RadioListItem'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import Navigation from '@navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; -import ROUTES from '@src/ROUTES'; + +const draft = [ + {name: '+14153166423@expensify.sms', currency: 'USD', id: '94', email: '+14153166423@expensify.sms'}, + {name: 'Account Maintenance Fee', currency: 'USD', id: '141', email: 'alberto@expensify213.com'}, + {name: 'Admin Test', currency: 'USD', id: '119', email: 'admin@qbocard.com'}, + {name: 'Alberto Gonzalez-Cela', currency: 'USD', id: '104', email: 'alberto@expensify.com'}, + {name: 'Aldo test QBO2 QBO2 Last name', currency: 'USD', id: '140', email: 'admin@qbo.com'}, +]; function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const policyID = policy?.id ?? ''; - const policyOwner = policy?.owner ?? ''; - const {exporter} = policy?.connections?.quickbooksOnline?.config?.export ?? {}; + const {data, config} = policy?.connections?.quickbooksOnline ?? {}; + // const policyID = policy?.id ?? ''; + const sections = useMemo( + () => + (data?.vendors ?? draft)?.map((vendor) => ({ + value: vendor.email, + text: vendor.email, + keyForList: vendor.email, + isSelected: config?.export?.exporter === vendor.email, + })) ?? [], + [config?.export?.exporter, data?.vendors], + ); + + const updateMode = useCallback((mode: {value: string}) => { + // TODO add API call for change + }, []); return ( {translate('workspace.qbo.exportPreferredExporterNote')} {translate('workspace.qbo.exportPreferredExporterSubNote')} - - Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER_SELECT.getRoute(policyID))} - brickRoadIndicator={undefined} - /> - + mode.isSelected)?.keyForList} + /> ); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterSelectPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterSelectPage.tsx deleted file mode 100644 index 63f4efbe69c0..000000000000 --- a/src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterSelectPage.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import React, {useCallback, useMemo} from 'react'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; -import ScrollView from '@components/ScrollView'; -import SelectionList from '@components/SelectionList'; -import RadioListItem from '@components/SelectionList/RadioListItem'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import withPolicy from '@pages/workspace/withPolicy'; -import type {WithPolicyProps} from '@pages/workspace/withPolicy'; - -const draft = [ - {name: '+14153166423@expensify.sms', currency: 'USD', id: '94', email: '+14153166423@expensify.sms'}, - {name: 'Account Maintenance Fee', currency: 'USD', id: '141', email: 'alberto@expensify213.com'}, - {name: 'Admin Test', currency: 'USD', id: '119', email: 'admin@qbocard.com'}, - {name: 'Alberto Gonzalez-Cela', currency: 'USD', id: '104', email: 'alberto@expensify.com'}, - {name: 'Aldo test QBO2 QBO2 Last name', currency: 'USD', id: '140', email: 'admin@qbo.com'}, -]; - -function QuickBooksExportPreferredExporterListPage({policy}: WithPolicyProps) { - const {translate} = useLocalize(); - const styles = useThemeStyles(); - const {data, config} = policy?.connections?.quickbooksOnline ?? {}; - // const policyID = policy?.id ?? ''; - const sections = useMemo( - () => - (data?.vendors ?? draft)?.map((vendor) => ({ - value: vendor.email, - text: vendor.email, - keyForList: vendor.email, - isSelected: config?.export?.exporter === vendor.email, - })) ?? [], - [config?.export?.exporter, data?.vendors], - ); - - const updateMode = useCallback((mode: {value: string}) => { - // TODO add API call for change - }, []); - - return ( - - - - mode.isSelected)?.keyForList} - /> - - - ); -} - -QuickBooksExportPreferredExporterListPage.displayName = 'QuickBooksExportPreferredExporterListPage'; - -export default withPolicy(QuickBooksExportPreferredExporterListPage); From ce5924a5fc640bc82c5d4e8b590bffcb3dd08eb2 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 11 Apr 2024 14:17:30 +0100 Subject: [PATCH 113/339] add collectionAccountID and reimbursementAccountID and updatePolicyConnectionConfig --- src/CONST.ts | 2 ++ .../API/parameters/UpdatePolicyConnectionConfigParams.ts | 2 +- src/libs/actions/Policy.ts | 6 +++++- src/types/onyx/Policy.ts | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 04326b39f833..c6a19e40c1c3 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1220,6 +1220,8 @@ const CONST = { AUTO_SYNC: 'autoSync', SYNCE_PEOPLE: 'syncPeople', AUTO_CREATE_VENDOR: 'autoCreateVendor', + REIMBURSEMENT_ACCOUNT_ID: 'reimbursementAccountID', + COLLECTION_ACCOUNT_ID: 'collectionAccountID', SYNC_CLASSES: 'syncClasses', ENABLE_NEW_CATEGORIES: 'enableNewCategories', SYNC_CUSTOMERS: 'syncCustomers', diff --git a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts index 319f8b0fdcca..4cf0123b6ec2 100644 --- a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts +++ b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts @@ -5,7 +5,7 @@ type UpdatePolicyConnectionConfigParams = { policyID: string; connectionName: string; settingName: ValueOf; - settingValue: ValueOf | boolean; + settingValue: ValueOf | string | boolean; idempotencyKey: string; }; diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 7f2bca0ec05c..21c8390ee2e6 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -3721,7 +3721,11 @@ function openPolicyDistanceRatesPage(policyID?: string) { API.read(READ_COMMANDS.OPEN_POLICY_DISTANCE_RATES_PAGE, params); } -function updatePolicyConnectionConfig(policyID: string, settingName: ValueOf, settingValue: ValueOf | boolean) { +function updatePolicyConnectionConfig( + policyID: string, + settingName: ValueOf, + settingValue: ValueOf | string | boolean, +) { const parameters = {policyID, connectionName: CONST.QUICK_BOOKS_ONLINE, settingName, settingValue, idempotencyKey: settingName}; const optimisticData: OnyxUpdate[] = [ { diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index a21e98f4bfec..be11a5dce005 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -159,6 +159,8 @@ type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ reimbursableExpensesExportDestination: IntegrationEntityMap; nonReimbursableExpensesExportDestination: IntegrationEntityMap; + collectionAccountID?: string; + reimbursementAccountID?: string; reimbursableExpensesAccount?: string; nonReimbursableExpensesAccount?: string; autoCreateVendor: boolean; From 6325a567bf50d4e59a074dab82b35cf286f918f0 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 11 Apr 2024 14:17:59 +0100 Subject: [PATCH 114/339] implement toggles --- .../qbo/advanced/QuickbooksAdvancedPage.tsx | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index 88ea8ab3dd67..ac81eff5b12b 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -15,8 +15,8 @@ import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import * as Policy from '@userActions/Policy'; -import ROUTES from '@src/ROUTES'; import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); @@ -24,38 +24,26 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? ''; - const {autoSync, syncPeople, autoCreateVendor} = policy?.connections?.quickbooksOnline?.config ?? {}; + const {autoSync, syncPeople, autoCreateVendor, reimbursementAccountID} = policy?.connections?.quickbooksOnline?.config ?? {}; const qboSyncToggleSettings = [ { title: translate('workspace.qbo.advancedConfig.autoSync'), subTitle: translate('workspace.qbo.advancedConfig.autoSyncDescription'), isActive: Boolean(autoSync), - onToggle: () => Policy.updatePolicyConnectionConfig( - policyID, - CONST.QUICK_BOOKS_CONFIG.AUTO_SYNC, - !autoSync, - ), + onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.AUTO_SYNC, !autoSync), }, { title: translate('workspace.qbo.advancedConfig.inviteEmployees'), subTitle: translate('workspace.qbo.advancedConfig.inviteEmployeesDescription'), isActive: Boolean(syncPeople), - onToggle: () => Policy.updatePolicyConnectionConfig( - policyID, - CONST.QUICK_BOOKS_CONFIG.SYNCE_PEOPLE, - !syncPeople, - ), + onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.SYNCE_PEOPLE, !syncPeople), }, { title: translate('workspace.qbo.advancedConfig.createEntities'), subTitle: translate('workspace.qbo.advancedConfig.createEntitiesDescription'), isActive: Boolean(autoCreateVendor), - onToggle: () => Policy.updatePolicyConnectionConfig( - policyID, - CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR, - !autoCreateVendor, - ), + onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR, !autoCreateVendor), }, ]; @@ -93,8 +81,8 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { {}} + isActive={Boolean(reimbursementAccountID)} + onToggle={() => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, !reimbursementAccountID)} /> From ae642b85c6f787c45da3b00ce8243b655b08b941 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 11 Apr 2024 14:22:30 +0100 Subject: [PATCH 115/339] fix QuickbooksTaxesPage lint --- .../accounting/qbo/import/QuickbooksTaxesPage.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/import/QuickbooksTaxesPage.tsx b/src/pages/workspace/accounting/qbo/import/QuickbooksTaxesPage.tsx index 99d16fd1b497..433209f2ee51 100644 --- a/src/pages/workspace/accounting/qbo/import/QuickbooksTaxesPage.tsx +++ b/src/pages/workspace/accounting/qbo/import/QuickbooksTaxesPage.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { View } from 'react-native'; +import {View} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import ScreenWrapper from '@components/ScreenWrapper'; @@ -11,16 +11,16 @@ import useThemeStyles from '@hooks/useThemeStyles'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; -import type { WithPolicyProps } from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import variables from '@styles/variables'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; -function QuickbooksTaxesPage({ policy }: WithPolicyProps) { - const { translate } = useLocalize(); +function QuickbooksTaxesPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; - const { syncTaxes, pendingFields } = policy?.connections?.quickbooksOnline?.config ?? {}; + const {syncTaxes, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {}; const isSwitchOn = Boolean(syncTaxes && syncTaxes !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); return ( From 57002826401862cbe911adcc848ea1e7b266e26a Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 11 Apr 2024 14:23:21 +0100 Subject: [PATCH 116/339] block routes without permission for QuickbooksAdvancedPage --- .../qbo/advanced/QuickbooksAdvancedPage.tsx | 142 ++++++++++-------- 1 file changed, 77 insertions(+), 65 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index ac81eff5b12b..5231fcec9523 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -11,6 +11,9 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import useWaitForNavigation from '@hooks/useWaitForNavigation'; import Navigation from '@libs/Navigation/Navigation'; +import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; +import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; +import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; @@ -48,77 +51,86 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { ]; return ( - - - - - {qboSyncToggleSettings.map((item) => ( - + + + - - - ))} + + + + {qboSyncToggleSettings.map((item) => ( + + + + ))} - - - + + + - - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, !reimbursementAccountID)} - /> - - - Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.getRoute(policyID)))} - /> - + + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, !reimbursementAccountID)} + /> + + + Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.getRoute(policyID)))} + /> + - - - + + + - + - Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR.getRoute(policyID)))} - /> - - + Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR.getRoute(policyID)))} + /> + + + + + ); } From 5a127b64ba8564fda76f2ac6731bb31ef53106f0 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 11 Apr 2024 14:27:30 +0100 Subject: [PATCH 117/339] block routes without permission for QuickbooksAccountSelectPage --- .../advanced/QuickbooksAccountSelectPage.tsx | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 0327ef2a9be5..246d0df93aed 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -9,6 +9,9 @@ import RadioListItem from '@components/SelectionList/RadioListItem'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; +import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; +import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; @@ -28,6 +31,8 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const [selectedAccount, setSelectedAccount] = useState(CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_PAYROLL_ACCOUNT); + const policyID = policy?.id ?? ''; + const qboOnlineSelectorOptions = useMemo( () => Object.entries(CONST.QBO_SELECTOR_OPTIONS).map(([key, value]) => ({ @@ -55,18 +60,27 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { ); return ( - - + + + + + - - {translate('workspace.qbo.advancedConfig.accountSelectDescription')} - - {showQBOOnlineSelectorOptions()} - + + {translate('workspace.qbo.advancedConfig.accountSelectDescription')} + + {showQBOOnlineSelectorOptions()} + + + + ); } From 798d001d24d7941c303e2aa5a65ff5afbb22ab94 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 11 Apr 2024 14:31:17 +0100 Subject: [PATCH 118/339] block routes without permission for QuickbooksInvoiceAccountSelectPage --- .../QuickbooksInvoiceAccountSelectPage.tsx | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 3c95f0f83f0e..7a05f16c4577 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -9,6 +9,9 @@ import RadioListItem from '@components/SelectionList/RadioListItem'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; +import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; +import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; @@ -28,6 +31,8 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const [selectedAccount, setSelectedAccount] = useState(CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_MONEY_IN_CLEARING); + const policyID = policy?.id ?? ''; + const qboOnlineSelectorOptions = useMemo( () => Object.entries(CONST.QBO_SELECTOR_OPTIONS).map(([key, value]) => ({ @@ -55,18 +60,27 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { ); return ( - - + + + + + - - {translate('workspace.qbo.advancedConfig.invoiceAccountSelectDescription')} - - {showQBOOnlineSelectorOptions()} - + + {translate('workspace.qbo.advancedConfig.invoiceAccountSelectDescription')} + + {showQBOOnlineSelectorOptions()} + + + + ); } From fb5e231cb503622e650bfcf85c2e2d1f7028831f Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 11 Apr 2024 14:53:31 +0100 Subject: [PATCH 119/339] fix lint --- .../API/parameters/UpdatePolicyConnectionConfigParams.ts | 2 +- src/libs/actions/Policy.ts | 6 +----- .../accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx | 2 +- .../qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts index 4cf0123b6ec2..40b09bf5f628 100644 --- a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts +++ b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts @@ -5,7 +5,7 @@ type UpdatePolicyConnectionConfigParams = { policyID: string; connectionName: string; settingName: ValueOf; - settingValue: ValueOf | string | boolean; + settingValue: string | boolean; idempotencyKey: string; }; diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 21c8390ee2e6..7526402df2ed 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -3721,11 +3721,7 @@ function openPolicyDistanceRatesPage(policyID?: string) { API.read(READ_COMMANDS.OPEN_POLICY_DISTANCE_RATES_PAGE, params); } -function updatePolicyConnectionConfig( - policyID: string, - settingName: ValueOf, - settingValue: ValueOf | string | boolean, -) { +function updatePolicyConnectionConfig(policyID: string, settingName: ValueOf, settingValue: string | boolean) { const parameters = {policyID, connectionName: CONST.QUICK_BOOKS_ONLINE, settingName, settingValue, idempotencyKey: settingName}; const optimisticData: OnyxUpdate[] = [ { diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 246d0df93aed..8bc94a16dd23 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -41,7 +41,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { keyForList: key, isSelected: selectedAccount === value, })), - [selectedAccount], + [selectedAccount, translate], ); const showQBOOnlineSelectorOptions = useCallback( diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 7a05f16c4577..60063e4a5246 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -41,7 +41,7 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { keyForList: key, isSelected: selectedAccount === value, })), - [selectedAccount], + [selectedAccount, translate], ); const showQBOOnlineSelectorOptions = useCallback( From 0527498891029bd178e4a6f12c64a4fd5ba168c7 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 11 Apr 2024 15:45:12 +0100 Subject: [PATCH 120/339] add pending fields --- .../qbo/advanced/QuickbooksAdvancedPage.tsx | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index 5231fcec9523..533961bd2e59 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -27,7 +27,8 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? ''; - const {autoSync, syncPeople, autoCreateVendor, reimbursementAccountID} = policy?.connections?.quickbooksOnline?.config ?? {}; + const {autoSync, syncPeople, autoCreateVendor, reimbursementAccountID, collectionAccountID, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {}; + const {bankAccounts} = policy?.connections?.quickbooksOnline?.data ?? {}; const qboSyncToggleSettings = [ { @@ -35,18 +36,21 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { subTitle: translate('workspace.qbo.advancedConfig.autoSyncDescription'), isActive: Boolean(autoSync), onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.AUTO_SYNC, !autoSync), + pendingAction: pendingFields?.autoSync, }, { title: translate('workspace.qbo.advancedConfig.inviteEmployees'), subTitle: translate('workspace.qbo.advancedConfig.inviteEmployeesDescription'), isActive: Boolean(syncPeople), onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.SYNCE_PEOPLE, !syncPeople), + pendingAction: pendingFields?.syncPeople, }, { title: translate('workspace.qbo.advancedConfig.createEntities'), subTitle: translate('workspace.qbo.advancedConfig.createEntitiesDescription'), isActive: Boolean(autoCreateVendor), onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR, !autoCreateVendor), + pendingAction: pendingFields?.autoCreateVendor, }, ]; @@ -66,9 +70,10 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { {qboSyncToggleSettings.map((item) => ( - - + ))} @@ -86,24 +91,26 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { /> - + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, !reimbursementAccountID)} - /> - - - Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.getRoute(policyID)))} + isActive={Boolean(reimbursementAccountID && collectionAccountID)} + onToggle={() => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, bankAccounts?.[0].id ?? '')} /> + Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.getRoute(policyID)))} + /> + Date: Fri, 12 Apr 2024 11:26:39 +0100 Subject: [PATCH 121/339] update toggle switch component --- .../workflows/ToggleSettingsOptionRow.tsx | 54 ++++++++++++++----- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index ec8cec4aaa20..b2489cdd3746 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import {View} from 'react-native'; +import {View, ViewStyle} from 'react-native'; import Icon from '@components/Icon'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import Switch from '@components/Switch'; @@ -9,12 +9,18 @@ import type {Errors, PendingAction} from '@src/types/onyx/OnyxCommon'; import type IconAsset from '@src/types/utils/IconAsset'; type ToggleSettingOptionRowProps = { + // Key used internally by React + key?: string; /** Icon to be shown for the option */ icon?: IconAsset; /** Title of the option */ title: string; /** Subtitle of the option */ subtitle: string; + /** subtitle should show below switch and title */ + shouldPlaceSubtitleBelowSwitch?: boolean; + /** Used to apply styles to the outermost container */ + wrapperStyle?: ViewStyle; /** Whether the option is enabled or not */ isActive: boolean; /** Callback to be called when the switch is toggled */ @@ -30,14 +36,44 @@ type ToggleSettingOptionRowProps = { }; const ICON_SIZE = 48; -function ToggleSettingOptionRow({icon, title, subtitle, onToggle, subMenuItems, isActive, pendingAction, errors, onCloseError}: ToggleSettingOptionRowProps) { +function ToggleSettingOptionRow({ + key, + icon, + title, + subtitle, + shouldPlaceSubtitleBelowSwitch, + wrapperStyle, + onToggle, + subMenuItems, + isActive, + pendingAction, + errors, + onCloseError, +}: ToggleSettingOptionRowProps) { const styles = useThemeStyles(); + const subTitleView = () => { + return ( + + {subtitle} + + ); + }; + return ( @@ -56,23 +92,14 @@ function ToggleSettingOptionRow({icon, title, subtitle, onToggle, subMenuItems, {title} - - {subtitle} - + {!shouldPlaceSubtitleBelowSwitch && subTitleView()} + {shouldPlaceSubtitleBelowSwitch && subTitleView()} {isActive && subMenuItems} From 4655224bd0afa2c153007207869bc6d5285bdcb3 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 11:27:16 +0100 Subject: [PATCH 122/339] update advanced component --- .../qbo/advanced/QuickbooksAdvancedPage.tsx | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index 533961bd2e59..5423cca53f04 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -70,18 +70,16 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { {qboSyncToggleSettings.map((item) => ( - - - + /> ))} @@ -91,17 +89,15 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { /> - - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, bankAccounts?.[0].id ?? '')} - /> - + isActive={Boolean(reimbursementAccountID && collectionAccountID)} + onToggle={() => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, bankAccounts?.[0].id ?? '')} + /> - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, !collectionAccountID)} /> Date: Fri, 12 Apr 2024 11:33:12 +0100 Subject: [PATCH 123/339] fix lint --- .../qbo/advanced/QuickbooksAdvancedPage.tsx | 1 - .../workflows/ToggleSettingsOptionRow.tsx | 29 +++++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index 5423cca53f04..16019b9c6aa8 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -3,7 +3,6 @@ import {View} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import MenuItem from '@components/MenuItem'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import SpacerView from '@components/SpacerView'; diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index b2489cdd3746..e7bdbfbd04e0 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -1,5 +1,6 @@ import React from 'react'; -import {View, ViewStyle} from 'react-native'; +import {View} from 'react-native'; +import type {ViewStyle} from 'react-native'; import Icon from '@components/Icon'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import Switch from '@components/Switch'; @@ -52,20 +53,18 @@ function ToggleSettingOptionRow({ }: ToggleSettingOptionRowProps) { const styles = useThemeStyles(); - const subTitleView = () => { - return ( - - {subtitle} - - ); - }; + const subTitleView = () => ( + + {subtitle} + + ); return ( Date: Fri, 12 Apr 2024 12:19:12 +0100 Subject: [PATCH 124/339] remove shouldEnableMaxHeight --- .../accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx | 1 - .../qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 8bc94a16dd23..007f9e66ce45 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -68,7 +68,6 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { > diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 60063e4a5246..058ae72c095f 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -68,7 +68,6 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { > From 57f70512ebbabd773b1ef64e902af45edad2cb8b Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 13:05:29 +0100 Subject: [PATCH 125/339] use selectionList for QuickbooksAccountSelectPage --- .../advanced/QuickbooksAccountSelectPage.tsx | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 007f9e66ce45..4fa5a038353f 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -2,9 +2,8 @@ import React, {useCallback, useMemo, useState} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; import ScreenWrapper from '@components/ScreenWrapper'; -import ScrollView from '@components/ScrollView'; +import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; @@ -43,22 +42,22 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { })), [selectedAccount, translate], ); - - const showQBOOnlineSelectorOptions = useCallback( - () => - qboOnlineSelectorOptions.map((item) => ( - - setSelectedAccount(item.value)} - showTooltip={false} - isFocused={item.isSelected} - /> - - )), - [qboOnlineSelectorOptions, setSelectedAccount], + const listHeaderComponent = useMemo( + () => ( + + {translate('workspace.qbo.advancedConfig.invoiceAccountSelectDescription')} + + ), + [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], ); + const initiallyFocusedOptionKey = useMemo(() => qboOnlineSelectorOptions.find((mode) => mode.isSelected)?.keyForList, [qboOnlineSelectorOptions]); + + const updateMode = useCallback((mode: SelectorType) => { + // TODO add API call for change + setSelectedAccount(mode.value); + }, []); + return ( @@ -72,10 +71,13 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { > - - {translate('workspace.qbo.advancedConfig.accountSelectDescription')} - - {showQBOOnlineSelectorOptions()} + From f195d67537407f44d795330bdcd92827113cfa25 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 13:05:52 +0100 Subject: [PATCH 126/339] use selectionList for QuickbooksInvoiceAccountSelectPage --- .../QuickbooksInvoiceAccountSelectPage.tsx | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 058ae72c095f..15fdf2e9424d 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -2,9 +2,8 @@ import React, {useCallback, useMemo, useState} from 'react'; import {View} from 'react-native'; import type {ValueOf} from 'type-fest'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; import ScreenWrapper from '@components/ScreenWrapper'; -import ScrollView from '@components/ScrollView'; +import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; @@ -44,21 +43,22 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { [selectedAccount, translate], ); - const showQBOOnlineSelectorOptions = useCallback( - () => - qboOnlineSelectorOptions.map((item) => ( - - setSelectedAccount(item.value)} - showTooltip={false} - isFocused={item.isSelected} - /> - - )), - [qboOnlineSelectorOptions, setSelectedAccount], + const listHeaderComponent = useMemo( + () => ( + + {translate('workspace.qbo.advancedConfig.invoiceAccountSelectDescription')} + + ), + [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], ); + const initiallyFocusedOptionKey = useMemo(() => qboOnlineSelectorOptions.find((mode) => mode.isSelected)?.keyForList, [qboOnlineSelectorOptions]); + + const updateMode = useCallback((mode: SelectorType) => { + // TODO add API call for change + setSelectedAccount(mode.value); + }, []); + return ( @@ -72,10 +72,13 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { > - - {translate('workspace.qbo.advancedConfig.invoiceAccountSelectDescription')} - - {showQBOOnlineSelectorOptions()} + From c3979f67318f56ca026d1d632c88ecb467ba3da8 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 13:10:17 +0100 Subject: [PATCH 127/339] extend ListItem for SelectorType for QuickbooksAccountSelectPage --- .../accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 4fa5a038353f..1ce4ebf13e81 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -5,6 +5,7 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; +import {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -17,11 +18,8 @@ import CONST from '@src/CONST'; type CustomSelectorTypes = ValueOf; -type SelectorType = { +type SelectorType = ListItem & { value: CustomSelectorTypes; - text: string; - keyForList: string; - isSelected: boolean; }; function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { From 192ab99c2bf0bbc3aa720bf01acbc09f43737846 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 13:11:10 +0100 Subject: [PATCH 128/339] extend ListItem for SelectorType for QuickbooksInvoiceAccountSelectPage --- .../qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 15fdf2e9424d..481d1464d9c7 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -5,6 +5,7 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; +import {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -17,11 +18,8 @@ import CONST from '@src/CONST'; type CustomSelectorTypes = ValueOf; -type SelectorType = { +type SelectorType = ListItem & { value: CustomSelectorTypes; - text: string; - keyForList: string; - isSelected: boolean; }; function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { From 39e92ba6a48811ab2399fb531d519d0cd4724bb1 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 13:13:19 +0100 Subject: [PATCH 129/339] fix lint --- .../accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx | 2 +- .../qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 1ce4ebf13e81..57eba473885d 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -5,7 +5,7 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; -import {ListItem} from '@components/SelectionList/types'; +import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 481d1464d9c7..eeb09eb99137 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -5,7 +5,7 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; -import {ListItem} from '@components/SelectionList/types'; +import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; From 16207ef60f18120884252e65b8949753c3759a64 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 13:21:33 +0100 Subject: [PATCH 130/339] Navigate back after selection for QuickbooksAccountSelectPage --- .../accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 57eba473885d..cf4060263aee 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -9,6 +9,7 @@ import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@libs/Navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper'; @@ -54,6 +55,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const updateMode = useCallback((mode: SelectorType) => { // TODO add API call for change setSelectedAccount(mode.value); + Navigation.goBack(); }, []); return ( From 5b238310662e4a8b94cf422b46e270b45d6a05d5 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 13:21:51 +0100 Subject: [PATCH 131/339] Navigate back after selection for QuickbooksInvoiceAccountSelectPage --- .../qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index eeb09eb99137..cf278c99ec86 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -9,6 +9,7 @@ import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@libs/Navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper'; @@ -55,6 +56,7 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const updateMode = useCallback((mode: SelectorType) => { // TODO add API call for change setSelectedAccount(mode.value); + Navigation.goBack(); }, []); return ( From 1794de9bd6192f3a2452c38457df7266b60239de Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 13:58:28 +0100 Subject: [PATCH 132/339] use ToggleSettingOptionRowProps --- .../qbo/advanced/QuickbooksAdvancedPage.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index 16019b9c6aa8..c6df17e53625 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -16,6 +16,7 @@ import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccess import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; +import type {ToggleSettingOptionRowProps} from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -29,24 +30,24 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const {autoSync, syncPeople, autoCreateVendor, reimbursementAccountID, collectionAccountID, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {}; const {bankAccounts} = policy?.connections?.quickbooksOnline?.data ?? {}; - const qboSyncToggleSettings = [ + const qboSyncToggleSettings: ToggleSettingOptionRowProps[] = [ { title: translate('workspace.qbo.advancedConfig.autoSync'), - subTitle: translate('workspace.qbo.advancedConfig.autoSyncDescription'), + subtitle: translate('workspace.qbo.advancedConfig.autoSyncDescription'), isActive: Boolean(autoSync), onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.AUTO_SYNC, !autoSync), pendingAction: pendingFields?.autoSync, }, { title: translate('workspace.qbo.advancedConfig.inviteEmployees'), - subTitle: translate('workspace.qbo.advancedConfig.inviteEmployeesDescription'), + subtitle: translate('workspace.qbo.advancedConfig.inviteEmployeesDescription'), isActive: Boolean(syncPeople), onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.SYNCE_PEOPLE, !syncPeople), pendingAction: pendingFields?.syncPeople, }, { title: translate('workspace.qbo.advancedConfig.createEntities'), - subTitle: translate('workspace.qbo.advancedConfig.createEntitiesDescription'), + subtitle: translate('workspace.qbo.advancedConfig.createEntitiesDescription'), isActive: Boolean(autoCreateVendor), onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR, !autoCreateVendor), pendingAction: pendingFields?.autoCreateVendor, @@ -72,7 +73,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { Date: Fri, 12 Apr 2024 14:32:50 +0100 Subject: [PATCH 133/339] use MenuItemWithTopDescription --- .../accounting/qbo/advanced/QuickbooksAdvancedPage.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index c6df17e53625..7f55af328a33 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -94,7 +94,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { subtitle={translate('workspace.qbo.advancedConfig.reimbursedReportsDescription')} shouldPlaceSubtitleBelowSwitch wrapperStyle={styles.mv3} - pendingAction={pendingFields?.reimbursementAccountID && pendingFields?.collectionAccountID} + pendingAction={pendingFields?.reimbursementAccountID || pendingFields?.collectionAccountID} isActive={Boolean(reimbursementAccountID && collectionAccountID)} onToggle={() => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, bankAccounts?.[0].id ?? '')} /> @@ -124,10 +124,9 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { onToggle={() => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, !collectionAccountID)} /> - Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR.getRoute(policyID)))} /> From 015f7d87d4ad2607a48fc1922a035d79b1687501 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 14:33:56 +0100 Subject: [PATCH 134/339] fix lint --- .../workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index 7f55af328a33..24c86f2a51d9 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -1,7 +1,6 @@ import React from 'react'; import {View} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import MenuItem from '@components/MenuItem'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; From 025758bd07f9339f8c2aa68d31015b7e0fcdf20d Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 21:47:43 +0100 Subject: [PATCH 135/339] rename to policy accounting --- src/SCREENS.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 1640ce8f3d3a..dbd8a974e136 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -251,7 +251,7 @@ const SCREENS = { OWNER_CHANGE_SUCCESS: 'Workspace_Owner_Change_Success', OWNER_CHANGE_ERROR: 'Workspace_Owner_Change_Error', DISTANCE_RATES: 'Distance_Rates', - QUICKBOOKS_ONLINE_ADVANCED: 'Workspace_Accounting_Quickbooks_Online_Advanced', + QUICKBOOKS_ONLINE_ADVANCED: 'Policy_Accounting_Quickbooks_Online_Advanced', QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR: 'Policy_Accounting_Quickbooks_Online_Account_Selector', QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR: 'Policy_Accounting_Quickbooks_Online_Invoice_Account_Selector', CREATE_DISTANCE_RATE: 'Create_Distance_Rate', From ac5a92416e6b2f948459d354fc8f82f3ff423156 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 21:50:00 +0100 Subject: [PATCH 136/339] move close to other policy accounting routes --- src/ROUTES.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 3060c24baf21..9337d544f199 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -550,6 +550,18 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting` as const, }, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ADVANCED: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/advanced', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/advanced` as const, + }, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/account-selector', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/account-selector` as const, + }, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/invoice-account-selector', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/invoice-account-selector` as const, + }, WORKSPACE_CATEGORIES: { route: 'settings/workspaces/:policyID/categories', getRoute: (policyID: string) => `settings/workspaces/${policyID}/categories` as const, @@ -574,18 +586,6 @@ const ROUTES = { route: 'settings/workspaces/:policyID/categories/:categoryName/edit', getRoute: (policyID: string, categoryName: string) => `settings/workspaces/${policyID}/categories/${encodeURIComponent(categoryName)}/edit` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ADVANCED: { - route: 'settings/workspaces/:policyID/accounting/quickbooks-online/advanced', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/advanced` as const, - }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR: { - route: 'settings/workspaces/:policyID/accounting/quickbooks-online/account-selector', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/account-selector` as const, - }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR: { - route: 'settings/workspaces/:policyID/accounting/quickbooks-online/invoice-account-selector', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/invoice-account-selector` as const, - }, WORKSPACE_TAGS: { route: 'settings/workspaces/:policyID/tags', getRoute: (policyID: string) => `settings/workspaces/${policyID}/tags` as const, From e30539f01eee6343c708475ecfa4983a1c59ed62 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 21:55:41 +0100 Subject: [PATCH 137/339] use array instead of object spread --- .../workspace/workflows/ToggleSettingsOptionRow.tsx | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index f1141b5ee4ba..7e4425c08d31 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -56,18 +56,7 @@ function ToggleSettingOptionRow({ }: ToggleSettingOptionRowProps) { const styles = useThemeStyles(); - const subTitleView = () => ( - - {subtitle} - - ); + const subTitleView = () => {subtitle}; return ( Date: Fri, 12 Apr 2024 21:59:35 +0100 Subject: [PATCH 138/339] use useMemo to rerun a ready-to-render view --- .../workspace/workflows/ToggleSettingsOptionRow.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index 7e4425c08d31..c15c4645ca62 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useMemo} from 'react'; import {View} from 'react-native'; import type {ViewStyle} from 'react-native'; import Icon from '@components/Icon'; @@ -56,7 +56,10 @@ function ToggleSettingOptionRow({ }: ToggleSettingOptionRowProps) { const styles = useThemeStyles(); - const subTitleView = () => {subtitle}; + const subTitleView = useMemo( + () => {subtitle}, + [shouldPlaceSubtitleBelowSwitch, styles.mr5, styles.mt1, styles.mt4, styles.textLabel, styles.textSupporting], + ); return ( {title} - {!shouldPlaceSubtitleBelowSwitch && subTitleView()} + {!shouldPlaceSubtitleBelowSwitch && subTitleView} - {shouldPlaceSubtitleBelowSwitch && subTitleView()} + {shouldPlaceSubtitleBelowSwitch && subTitleView} {isActive && subMenuItems} From 65f8f41630ec1e71ef2ffd1377bd307183a6d130 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 22:02:06 +0100 Subject: [PATCH 139/339] update wrapperStyle types --- src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index c15c4645ca62..7aa22826c2ac 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -1,6 +1,6 @@ import React, {useMemo} from 'react'; import {View} from 'react-native'; -import type {ViewStyle} from 'react-native'; +import type {StyleProp, ViewStyle} from 'react-native'; import Icon from '@components/Icon'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import Switch from '@components/Switch'; @@ -21,7 +21,7 @@ type ToggleSettingOptionRowProps = { /** subtitle should show below switch and title */ shouldPlaceSubtitleBelowSwitch?: boolean; /** Used to apply styles to the outermost container */ - wrapperStyle?: ViewStyle; + wrapperStyle?: StyleProp; /** Whether the option is enabled or not */ isActive: boolean; /** Callback to be called when the switch is toggled */ @@ -73,7 +73,7 @@ function ToggleSettingOptionRow({ - {icon && ( + {!!icon && ( Date: Fri, 12 Apr 2024 22:04:08 +0100 Subject: [PATCH 140/339] use array instead of object spread --- .../workflows/ToggleSettingsOptionRow.tsx | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index 7aa22826c2ac..58ba5577ed49 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -78,21 +78,11 @@ function ToggleSettingOptionRow({ src={icon} height={ICON_SIZE} width={ICON_SIZE} - additionalStyles={{ - ...styles.mr3, - }} + additionalStyles={[styles.mr3]} /> )} - - {title} - + {title} {!shouldPlaceSubtitleBelowSwitch && subTitleView} From 06fbd1aff4903319f87d01a6b16283d3d8bc0c13 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 12 Apr 2024 22:10:45 +0100 Subject: [PATCH 141/339] add TODO to unfinished implementations --- .../accounting/qbo/advanced/QuickbooksAdvancedPage.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index 24c86f2a51d9..7e86a64592bb 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -93,6 +93,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { subtitle={translate('workspace.qbo.advancedConfig.reimbursedReportsDescription')} shouldPlaceSubtitleBelowSwitch wrapperStyle={styles.mv3} + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing pendingAction={pendingFields?.reimbursementAccountID || pendingFields?.collectionAccountID} isActive={Boolean(reimbursementAccountID && collectionAccountID)} onToggle={() => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, bankAccounts?.[0].id ?? '')} @@ -100,7 +101,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.getRoute(policyID)))} @@ -114,7 +115,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { Date: Fri, 12 Apr 2024 22:22:19 +0100 Subject: [PATCH 142/339] fix lint: add missing dep. --- src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index 58ba5577ed49..348bc576c67d 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -58,7 +58,7 @@ function ToggleSettingOptionRow({ const subTitleView = useMemo( () => {subtitle}, - [shouldPlaceSubtitleBelowSwitch, styles.mr5, styles.mt1, styles.mt4, styles.textLabel, styles.textSupporting], + [shouldPlaceSubtitleBelowSwitch, subtitle, styles.mr5, styles.mt1, styles.mt4, styles.textLabel, styles.textSupporting], ); return ( From 44f8588362082b7f54888dbab295561c4e6e2359 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 15 Apr 2024 12:30:03 +0100 Subject: [PATCH 143/339] remove waitForNavigate --- src/pages/workspace/accounting/WorkspaceAccountingPage.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx b/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx index efcd3e29c641..8f82f1520286 100644 --- a/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx +++ b/src/pages/workspace/accounting/WorkspaceAccountingPage.tsx @@ -16,7 +16,6 @@ import type ThreeDotsMenuProps from '@components/ThreeDotsMenu/types'; import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import useWaitForNavigation from '@hooks/useWaitForNavigation'; import useWindowDimensions from '@hooks/useWindowDimensions'; import Navigation from '@navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; @@ -33,7 +32,6 @@ function WorkspaceAccountingPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); // const {environmentURL} = useEnvironment(); - const waitForNavigate = useWaitForNavigation(); const {isSmallScreenWidth, windowWidth} = useWindowDimensions(); const [threeDotsMenuPosition, setThreeDotsMenuPosition] = useState({horizontal: 0, vertical: 0}); @@ -159,11 +157,11 @@ function WorkspaceAccountingPage({policy}: WithPolicyProps) { shouldShowRightIcon: true, title: translate('workspace.accounting.advanced'), wrapperStyle: [styles.sectionMenuItemTopDescription], - onPress: waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ADVANCED.getRoute(policyID))), + onPress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ADVANCED.getRoute(policyID)), }, ]), ], - [styles.sectionMenuItemTopDescription, styles.popoverMenuIcon, translate, waitForNavigate, isSyncInProgress, theme.spinner, overflowMenu, threeDotsMenuPosition, policyID], + [styles.sectionMenuItemTopDescription, styles.popoverMenuIcon, translate, isSyncInProgress, theme.spinner, overflowMenu, threeDotsMenuPosition, policyID], ); const headerThreeDotsMenuItems: ThreeDotsMenuProps['menuItems'] = [ From 76d4ef7fd06b1e35bcc5ba8f75a2573e422a8357 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 15 Apr 2024 12:33:22 +0100 Subject: [PATCH 144/339] update function name saveSelection --- .../accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index cf4060263aee..c7366689237b 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -52,7 +52,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const initiallyFocusedOptionKey = useMemo(() => qboOnlineSelectorOptions.find((mode) => mode.isSelected)?.keyForList, [qboOnlineSelectorOptions]); - const updateMode = useCallback((mode: SelectorType) => { + const saveSelection = useCallback((mode: SelectorType) => { // TODO add API call for change setSelectedAccount(mode.value); Navigation.goBack(); @@ -75,7 +75,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { sections={[{data: qboOnlineSelectorOptions}]} ListItem={RadioListItem} headerContent={listHeaderComponent} - onSelectRow={updateMode} + onSelectRow={saveSelection} initiallyFocusedOptionKey={initiallyFocusedOptionKey} /> From 459a47a7d7b848e11c1cf212690ca94e6678a410 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 15 Apr 2024 12:37:02 +0100 Subject: [PATCH 145/339] update object name to qboToggleSettingItems --- .../accounting/qbo/advanced/QuickbooksAdvancedPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index 7e86a64592bb..30e1888da0ba 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -29,7 +29,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const {autoSync, syncPeople, autoCreateVendor, reimbursementAccountID, collectionAccountID, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {}; const {bankAccounts} = policy?.connections?.quickbooksOnline?.data ?? {}; - const qboSyncToggleSettings: ToggleSettingOptionRowProps[] = [ + const qboToggleSettingItems: ToggleSettingOptionRowProps[] = [ { title: translate('workspace.qbo.advancedConfig.autoSync'), subtitle: translate('workspace.qbo.advancedConfig.autoSyncDescription'), @@ -68,7 +68,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { - {qboSyncToggleSettings.map((item) => ( + {qboToggleSettingItems.map((item) => ( Date: Mon, 15 Apr 2024 12:42:57 +0100 Subject: [PATCH 146/339] update ToggleSettingOptionRow --- src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index 348bc576c67d..e6adc6f451c6 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -82,7 +82,7 @@ function ToggleSettingOptionRow({ /> )} - {title} + {title} {!shouldPlaceSubtitleBelowSwitch && subTitleView} From b06c5bfa9ef90a8813bc5aaff90bce7b96790269 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 15 Apr 2024 13:31:09 +0100 Subject: [PATCH 147/339] add 20px padding bottom to content container --- .../accounting/qbo/advanced/QuickbooksAdvancedPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index 30e1888da0ba..4d59058f00be 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -67,7 +67,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { > - + {qboToggleSettingItems.map((item) => ( Date: Mon, 15 Apr 2024 17:20:24 +0300 Subject: [PATCH 148/339] Design updates + updates for translations + updates for onyx api keys usage --- src/languages/en.ts | 18 ++++----- src/languages/es.ts | 40 +++++++++---------- .../ModalStackNavigators/index.tsx | 16 ++++---- src/libs/PolicyUtils.ts | 6 +++ ...oksCompanyCardExpenseAccountSelectPage.tsx | 35 +++++----------- ...oksCompanyCardExpenseConfigurationPage.tsx | 0 .../QuickbooksExportConfigurationPage.tsx | 0 .../QuickbooksExportDateSelectPage.tsx | 0 .../QuickbooksInvoiceAccountSelectPage.tsx | 25 +++++------- ...oksOutOfPocketExpenseConfigurationPage.tsx | 4 +- ...ooksOutOfPocketExpenseEntitySelectPage.tsx | 2 +- ...ooksPreferredExporterConfigurationPage.tsx | 15 +++---- src/types/onyx/Policy.ts | 2 +- src/types/onyx/PolicyMember.ts | 4 +- tests/utils/collections/policyMembers.ts | 4 +- 15 files changed, 77 insertions(+), 94 deletions(-) rename src/pages/workspace/accounting/qbo/{ => export}/QuickbooksCompanyCardExpenseAccountSelectPage.tsx (64%) rename src/pages/workspace/accounting/qbo/{ => export}/QuickbooksCompanyCardExpenseConfigurationPage.tsx (100%) rename src/pages/workspace/accounting/qbo/{ => export}/QuickbooksExportConfigurationPage.tsx (100%) rename src/pages/workspace/accounting/qbo/{ => export}/QuickbooksExportDateSelectPage.tsx (100%) rename src/pages/workspace/accounting/qbo/{ => export}/QuickbooksInvoiceAccountSelectPage.tsx (83%) rename src/pages/workspace/accounting/qbo/{ => export}/QuickbooksOutOfPocketExpenseConfigurationPage.tsx (93%) rename src/pages/workspace/accounting/qbo/{ => export}/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx (95%) rename src/pages/workspace/accounting/qbo/{ => export}/QuickbooksPreferredExporterConfigurationPage.tsx (78%) diff --git a/src/languages/en.ts b/src/languages/en.ts index f21fdd57c22e..32d301aed491 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1881,15 +1881,15 @@ export default { exportInvoices: 'Export invoices to', exportCompany: 'Export company cards as', exportExpensifyCard: 'Export Expensify Card transactions as', - deepDiveExpensifyCard: 'Expensify Card transactions automatically export to a “Expensify Card Liability Account” created with', + deepDiveExpensifyCard: 'Expensify Card transactions automatically export to a "Expensify Card Liability Account" created with', deepDiveExpensifyCardIntegration: 'our integration.', - exportDate: 'Export Date', + exportDate: 'Export date', exportDateDescription: 'Use this date when exporting reports to QuickBooks Online.', lastExpense: {label: 'Date of last expense', description: 'The date of the most recent expense on the report'}, - exportedDate: {label: 'Export date', description: 'The date the report was exported to QuickBooksOnline'}, - submittedData: {label: 'Submitted data', description: 'The date the report was submitted for approval'}, - receivable: 'Accounts receivable', - archive: 'Accounts receivable archive', + exportedDate: {label: 'Export date', description: 'The date the report was exported to QuickBooks Online'}, + submittedData: {label: 'Submitted date', description: 'The date the report was submitted for approval'}, + receivable: 'Accounts receivable', // This is an account name that will come directly from QBO, so I don't know why we need a translation for it. It should take whatever the name of the account is in QBO. Leaving this note for CS. + archive: 'Accounts receivable archive', // This is an account name that will come directly from QBO, so I don't know why we need a translation for it. It should take whatever the name of the account is in QBO. Leaving this note for CS. exportInvoicesDescription: 'Invoices will be exported to this account in QuickBooks Online.', exportCompanyCardsDescription: 'Set how company card purchases export to QuickBooks Online.', creditCard: 'Credit Card', @@ -1899,16 +1899,16 @@ export default { exportPreferredExporterSubNote: 'Once set, the preferred exporter will see reports for export in their account.', exportOutOfPocketExpensesDescription: 'Set how out-of-pocket expenses export to QuickBooks Online.', exportVendorBillDescription: - 'We’ll create a single itemized vendor bill for each Expensify report. If the period of the bill is closed, we’ll post to the 1st of the next open period. You can add the vendor bill to your A/P account of choice (below).', + 'We`ll create a single itemized vendor bill for each Expensify report. If the period of the bill is closed, we`ll post to the 1st of the next open period. You can add the vendor bill to your A/P account of choice (below).', check: 'Check', journalEntry: 'Journal Entry', optionBelow: 'Choose an option below:', outOfPocketTaxEnabledDescription: - 'Note: QuickBooks Online doesn’t support a field for tax on Journal Entry exports. Because you have tax tracking enabled on your workspace, this export option is unavailable.', + 'Note: QuickBooks Online doesn`t support a field for tax on Journal Entry exports. Because you have tax tracking enabled on your workspace, this export option is unavailable.', outOfPocketTaxEnabledError: 'Journal entry is not available when taxes enabled. please select a different export option.', outOfPocketLocationEnabledError: 'Vendor Bills are not available when locations are enabled. Please select a different export option.', outOfPocketLocationEnabledDescription: - 'Note: QuickBooks Online does not support a field for Locations as Tags on Vendor Bills exports. As you import Locations from, this this export option is unavailable.', + 'Note: QuickBooks Online does not support a field for Locations as Tags on Vendor Bills exports. As you import Locations as Tags, this export option is unavailable.', }, type: { free: 'Free', diff --git a/src/languages/es.ts b/src/languages/es.ts index 3d5f0be75fe4..b7760e856aa3 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1901,42 +1901,42 @@ export default { 'Los lugares son importados como Etiquegas. Esto limita a exportar los informes de gastos como Factura del Proveedor o Cheques a Quicbooks Online. Para desbloquear estas opciones de exportación desactiva la importación de Lugares o cambia al Plan Control para exportar Lugares como Campos de Informes.', export: 'Exportar', exportAs: 'Exportar cómo', - exportDescription: 'Configure cómo se exportan los datos de Expensify a QuickBooks Online.', - preferredExporter: 'Exportador preferido', - date: 'Fecha', exportExpenses: 'Exportar gastos de bolsillo como', exportInvoices: 'Exportar facturas a', exportCompany: 'Exportar tarjetas de empresa como', - exportExpensifyCard: 'Exportar transacciones de la tarjeta Expensify como', + exportDescription: 'Configura cómo se exportan los datos de Expensify a QuickBooks Online.', + preferredExporter: 'Exportador preferido', + date: 'Fecha', deepDiveExpensifyCard: 'Las transacciones de la Tarjeta Expensify se exportan automáticamente a una "Cuenta de Responsabilidad de la Tarjeta Expensify" creada con', deepDiveExpensifyCardIntegration: 'nuestra integración.', + exportExpensifyCard: 'Exportar las transacciones de las tarjetas Expensify como', exportDate: 'Fecha de exportación', - exportDateDescription: 'Utilice esta fecha al exportar informes a QuickBooks Online.', - lastExpense: {label: 'Fecha del último gasto', description: 'La fecha del gasto más reciente en el informe.'}, - exportedDate: {label: 'Fecha de exportación', description: 'La fecha en que se exportó el informe a QuickBooks Online'}, - submittedData: {label: 'Datos enviados', description: 'La fecha en que se presentó el informe para su aprobación.'}, - receivable: 'Cuentas por cobrar', - archive: 'Archivo de cuentas por cobrar', + exportDateDescription: 'Use this date when exporting reports to QuickBooks Online.', + lastExpense: {label: 'Date of last expense', description: 'The date of the most recent expense on the report'}, + exportedDate: {label: 'Fecha de exportación', description: 'Fecha de exportación del informe a QuickBooks Online'}, + submittedData: {label: 'Fecha de envío', description: 'Fecha en la que el informe se envió para su aprobación'}, + receivable: 'Cuentas por cobrar', // This is an account name that will come directly from QBO, so I don't know why we need a translation for it. It should take whatever the name of the account is in QBO. Leaving this note for CS. + archive: 'Archivo de cuentas por cobrar', // This is an account name that will come directly from QBO, so I don't know why we need a translation for it. It should take whatever the name of the account is in QBO. Leaving this note for CS. exportInvoicesDescription: 'Las facturas se exportarán a esta cuenta en QuickBooks Online.', - exportCompanyCardsDescription: 'Establezca cómo se exportan las compras con tarjeta de empresa a QuickBooks Online.', - creditCard: 'Tarjeta de crédito', + exportCompanyCardsDescription: 'Establece cómo se exportan las compras con tarjeta de empresa a QuickBooks Online.', debitCard: 'Tarjeta de débito', + check: 'Cheque', + optionBelow: 'Elija una opción a continuación:', + creditCard: 'Tarjeta de crédito', vendorBill: 'Factura del proveedor', exportPreferredExporterNote: 'Puede ser cualquier administrador del espacio de trabajo, pero debe ser un administrador de dominio si configura diferentes cuentas de exportación para tarjetas de empresa individuales en la configuración del dominio.', exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en su cuenta.', + journalEntry: 'Anotación en el diario', // I have no idea what this means in english, sounds ok as a literal tranlsation exportOutOfPocketExpensesDescription: 'Establezca cómo se exportan los gastos de bolsillo a QuickBooks Online.', exportVendorBillDescription: - 'Crearemos una única factura de proveedor detallada para cada informe de Expensify. Si el período de la factura está cerrado, lo publicaremos en el día 1 del próximo período abierto. Puede agregar la factura del proveedor a la cuenta A/P de su elección (a continuación).', - check: 'Cheque', - journalEntry: 'Entrada de diario', - optionBelow: 'Elija una opción a continuación:', + 'Crearemos una única factura de proveedor detallada para cada informe de Expensify. Si el período de la factura está cerrado, lo publicaremos en el día 1 del siguiente período abierto. Puede agregar la factura del proveedor a la cuenta A/P de su elección (a continuación).', outOfPocketTaxEnabledDescription: - 'Nota: QuickBooks Online no admite un campo para impuestos sobre las exportaciones de asientos de diario. Debido a que tiene habilitado el seguimiento de impuestos en su espacio de trabajo, esta opción de exportación no está disponible.', - outOfPocketTaxEnabledError: 'El asiento de diario no está disponible cuando los impuestos están habilitados. seleccione una opción de exportación diferente.', - outOfPocketLocationEnabledError: 'Las facturas de proveedores no están disponibles cuando las ubicaciones están habilitadas. Seleccione una opción de exportación diferente.', + 'Nota: QuickBooks Online no admite un campo para impuestos en las exportaciones de Anotación en el diario. Debido a que tienes habilitado el seguimiento de impuestos en tu área de trabajo, esta opción de exportación no está disponible.', + outOfPocketTaxEnabledError: 'La Anotacion en el diario no está disponible cuando los impuestos están activados. Por favor, selecciona una opción de exportación diferente.', + outOfPocketLocationEnabledError: 'Las facturas de proveedores no están disponibles cuando las ubicaciones están activadas. Seleccione otra opción de exportación.', outOfPocketLocationEnabledDescription: - 'Nota: QuickBooks Online no admite un campo para Ubicaciones como etiquetas en las exportaciones de facturas de proveedores. A medida que importa ubicaciones, esta opción de exportación no está disponible.', + 'Nota: QuickBooks Online no admite un campo para Ubicaciones como Etiquetas en las exportaciones de Facturas de Proveedor. Al importar Ubicaciones como Etiquetas, esta opción de exportación no está disponible.', }, type: { free: 'Gratis', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 869d234ff584..6b114cb58633 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -253,20 +253,20 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsCustomTaxName').default as React.ComponentType, [SCREENS.WORKSPACE.TAXES_SETTINGS_FOREIGN_CURRENCY_DEFAULT]: () => require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsForeignCurrency').default as React.ComponentType, [SCREENS.WORKSPACE.TAXES_SETTINGS_WORKSPACE_CURRENCY_DEFAULT]: () => require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsWorkspaceCurrency').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportConfigurationPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: () => require('../../../../pages/workspace/accounting/qbo/QuickbooksExportDateSelectPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: () => require('@pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: () => require('@pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: () => - require('../../../../pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage').default as React.ComponentType, + require('@pages/workspace/accounting/qbo/export/QuickbooksInvoiceAccountSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: () => - require('../../../../pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseConfigurationPage').default as React.ComponentType, + require('@pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: () => - require('../../../../pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseEntitySelectPage').default as React.ComponentType, + require('@pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE]: () => - require('../../../../pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseConfigurationPage').default as React.ComponentType, + require('@pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: () => - require('../../../../pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseAccountSelectPage').default as React.ComponentType, + require('@pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: () => - require('../../../../pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage').default as React.ComponentType, + require('@pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage').default as React.ComponentType, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType, [SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default as React.ComponentType, [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default as React.ComponentType, diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 665830ca7167..77b297cdd5e5 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -6,6 +6,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {PersonalDetailsList, Policy, PolicyCategories, PolicyMembers, PolicyTagList, PolicyTags, TaxRate} from '@src/types/onyx'; import type {PolicyFeatureName, Rate} from '@src/types/onyx/Policy'; +import PolicyMember from '@src/types/onyx/PolicyMember'; import type {EmptyObject} from '@src/types/utils/EmptyObject'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import getPolicyIDFromState from './Navigation/getPolicyIDFromState'; @@ -317,6 +318,10 @@ function getPolicyIDFromNavigationState() { return getPolicyIDFromState(navigationRef.getRootState() as State); } +function getAdminEmailList(policy: Policy | null) { + return policy?.employeeList?.filter((employee: PolicyMember) => employee?.role === CONST.POLICY.ROLE.ADMIN).map((admin) => admin.email); +} + export { getActivePolicies, hasAccountingConnections, @@ -355,6 +360,7 @@ export { getTaxByID, hasPolicyCategoriesError, getPolicyIDFromNavigationState, + getAdminEmailList, }; export type {MemberEmailsToAccountIDs}; diff --git a/src/pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx similarity index 64% rename from src/pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseAccountSelectPage.tsx rename to src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index 6925dde83b8c..b7183c1d4224 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -9,37 +9,20 @@ import useThemeStyles from '@hooks/useThemeStyles'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; -const CARDS = { - CREDIT_CARD: 'credit_card', - DEBIT_CARD: 'debit_card', - VENDOR_BILL: 'vendor_bill', -}; +const selected = 'selected'; function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const {nonReimbursableExpensesExportDestination} = policy?.connections?.quickbooksOnline?.config ?? {}; + const {creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; // const policyID = policy?.id ?? ''; - const data = [ - { - value: CARDS.CREDIT_CARD, - text: translate(`workspace.qbo.creditCard`), - keyForList: CARDS.CREDIT_CARD, - isSelected: nonReimbursableExpensesExportDestination === CARDS.CREDIT_CARD, - }, - { - value: CARDS.DEBIT_CARD, - text: translate(`workspace.qbo.debitCard`), - keyForList: CARDS.DEBIT_CARD, - isSelected: nonReimbursableExpensesExportDestination === CARDS.DEBIT_CARD, - }, - { - value: CARDS.VENDOR_BILL, - text: translate(`workspace.qbo.vendorBill`), - keyForList: CARDS.VENDOR_BILL, - isSelected: nonReimbursableExpensesExportDestination === CARDS.VENDOR_BILL, - }, - ]; + const data = + creditCards?.map((card) => ({ + value: card.name, + text: card.name, + keyForList: card.name, + isSelected: card.name === selected, + })) || []; const updateMode = useCallback((mode: {value: string}) => { // TODO add API call for change diff --git a/src/pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage.tsx similarity index 100% rename from src/pages/workspace/accounting/qbo/QuickbooksCompanyCardExpenseConfigurationPage.tsx rename to src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage.tsx diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx similarity index 100% rename from src/pages/workspace/accounting/qbo/QuickbooksExportConfigurationPage.tsx rename to src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx diff --git a/src/pages/workspace/accounting/qbo/QuickbooksExportDateSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx similarity index 100% rename from src/pages/workspace/accounting/qbo/QuickbooksExportDateSelectPage.tsx rename to src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx diff --git a/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksInvoiceAccountSelectPage.tsx similarity index 83% rename from src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx rename to src/pages/workspace/accounting/qbo/export/QuickbooksInvoiceAccountSelectPage.tsx index 430c59059676..a2f7c57cbb89 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksInvoiceAccountSelectPage.tsx @@ -10,24 +10,21 @@ import useThemeStyles from '@hooks/useThemeStyles'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +const selected = 'selected'; + function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); + const {accountsReceivable} = policy?.connections?.quickbooksOnline?.data ?? {}; + // const policyID = policy?.id ?? ''; - const data = [ - { - value: 'receivable', - text: translate(`workspace.qbo.receivable`), - keyForList: 'receivable', - isSelected: false, - }, - { - value: 'archive', - text: translate(`workspace.qbo.archive`), - keyForList: 'archive', - isSelected: false, - }, - ]; + const data = + accountsReceivable?.map((account) => ({ + value: account.name, + text: account.name, + keyForList: account.name, + isSelected: account.name === selected, + })) || []; const updateMode = useCallback((mode: {value: string}) => { // TODO add API call for change diff --git a/src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx similarity index 93% rename from src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseConfigurationPage.tsx rename to src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx index a5e02a7c8b42..fcacb068b8e5 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksOutOfPocketExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx @@ -40,8 +40,8 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps interactive={!isLocationEnabled} /> - {isVendorBill && !isLocationEnabled && {translate('workspace.qbo.exportVendorBillDescription')}} - {isLocationEnabled && {translate('workspace.qbo.outOfPocketLocationEnabledDescription')}} + {isVendorBill && !isLocationEnabled && {translate('workspace.qbo.exportVendorBillDescription')}} + {isLocationEnabled && {translate('workspace.qbo.outOfPocketLocationEnabledDescription')}} {!isLocationEnabled && ( mode.isSelected)?.keyForList} /> - {translate('workspace.qbo.outOfPocketTaxEnabledDescription')} + {translate('workspace.qbo.outOfPocketTaxEnabledDescription')} ); diff --git a/src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx similarity index 78% rename from src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage.tsx rename to src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx index 23d8a8994ba9..bd47b4ab0dc3 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx @@ -7,25 +7,20 @@ import RadioListItem from '@components/SelectionList/RadioListItem'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import {getAdminEmailList} from '@libs/PolicyUtils'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; -const draft = [ - {name: '+14153166423@expensify.sms', currency: 'USD', id: '94', email: '+14153166423@expensify.sms'}, - {name: 'Account Maintenance Fee', currency: 'USD', id: '141', email: 'alberto@expensify213.com'}, - {name: 'Admin Test', currency: 'USD', id: '119', email: 'admin@qbocard.com'}, - {name: 'Alberto Gonzalez-Cela', currency: 'USD', id: '104', email: 'alberto@expensify.com'}, - {name: 'Aldo test QBO2 QBO2 Last name', currency: 'USD', id: '140', email: 'admin@qbo.com'}, -]; - function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const {data, config} = policy?.connections?.quickbooksOnline ?? {}; + const exporters = getAdminEmailList(policy); + // const policyID = policy?.id ?? ''; const sections = useMemo( () => - (data?.vendors ?? draft)?.map((vendor) => ({ + exporters?.map((vendor) => ({ value: vendor.email, text: vendor.email, keyForList: vendor.email, @@ -34,7 +29,7 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { [config?.export?.exporter, data?.vendors], ); - const updateMode = useCallback((mode: {value: string}) => { + const updateMode = useCallback((mode: {value?: string}) => { // TODO add API call for change }, []); diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index b7c38f95792e..d2563f1c19eb 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -331,7 +331,7 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< submitsTo?: number; /** The employee list of the policy */ - employeeList?: OnyxTypes.PolicyMembers | []; + employeeList?: OnyxTypes.PolicyMembers[] | []; /** The reimbursement choice for policy */ reimbursementChoice?: ValueOf; diff --git a/src/types/onyx/PolicyMember.ts b/src/types/onyx/PolicyMember.ts index 366a7ef7d530..bb41a66affe0 100644 --- a/src/types/onyx/PolicyMember.ts +++ b/src/types/onyx/PolicyMember.ts @@ -1,8 +1,10 @@ +import type {ValueOf} from 'type-fest'; +import type CONST from '@src/CONST'; import type * as OnyxCommon from './OnyxCommon'; type PolicyMember = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Role of the user in the policy */ - role?: string; + role?: ValueOf; /** Email of the user */ email?: string; diff --git a/tests/utils/collections/policyMembers.ts b/tests/utils/collections/policyMembers.ts index 076c8ddb2d3d..74b5945e962c 100644 --- a/tests/utils/collections/policyMembers.ts +++ b/tests/utils/collections/policyMembers.ts @@ -1,9 +1,9 @@ -import {randWord} from '@ngneat/falso'; +import CONST from '@src/CONST'; import type {PolicyMember} from '@src/types/onyx'; export default function createRandomPolicyMember(): PolicyMember { return { - role: randWord(), + role: CONST.POLICY.ROLE.USER, errors: {}, }; } From ce96fdde8f0239a3181d8ca1571f4b65a6d60816 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader Date: Mon, 15 Apr 2024 18:27:49 +0300 Subject: [PATCH 149/339] [Fabric] iOS - Stretched border animations between screen transitions --- ...+014+iOSCoreAnimationBorderRendering.patch | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 patches/react-native+0.73.4+014+iOSCoreAnimationBorderRendering.patch diff --git a/patches/react-native+0.73.4+014+iOSCoreAnimationBorderRendering.patch b/patches/react-native+0.73.4+014+iOSCoreAnimationBorderRendering.patch new file mode 100644 index 000000000000..b59729e79622 --- /dev/null +++ b/patches/react-native+0.73.4+014+iOSCoreAnimationBorderRendering.patch @@ -0,0 +1,22 @@ +diff --git a/node_modules/react-native/React/Fabric/Mounting/RCTMountingManager.mm b/node_modules/react-native/React/Fabric/Mounting/RCTMountingManager.mm +index b4cfb3d..7aa00e5 100644 +--- a/node_modules/react-native/React/Fabric/Mounting/RCTMountingManager.mm ++++ b/node_modules/react-native/React/Fabric/Mounting/RCTMountingManager.mm +@@ -49,6 +49,9 @@ static void RCTPerformMountInstructions( + { + SystraceSection s("RCTPerformMountInstructions"); + ++ [CATransaction begin]; ++ [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; ++ + for (const auto &mutation : mutations) { + switch (mutation.type) { + case ShadowViewMutation::Create: { +@@ -147,6 +150,7 @@ static void RCTPerformMountInstructions( + } + } + } ++ [CATransaction commit]; + } + + @implementation RCTMountingManager { From fb5d2823922e60f8efe34ed6bbda48de3699f5ab Mon Sep 17 00:00:00 2001 From: usman-ghani564 Date: Mon, 15 Apr 2024 21:35:19 +0500 Subject: [PATCH 150/339] Add live markdown to private notes --- src/pages/PrivateNotes/PrivateNotesEditPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/PrivateNotes/PrivateNotesEditPage.tsx b/src/pages/PrivateNotes/PrivateNotesEditPage.tsx index 7d0b8fff8e41..7ab8fadc496a 100644 --- a/src/pages/PrivateNotes/PrivateNotesEditPage.tsx +++ b/src/pages/PrivateNotes/PrivateNotesEditPage.tsx @@ -165,6 +165,7 @@ function PrivateNotesEditPage({route, personalDetailsList, report}: PrivateNotes privateNotesInput.current = el; updateMultilineInputRange(privateNotesInput.current); }} + isMarkdownEnabled /> From ecc749607219e5ebba033e9e5c6140ef62fca44d Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 16 Apr 2024 11:09:14 +0700 Subject: [PATCH 151/339] fix: Track expense shortcut doesn't update to the correct one in offline mode --- src/libs/actions/IOU.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 85f4b74f3436..c9e3e409b347 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -823,6 +823,22 @@ function buildOnyxDataForTrackExpense( const isScanRequest = TransactionUtils.isScanRequest(transaction); const clearedPendingFields = Object.fromEntries(Object.keys(transaction.pendingFields ?? {}).map((key) => [key, null])); const optimisticData: OnyxUpdate[] = []; + const isDistanceRequest = TransactionUtils.isDistanceRequest(transaction); + let newQuickAction: ValueOf = CONST.QUICK_ACTIONS.TRACK_MANUAL; + if (isScanRequest) { + newQuickAction = CONST.QUICK_ACTIONS.TRACK_SCAN + } else if (isDistanceRequest) { + newQuickAction = CONST.QUICK_ACTIONS.TRACK_DISTANCE + } + optimisticData.push({ + onyxMethod: Onyx.METHOD.SET, + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + value: { + action: newQuickAction, + chatReportID: chatReport?.reportID, + isFirstQuickAction: isEmptyObject(quickAction), + }, + }); if (chatReport) { optimisticData.push({ From 7a61a34b3706236394b3a4b8bded8daa5f83ded9 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 16 Apr 2024 11:56:45 +0700 Subject: [PATCH 152/339] fix: lint --- src/libs/actions/IOU.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index c9e3e409b347..b47ebf18694e 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -826,9 +826,9 @@ function buildOnyxDataForTrackExpense( const isDistanceRequest = TransactionUtils.isDistanceRequest(transaction); let newQuickAction: ValueOf = CONST.QUICK_ACTIONS.TRACK_MANUAL; if (isScanRequest) { - newQuickAction = CONST.QUICK_ACTIONS.TRACK_SCAN + newQuickAction = CONST.QUICK_ACTIONS.TRACK_SCAN; } else if (isDistanceRequest) { - newQuickAction = CONST.QUICK_ACTIONS.TRACK_DISTANCE + newQuickAction = CONST.QUICK_ACTIONS.TRACK_DISTANCE; } optimisticData.push({ onyxMethod: Onyx.METHOD.SET, From feb7d7429e5836c6520e9b84aaf94ad7be1aa0c0 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 16 Apr 2024 10:06:05 +0100 Subject: [PATCH 153/339] remove croissantCo translations --- src/languages/en.ts | 5 ----- src/languages/es.ts | 5 ----- 2 files changed, 10 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 2dd4399cdfa9..0f15d3599ab8 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1903,11 +1903,6 @@ export default { "As you've enabled sync reimbursed reports, you will need select the bank account your reimbursements are coming out of, and we'll create the payment in QuickBooks.", invoiceAccountSelectDescription: 'If you are exporting Invoices from Expensify to Quickbooks Online, this is the account the Invoice will appear against once marked as Paid.', - croissantCo: { - [CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_PAYROLL_ACCOUNT]: 'Croissant Co Payroll Account', - [CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_MONEY_IN_CLEARING]: 'Croissant Co Money in Clearing', - [CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_DEBTS_AND_LOANS]: 'Croissant Co Debts and Loans', - }, }, }, type: { diff --git a/src/languages/es.ts b/src/languages/es.ts index fdd03faed6a4..82bed64f98e7 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1930,11 +1930,6 @@ export default { "As you've enabled sync reimbursed reports, you will need select the bank account your reimbursements are coming out of, and we'll create the payment in QuickBooks.", invoiceAccountSelectDescription: 'If you are exporting Invoices from Expensify to Quickbooks Online, this is the account the Invoice will appear against once marked as Paid.', - croissantCo: { - [CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_PAYROLL_ACCOUNT]: 'Croissant Co Payroll Account', - [CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_MONEY_IN_CLEARING]: 'Croissant Co Money in Clearing', - [CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_DEBTS_AND_LOANS]: 'Croissant Co Debts and Loans', - }, }, }, type: { From 5725e8deb58609ff11a0acc4b38a267dc35a36e8 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 16 Apr 2024 10:10:47 +0100 Subject: [PATCH 154/339] update selections default --- .../accounting/qbo/advanced/QuickbooksAdvancedPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index 4d59058f00be..bd065fedba6d 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -101,7 +101,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.getRoute(policyID)))} @@ -125,7 +125,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { /> Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR.getRoute(policyID)))} From 2420297b914b700a9f6a196cbfdde2e5e9194646 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 16 Apr 2024 11:07:59 +0100 Subject: [PATCH 155/339] remove acount options draft --- .../advanced/QuickbooksAccountSelectPage.tsx | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index c7366689237b..cef69f10ed77 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -1,6 +1,5 @@ import React, {useCallback, useMemo, useState} from 'react'; import {View} from 'react-native'; -import type {ValueOf} from 'type-fest'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; @@ -17,27 +16,28 @@ import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; -type CustomSelectorTypes = ValueOf; - type SelectorType = ListItem & { - value: CustomSelectorTypes; + value: string; }; function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); + const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const accountOptions = bankAccounts || creditCards; - const [selectedAccount, setSelectedAccount] = useState(CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_PAYROLL_ACCOUNT); + const [selectedAccount, setSelectedAccount] = useState('selected'); const policyID = policy?.id ?? ''; - const qboOnlineSelectorOptions = useMemo( + const qboOnlineSelectorOptions = useMemo( () => - Object.entries(CONST.QBO_SELECTOR_OPTIONS).map(([key, value]) => ({ - value, - text: translate(`workspace.qbo.advancedConfig.croissantCo.${value}`), - keyForList: key, - isSelected: selectedAccount === value, + accountOptions?.map(({name}) => ({ + value: name, + text: name, + keyForList: name, + isSelected: selectedAccount === name, })), [selectedAccount, translate], ); @@ -50,11 +50,11 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], ); - const initiallyFocusedOptionKey = useMemo(() => qboOnlineSelectorOptions.find((mode) => mode.isSelected)?.keyForList, [qboOnlineSelectorOptions]); + const initiallyFocusedOptionKey = useMemo(() => qboOnlineSelectorOptions?.find((mode) => mode.isSelected)?.keyForList, [qboOnlineSelectorOptions]); - const saveSelection = useCallback((mode: SelectorType) => { - // TODO add API call for change - setSelectedAccount(mode.value); + const saveSelection = useCallback(({value}: SelectorType) => { + // TODO add API call for change instead setting state + setSelectedAccount(value); Navigation.goBack(); }, []); @@ -72,7 +72,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { Date: Tue, 16 Apr 2024 11:09:08 +0100 Subject: [PATCH 156/339] remove acount options draft --- .../QuickbooksInvoiceAccountSelectPage.tsx | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index cf278c99ec86..e22976d28d42 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -1,6 +1,5 @@ import React, {useCallback, useMemo, useState} from 'react'; import {View} from 'react-native'; -import type {ValueOf} from 'type-fest'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; @@ -17,27 +16,28 @@ import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; -type CustomSelectorTypes = ValueOf; - type SelectorType = ListItem & { - value: CustomSelectorTypes; + value: string; }; function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); + const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const accountOptions = bankAccounts || creditCards; - const [selectedAccount, setSelectedAccount] = useState(CONST.QBO_SELECTOR_OPTIONS.CROISSANT_CO_MONEY_IN_CLEARING); + const [selectedAccount, setSelectedAccount] = useState('selected'); const policyID = policy?.id ?? ''; - const qboOnlineSelectorOptions = useMemo( + const qboOnlineSelectorOptions = useMemo( () => - Object.entries(CONST.QBO_SELECTOR_OPTIONS).map(([key, value]) => ({ - value, - text: translate(`workspace.qbo.advancedConfig.croissantCo.${value}`), - keyForList: key, - isSelected: selectedAccount === value, + accountOptions?.map(({name}) => ({ + value: name, + text: name, + keyForList: name, + isSelected: selectedAccount === name, })), [selectedAccount, translate], ); @@ -51,10 +51,10 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { [translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal], ); - const initiallyFocusedOptionKey = useMemo(() => qboOnlineSelectorOptions.find((mode) => mode.isSelected)?.keyForList, [qboOnlineSelectorOptions]); + const initiallyFocusedOptionKey = useMemo(() => qboOnlineSelectorOptions?.find((mode) => mode.isSelected)?.keyForList, [qboOnlineSelectorOptions]); const updateMode = useCallback((mode: SelectorType) => { - // TODO add API call for change + // TODO add API call for change instead setting state setSelectedAccount(mode.value); Navigation.goBack(); }, []); @@ -73,7 +73,7 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { Date: Tue, 16 Apr 2024 11:21:09 +0100 Subject: [PATCH 157/339] use acount options draft --- .../qbo/advanced/QuickbooksAccountSelectPage.tsx | 7 +++++-- .../qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index cef69f10ed77..dd1928469ad8 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -20,12 +20,15 @@ type SelectorType = ListItem & { value: string; }; +// TODO: remove once UI is approved +const DRAFT = [{name: 'Croissant Co Payroll Account'}, {name: 'Croissant Co Money in Clearing'}, {name: 'Croissant Co Debts and Loans'}]; + function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const accountOptions = bankAccounts || creditCards; + const accountOptions = bankAccounts || creditCards || DRAFT; const [selectedAccount, setSelectedAccount] = useState('selected'); @@ -39,7 +42,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { keyForList: name, isSelected: selectedAccount === name, })), - [selectedAccount, translate], + [selectedAccount, translate, accountOptions], ); const listHeaderComponent = useMemo( () => ( diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index e22976d28d42..38764bf98869 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -20,12 +20,15 @@ type SelectorType = ListItem & { value: string; }; +// TODO: remove once UI is approved +const DRAFT = [{name: 'Croissant Co Payroll Account'}, {name: 'Croissant Co Money in Clearing'}, {name: 'Croissant Co Debts and Loans'}]; + function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const accountOptions = bankAccounts || creditCards; + const accountOptions = bankAccounts || creditCards || DRAFT; const [selectedAccount, setSelectedAccount] = useState('selected'); @@ -39,7 +42,7 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { keyForList: name, isSelected: selectedAccount === name, })), - [selectedAccount, translate], + [selectedAccount, translate, accountOptions], ); const listHeaderComponent = useMemo( From 2b5522141acafd9b0d4cf8e9f95d1bb759d52a57 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 16 Apr 2024 11:25:38 +0100 Subject: [PATCH 158/339] set default --- .../accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx | 2 +- .../qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index dd1928469ad8..cfa931cc1ba5 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -30,7 +30,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const accountOptions = bankAccounts || creditCards || DRAFT; - const [selectedAccount, setSelectedAccount] = useState('selected'); + const [selectedAccount, setSelectedAccount] = useState('Croissant Co Payroll Account'); const policyID = policy?.id ?? ''; diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 38764bf98869..00082c3aaa6e 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -30,7 +30,7 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const accountOptions = bankAccounts || creditCards || DRAFT; - const [selectedAccount, setSelectedAccount] = useState('selected'); + const [selectedAccount, setSelectedAccount] = useState('Croissant Co Money in Clearing'); const policyID = policy?.id ?? ''; From f749eb434500afddb395e4dc8787ffb143eedd0d Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 16 Apr 2024 11:29:21 +0100 Subject: [PATCH 159/339] should be bank account and creditCards --- .../accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx | 2 +- .../qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index cfa931cc1ba5..729dd9767022 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -28,7 +28,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const accountOptions = bankAccounts || creditCards || DRAFT; + const accountOptions = [...(bankAccounts ?? []), ...(creditCards ?? [])] || DRAFT; const [selectedAccount, setSelectedAccount] = useState('Croissant Co Payroll Account'); diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 00082c3aaa6e..3cc295a4ed1d 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -28,13 +28,13 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const accountOptions = bankAccounts || creditCards || DRAFT; + const accountOptions = [...(bankAccounts ?? []), ...(creditCards ?? [])] || DRAFT; const [selectedAccount, setSelectedAccount] = useState('Croissant Co Money in Clearing'); const policyID = policy?.id ?? ''; - const qboOnlineSelectorOptions = useMemo( + const qboOnlineSelectorOptions = useMemo( () => accountOptions?.map(({name}) => ({ value: name, From d1f641af2b880510017b18ab49f0fe31ce5f6638 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 16 Apr 2024 17:31:29 +0700 Subject: [PATCH 160/339] compare reportID --- src/pages/home/report/ReportActionsView.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 1ed74b488837..40307b75f1a1 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -145,8 +145,7 @@ function ReportActionsView({ // Filter out the created action from the transaction thread report actions, since we already have the parent report's created action in `reportActions` const filteredTransactionThreadReportActions = transactionThreadReportActions?.filter((action) => action.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED); const moneyRequestAction = allReportActions.find((action) => { - const actionType = (action as OnyxTypes.OriginalMessageIOU).originalMessage?.type ?? ''; - return actionType === CONST.IOU.REPORT_ACTION_TYPE.CREATE || actionType === CONST.IOU.REPORT_ACTION_TYPE.TRACK || ReportActionsUtils.isSentMoneyReportAction(action); + return action.reportActionID === transactionThreadReport?.parentReportActionID; }); // Filter out the money request actions because we don't want to show any preview actions for one-transaction reports @@ -155,7 +154,7 @@ function ReportActionsView({ return actionType !== CONST.IOU.REPORT_ACTION_TYPE.CREATE && actionType !== CONST.IOU.REPORT_ACTION_TYPE.TRACK && !ReportActionsUtils.isSentMoneyReportAction(action); }); return [ReportActionsUtils.getSortedReportActions(filteredReportActions, true), moneyRequestAction ?? null]; - }, [allReportActions, transactionThreadReportActions]); + }, [allReportActions, transactionThreadReportActions, transactionThreadReport?.parentReportActionID]); const indexOfLinkedAction = useMemo(() => { if (!reportActionID) { From 330c2a7ba3cefcb4b80f1eee47edc63dc1774bd8 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 16 Apr 2024 11:34:00 +0100 Subject: [PATCH 161/339] move state to top --- .../qbo/advanced/QuickbooksAccountSelectPage.tsx | 8 ++++---- .../qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 729dd9767022..55c4602d1b90 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -26,13 +26,13 @@ const DRAFT = [{name: 'Croissant Co Payroll Account'}, {name: 'Croissant Co Mone function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const accountOptions = [...(bankAccounts ?? []), ...(creditCards ?? [])] || DRAFT; - const [selectedAccount, setSelectedAccount] = useState('Croissant Co Payroll Account'); + const [selectedAccount, setSelectedAccount] = useState(DRAFT[0].name); const policyID = policy?.id ?? ''; + const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const accountOptions = [...(bankAccounts ?? []), ...(creditCards ?? [])] || DRAFT; const qboOnlineSelectorOptions = useMemo( () => diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 3cc295a4ed1d..014cb5127224 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -26,13 +26,13 @@ const DRAFT = [{name: 'Croissant Co Payroll Account'}, {name: 'Croissant Co Mone function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const accountOptions = [...(bankAccounts ?? []), ...(creditCards ?? [])] || DRAFT; - const [selectedAccount, setSelectedAccount] = useState('Croissant Co Money in Clearing'); + const [selectedAccount, setSelectedAccount] = useState(DRAFT[0].name); const policyID = policy?.id ?? ''; + const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const accountOptions = [...(bankAccounts ?? []), ...(creditCards ?? [])] || DRAFT; const qboOnlineSelectorOptions = useMemo( () => From fb6779b1b1bc194829163be59351e812b9b80627 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 16 Apr 2024 11:44:35 +0100 Subject: [PATCH 162/339] update qbo advanced spanish translations --- src/languages/es.ts | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 82bed64f98e7..a9eb594d1753 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1913,23 +1913,24 @@ export default { locationsAdditionalDescription: 'Los lugares son importados como Etiquegas. Esto limita a exportar los informes de gastos como Factura del Proveedor o Cheques a Quicbooks Online. Para desbloquear estas opciones de exportación desactiva la importación de Lugares o cambia al Plan Control para exportar Lugares como Campos de Informes.', advancedConfig: { - advanced: 'Advanced', - autoSync: 'Auto-Sync', - autoSyncDescription: 'Changes made in Quickbooks will automatically be reflected in Expensify.', - inviteEmployees: 'Invite Employees', - inviteEmployeesDescription: 'Import Quickbooks Online employee records and invite them to this workspace.', - createEntities: 'Automatically Create Entities', + advanced: 'Avanzado', + autoSync: 'Autosincronización', + autoSyncDescription: 'Los cambios realizados en Quickbooks se reflejarán automáticamente en Expensify.', + inviteEmployees: 'Invitar empleados', + inviteEmployeesDescription: 'Importe los registros de los empleados de Quickbooks Online e invítelos a este espacio de trabajo.', + createEntities: 'Crear entidades automáticamente', createEntitiesDescription: - 'Expensify will automatically create a vendor in Quickbooks, if one does not exist. Expensify will also automatically create a customer when exporting invoices.', - reimbursedReports: 'Sync Reimbursed Reports', - reimbursedReportsDescription: 'Any time report is reimbursed using Expensify ACH, the corresponding bill payment will be created in the Quickbooks accounts below.', - qboAccount: 'Quickbooks Account', - collectionAccount: 'Invoice Collection Account', - collectionAccountDescription: 'Once invoices have been Paid, the payment will appear in the account configured below.', + 'Expensify creará automáticamente un proveedor en Quickbooks, si no existe. Expensify también creará automáticamente un cliente al exportar facturas.', + reimbursedReports: 'Sincronizar informes reembolsados', + reimbursedReportsDescription: + 'Cada vez que se pague un informe utilizando Expensify ACH, se creará el pago de la factura correspondiente en las cuentas de Quickbooks indicadas a continuación.', + qboAccount: 'Cuenta Quickbooks', + collectionAccount: 'Cuenta de cobro de facturas', + collectionAccountDescription: 'Una vez abonadas las facturas, el pago aparecerá en la cuenta configurada a continuación.', accountSelectDescription: - "As you've enabled sync reimbursed reports, you will need select the bank account your reimbursements are coming out of, and we'll create the payment in QuickBooks.", + 'Como has activado la sincronización de los informes de reembolso, tendrás que seleccionar la cuenta bancaria de la que saldrán tus reembolsos y crearemos el pago en QuickBooks.', invoiceAccountSelectDescription: - 'If you are exporting Invoices from Expensify to Quickbooks Online, this is the account the Invoice will appear against once marked as Paid.', + 'Si está exportando facturas de Expensify a Quickbooks Online, ésta es la cuenta en la que aparecerá la factura una vez marcada como pagada.', }, }, type: { From cfd42c57999e682b9bb5e696b8957ea8fee762c0 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 16 Apr 2024 11:53:10 +0100 Subject: [PATCH 163/339] update qbo advanced english strings --- src/languages/en.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 0f15d3599ab8..f6c2dc4b597c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1887,22 +1887,22 @@ export default { 'Locations are imported as Tags. This limits exporting expense reports as Vendor Bills or Checks to QuickBooks Online. To unlock these export options, either disable Locations import or upgrade to the Control Plan to export Locations encoded as a Report Field.', advancedConfig: { advanced: 'Advanced', - autoSync: 'Auto-Sync', + autoSync: 'Auto-sync', autoSyncDescription: 'Changes made in Quickbooks will automatically be reflected in Expensify.', - inviteEmployees: 'Invite Employees', + inviteEmployees: 'Invite employees', inviteEmployeesDescription: 'Import Quickbooks Online employee records and invite them to this workspace.', - createEntities: 'Automatically Create Entities', + createEntities: 'Automatically create entities', createEntitiesDescription: 'Expensify will automatically create a vendor in Quickbooks, if one does not exist. Expensify will also automatically create a customer when exporting invoices.', - reimbursedReports: 'Sync Reimbursed Reports', - reimbursedReportsDescription: 'Any time report is reimbursed using Expensify ACH, the corresponding bill payment will be created in the Quickbooks accounts below.', - qboAccount: 'Quickbooks Account', - collectionAccount: 'Invoice Collection Account', - collectionAccountDescription: 'Once invoices have been Paid, the payment will appear in the account configured below.', + reimbursedReports: 'Sync reimbursed reports', + reimbursedReportsDescription: 'Any time report is paid using Expensify ACH, the corresponding bill payment will be created in the Quickbooks accounts below.', + qboAccount: 'Quickbooks account', + collectionAccount: 'Invoice collection account', + collectionAccountDescription: 'Once invoices have been paid, the payment will appear in the account configured below.', accountSelectDescription: "As you've enabled sync reimbursed reports, you will need select the bank account your reimbursements are coming out of, and we'll create the payment in QuickBooks.", invoiceAccountSelectDescription: - 'If you are exporting Invoices from Expensify to Quickbooks Online, this is the account the Invoice will appear against once marked as Paid.', + 'If you are exporting invoices from Expensify to Quickbooks Online, this is the account the invoice will appear against once marked as paid.', }, }, type: { From e743e38f9291c30cde76c99c4390ca9c89718e58 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 16 Apr 2024 18:09:51 +0700 Subject: [PATCH 164/339] fix lint --- src/pages/home/report/ReportActionsView.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 40307b75f1a1..db6d470ec724 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -144,9 +144,7 @@ function ReportActionsView({ // Filter out the created action from the transaction thread report actions, since we already have the parent report's created action in `reportActions` const filteredTransactionThreadReportActions = transactionThreadReportActions?.filter((action) => action.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED); - const moneyRequestAction = allReportActions.find((action) => { - return action.reportActionID === transactionThreadReport?.parentReportActionID; - }); + const moneyRequestAction = allReportActions.find((action) => action.reportActionID === transactionThreadReport?.parentReportActionID); // Filter out the money request actions because we don't want to show any preview actions for one-transaction reports const filteredReportActions = [...allReportActions, ...filteredTransactionThreadReportActions].filter((action) => { From cf3cf1b459e7760b3984c41dd18c7526afa8f175 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 16 Apr 2024 12:39:47 +0100 Subject: [PATCH 165/339] update saveSelection --- .../qbo/advanced/QuickbooksAccountSelectPage.tsx | 12 ++++++------ .../advanced/QuickbooksInvoiceAccountSelectPage.tsx | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 55c4602d1b90..04a866f5f4ee 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useMemo, useState} from 'react'; +import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; @@ -14,6 +14,7 @@ import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabl import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; type SelectorType = ListItem & { @@ -27,7 +28,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const [selectedAccount, setSelectedAccount] = useState(DRAFT[0].name); + const selectedAccount = DRAFT[0].name; // selected const policyID = policy?.id ?? ''; const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; @@ -36,8 +37,8 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const qboOnlineSelectorOptions = useMemo( () => - accountOptions?.map(({name}) => ({ - value: name, + accountOptions?.map(({id, name}) => ({ + value: id, text: name, keyForList: name, isSelected: selectedAccount === name, @@ -56,8 +57,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const initiallyFocusedOptionKey = useMemo(() => qboOnlineSelectorOptions?.find((mode) => mode.isSelected)?.keyForList, [qboOnlineSelectorOptions]); const saveSelection = useCallback(({value}: SelectorType) => { - // TODO add API call for change instead setting state - setSelectedAccount(value); + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, value); Navigation.goBack(); }, []); diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 014cb5127224..3aea7b216364 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useMemo, useState} from 'react'; +import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; @@ -14,6 +14,7 @@ import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabl import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; type SelectorType = ListItem & { @@ -27,7 +28,7 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const [selectedAccount, setSelectedAccount] = useState(DRAFT[0].name); + const selectedAccount = DRAFT[0].name; // selected const policyID = policy?.id ?? ''; const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; @@ -56,9 +57,8 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const initiallyFocusedOptionKey = useMemo(() => qboOnlineSelectorOptions?.find((mode) => mode.isSelected)?.keyForList, [qboOnlineSelectorOptions]); - const updateMode = useCallback((mode: SelectorType) => { - // TODO add API call for change instead setting state - setSelectedAccount(mode.value); + const updateMode = useCallback(({value}: SelectorType) => { + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, value); Navigation.goBack(); }, []); From 81a5cba86c561b1890e5aada2f0b68d8619ed71e Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 16 Apr 2024 12:52:37 +0100 Subject: [PATCH 166/339] fix lint --- .../qbo/advanced/QuickbooksAccountSelectPage.tsx | 4 ++-- .../advanced/QuickbooksInvoiceAccountSelectPage.tsx | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 04a866f5f4ee..5e2edbc15676 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -43,7 +43,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { keyForList: name, isSelected: selectedAccount === name, })), - [selectedAccount, translate, accountOptions], + [selectedAccount, accountOptions], ); const listHeaderComponent = useMemo( () => ( @@ -59,7 +59,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const saveSelection = useCallback(({value}: SelectorType) => { Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, value); Navigation.goBack(); - }, []); + }, [policyID]); return ( diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 3aea7b216364..039f71cf3421 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -43,7 +43,7 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { keyForList: name, isSelected: selectedAccount === name, })), - [selectedAccount, translate, accountOptions], + [selectedAccount, accountOptions], ); const listHeaderComponent = useMemo( @@ -57,10 +57,13 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const initiallyFocusedOptionKey = useMemo(() => qboOnlineSelectorOptions?.find((mode) => mode.isSelected)?.keyForList, [qboOnlineSelectorOptions]); - const updateMode = useCallback(({value}: SelectorType) => { - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, value); - Navigation.goBack(); - }, []); + const updateMode = useCallback( + ({value}: SelectorType) => { + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, value); + Navigation.goBack(); + }, + [policyID], + ); return ( From 0c8d5ef0373b90b9f0a7cc3fc7ed61b9b90e1a18 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 16 Apr 2024 12:59:29 +0100 Subject: [PATCH 167/339] add otherCurrentAssetAccounts in accountOptions --- .../qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 039f71cf3421..36b401370430 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -31,9 +31,9 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const selectedAccount = DRAFT[0].name; // selected const policyID = policy?.id ?? ''; - const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; + const {bankAccounts, otherCurrentAssetAccounts} = policy?.connections?.quickbooksOnline?.data ?? {}; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const accountOptions = [...(bankAccounts ?? []), ...(creditCards ?? [])] || DRAFT; + const accountOptions = [...(bankAccounts ?? []), ...(otherCurrentAssetAccounts ?? [])] || DRAFT; const qboOnlineSelectorOptions = useMemo( () => From d4cdb078251defe73d0ec298e6de107180e792a5 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 16 Apr 2024 13:40:55 +0100 Subject: [PATCH 168/339] fix lint --- ios/Podfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index f9244c515a2c..e442d33cc9fb 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -2582,7 +2582,7 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: 3033e0dd5272d46e97bcb406adea4ae0e6907abf - Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70 + Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 PODFILE CHECKSUM: a25a81f2b50270f0c0bd0aff2e2ebe4d0b4ec06d From 6f7e3fedd01ce20391866e6632e6408bddd48ce3 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 16 Apr 2024 13:41:30 +0100 Subject: [PATCH 169/339] fix lint --- .../advanced/QuickbooksAccountSelectPage.tsx | 19 +++++++++++++------ .../qbo/advanced/QuickbooksAdvancedPage.tsx | 5 +++-- .../QuickbooksInvoiceAccountSelectPage.tsx | 10 +++++++--- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 5e2edbc15676..8d850115d14a 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -22,7 +22,11 @@ type SelectorType = ListItem & { }; // TODO: remove once UI is approved -const DRAFT = [{name: 'Croissant Co Payroll Account'}, {name: 'Croissant Co Money in Clearing'}, {name: 'Croissant Co Debts and Loans'}]; +const DRAFT = [ + {name: 'Croissant Co Payroll Account', id: 'Croissant Co Payroll Account'}, + {name: 'Croissant Co Money in Clearing', id: 'Croissant Co Money in Clearing'}, + {name: 'Croissant Co Debts and Loans', id: 'Croissant Co Debts and Loans'}, +]; function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); @@ -33,7 +37,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const policyID = policy?.id ?? ''; const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const accountOptions = [...(bankAccounts ?? []), ...(creditCards ?? [])] || DRAFT; + const accountOptions = useMemo(() => DRAFT || [...(bankAccounts ?? []), ...(creditCards ?? [])], [bankAccounts, creditCards]); const qboOnlineSelectorOptions = useMemo( () => @@ -56,10 +60,13 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const initiallyFocusedOptionKey = useMemo(() => qboOnlineSelectorOptions?.find((mode) => mode.isSelected)?.keyForList, [qboOnlineSelectorOptions]); - const saveSelection = useCallback(({value}: SelectorType) => { - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, value); - Navigation.goBack(); - }, [policyID]); + const saveSelection = useCallback( + ({value}: SelectorType) => { + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, value); + Navigation.goBack(); + }, + [policyID], + ); return ( diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index bd065fedba6d..fdca8cff1e4b 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -27,7 +27,8 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const policyID = policy?.id ?? ''; const {autoSync, syncPeople, autoCreateVendor, reimbursementAccountID, collectionAccountID, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {}; - const {bankAccounts} = policy?.connections?.quickbooksOnline?.data ?? {}; + const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; + const accountOptions = [...(bankAccounts ?? []), ...(creditCards ?? [])]; const qboToggleSettingItems: ToggleSettingOptionRowProps[] = [ { @@ -96,7 +97,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing pendingAction={pendingFields?.reimbursementAccountID || pendingFields?.collectionAccountID} isActive={Boolean(reimbursementAccountID && collectionAccountID)} - onToggle={() => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, bankAccounts?.[0].id ?? '')} + onToggle={() => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, accountOptions[0].id)} /> DRAFT || [...(bankAccounts ?? []), ...(otherCurrentAssetAccounts ?? [])], [bankAccounts, otherCurrentAssetAccounts]); const qboOnlineSelectorOptions = useMemo( () => From 2c1135d47411ae1521640252160b447349eddffb Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 16 Apr 2024 13:47:19 +0100 Subject: [PATCH 170/339] undo podfile change --- ios/Podfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index e442d33cc9fb..f9244c515a2c 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -2582,7 +2582,7 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: 3033e0dd5272d46e97bcb406adea4ae0e6907abf - Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 + Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70 PODFILE CHECKSUM: a25a81f2b50270f0c0bd0aff2e2ebe4d0b4ec06d From d7a117bb27a3c2b670a9844202bfec53e0be8de1 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Tue, 16 Apr 2024 18:06:59 +0300 Subject: [PATCH 171/339] Updates for some mock api calls, clean based on the high level design doc --- src/CONST.ts | 15 ++- src/ROUTES.ts | 4 + src/SCREENS.ts | 1 + src/languages/en.ts | 4 + src/languages/es.ts | 6 +- .../ModalStackNavigators/index.tsx | 19 ++-- .../FULL_SCREEN_TO_RHP_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 3 + src/libs/Navigation/types.ts | 48 +++++----- src/libs/actions/Policy.ts | 2 +- .../qbo/QuickbooksChartOfAccountsPage.tsx | 2 +- .../accounting/qbo/QuickbooksClassesPage.tsx | 2 +- .../qbo/QuickbooksCustomersPage.tsx | 2 +- .../qbo/QuickbooksLocationsPage.tsx | 2 +- .../accounting/qbo/QuickbooksTaxesPage.tsx | 2 +- ...oksCompanyCardExpenseAccountSelectPage.tsx | 62 +++++++++--- ...oksCompanyCardExpenseConfigurationPage.tsx | 3 +- .../QuickbooksExportConfigurationPage.tsx | 19 ++-- .../export/QuickbooksExportDateSelectPage.tsx | 21 +++-- ...ickbooksExportInvoiceAccountSelectPage.tsx | 79 ++++++++++++++++ .../QuickbooksInvoiceAccountSelectPage.tsx | 55 ----------- ...oksOutOfPocketExpenseAccountSelectPage.tsx | 94 +++++++++++++++++++ ...oksOutOfPocketExpenseConfigurationPage.tsx | 16 ++-- ...ooksOutOfPocketExpenseEntitySelectPage.tsx | 47 +++++----- ...ooksPreferredExporterConfigurationPage.tsx | 42 +++++++-- src/types/onyx/Policy.ts | 11 ++- 26 files changed, 390 insertions(+), 172 deletions(-) create mode 100644 src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx delete mode 100644 src/pages/workspace/accounting/qbo/export/QuickbooksInvoiceAccountSelectPage.tsx create mode 100644 src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx diff --git a/src/CONST.ts b/src/CONST.ts index 52532e4ece0e..2212441b5c49 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1214,12 +1214,25 @@ const CONST = { }, QUICK_BOOKS_ONLINE: 'quickbooksOnline', - QUICK_BOOKS_IMPORTS: { + QUICK_BOOKS_CONFIG: { SYNC_CLASSES: 'syncClasses', ENABLE_NEW_CATEGORIES: 'enableNewCategories', SYNC_CUSTOMERS: 'syncCustomers', SYNC_LOCATIONS: 'syncLocations', SYNC_TAXES: 'syncTaxes', + PREFERRED_EXPORTER: 'exporter', + EXPORT_DATE: 'exportDate', + OUT_OF_POCKET_EXPENSES: 'outOfPocketExpenses', + EXPORT_INVOICE: 'exportInvoice', + EXPORT_ENTITY: 'exportEntity', + EXPORT_ACCOUNT: 'exportAccount', + EXPORT_COMPANY_CARD: 'exportCompanyCard', + }, + + QUICKBOOKS_EXPORT_ENTITY: { + VENDOR_BILL: 'vendorBill', + CHECK: 'check', + JOURNAL_ENTRY: 'journalEntry', }, ACCOUNT_ID: { diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 317e40a16b40..721554d80011 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -511,6 +511,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/out-of-pocket-expense', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/out-of-pocket-expense` as const, }, + WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/out-of-pocket-expense/account-select', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/out-of-pocket-expense/account-select` as const, + }, WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/out-of-pocket-expense/entity-select', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/out-of-pocket-expense/entity-select` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 4c36235f0250..ae49bcf47fde 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -269,6 +269,7 @@ const SCREENS = { QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter', QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses', QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses_Select', + QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses_Account_Select', DISTANCE_RATE_EDIT: 'Distance_Rate_Edit', }, diff --git a/src/languages/en.ts b/src/languages/en.ts index 8f52f5e0e15b..ef491a77275d 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1914,8 +1914,12 @@ export default { exportVendorBillDescription: 'We`ll create a single itemized vendor bill for each Expensify report. If the period of the bill is closed, we`ll post to the 1st of the next open period. You can add the vendor bill to your A/P account of choice (below).', check: 'Check', + accountsPayable: 'Accounts Payable', + accountsPayableDescription: 'This is your chosen A/P account, against which vendor bills for each report are created.', journalEntry: 'Journal Entry', optionBelow: 'Choose an option below:', + companyCardsLocationEnabledDescription: + 'Note: QuickBooks Online does not support a field for Locations as Tags on Vendor Bills exports. As you import Locations from, this this export option is unavailable.', outOfPocketTaxEnabledDescription: 'Note: QuickBooks Online doesn`t support a field for tax on Journal Entry exports. Because you have tax tracking enabled on your workspace, this export option is unavailable.', outOfPocketTaxEnabledError: 'Journal entry is not available when taxes enabled. please select a different export option.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 7aca1669e4c3..669ddd0d89ce 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1937,10 +1937,14 @@ export default { optionBelow: 'Elija una opción a continuación:', creditCard: 'Tarjeta de crédito', vendorBill: 'Factura del proveedor', + accountsPayable: 'Cuentas por pagar', + accountsPayableDescription: 'Esta es la cuenta de cuentas por pagar elegida, contra la cual se crean las facturas de proveedores para cada informe.', + companyCardsLocationEnabledDescription: + 'Nota: QuickBooks Online no admite un campo para Ubicaciones como etiquetas en las exportaciones de facturas de proveedores. A medida que importa ubicaciones, esta opción de exportación no está disponible.', exportPreferredExporterNote: 'Puede ser cualquier administrador del espacio de trabajo, pero debe ser un administrador de dominio si configura diferentes cuentas de exportación para tarjetas de empresa individuales en la configuración del dominio.', exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en su cuenta.', - journalEntry: 'Anotación en el diario', // I have no idea what this means in english, sounds ok as a literal tranlsation + journalEntry: 'Asiento contable', exportOutOfPocketExpensesDescription: 'Establezca cómo se exportan los gastos de bolsillo a QuickBooks Online.', exportVendorBillDescription: 'Crearemos una única factura de proveedor detallada para cada informe de Expensify. Si el período de la factura está cerrado, lo publicaremos en el día 1 del siguiente período abierto. Puede agregar la factura del proveedor a la cuenta A/P de su elección (a continuación).', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index a74387edd9a6..82e266984a11 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -255,20 +255,23 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsCustomTaxName').default as React.ComponentType, [SCREENS.WORKSPACE.TAXES_SETTINGS_FOREIGN_CURRENCY_DEFAULT]: () => require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsForeignCurrency').default as React.ComponentType, [SCREENS.WORKSPACE.TAXES_SETTINGS_WORKSPACE_CURRENCY_DEFAULT]: () => require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsWorkspaceCurrency').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: () => require('@pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: () => require('@pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: () => require('../../../../pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: () => + require('../../../../pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: () => - require('@pages/workspace/accounting/qbo/export/QuickbooksInvoiceAccountSelectPage').default as React.ComponentType, + require('../../../../pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage').default as React.ComponentType, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT]: () => + require('../../../../pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: () => - require('@pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage').default as React.ComponentType, + require('../../../../pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: () => - require('@pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage').default as React.ComponentType, + require('../../../../pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE]: () => - require('@pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage').default as React.ComponentType, + require('../../../../pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: () => - require('@pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage').default as React.ComponentType, + require('../../../../pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: () => - require('@pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage').default as React.ComponentType, + require('../../../../pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage').default as React.ComponentType, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType, [SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default as React.ComponentType, [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 787b401d05d3..53e03a4e751d 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -28,6 +28,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT, + SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 2b3c7a8d23a7..7d610ffd7310 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -272,6 +272,9 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.route}, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.route}, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.route}, + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT]: { + path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.route, + }, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.route}, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: { path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.route, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 7352069da1d8..96a47fabde39 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -262,30 +262,6 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_TAXES]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: { - policyID: string; - }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: { - policyID: string; - }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: { - policyID: string; - }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: { - policyID: string; - }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: { - policyID: string; - }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE]: { - policyID: string; - }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: { - policyID: string; - }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: { - policyID: string; - }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; @@ -725,6 +701,30 @@ type WorkspacesCentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: { policyID: string; }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: { + policyID: string; + }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: { + policyID: string; + }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT]: { + policyID: string; + }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: { + policyID: string; + }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: { + policyID: string; + }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE]: { + policyID: string; + }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: { + policyID: string; + }; + [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: { + policyID: string; + }; }; type FullScreenNavigatorParamList = { diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 74965bcaca13..3c87bfc33065 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -3832,7 +3832,7 @@ function openPolicyDistanceRatesPage(policyID?: string) { API.read(READ_COMMANDS.OPEN_POLICY_DISTANCE_RATES_PAGE, params); } -function updatePolicyConnectionConfig(policyID: string, settingName: ValueOf, settingValue: ValueOf) { +function updatePolicyConnectionConfig(policyID: string, settingName: ValueOf, settingValue: string) { const parameters = {policyID, connectionName: CONST.QUICK_BOOKS_ONLINE, settingName, settingValue, idempotencyKey: settingName}; const optimisticData: OnyxUpdate[] = [ { diff --git a/src/pages/workspace/accounting/qbo/QuickbooksChartOfAccountsPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksChartOfAccountsPage.tsx index 593e5f9dc00a..1fee44687592 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksChartOfAccountsPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksChartOfAccountsPage.tsx @@ -49,7 +49,7 @@ function QuickbooksChartOfAccountsPage({policy}: WithPolicyProps) { onToggle={() => Policy.updatePolicyConnectionConfig( policyID, - CONST.QUICK_BOOKS_IMPORTS.ENABLE_NEW_CATEGORIES, + CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } diff --git a/src/pages/workspace/accounting/qbo/QuickbooksClassesPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksClassesPage.tsx index f8c631b31476..620d86704308 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksClassesPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksClassesPage.tsx @@ -51,7 +51,7 @@ function QuickbooksClassesPage({policy}: WithPolicyProps) { onToggle={() => Policy.updatePolicyConnectionConfig( policyID, - CONST.QUICK_BOOKS_IMPORTS.SYNC_CLASSES, + CONST.QUICK_BOOKS_CONFIG.SYNC_CLASSES, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } diff --git a/src/pages/workspace/accounting/qbo/QuickbooksCustomersPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksCustomersPage.tsx index 27fde14081e7..7dafe1dfd206 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksCustomersPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksCustomersPage.tsx @@ -50,7 +50,7 @@ function QuickbooksCustomersPage({policy}: WithPolicyProps) { onToggle={() => Policy.updatePolicyConnectionConfig( policyID, - CONST.QUICK_BOOKS_IMPORTS.SYNC_CUSTOMERS, + CONST.QUICK_BOOKS_CONFIG.SYNC_CUSTOMERS, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } diff --git a/src/pages/workspace/accounting/qbo/QuickbooksLocationsPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksLocationsPage.tsx index 21da79587c0c..0e9150549e64 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksLocationsPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksLocationsPage.tsx @@ -51,7 +51,7 @@ function QuickbooksLocationsPage({policy}: WithPolicyProps) { onToggle={() => Policy.updatePolicyConnectionConfig( policyID, - CONST.QUICK_BOOKS_IMPORTS.SYNC_LOCATIONS, + CONST.QUICK_BOOKS_CONFIG.SYNC_LOCATIONS, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } diff --git a/src/pages/workspace/accounting/qbo/QuickbooksTaxesPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksTaxesPage.tsx index 293d6518baa0..433209f2ee51 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksTaxesPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksTaxesPage.tsx @@ -48,7 +48,7 @@ function QuickbooksTaxesPage({policy}: WithPolicyProps) { onToggle={() => Policy.updatePolicyConnectionConfig( policyID, - CONST.QUICK_BOOKS_IMPORTS.SYNC_TAXES, + CONST.QUICK_BOOKS_CONFIG.SYNC_TAXES, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index b7183c1d4224..042b2a8b283d 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -1,32 +1,63 @@ -import React, {useCallback} from 'react'; +import React, {useCallback, useMemo} from 'react'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; +import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; - -const selected = 'selected'; +import * as Policy from '@userActions/Policy'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const {creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; - // const policyID = policy?.id ?? ''; - const data = - creditCards?.map((card) => ({ - value: card.name, - text: card.name, - keyForList: card.name, - isSelected: card.name === selected, - })) || []; - const updateMode = useCallback((mode: {value: string}) => { - // TODO add API call for change - }, []); + const {exportCompanyCard, syncLocations} = policy?.connections?.quickbooksOnline?.config ?? {}; + const isLocationEnabled = Boolean(syncLocations && syncLocations !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); + + const defaultCards = [ + { + name: translate(`workspace.qbo.creditCard`), + }, + { + name: translate(`workspace.qbo.debitCard`), + }, + { + name: translate(`workspace.qbo.vendorBill`), + }, + ]; + const cardsBasedOnLocation = isLocationEnabled ? defaultCards.slice(0, -1) : defaultCards; + const result = creditCards?.length ? creditCards : cardsBasedOnLocation; + const policyID = policy?.id ?? ''; + const data = useMemo( + () => + result?.map((card) => ({ + value: card.name, + text: card.name, + keyForList: card.name, + isSelected: card.name === exportCompanyCard, + })), + [exportCompanyCard, result], + ); + + const onSelectRow = useCallback( + (row: {value: string}) => { + if (exportCompanyCard && row.value === exportCompanyCard) { + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE.getRoute(policyID)); + return; + } + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_COMPANY_CARD, row.value); + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE.getRoute(policyID)); + }, + [exportCompanyCard, policyID], + ); return ( mode.isSelected)?.keyForList} /> + {isLocationEnabled && {translate('workspace.qbo.companyCardsLocationEnabledDescription')}} ); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage.tsx index 83b967d99ab0..457e12c3c666 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage.tsx @@ -16,6 +16,7 @@ function QuickbooksCompanyCardExpenseConfigurationPage({policy}: WithPolicyProps const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; + const {exportCompanyCard} = policy?.connections?.quickbooksOnline?.config ?? {}; return ( {translate('workspace.qbo.exportCompanyCardsDescription')} Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID))} brickRoadIndicator={undefined} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx index 3bf77f4f3500..9964c792f6ad 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx @@ -20,38 +20,37 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const policyID = policy?.id ?? ''; const policyOwner = policy?.owner ?? ''; - const {exporter} = policy?.connections?.quickbooksOnline?.config?.export ?? {}; - + const {exporter, exportDate, exportEntity, exportInvoice, exportCompanyCard} = policy?.connections?.quickbooksOnline?.config ?? {}; const sections = [ { description: translate('workspace.qbo.preferredExporter'), action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)), - hasError: Boolean(policy?.errors?.enableNewCategories), + hasError: Boolean(policy?.errors?.exporter), title: exporter ?? policyOwner, }, { description: translate('workspace.qbo.date'), action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.getRoute(policyID)), - hasError: Boolean(policy?.errors?.syncClasses), - title: 'Date of last expense', + hasError: Boolean(policy?.errors?.exportDate), + title: exportDate ? translate(`workspace.qbo.${exportDate}.label`) : undefined, }, { description: translate('workspace.qbo.exportExpenses'), action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)), hasError: Boolean(policy?.errors?.syncCustomers), - title: 'Vendor bill', + title: exportEntity ? translate(`workspace.qbo.${exportEntity}`) : undefined, }, { description: translate('workspace.qbo.exportInvoices'), action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.getRoute(policyID)), - hasError: Boolean(policy?.errors?.syncLocations), - title: 'Accounts Receivable (A/R)', + hasError: Boolean(policy?.errors?.exportInvoice), + title: exportInvoice, }, { description: translate('workspace.qbo.exportCompany'), action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE.getRoute(policyID)), - hasError: Boolean(policy?.errors?.syncTaxes), - title: 'Debit card', + hasError: Boolean(policy?.errors?.exportCompanyCard), + title: exportCompanyCard, }, { description: translate('workspace.qbo.exportExpensifyCard'), diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx index 3c0200ab116e..4278ecbd72b3 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx @@ -10,30 +10,33 @@ import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; function QuickbooksExportDateSelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - // const policyID = policy?.id ?? ''; + const policyID = policy?.id ?? ''; const {exportDate} = policy?.connections?.quickbooksOnline?.config ?? {}; const data = Object.values(CONST.QUICKBOOKS_EXPORT_DATE).map((dateType) => ({ value: dateType, text: translate(`workspace.qbo.${dateType}.label`), alternateText: translate(`workspace.qbo.${dateType}.description`), keyForList: dateType, - isSelected: exportDate ? CONST.QUICKBOOKS_EXPORT_DATE[exportDate] === dateType : false, + isSelected: exportDate ? exportDate === dateType : false, })); - const updateMode = useCallback( - (mode: {value: string}) => { - if (exportDate && mode.value === CONST.QUICKBOOKS_EXPORT_DATE[exportDate]) { - Navigation.goBack(); + const onSelectRow = useCallback( + (row: {value: string}) => { + if (exportDate && row.value === exportDate) { + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.getRoute(policyID)); return; } - // TODO add API call for change + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_DATE, row.value); + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.getRoute(policyID)); }, - [exportDate], + [exportDate, policyID], ); return ( @@ -48,7 +51,7 @@ function QuickbooksExportDateSelectPage({policy}: WithPolicyProps) { mode.isSelected)?.keyForList} /> diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx new file mode 100644 index 000000000000..b9c6c0466dc2 --- /dev/null +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx @@ -0,0 +1,79 @@ +import React, {useCallback, useMemo} from 'react'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import SelectionList from '@components/SelectionList'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@navigation/Navigation'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import * as Policy from '@userActions/Policy'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const {accountsReceivable} = policy?.connections?.quickbooksOnline?.data ?? {}; + const {exportInvoice} = policy?.connections?.quickbooksOnline?.config ?? {}; + // TODO - should be removed after API fully working + const draft = [ + { + name: translate(`workspace.qbo.receivable`), + }, + { + name: translate(`workspace.qbo.archive`), + }, + ]; + const result = accountsReceivable?.length ? accountsReceivable : draft; + + const policyID = policy?.id ?? ''; + const data = useMemo( + () => + result?.map((account) => ({ + value: account.name, + text: account.name, + keyForList: account.name, + isSelected: account.name === exportInvoice, + })), + [exportInvoice, result], + ); + + const onSelectRow = useCallback( + (row: {value: string}) => { + if (exportInvoice && row.value === exportInvoice) { + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.getRoute(policyID)); + return; + } + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_INVOICE, row.value); + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.getRoute(policyID)); + }, + [exportInvoice, policyID], + ); + + return ( + + + + {translate('workspace.qbo.exportInvoicesDescription')} + mode.isSelected)?.keyForList} + /> + + + ); +} + +QuickbooksExportInvoiceAccountSelectPage.displayName = 'QuickbooksExportInvoiceAccountSelectPage'; + +export default withPolicy(QuickbooksExportInvoiceAccountSelectPage); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksInvoiceAccountSelectPage.tsx deleted file mode 100644 index a2f7c57cbb89..000000000000 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksInvoiceAccountSelectPage.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import React, {useCallback} from 'react'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; -import ScrollView from '@components/ScrollView'; -import SelectionList from '@components/SelectionList'; -import RadioListItem from '@components/SelectionList/RadioListItem'; -import Text from '@components/Text'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import withPolicy from '@pages/workspace/withPolicy'; -import type {WithPolicyProps} from '@pages/workspace/withPolicy'; - -const selected = 'selected'; - -function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { - const {translate} = useLocalize(); - const styles = useThemeStyles(); - const {accountsReceivable} = policy?.connections?.quickbooksOnline?.data ?? {}; - - // const policyID = policy?.id ?? ''; - const data = - accountsReceivable?.map((account) => ({ - value: account.name, - text: account.name, - keyForList: account.name, - isSelected: account.name === selected, - })) || []; - - const updateMode = useCallback((mode: {value: string}) => { - // TODO add API call for change - }, []); - - return ( - - - - {translate('workspace.qbo.exportInvoicesDescription')} - mode.isSelected)?.keyForList} - /> - - - ); -} - -QuickbooksInvoiceAccountSelectPage.displayName = 'QuickbooksInvoiceAccountSelectPage'; - -export default withPolicy(QuickbooksInvoiceAccountSelectPage); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx new file mode 100644 index 000000000000..095d4494a583 --- /dev/null +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx @@ -0,0 +1,94 @@ +import React, {useCallback, useMemo} from 'react'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import SelectionList from '@components/SelectionList'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@navigation/Navigation'; +import withPolicy from '@pages/workspace/withPolicy'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import * as Policy from '@userActions/Policy'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +// TODO - should be removed after API fully working +const draft = [ + { + name: 'Accounts Payable (A/P)', + }, + { + name: 'Payroll Accounts', + }, +]; + +function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const {bankAccounts, journalEntryAccounts, accountsPayable} = policy?.connections?.quickbooksOnline?.data ?? {}; + + const {exportEntity, exportAccount} = policy?.connections?.quickbooksOnline?.config ?? {}; + + const data = useMemo(() => { + let result; + switch (exportEntity) { + case CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK: + result = bankAccounts ?? []; + break; + case CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL: + result = accountsPayable ?? []; + break; + case CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY: + result = journalEntryAccounts ?? []; + break; + default: + result = draft; + } + + return (draft ?? result)?.map((card) => ({ + value: card.name, + text: card.name, + keyForList: card.name, + isSelected: card.name === exportAccount, + })); + }, [accountsPayable, bankAccounts, exportAccount, exportEntity, journalEntryAccounts]); + + const policyID = policy?.id ?? ''; + + const onSelectRow = useCallback( + (row: {value: string}) => { + if (exportAccount && row.value === exportAccount) { + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)); + return; + } + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_ACCOUNT, row.value); + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)); + }, + [exportAccount, policyID], + ); + + return ( + + + + {translate('workspace.qbo.accountsPayableDescription')} + mode.isSelected)?.keyForList} + /> + + + ); +} + +QuickbooksOutOfPocketExpenseAccountSelectPage.displayName = 'QuickbooksOutOfPocketExpenseAccountSelectPage'; + +export default withPolicy(QuickbooksOutOfPocketExpenseAccountSelectPage); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx index fcacb068b8e5..38c0017e04b1 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx @@ -13,12 +13,11 @@ import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; -const isVendorBill = true; function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; - const {syncLocations} = policy?.connections?.quickbooksOnline?.config ?? {}; + const {syncLocations, exportAccount, exportEntity} = policy?.connections?.quickbooksOnline?.config ?? {}; const isLocationEnabled = Boolean(syncLocations && syncLocations !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); return ( @@ -32,21 +31,22 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps {!isLocationEnabled && {translate('workspace.qbo.exportOutOfPocketExpensesDescription')}} Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.getRoute(policyID))} brickRoadIndicator={undefined} - shouldShowRightIcon={!isLocationEnabled} - interactive={!isLocationEnabled} + shouldShowRightIcon /> - {isVendorBill && !isLocationEnabled && {translate('workspace.qbo.exportVendorBillDescription')}} + {exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL && !isLocationEnabled && ( + {translate('workspace.qbo.exportVendorBillDescription')} + )} {isLocationEnabled && {translate('workspace.qbo.outOfPocketLocationEnabledDescription')}} {!isLocationEnabled && ( Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID))} + title={exportAccount} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.getRoute(policyID))} brickRoadIndicator={undefined} shouldShowRightIcon /> diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx index 9a0d81721951..d099f53b7332 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx @@ -7,50 +7,55 @@ import RadioListItem from '@components/SelectionList/RadioListItem'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; - -const CARDS = { - CHECK: 'check', - JOURNAL_ENTRY: 'journal_entry', - VENDOR_BILL: 'vendor_bill', -}; +import ROUTES from '@src/ROUTES'; function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const {nonReimbursableExpensesExportDestination, syncTaxes} = policy?.connections?.quickbooksOnline?.config ?? {}; + const {exportEntity, syncTaxes} = policy?.connections?.quickbooksOnline?.config ?? {}; const isTaxesEnabled = Boolean(syncTaxes && syncTaxes !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); - // const policyID = policy?.id ?? ''; + const policyID = policy?.id ?? ''; const data = [ { - value: CARDS.CHECK, + value: CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK, text: translate(`workspace.qbo.check`), - keyForList: CARDS.CHECK, - isSelected: nonReimbursableExpensesExportDestination === CARDS.CHECK, + keyForList: CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK, + isSelected: exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK, isShown: true, }, { - value: CARDS.JOURNAL_ENTRY, + value: CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY, text: translate(`workspace.qbo.journalEntry`), - keyForList: CARDS.JOURNAL_ENTRY, - isSelected: nonReimbursableExpensesExportDestination === CARDS.JOURNAL_ENTRY, + keyForList: CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY, + isSelected: exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY, isShown: !isTaxesEnabled, }, { - value: CARDS.VENDOR_BILL, + value: CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL, text: translate(`workspace.qbo.vendorBill`), - keyForList: CARDS.VENDOR_BILL, - isSelected: nonReimbursableExpensesExportDestination === CARDS.VENDOR_BILL, + keyForList: CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL, + isSelected: exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL, isShown: true, }, ]; - const updateMode = useCallback((mode: {value: string}) => { - // TODO add API call for change - }, []); + const onSelectRow = useCallback( + (row: {value: string}) => { + if (exportEntity && row.value === exportEntity) { + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)); + return; + } + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY, row.value); + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)); + }, + [exportEntity, policyID], + ); return ( item.isShown)}]} ListItem={RadioListItem} - onSelectRow={updateMode} + onSelectRow={onSelectRow} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} /> {translate('workspace.qbo.outOfPocketTaxEnabledDescription')} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx index bd47b4ab0dc3..9b81b17961ed 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx @@ -8,30 +8,53 @@ import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import {getAdminEmailList} from '@libs/PolicyUtils'; +import Navigation from '@navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import * as Policy from '@userActions/Policy'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; +// TODO - should be removed after API fully working +const draft = [ + {name: '+14153166423@expensify.sms', currency: 'USD', id: '94', email: '+14153166423@expensify.sms'}, + {name: 'Account Maintenance Fee', currency: 'USD', id: '141', email: 'alberto@expensify213.com'}, + {name: 'Admin Test', currency: 'USD', id: '119', email: 'admin@qbocard.com'}, + {name: 'Alberto Gonzalez-Cela', currency: 'USD', id: '104', email: 'alberto@expensify.com'}, + {name: 'Aldo test QBO2 QBO2 Last name', currency: 'USD', id: '140', email: 'admin@qbo.com'}, +]; function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const {data, config} = policy?.connections?.quickbooksOnline ?? {}; + const {exporter} = policy?.connections?.quickbooksOnline?.config ?? {}; const exporters = getAdminEmailList(policy); + const result = exporters?.length ? exporters : draft; - // const policyID = policy?.id ?? ''; + const policyID = policy?.id ?? ''; const sections = useMemo( () => - exporters?.map((vendor) => ({ + result?.map((vendor) => ({ value: vendor.email, text: vendor.email, keyForList: vendor.email, - isSelected: config?.export?.exporter === vendor.email, + isSelected: exporter === vendor.email, })) ?? [], - [config?.export?.exporter, data?.vendors], + [result, exporter], ); - const updateMode = useCallback((mode: {value?: string}) => { - // TODO add API call for change - }, []); + const onSelectRow = useCallback( + (row: {value?: string}) => { + if (exporter && row.value === exporter) { + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)); + return; + } + if (row?.value) { + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.PREFERRED_EXPORTER, row.value); + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)); + } + }, + [policyID, exporter], + ); return ( {translate('workspace.qbo.exportPreferredExporterNote')} {translate('workspace.qbo.exportPreferredExporterSubNote')} mode.isSelected)?.keyForList} /> diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 24233018362b..2adf7d4773ef 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -168,15 +168,18 @@ type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ syncLocations: IntegrationEntityMap; syncAccounts: IntegrationEntityMap; syncTaxes: IntegrationEntityMap; - exportDate: keyof typeof CONST.QUICKBOOKS_EXPORT_DATE; lastConfigurationTime: number; syncTax: boolean; enableNewCategories: IntegrationEntityMap; errors?: OnyxCommon.Errors; + exporter: string; + exportDate: ValueOf; + outOfPocketExpenses: string; + exportInvoice: string; + exportAccount: string; + exportEntity: ValueOf; + exportCompanyCard: string; errorFields?: OnyxCommon.ErrorFields; - export: { - exporter: string; - }; }>; type Connection = { lastSync?: ConnectionLastSync; From 8ce62d9efd5d818eca0002c7eac278b44e56156c Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Tue, 16 Apr 2024 18:17:17 +0300 Subject: [PATCH 172/339] fix ts --- src/libs/PolicyUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 017b747df987..71df3a670594 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -6,7 +6,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {PersonalDetailsList, Policy, PolicyCategories, PolicyMembers, PolicyTagList, PolicyTags, TaxRate} from '@src/types/onyx'; import type {PolicyFeatureName, Rate} from '@src/types/onyx/Policy'; -import PolicyMember from '@src/types/onyx/PolicyMember'; +import type PolicyMember from '@src/types/onyx/PolicyMember'; import type {EmptyObject} from '@src/types/utils/EmptyObject'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import getPolicyIDFromState from './Navigation/getPolicyIDFromState'; From cc5ddf582d05bd48c0e47f0a02b586c2d921ee88 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Wed, 17 Apr 2024 00:18:19 +0700 Subject: [PATCH 173/339] fix lint --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index b47ebf18694e..25311f2e29b5 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -821,9 +821,9 @@ function buildOnyxDataForTrackExpense( policyCategories?: OnyxEntry, ): [OnyxUpdate[], OnyxUpdate[], OnyxUpdate[]] { const isScanRequest = TransactionUtils.isScanRequest(transaction); + const isDistanceRequest = TransactionUtils.isDistanceRequest(transaction); const clearedPendingFields = Object.fromEntries(Object.keys(transaction.pendingFields ?? {}).map((key) => [key, null])); const optimisticData: OnyxUpdate[] = []; - const isDistanceRequest = TransactionUtils.isDistanceRequest(transaction); let newQuickAction: ValueOf = CONST.QUICK_ACTIONS.TRACK_MANUAL; if (isScanRequest) { newQuickAction = CONST.QUICK_ACTIONS.TRACK_SCAN; From facd36b9aad1aca5672525e93e77fd5dd7b8215c Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Wed, 17 Apr 2024 10:10:29 +0530 Subject: [PATCH 174/339] Fixed a minor bug in distance preview --- .../MoneyTemporaryForRefactorRequestConfirmationList.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx index f460b9d8e88c..e5b013bb3be0 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.tsx @@ -941,7 +941,8 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ )} - {(!isMovingTransactionFromTrackExpense || !hasRoute) && + {!isMovingTransactionFromTrackExpense && + !hasRoute && // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing (receiptImage || receiptThumbnail ? receiptThumbnailContent From 030f7798f06d56bf4c19b9586d8220683102625e Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Wed, 17 Apr 2024 13:10:26 +0300 Subject: [PATCH 175/339] fix employee list --- src/libs/PolicyUtils.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index cb3e223bea8d..85a20ceaf512 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -6,7 +6,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {Policy, PolicyCategories, PolicyEmployeeList, PolicyTagList, PolicyTags, TaxRate} from '@src/types/onyx'; import type {PolicyFeatureName, Rate} from '@src/types/onyx/Policy'; -import type PolicyMember from '@src/types/onyx/PolicyMember'; import type {EmptyObject} from '@src/types/utils/EmptyObject'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import getPolicyIDFromState from './Navigation/getPolicyIDFromState'; @@ -320,7 +319,17 @@ function getPolicyIDFromNavigationState() { } function getAdminEmailList(policy: Policy | null) { - return policy?.employeeList?.filter((employee: PolicyMember) => employee?.role === CONST.POLICY.ROLE.ADMIN).map((admin) => admin.email); + const adminEmailList: Array<{email: string}> = []; + if (!policy?.employeeList) { + return adminEmailList; + } + Object.keys(policy.employeeList).forEach((email: string) => { + if (policy?.employeeList?.[email].role !== CONST.POLICY.ROLE.ADMIN) { + return; + } + adminEmailList.push({email}); + }); + return adminEmailList; } export { From 9aa233c33eb954528fffd433272ed4c21f03438a Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Wed, 17 Apr 2024 14:31:54 +0300 Subject: [PATCH 176/339] Resolve C+ review comments --- ...oksCompanyCardExpenseAccountSelectPage.tsx | 64 ++++++++++------ ...oksCompanyCardExpenseConfigurationPage.tsx | 7 +- .../QuickbooksExportConfigurationPage.tsx | 72 ++++++++---------- .../export/QuickbooksExportDateSelectPage.tsx | 20 ++--- ...ickbooksExportInvoiceAccountSelectPage.tsx | 18 +++-- ...oksOutOfPocketExpenseAccountSelectPage.tsx | 18 +++-- ...oksOutOfPocketExpenseConfigurationPage.tsx | 8 +- ...ooksOutOfPocketExpenseEntitySelectPage.tsx | 75 +++++++++++-------- ...ooksPreferredExporterConfigurationPage.tsx | 31 ++++---- src/types/onyx/PolicyEmployee.ts | 4 +- 10 files changed, 173 insertions(+), 144 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index 042b2a8b283d..71dc3118ecc7 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -1,9 +1,11 @@ import React, {useCallback, useMemo} from 'react'; +import type {SectionListData} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {ListItem, Section} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -14,6 +16,12 @@ import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; +type CardListItem = ListItem & { + value: string; +}; +type CardsSection = SectionListData>; +type Card = {name: string}; + function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); @@ -22,38 +30,46 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps const {exportCompanyCard, syncLocations} = policy?.connections?.quickbooksOnline?.config ?? {}; const isLocationEnabled = Boolean(syncLocations && syncLocations !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); - const defaultCards = [ - { - name: translate(`workspace.qbo.creditCard`), - }, - { - name: translate(`workspace.qbo.debitCard`), - }, - { - name: translate(`workspace.qbo.vendorBill`), - }, - ]; - const cardsBasedOnLocation = isLocationEnabled ? defaultCards.slice(0, -1) : defaultCards; - const result = creditCards?.length ? creditCards : cardsBasedOnLocation; - const policyID = policy?.id ?? ''; - const data = useMemo( + const defaultCards = useMemo( + () => [ + { + name: translate(`workspace.qbo.creditCard`), + }, + { + name: translate(`workspace.qbo.debitCard`), + }, + { + name: translate(`workspace.qbo.vendorBill`), + }, + ], + [translate], + ); + const cards = useMemo(() => { + if (creditCards?.length) { + return creditCards; + } + return isLocationEnabled ? defaultCards.slice(0, -1) : defaultCards; + }, [creditCards, isLocationEnabled, defaultCards]); + + const data = useMemo( () => - result?.map((card) => ({ + cards.map((card) => ({ value: card.name, text: card.name, keyForList: card.name, isSelected: card.name === exportCompanyCard, })), - [exportCompanyCard, result], + [cards, exportCompanyCard], ); + const sections = useMemo(() => [{data}], [data]); + const policyID = policy?.id ?? ''; + const onSelectRow = useCallback( - (row: {value: string}) => { - if (exportCompanyCard && row.value === exportCompanyCard) { - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE.getRoute(policyID)); - return; + (row: CardListItem) => { + if (row.value !== exportCompanyCard) { + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_COMPANY_CARD, row.value); } - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_COMPANY_CARD, row.value); Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE.getRoute(policyID)); }, [exportCompanyCard, policyID], @@ -68,12 +84,12 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps mode.isSelected)?.keyForList} + footerContent={isLocationEnabled && {translate('workspace.qbo.companyCardsLocationEnabledDescription')}} /> - {isLocationEnabled && {translate('workspace.qbo.companyCardsLocationEnabledDescription')}} ); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage.tsx index 457e12c3c666..3a1f40a0de32 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage.tsx @@ -10,18 +10,17 @@ import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; function QuickbooksCompanyCardExpenseConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; - const {exportCompanyCard} = policy?.connections?.quickbooksOnline?.config ?? {}; - + const {exportCompanyCard, errors} = policy?.connections?.quickbooksOnline?.config ?? {}; return ( @@ -32,7 +31,7 @@ function QuickbooksCompanyCardExpenseConfigurationPage({policy}: WithPolicyProps title={exportCompanyCard} description={translate('workspace.qbo.exportAs')} onPress={() => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID))} - brickRoadIndicator={undefined} + brickRoadIndicator={errors?.exportCompanyCard ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} shouldShowRightIcon /> diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx index 9964c792f6ad..1a51d36c9ec2 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx @@ -1,11 +1,12 @@ import React from 'react'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import type {MenuItemProps} from '@components/MenuItem'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; -import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import Text from '@components/Text'; +import TextLink from '@components/TextLink'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@navigation/Navigation'; @@ -20,81 +21,74 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const policyID = policy?.id ?? ''; const policyOwner = policy?.owner ?? ''; - const {exporter, exportDate, exportEntity, exportInvoice, exportCompanyCard} = policy?.connections?.quickbooksOnline?.config ?? {}; - const sections = [ + const {exporter, exportDate, exportEntity, exportInvoice, exportCompanyCard, errors} = policy?.connections?.quickbooksOnline?.config ?? {}; + const menuItems: MenuItemProps[] = [ { description: translate('workspace.qbo.preferredExporter'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)), - hasError: Boolean(policy?.errors?.exporter), + onPress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)), + brickRoadIndicator: errors?.exporter ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exporter ?? policyOwner, }, { description: translate('workspace.qbo.date'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.getRoute(policyID)), - hasError: Boolean(policy?.errors?.exportDate), + onPress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.getRoute(policyID)), + brickRoadIndicator: errors?.exportDate ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportDate ? translate(`workspace.qbo.${exportDate}.label`) : undefined, }, { description: translate('workspace.qbo.exportExpenses'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)), - hasError: Boolean(policy?.errors?.syncCustomers), + onPress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)), + brickRoadIndicator: errors?.exportExpenses ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportEntity ? translate(`workspace.qbo.${exportEntity}`) : undefined, }, { description: translate('workspace.qbo.exportInvoices'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.getRoute(policyID)), - hasError: Boolean(policy?.errors?.exportInvoice), + onPress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.getRoute(policyID)), + brickRoadIndicator: errors?.exportInvoice ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportInvoice, }, { description: translate('workspace.qbo.exportCompany'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE.getRoute(policyID)), - hasError: Boolean(policy?.errors?.exportCompanyCard), + onPress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE.getRoute(policyID)), + brickRoadIndicator: errors?.exportCompanyCard ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportCompanyCard, }, { description: translate('workspace.qbo.exportExpensifyCard'), - action: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.getRoute(policyID)), - hasError: Boolean(policy?.errors?.syncTaxes), - title: 'Credit card', - interactive: false, + title: translate('workspace.qbo.creditCard'), + shouldShowRightIcon: false, }, ]; return ( {translate('workspace.qbo.exportDescription')} - {sections.map((section) => ( - + {menuItems.map((menuItem) => ( + ))} - { - Link.openExternalLink(CONST.DEEP_DIVE_EXPENSIFY_CARD); - }} - style={[styles.ph5, styles.pb5]} - accessibilityLabel={translate('workspace.qbo.deepDiveExpensifyCard')} - role={CONST.ROLE.LINK} - > - - {`${translate('workspace.qbo.deepDiveExpensifyCard')} `} - {translate('workspace.qbo.deepDiveExpensifyCardIntegration')} - - + + {`${translate('workspace.qbo.deepDiveExpensifyCard')} `} + Link.openExternalLink(CONST.DEEP_DIVE_EXPENSIFY_CARD)} + style={[styles.optionAlternateText, styles.textLabelSupporting, styles.link]} + > + {translate('workspace.qbo.deepDiveExpensifyCardIntegration')} + + ); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx index 4278ecbd72b3..38e326ff6694 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx @@ -1,9 +1,11 @@ import React, {useCallback} from 'react'; +import type {ValueOf} from 'type-fest'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -14,26 +16,27 @@ import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; +type CardListItem = ListItem & { + value: ValueOf; +}; function QuickbooksExportDateSelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; const {exportDate} = policy?.connections?.quickbooksOnline?.config ?? {}; - const data = Object.values(CONST.QUICKBOOKS_EXPORT_DATE).map((dateType) => ({ + const data: CardListItem[] = Object.values(CONST.QUICKBOOKS_EXPORT_DATE).map((dateType) => ({ value: dateType, text: translate(`workspace.qbo.${dateType}.label`), alternateText: translate(`workspace.qbo.${dateType}.description`), keyForList: dateType, - isSelected: exportDate ? exportDate === dateType : false, + isSelected: exportDate === dateType, })); const onSelectRow = useCallback( - (row: {value: string}) => { - if (exportDate && row.value === exportDate) { - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.getRoute(policyID)); - return; + (row: CardListItem) => { + if (row.value !== exportDate) { + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_DATE, row.value); } - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_DATE, row.value); Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.getRoute(policyID)); }, [exportDate, policyID], @@ -42,13 +45,12 @@ function QuickbooksExportDateSelectPage({policy}: WithPolicyProps) { return ( - {translate('workspace.qbo.exportDateDescription')} {translate('workspace.qbo.exportDateDescription')}} sections={[{data}]} ListItem={RadioListItem} onSelectRow={onSelectRow} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx index b9c6c0466dc2..51ec82f65d0a 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx @@ -4,6 +4,7 @@ import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -14,6 +15,10 @@ import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; +type CardListItem = ListItem & { + value: string; +}; + function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); @@ -31,7 +36,7 @@ function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyProps) { const result = accountsReceivable?.length ? accountsReceivable : draft; const policyID = policy?.id ?? ''; - const data = useMemo( + const data: CardListItem[] = useMemo( () => result?.map((account) => ({ value: account.name, @@ -43,12 +48,10 @@ function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyProps) { ); const onSelectRow = useCallback( - (row: {value: string}) => { - if (exportInvoice && row.value === exportInvoice) { - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.getRoute(policyID)); - return; + (row: CardListItem) => { + if (row.value !== exportInvoice) { + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_INVOICE, row.value); } - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_INVOICE, row.value); Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.getRoute(policyID)); }, [exportInvoice, policyID], @@ -57,13 +60,12 @@ function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyProps) { return ( - {translate('workspace.qbo.exportInvoicesDescription')} {translate('workspace.qbo.exportInvoicesDescription')}} sections={[{data}]} ListItem={RadioListItem} onSelectRow={onSelectRow} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx index 095d4494a583..4af0e8ad4261 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx @@ -4,6 +4,7 @@ import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -24,6 +25,10 @@ const draft = [ }, ]; +type CardListItem = ListItem & { + value: string; +}; + function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); @@ -31,7 +36,7 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps const {exportEntity, exportAccount} = policy?.connections?.quickbooksOnline?.config ?? {}; - const data = useMemo(() => { + const data: CardListItem[] = useMemo(() => { let result; switch (exportEntity) { case CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK: @@ -58,12 +63,10 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps const policyID = policy?.id ?? ''; const onSelectRow = useCallback( - (row: {value: string}) => { - if (exportAccount && row.value === exportAccount) { - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)); - return; + (row: CardListItem) => { + if (row.value !== exportAccount) { + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_ACCOUNT, row.value); } - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_ACCOUNT, row.value); Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)); }, [exportAccount, policyID], @@ -72,13 +75,12 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps return ( - {translate('workspace.qbo.accountsPayableDescription')} {translate('workspace.qbo.accountsPayableDescription')}} sections={[{data}]} ListItem={RadioListItem} onSelectRow={onSelectRow} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx index 38c0017e04b1..9151afcca9d3 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx @@ -17,13 +17,12 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; - const {syncLocations, exportAccount, exportEntity} = policy?.connections?.quickbooksOnline?.config ?? {}; + const {syncLocations, exportAccount, exportEntity, errors} = policy?.connections?.quickbooksOnline?.config ?? {}; const isLocationEnabled = Boolean(syncLocations && syncLocations !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); return ( @@ -34,7 +33,7 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps title={exportEntity ? translate(`workspace.qbo.${exportEntity}`) : undefined} description={translate('workspace.qbo.exportAs')} onPress={() => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.getRoute(policyID))} - brickRoadIndicator={undefined} + brickRoadIndicator={errors?.exportEntity ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} shouldShowRightIcon /> @@ -46,8 +45,9 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.getRoute(policyID))} - brickRoadIndicator={undefined} + brickRoadIndicator={errors?.exportAccount ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} shouldShowRightIcon /> diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx index d099f53b7332..d6ef35a3a1d0 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx @@ -1,9 +1,12 @@ -import React, {useCallback} from 'react'; +import React, {useCallback, useMemo} from 'react'; +import type {SectionListData} from 'react-native'; +import type {ValueOf} from 'type-fest'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {ListItem, Section} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -14,6 +17,12 @@ import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; +type CardListItem = ListItem & { + value: ValueOf; + isShown: boolean; +}; +type CardsSection = SectionListData>; + function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); @@ -21,37 +30,40 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) const isTaxesEnabled = Boolean(syncTaxes && syncTaxes !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); const policyID = policy?.id ?? ''; - const data = [ - { - value: CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK, - text: translate(`workspace.qbo.check`), - keyForList: CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK, - isSelected: exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK, - isShown: true, - }, - { - value: CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY, - text: translate(`workspace.qbo.journalEntry`), - keyForList: CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY, - isSelected: exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY, - isShown: !isTaxesEnabled, - }, - { - value: CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL, - text: translate(`workspace.qbo.vendorBill`), - keyForList: CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL, - isSelected: exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL, - isShown: true, - }, - ]; + const data: CardListItem[] = useMemo( + () => [ + { + value: CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK, + text: translate(`workspace.qbo.check`), + keyForList: CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK, + isSelected: exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK, + isShown: true, + }, + { + value: CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY, + text: translate(`workspace.qbo.journalEntry`), + keyForList: CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY, + isSelected: exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY, + isShown: !isTaxesEnabled, + }, + { + value: CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL, + text: translate(`workspace.qbo.vendorBill`), + keyForList: CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL, + isSelected: exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL, + isShown: true, + }, + ], + [exportEntity, isTaxesEnabled, translate], + ); + + const sections: CardsSection[] = useMemo(() => [{data: data.filter((item) => item.isShown)}], [data]); const onSelectRow = useCallback( - (row: {value: string}) => { - if (exportEntity && row.value === exportEntity) { - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)); - return; + (row: CardListItem) => { + if (row.value !== exportEntity) { + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY, row.value); } - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY, row.value); Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)); }, [exportEntity, policyID], @@ -60,14 +72,13 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) return ( - {translate('workspace.qbo.optionBelow')} item.isShown)}]} + headerContent={{translate('workspace.qbo.optionBelow')}} + sections={sections} ListItem={RadioListItem} onSelectRow={onSelectRow} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx index 9b81b17961ed..d86ed1e8d783 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx @@ -4,6 +4,7 @@ import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -23,6 +24,11 @@ const draft = [ {name: 'Alberto Gonzalez-Cela', currency: 'USD', id: '104', email: 'alberto@expensify.com'}, {name: 'Aldo test QBO2 QBO2 Last name', currency: 'USD', id: '140', email: 'admin@qbo.com'}, ]; + +type CardListItem = ListItem & { + value: string; +}; + function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); @@ -31,7 +37,7 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { const result = exporters?.length ? exporters : draft; const policyID = policy?.id ?? ''; - const sections = useMemo( + const data: CardListItem[] = useMemo( () => result?.map((vendor) => ({ value: vendor.email, @@ -43,15 +49,11 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { ); const onSelectRow = useCallback( - (row: {value?: string}) => { - if (exporter && row.value === exporter) { - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)); - return; - } - if (row?.value) { + (row: CardListItem) => { + if (row.value !== exporter) { Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.PREFERRED_EXPORTER, row.value); - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)); } + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)); }, [policyID, exporter], ); @@ -59,19 +61,22 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { return ( - {translate('workspace.qbo.exportPreferredExporterNote')} - {translate('workspace.qbo.exportPreferredExporterSubNote')} + {translate('workspace.qbo.exportPreferredExporterNote')} + {translate('workspace.qbo.exportPreferredExporterSubNote')} + + } shouldStopPropagation - sections={[{data: sections}]} + sections={[{data}]} ListItem={RadioListItem} onSelectRow={onSelectRow} - initiallyFocusedOptionKey={sections.find((mode) => mode.isSelected)?.keyForList} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} /> diff --git a/src/types/onyx/PolicyEmployee.ts b/src/types/onyx/PolicyEmployee.ts index 175bfdfbb149..4a5f374de44a 100644 --- a/src/types/onyx/PolicyEmployee.ts +++ b/src/types/onyx/PolicyEmployee.ts @@ -1,10 +1,8 @@ -import type {ValueOf} from 'type-fest'; -import type CONST from '@src/CONST'; import type * as OnyxCommon from './OnyxCommon'; type PolicyEmployee = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Role of the user in the policy */ - role?: ValueOf; + role?: string; /** Email of the user */ email?: string; From 3a905c7f3629610b08162c23b65cdd4ee5bcac61 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 17 Apr 2024 20:03:58 +0800 Subject: [PATCH 177/339] remove underscore and unused file --- src/ROUTES.ts | 5 - src/SCREENS.ts | 1 - src/components/Modal/modalPropTypes.js | 89 --------- .../OptionsSelector/BaseOptionsSelector.js | 35 ++-- src/components/Popover/popoverPropTypes.js | 48 ----- src/components/menuItemPropTypes.js | 179 ----------------- .../ModalStackNavigators/index.tsx | 1 - src/libs/Navigation/linkingConfig/config.ts | 1 - src/libs/Navigation/types.ts | 5 +- src/pages/EditRequestPage.js | 189 ------------------ ...yForRefactorRequestParticipantsSelector.js | 34 ++-- .../step/IOURequestStepRoutePropTypes.js | 29 --- src/pages/reportPropTypes.js | 79 -------- 13 files changed, 37 insertions(+), 658 deletions(-) delete mode 100644 src/components/Modal/modalPropTypes.js delete mode 100644 src/components/Popover/popoverPropTypes.js delete mode 100644 src/components/menuItemPropTypes.js delete mode 100644 src/pages/EditRequestPage.js delete mode 100644 src/pages/iou/request/step/IOURequestStepRoutePropTypes.js delete mode 100644 src/pages/reportPropTypes.js diff --git a/src/ROUTES.ts b/src/ROUTES.ts index ec2bf11957e1..11988af00d5b 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -202,11 +202,6 @@ const ROUTES = { route: 'r/:reportID/avatar', getRoute: (reportID: string) => `r/${reportID}/avatar` as const, }, - EDIT_REQUEST: { - route: 'r/:threadReportID/edit/:field/:tagIndex?', - getRoute: (threadReportID: string, field: ValueOf, tagIndex?: number) => - `r/${threadReportID}/edit/${field}${typeof tagIndex === 'number' ? `/${tagIndex}` : ''}` as const, - }, EDIT_CURRENCY_REQUEST: { route: 'r/:threadReportID/edit/currency', getRoute: (threadReportID: string, currency: string, backTo: string) => `r/${threadReportID}/edit/currency?currency=${currency}&backTo=${backTo}` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 96372d5bbabb..6fbaf047e544 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -265,7 +265,6 @@ const SCREENS = { }, EDIT_REQUEST: { - ROOT: 'EditRequest_Root', CURRENCY: 'EditRequest_Currency', REPORT_FIELD: 'EditRequest_ReportField', }, diff --git a/src/components/Modal/modalPropTypes.js b/src/components/Modal/modalPropTypes.js deleted file mode 100644 index 84e610b694e4..000000000000 --- a/src/components/Modal/modalPropTypes.js +++ /dev/null @@ -1,89 +0,0 @@ -import PropTypes from 'prop-types'; -import _ from 'underscore'; -import {windowDimensionsPropTypes} from '@components/withWindowDimensions'; -import stylePropTypes from '@styles/stylePropTypes'; -import CONST from '@src/CONST'; - -const propTypes = { - /** Decides whether the modal should cover fullscreen. FullScreen modal has backdrop */ - fullscreen: PropTypes.bool, - - /** Should we close modal on outside click */ - shouldCloseOnOutsideClick: PropTypes.bool, - - /** Should we announce the Modal visibility changes? */ - shouldSetModalVisibility: PropTypes.bool, - - /** Callback method fired when the user requests to close the modal */ - onClose: PropTypes.func.isRequired, - - /** State that determines whether to display the modal or not */ - isVisible: PropTypes.bool.isRequired, - - /** Modal contents */ - children: PropTypes.node.isRequired, - - /** Callback method fired when the user requests to submit the modal content. */ - onSubmit: PropTypes.func, - - /** Callback method fired when the modal is hidden */ - onModalHide: PropTypes.func, - - /** Callback method fired when the modal is shown */ - onModalShow: PropTypes.func, - - /** Style of modal to display */ - type: PropTypes.oneOf(_.values(CONST.MODAL.MODAL_TYPE)), - - /** A react-native-animatable animation definition for the modal display animation. */ - animationIn: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), - - /** A react-native-animatable animation definition for the modal hide animation. */ - animationOut: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), - - /** The anchor position of a popover modal. Has no effect on other modal types. */ - popoverAnchorPosition: PropTypes.shape({ - top: PropTypes.number, - right: PropTypes.number, - bottom: PropTypes.number, - left: PropTypes.number, - }), - - /** Modal container styles */ - innerContainerStyle: stylePropTypes, - - /** Whether the modal should go under the system statusbar */ - statusBarTranslucent: PropTypes.bool, - - /** Whether the modal should avoid the keyboard */ - avoidKeyboard: PropTypes.bool, - - /** - * Whether the modal should hide its content while animating. On iOS, set to true - * if `useNativeDriver` is also true, to avoid flashes in the UI. - * - * See: https://github.com/react-native-modal/react-native-modal/pull/116 - * */ - hideModalContentWhileAnimating: PropTypes.bool, - - ...windowDimensionsPropTypes, -}; - -const defaultProps = { - fullscreen: true, - shouldCloseOnOutsideClick: false, - shouldSetModalVisibility: true, - onSubmit: null, - type: '', - onModalHide: () => {}, - onModalShow: () => {}, - animationIn: null, - animationOut: null, - popoverAnchorPosition: {}, - innerContainerStyle: {}, - statusBarTranslucent: true, - avoidKeyboard: false, - hideModalContentWhileAnimating: false, -}; - -export {propTypes, defaultProps}; diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index cc73a6fc8fd7..13ac5160b30b 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -1,8 +1,9 @@ +import lodashDebounce from 'lodash/debounce'; import lodashGet from 'lodash/get'; +import lodashIsEqual from 'lodash/isEqual'; import PropTypes from 'prop-types'; import React, {Component} from 'react'; import {View} from 'react-native'; -import _ from 'underscore'; import ArrowKeyFocusManager from '@components/ArrowKeyFocusManager'; import Button from '@components/Button'; import FixedFooter from '@components/FixedFooter'; @@ -77,9 +78,9 @@ class BaseOptionsSelector extends Component { this.calculateAllVisibleOptionsCount = this.calculateAllVisibleOptionsCount.bind(this); this.handleFocusIn = this.handleFocusIn.bind(this); this.handleFocusOut = this.handleFocusOut.bind(this); - this.debouncedUpdateSearchValue = _.debounce(this.updateSearchValue, CONST.TIMING.SEARCH_OPTION_LIST_DEBOUNCE_TIME); + this.debouncedUpdateSearchValue = lodashDebounce(this.updateSearchValue, CONST.TIMING.SEARCH_OPTION_LIST_DEBOUNCE_TIME); this.relatedTarget = null; - this.accessibilityRoles = _.values(CONST.ROLE); + this.accessibilityRoles = Object.values(CONST.ROLE); this.isWebOrDesktop = [CONST.PLATFORM.DESKTOP, CONST.PLATFORM.WEB].includes(getPlatform()); const allOptions = this.flattenSections(); @@ -155,7 +156,7 @@ class BaseOptionsSelector extends Component { this.focusedOption = this.state.allOptions[this.state.focusedIndex]; } - if (_.isEqual(this.props.sections, prevProps.sections)) { + if (lodashIsEqual(this.props.sections, prevProps.sections)) { return; } @@ -171,14 +172,14 @@ class BaseOptionsSelector extends Component { } const newFocusedIndex = this.props.selectedOptions.length; const isNewFocusedIndex = newFocusedIndex !== this.state.focusedIndex; - const prevFocusedOption = _.find(newOptions, (option) => this.focusedOption && option.keyForList === this.focusedOption.keyForList); - const prevFocusedOptionIndex = prevFocusedOption ? _.findIndex(newOptions, (option) => this.focusedOption && option.keyForList === this.focusedOption.keyForList) : undefined; + const prevFocusedOption = newOptions.find((option) => this.focusedOption && option.keyForList === this.focusedOption.keyForList); + const prevFocusedOptionIndex = prevFocusedOption ? newOptions.findIndex((option) => this.focusedOption && option.keyForList === this.focusedOption.keyForList) : undefined; // eslint-disable-next-line react/no-did-update-set-state this.setState( { sections: newSections, allOptions: newOptions, - focusedIndex: prevFocusedOptionIndex || (_.isNumber(this.props.focusedIndex) ? this.props.focusedIndex : newFocusedIndex), + focusedIndex: prevFocusedOptionIndex || (typeof this.props.focusedIndex === 'number' ? this.props.focusedIndex : newFocusedIndex), }, () => { // If we just toggled an option on a multi-selection page or cleared the search input, scroll to top @@ -230,11 +231,11 @@ class BaseOptionsSelector extends Component { } else { defaultIndex = this.props.selectedOptions.length; } - if (_.isUndefined(this.props.initiallyFocusedOptionKey)) { + if (typeof this.props.initiallyFocusedOptionKey === 'undefined') { return defaultIndex; } - const indexOfInitiallyFocusedOption = _.findIndex(allOptions, (option) => option.keyForList === this.props.initiallyFocusedOptionKey); + const indexOfInitiallyFocusedOption = allOptions.findIndex((option) => option.keyForList === this.props.initiallyFocusedOptionKey); return indexOfInitiallyFocusedOption; } @@ -245,8 +246,8 @@ class BaseOptionsSelector extends Component { * @returns {Objects[]} */ sliceSections() { - return _.map(this.props.sections, (section) => { - if (_.isEmpty(section.data)) { + return this.props.sections.map((section) => { + if (section.data.length === 0) { return section; } @@ -266,7 +267,7 @@ class BaseOptionsSelector extends Component { calculateAllVisibleOptionsCount() { let count = 0; - _.forEach(this.state.sections, (section) => { + this.state.sections.forEach((section) => { count += lodashGet(section, 'data.length', 0); }); @@ -347,7 +348,7 @@ class BaseOptionsSelector extends Component { selectFocusedOption(e) { const focusedItemKey = lodashGet(e, ['target', 'attributes', 'id', 'value']); - const focusedOption = focusedItemKey ? _.find(this.state.allOptions, (option) => option.keyForList === focusedItemKey) : this.state.allOptions[this.state.focusedIndex]; + const focusedOption = focusedItemKey ? this.state.allOptions.find((option) => option.keyForList === focusedItemKey) : this.state.allOptions[this.state.focusedIndex]; if (!focusedOption || !this.props.isFocused) { return; @@ -393,8 +394,8 @@ class BaseOptionsSelector extends Component { const allOptions = []; this.disabledOptionsIndexes = []; let index = 0; - _.each(this.props.sections, (section, sectionIndex) => { - _.each(section.data, (option, optionIndex) => { + this.props.sections.forEach((section, sectionIndex) => { + section.data.forEach((option, optionIndex) => { allOptions.push({ ...option, sectionIndex, @@ -496,8 +497,8 @@ class BaseOptionsSelector extends Component { render() { const shouldShowShowMoreButton = this.state.allOptions.length > CONST.MAX_OPTIONS_SELECTOR_PAGE_LENGTH * this.state.paginationPage; const shouldShowFooter = - !this.props.isReadOnly && (this.props.shouldShowConfirmButton || this.props.footerContent) && !(this.props.canSelectMultipleOptions && _.isEmpty(this.props.selectedOptions)); - const defaultConfirmButtonText = _.isUndefined(this.props.confirmButtonText) ? this.props.translate('common.confirm') : this.props.confirmButtonText; + !this.props.isReadOnly && (this.props.shouldShowConfirmButton || this.props.footerContent) && !(this.props.canSelectMultipleOptions && this.props.selectedOptions.length === 0); + const defaultConfirmButtonText = typeof this.props.confirmButtonText === 'undefined' ? this.props.translate('common.confirm') : this.props.confirmButtonText; const shouldShowDefaultConfirmButton = !this.props.footerContent && defaultConfirmButtonText; const safeAreaPaddingBottomStyle = shouldShowFooter ? undefined : this.props.safeAreaPaddingBottomStyle; const listContainerStyles = this.props.listContainerStyles || [this.props.themeStyles.flex1]; diff --git a/src/components/Popover/popoverPropTypes.js b/src/components/Popover/popoverPropTypes.js deleted file mode 100644 index c758c4e6d311..000000000000 --- a/src/components/Popover/popoverPropTypes.js +++ /dev/null @@ -1,48 +0,0 @@ -import PropTypes from 'prop-types'; -import _ from 'underscore'; -import {defaultProps as defaultModalProps, propTypes as modalPropTypes} from '@components/Modal/modalPropTypes'; -import refPropTypes from '@components/refPropTypes'; -import CONST from '@src/CONST'; - -const propTypes = { - ..._.omit(modalPropTypes, ['type', 'popoverAnchorPosition']), - - /** The anchor position of the popover */ - anchorPosition: PropTypes.shape({ - top: PropTypes.number, - right: PropTypes.number, - bottom: PropTypes.number, - left: PropTypes.number, - }), - - /** The anchor ref of the popover */ - anchorRef: refPropTypes, - - /** A react-native-animatable animation timing for the modal display animation. */ - animationInTiming: PropTypes.number, - - /** Whether disable the animations */ - disableAnimation: PropTypes.bool, - - /** The ref of the popover */ - withoutOverlayRef: refPropTypes, - - /** Whether we want to show the popover on the right side of the screen */ - fromSidebarMediumScreen: PropTypes.bool, -}; - -const defaultProps = { - ..._.omit(defaultModalProps, ['type', 'popoverAnchorPosition']), - - animationIn: 'fadeIn', - animationOut: 'fadeOut', - animationInTiming: CONST.ANIMATED_TRANSITION, - - // Anchor position is optional only because it is not relevant on mobile - anchorPosition: {}, - anchorRef: () => {}, - disableAnimation: true, - withoutOverlayRef: () => {}, -}; - -export {propTypes, defaultProps}; diff --git a/src/components/menuItemPropTypes.js b/src/components/menuItemPropTypes.js deleted file mode 100644 index 80ae1edd5176..000000000000 --- a/src/components/menuItemPropTypes.js +++ /dev/null @@ -1,179 +0,0 @@ -import PropTypes from 'prop-types'; -import _ from 'underscore'; -import stylePropTypes from '@styles/stylePropTypes'; -import CONST from '@src/CONST'; -import avatarPropTypes from './avatarPropTypes'; -import sourcePropTypes from './Image/sourcePropTypes'; -import refPropTypes from './refPropTypes'; - -const propTypes = { - /** Text to be shown as badge near the right end. */ - badgeText: PropTypes.string, - - /** Any additional styles to apply */ - // eslint-disable-next-line react/forbid-prop-types - wrapperStyle: stylePropTypes, - - /** Used to apply offline styles to child text components */ - style: stylePropTypes, - - /** Used to apply styles specifically to the title */ - titleStyle: stylePropTypes, - - /** Function to fire when component is pressed */ - onPress: PropTypes.func, - - /** Icon to display on the left side of component */ - icon: PropTypes.oneOfType([PropTypes.string, sourcePropTypes, PropTypes.arrayOf(avatarPropTypes)]), - - /** Secondary icon to display on the left side of component, right of the icon */ - secondaryIcon: sourcePropTypes, - - /** Icon Width */ - iconWidth: PropTypes.number, - - /** Icon Height */ - iconHeight: PropTypes.number, - - /** Text to display for the item */ - title: PropTypes.string, - - /** Text that appears above the title */ - label: PropTypes.string, - - /** Boolean whether to display the title right icon */ - shouldShowTitleIcon: PropTypes.bool, - - /** Icon to display at right side of title */ - titleIcon: sourcePropTypes, - - /** Boolean whether to display the right icon */ - shouldShowRightIcon: PropTypes.bool, - - /** Should we make this selectable with a checkbox */ - shouldShowSelectedState: PropTypes.bool, - - /** Should the title show with normal font weight (not bold) */ - shouldShowBasicTitle: PropTypes.bool, - - /** Should the description be shown above the title (instead of the other way around) */ - shouldShowDescriptionOnTop: PropTypes.bool, - - /** Whether this item is selected */ - isSelected: PropTypes.bool, - - /** A boolean flag that gives the icon a green fill if true */ - success: PropTypes.bool, - - /** Overrides the icon for shouldShowRightIcon */ - iconRight: sourcePropTypes, - - /** A description text to show under the title */ - description: PropTypes.string, - - /** Any additional styles to pass to the icon container. */ - iconStyles: PropTypes.arrayOf(PropTypes.object), - - /** The fill color to pass into the icon. */ - iconFill: PropTypes.string, - - /** The fill color to pass into the secondary icon. */ - secondaryIconFill: PropTypes.string, - - /** Whether item is focused or active */ - focused: PropTypes.bool, - - /** Should we disable this menu item? */ - disabled: PropTypes.bool, - - /** A right-aligned subtitle for this menu option */ - subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), - - /** Flag to choose between avatar image or an icon */ - iconType: PropTypes.oneOf([CONST.ICON_TYPE_AVATAR, CONST.ICON_TYPE_ICON, CONST.ICON_TYPE_WORKSPACE]), - - /** Whether the menu item should be interactive at all */ - interactive: PropTypes.bool, - - /** A fallback avatar icon to display when there is an error on loading avatar from remote URL. */ - fallbackIcon: PropTypes.oneOfType([PropTypes.string, sourcePropTypes]), - - /** Avatars to show on the right of the menu item */ - floatRightAvatars: PropTypes.arrayOf(avatarPropTypes), - - /** The type of brick road indicator to show. */ - brickRoadIndicator: PropTypes.oneOf([CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR, CONST.BRICK_ROAD_INDICATOR_STATUS.INFO, '']), - - /** Prop to identify if we should load avatars vertically instead of diagonally */ - shouldStackHorizontally: PropTypes.bool, - - /** Prop to represent the size of the float right avatar images to be shown */ - floatRightAvatarSize: PropTypes.oneOf(_.values(CONST.AVATAR_SIZE)), - - /** Prop to represent the size of the avatar images to be shown */ - avatarSize: PropTypes.oneOf(_.values(CONST.AVATAR_SIZE)), - - /** The function that should be called when this component is LongPressed or right-clicked. */ - onSecondaryInteraction: PropTypes.func, - - /** Flag to indicate whether or not text selection should be disabled from long-pressing the menu item. */ - shouldBlockSelection: PropTypes.bool, - - /** The ref to the menu item */ - forwardedRef: refPropTypes, - - /** Any adjustments to style when menu item is hovered or pressed */ - hoverAndPressStyle: PropTypes.arrayOf(PropTypes.object), - - /** Text to display under the main item */ - furtherDetails: PropTypes.string, - - /** An icon to display under the main item */ - furtherDetailsIcon: PropTypes.oneOfType([PropTypes.elementType, PropTypes.string]), - - /** The action accept for anonymous user or not */ - isAnonymousAction: PropTypes.bool, - - /** Whether we should use small avatar subscript sizing the for menu item */ - isSmallAvatarSubscriptMenu: PropTypes.bool, - - /** The max number of lines the title text should occupy before ellipses are added */ - numberOfLines: PropTypes.number, - - /** Should we grey out the menu item when it is disabled? */ - shouldGreyOutWhenDisabled: PropTypes.bool, - - /** Error to display below the title */ - error: PropTypes.string, - - /** Should render the content in HTML format */ - shouldRenderAsHTML: PropTypes.bool, - - /** Label to be displayed on the right */ - rightLabel: PropTypes.string, - - /** Component to be displayed on the right */ - rightComponent: PropTypes.node, - - /** Should render component on the right */ - shouldShowRightComponent: PropTypes.bool, - - /** Array of objects that map display names to their corresponding tooltip */ - titleWithTooltips: PropTypes.arrayOf(PropTypes.object), - - /** Should check anonymous user in onPress function */ - shouldCheckActionAllowedOnPress: PropTypes.bool, - - shouldPutLeftPaddingWhenNoIcon: PropTypes.bool, - - /** The menu item link or function to get the link */ - link: PropTypes.oneOfType(PropTypes.func, PropTypes.string), - - /** Icon should be displayed in its own color */ - displayInDefaultIconColor: PropTypes.bool, - - /** Is this menu item in the settings pane */ - isPaneMenu: PropTypes.bool, -}; - -export default propTypes; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 7380bf102331..b1b9449fa92b 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -299,7 +299,6 @@ const FlagCommentStackNavigator = createModalStackNavigator({ - [SCREENS.EDIT_REQUEST.ROOT]: () => require('../../../../pages/EditRequestPage').default as React.ComponentType, [SCREENS.EDIT_REQUEST.REPORT_FIELD]: () => require('../../../../pages/EditReportFieldPage').default as React.ComponentType, }); diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 6165ccb16fa3..ec8b1fcdc2b5 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -618,7 +618,6 @@ const config: LinkingOptions['config'] = { }, [SCREENS.RIGHT_MODAL.EDIT_REQUEST]: { screens: { - [SCREENS.EDIT_REQUEST.ROOT]: ROUTES.EDIT_REQUEST.route, [SCREENS.EDIT_REQUEST.REPORT_FIELD]: ROUTES.EDIT_REPORT_FIELD_REQUEST.route, }, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 8273278f971e..a8e95be68e6d 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -584,10 +584,7 @@ type FlagCommentNavigatorParamList = { }; type EditRequestNavigatorParamList = { - [SCREENS.EDIT_REQUEST.ROOT]: { - field: string; - threadReportID: string; - }; + [SCREENS.EDIT_REQUEST.REPORT_FIELD]: undefined; }; type SignInNavigatorParamList = { diff --git a/src/pages/EditRequestPage.js b/src/pages/EditRequestPage.js deleted file mode 100644 index d3941dca044e..000000000000 --- a/src/pages/EditRequestPage.js +++ /dev/null @@ -1,189 +0,0 @@ -import lodashGet from 'lodash/get'; -import PropTypes from 'prop-types'; -import React, {useCallback, useEffect, useMemo} from 'react'; -import {withOnyx} from 'react-native-onyx'; -import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; -import categoryPropTypes from '@components/categoryPropTypes'; -import ScreenWrapper from '@components/ScreenWrapper'; -import tagPropTypes from '@components/tagPropTypes'; -import transactionPropTypes from '@components/transactionPropTypes'; -import compose from '@libs/compose'; -import * as IOUUtils from '@libs/IOUUtils'; -import Navigation from '@libs/Navigation/Navigation'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; -import * as PolicyUtils from '@libs/PolicyUtils'; -import * as ReportUtils from '@libs/ReportUtils'; -import * as TransactionUtils from '@libs/TransactionUtils'; -import * as IOU from '@userActions/IOU'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import EditRequestReceiptPage from './EditRequestReceiptPage'; -import EditRequestTagPage from './EditRequestTagPage'; -import reportActionPropTypes from './home/report/reportActionPropTypes'; -import reportPropTypes from './reportPropTypes'; -import {policyPropTypes} from './workspace/withPolicy'; - -const propTypes = { - /** Route from navigation */ - route: PropTypes.shape({ - /** Params from the route */ - params: PropTypes.shape({ - /** Which field we are editing */ - field: PropTypes.string, - - /** reportID for the "transaction thread" */ - threadReportID: PropTypes.string, - - /** Indicates which tag list index was selected */ - tagIndex: PropTypes.string, - }), - }).isRequired, - - /** Onyx props */ - /** The report object for the thread report */ - report: reportPropTypes, - - /** The policy of the report */ - policy: policyPropTypes.policy, - - /** Collection of categories attached to a policy */ - policyCategories: PropTypes.objectOf(categoryPropTypes), - - /** Collection of tags attached to a policy */ - policyTags: tagPropTypes, - - /** The actions from the parent report */ - parentReportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)), - - /** Transaction that stores the request data */ - transaction: transactionPropTypes, -}; - -const defaultProps = { - report: {}, - policy: {}, - policyCategories: {}, - policyTags: {}, - parentReportActions: {}, - transaction: {}, -}; - -function EditRequestPage({report, route, policy, policyCategories, policyTags, parentReportActions, transaction}) { - const parentReportActionID = lodashGet(report, 'parentReportActionID', '0'); - const parentReportAction = lodashGet(parentReportActions, parentReportActionID, {}); - const {tag: transactionTag} = ReportUtils.getTransactionDetails(transaction); - - const fieldToEdit = lodashGet(route, ['params', 'field'], ''); - const tagListIndex = Number(lodashGet(route, ['params', 'tagIndex'], undefined)); - - const tag = TransactionUtils.getTag(transaction, tagListIndex); - const policyTagListName = PolicyUtils.getTagListName(policyTags, tagListIndex); - const policyTagLists = useMemo(() => PolicyUtils.getTagLists(policyTags), [policyTags]); - - // A flag for verifying that the current report is a sub-report of a workspace chat - const isPolicyExpenseChat = ReportUtils.isGroupPolicy(report); - - // A flag for showing the tags page - const shouldShowTags = useMemo(() => isPolicyExpenseChat && (transactionTag || OptionsListUtils.hasEnabledTags(policyTagLists)), [isPolicyExpenseChat, policyTagLists, transactionTag]); - - // Decides whether to allow or disallow editing a money request - useEffect(() => { - // Do not dismiss the modal, when a current user can edit this property of the money request. - if (ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, fieldToEdit)) { - return; - } - - // Dismiss the modal when a current user cannot edit a money request. - Navigation.isNavigationReady().then(() => { - Navigation.dismissModal(); - }); - }, [parentReportAction, fieldToEdit]); - - const saveTag = useCallback( - ({tag: newTag}) => { - let updatedTag = newTag; - if (newTag === tag) { - // In case the same tag has been selected, reset the tag. - updatedTag = ''; - } - IOU.updateMoneyRequestTag( - transaction.transactionID, - report.reportID, - IOUUtils.insertTagIntoTransactionTagsString(transactionTag, updatedTag, tagListIndex), - policy, - policyTags, - policyCategories, - ); - Navigation.dismissModal(); - }, - [tag, transaction.transactionID, report.reportID, transactionTag, tagListIndex, policy, policyTags, policyCategories], - ); - - if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.TAG && shouldShowTags) { - return ( - - ); - } - - if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.RECEIPT) { - return ( - - ); - } - - return ( - - - - ); -} - -EditRequestPage.displayName = 'EditRequestPage'; -EditRequestPage.propTypes = propTypes; -EditRequestPage.defaultProps = defaultProps; -export default compose( - withOnyx({ - report: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.threadReportID}`, - }, - }), - // eslint-disable-next-line rulesdir/no-multiple-onyx-in-file - withOnyx({ - policy: { - key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, - }, - policyCategories: { - key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${report ? report.policyID : '0'}`, - }, - policyTags: { - key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${report ? report.policyID : '0'}`, - }, - parentReportActions: { - key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '0'}`, - canEvict: false, - }, - }), - // eslint-disable-next-line rulesdir/no-multiple-onyx-in-file - withOnyx({ - transaction: { - key: ({report, parentReportActions}) => { - const parentReportActionID = lodashGet(report, 'parentReportActionID', '0'); - const parentReportAction = lodashGet(parentReportActions, parentReportActionID); - return `${ONYXKEYS.COLLECTION.TRANSACTION}${lodashGet(parentReportAction, 'originalMessage.IOUTransactionID', 0)}`; - }, - }, - }), -)(EditRequestPage); diff --git a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js index 87883972f84f..a91bf03c6ed4 100644 --- a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js +++ b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js @@ -1,8 +1,10 @@ import lodashGet from 'lodash/get'; +import lodashIsEqual from 'lodash/isEqual'; +import lodashPick from 'lodash/pick'; +import lodashReject from 'lodash/reject'; import PropTypes from 'prop-types'; import React, {memo, useCallback, useEffect, useMemo} from 'react'; import {useOnyx} from 'react-native-onyx'; -import _ from 'underscore'; import BlockingView from '@components/BlockingViews/BlockingView'; import Button from '@components/Button'; import FormHelpMessage from '@components/FormHelpMessage'; @@ -51,13 +53,13 @@ const propTypes = { ), /** The type of IOU report, i.e. bill, request, send */ - iouType: PropTypes.oneOf(_.values(CONST.IOU.TYPE)).isRequired, + iouType: PropTypes.oneOf(Object.values(CONST.IOU.TYPE)).isRequired, /** The request type, ie. manual, scan, distance */ - iouRequestType: PropTypes.oneOf(_.values(CONST.IOU.REQUEST_TYPE)).isRequired, + iouRequestType: PropTypes.oneOf(Object.values(CONST.IOU.REQUEST_TYPE)).isRequired, /** The action of the IOU, i.e. create, split, move */ - action: PropTypes.oneOf(_.values(CONST.IOU.ACTION)), + action: PropTypes.oneOf(Object.values(CONST.IOU.ACTION)), }; const defaultProps = { @@ -141,21 +143,21 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF newSections.push({ title: translate('common.recents'), data: chatOptions.recentReports, - shouldShow: !_.isEmpty(chatOptions.recentReports), + shouldShow: chatOptions.recentReports.length > 0, }); if (![CONST.IOU.ACTION.CATEGORIZE, CONST.IOU.ACTION.SHARE].includes(action)) { newSections.push({ title: translate('common.contacts'), data: chatOptions.personalDetails, - shouldShow: !_.isEmpty(chatOptions.personalDetails), + shouldShow: chatOptions.personalDetails.length > 0, }); } if (chatOptions.userToInvite && !OptionsListUtils.isCurrentUser(chatOptions.userToInvite)) { newSections.push({ title: undefined, - data: _.map([chatOptions.userToInvite], (participant) => { + data: [chatOptions.userToInvite].map((participant) => { const isPolicyExpenseChat = lodashGet(participant, 'isPolicyExpenseChat', false); return isPolicyExpenseChat ? OptionsListUtils.getPolicyExpenseReportOption(participant) : OptionsListUtils.getParticipantsOption(participant, personalDetails); }), @@ -190,7 +192,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF (option) => { onParticipantsAdded([ { - ..._.pick(option, 'accountID', 'login', 'isPolicyExpenseChat', 'reportID', 'searchText'), + ...lodashPick(option, 'accountID', 'login', 'isPolicyExpenseChat', 'reportID', 'searchText'), selected: true, iouType, }, @@ -218,11 +220,11 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF return false; }; - const isOptionInList = _.some(participants, isOptionSelected); + const isOptionInList = participants.some(isOptionSelected); let newSelectedOptions; if (isOptionInList) { - newSelectedOptions = _.reject(participants, isOptionSelected); + newSelectedOptions = lodashReject(participants, isOptionSelected); } else { newSelectedOptions = [ ...participants, @@ -247,11 +249,11 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF const headerMessage = useMemo( () => OptionsListUtils.getHeaderMessage( - _.get(newChatOptions, 'personalDetails', []).length + _.get(newChatOptions, 'recentReports', []).length !== 0, + lodashGet(newChatOptions, 'personalDetails', []).length + lodashGet(newChatOptions, 'recentReports', []).length !== 0, Boolean(newChatOptions.userToInvite), debouncedSearchTerm.trim(), maxParticipantsReached, - _.some(participants, (participant) => participant.searchText.toLowerCase().includes(debouncedSearchTerm.trim().toLowerCase())), + participants.some((participant) => participant.searchText.toLowerCase().includes(debouncedSearchTerm.trim().toLowerCase())), ), [maxParticipantsReached, newChatOptions, participants, debouncedSearchTerm], ); @@ -259,7 +261,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF // Right now you can't split a request with a workspace and other additional participants // This is getting properly fixed in https://github.com/Expensify/App/issues/27508, but as a stop-gap to prevent // the app from crashing on native when you try to do this, we'll going to hide the button if you have a workspace and other participants - const hasPolicyExpenseChatParticipant = _.some(participants, (participant) => participant.isPolicyExpenseChat); + const hasPolicyExpenseChatParticipant = participants.some((participant) => participant.isPolicyExpenseChat); const shouldShowSplitBillErrorMessage = participants.length > 1 && hasPolicyExpenseChatParticipant; // canUseP2PDistanceRequests is true if the iouType is track expense, but we don't want to allow splitting distance with track expense yet @@ -377,7 +379,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF ); - const isAllSectionsEmpty = _.every(sections, (section) => section.data.length === 0); + const isAllSectionsEmpty = sections.every((section) => section.data.length === 0); if ([CONST.IOU.ACTION.CATEGORIZE, CONST.IOU.ACTION.SHARE].includes(action) && isAllSectionsEmpty && didScreenTransitionEnd && searchTerm.trim() === '') { return renderEmptyWorkspaceView(); } @@ -408,8 +410,8 @@ MoneyTemporaryForRefactorRequestParticipantsSelector.displayName = 'MoneyTempora export default memo( MoneyTemporaryForRefactorRequestParticipantsSelector, (prevProps, nextProps) => - _.isEqual(prevProps.participants, nextProps.participants) && + lodashIsEqual(prevProps.participants, nextProps.participants) && prevProps.iouRequestType === nextProps.iouRequestType && prevProps.iouType === nextProps.iouType && - _.isEqual(prevProps.betas, nextProps.betas), + lodashIsEqual(prevProps.betas, nextProps.betas), ); diff --git a/src/pages/iou/request/step/IOURequestStepRoutePropTypes.js b/src/pages/iou/request/step/IOURequestStepRoutePropTypes.js deleted file mode 100644 index 8b191fa0b58e..000000000000 --- a/src/pages/iou/request/step/IOURequestStepRoutePropTypes.js +++ /dev/null @@ -1,29 +0,0 @@ -import PropTypes from 'prop-types'; -import _ from 'underscore'; -import CONST from '@src/CONST'; - -export default PropTypes.shape({ - /** Route specific parameters used on this screen via route :iouType/new/category/:reportID? */ - params: PropTypes.shape({ - /** What action is being performed, ie. create, edit */ - action: PropTypes.oneOf(_.values(CONST.IOU.ACTION)), - - /** The type of IOU report, i.e. bill, request, send */ - iouType: PropTypes.oneOf(_.values(CONST.IOU.TYPE)).isRequired, - - /** The ID of the transaction being configured */ - transactionID: PropTypes.string.isRequired, - - /** The report ID of the IOU */ - reportID: PropTypes.string.isRequired, - - /** Index of the waypoint being edited */ - pageIndex: PropTypes.string, - - /** A path to go to when the user presses the back button */ - backTo: PropTypes.string, - - /** Indicates which tag list index was selected */ - tagIndex: PropTypes.string, - }), -}); diff --git a/src/pages/reportPropTypes.js b/src/pages/reportPropTypes.js deleted file mode 100644 index 7422bad8061f..000000000000 --- a/src/pages/reportPropTypes.js +++ /dev/null @@ -1,79 +0,0 @@ -import PropTypes from 'prop-types'; -import _ from 'underscore'; -import avatarPropTypes from '@components/avatarPropTypes'; -import CONST from '@src/CONST'; - -export default PropTypes.shape({ - /** The specific type of chat */ - chatType: PropTypes.oneOf(['', ..._.values(CONST.REPORT.CHAT_TYPE)]), - - /** List of icons for report participants */ - icons: PropTypes.arrayOf(avatarPropTypes), - - /** Whether the user is not an admin of policyExpenseChat chat */ - isOwnPolicyExpenseChat: PropTypes.bool, - - /** Indicates if the report is pinned to the LHN or not */ - isPinned: PropTypes.bool, - - /** Whether we're waiting on submitter to add a bank account */ - isWaitingOnBankAccount: PropTypes.bool, - - /** The accountID of the last message's actor */ - lastActorAccountID: PropTypes.number, - - /** The text of the last message on the report */ - lastMessageText: PropTypes.string, - - /** The time of the last message on the report */ - lastVisibleActionCreated: PropTypes.string, - - /** The time when user read the last message */ - lastReadTime: PropTypes.string, - - /** The current user's notification preference for this report */ - notificationPreference: PropTypes.oneOfType([ - // Some old reports have numbers for the notification preference - PropTypes.number, - PropTypes.string, - ]), - - /** The policy name to use for an archived report */ - oldPolicyName: PropTypes.string, - - /** The accountID of the report owner */ - ownerAccountID: PropTypes.number, - - /** List of accountIDs of participants of the report */ - participantAccountIDs: PropTypes.arrayOf(PropTypes.number), - - /** List of accountIDs of visible members of the report */ - visibleChatMemberAccountIDs: PropTypes.arrayOf(PropTypes.number), - - /** Linked policy's ID */ - policyID: PropTypes.string, - - /** Name of the report */ - reportName: PropTypes.string, - - /** ID of the report */ - reportID: PropTypes.string, - - /** The state that the report is currently in */ - stateNum: PropTypes.oneOf(_.values(CONST.REPORT.STATE_NUM)), - - /** The status of the current report */ - statusNum: PropTypes.oneOf(_.values(CONST.REPORT.STATUS_NUM)), - - /** Which user role is capable of posting messages on the report */ - writeCapability: PropTypes.oneOf(_.values(CONST.REPORT.WRITE_CAPABILITIES)), - - /** Field-specific pending states for offline UI status */ - pendingFields: PropTypes.objectOf(PropTypes.string), - - /** Custom fields attached to the report */ - reportFields: PropTypes.objectOf(PropTypes.string), - - /** ID of the transaction thread associated with the report, if any */ - transactionThreadReportID: PropTypes.string, -}); From 4005fd412d03b55f9e8228616dccc7409eb015f3 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 17 Apr 2024 13:16:54 +0100 Subject: [PATCH 178/339] Update src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> --- .../accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 8d850115d14a..0b3a9affd5df 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -82,7 +82,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { Date: Wed, 17 Apr 2024 13:18:44 +0100 Subject: [PATCH 179/339] Update src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> --- .../accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 0b3a9affd5df..5f7d2c4b267b 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -39,7 +39,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const accountOptions = useMemo(() => DRAFT || [...(bankAccounts ?? []), ...(creditCards ?? [])], [bankAccounts, creditCards]); - const qboOnlineSelectorOptions = useMemo( + const qboOnlineSelectorOptions = useMemo( () => accountOptions?.map(({id, name}) => ({ value: id, From 03c86ae9d72ac7f307773558d34218e9c77832f9 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 17 Apr 2024 13:18:52 +0100 Subject: [PATCH 180/339] Update src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> --- .../accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 5f7d2c4b267b..08bb5782cec2 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -44,8 +44,8 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { accountOptions?.map(({id, name}) => ({ value: id, text: name, - keyForList: name, - isSelected: selectedAccount === name, + keyForList: id, + isSelected: selectedAccount === id, })), [selectedAccount, accountOptions], ); From 78c43337640db7cee80a50fd62b9300b64736181 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 17 Apr 2024 13:52:30 +0100 Subject: [PATCH 181/339] update defaults --- .../qbo/advanced/QuickbooksAccountSelectPage.tsx | 2 +- .../advanced/QuickbooksInvoiceAccountSelectPage.tsx | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 08bb5782cec2..5449b8f6f905 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -32,7 +32,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const selectedAccount = DRAFT[0].name; // selected + const selectedAccount = DRAFT[0].id; // selected const policyID = policy?.id ?? ''; const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index b708737f5b56..af5b17fe04f5 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -32,7 +32,7 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const selectedAccount = DRAFT[1].name; // selected + const selectedAccount = DRAFT[1].id; // selected const policyID = policy?.id ?? ''; const {bankAccounts, otherCurrentAssetAccounts} = policy?.connections?.quickbooksOnline?.data ?? {}; @@ -41,11 +41,11 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const qboOnlineSelectorOptions = useMemo( () => - accountOptions?.map(({name}) => ({ - value: name, + accountOptions?.map(({id,name}) => ({ + value: id, text: name, - keyForList: name, - isSelected: selectedAccount === name, + keyForList: id, + isSelected: selectedAccount === id, })), [selectedAccount, accountOptions], ); @@ -83,7 +83,7 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { Date: Wed, 17 Apr 2024 14:14:25 +0100 Subject: [PATCH 182/339] fix lint --- .../accounting/qbo/advanced/QuickbooksAdvancedPage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index fdca8cff1e4b..e83cab15a433 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -34,8 +34,8 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { { title: translate('workspace.qbo.advancedConfig.autoSync'), subtitle: translate('workspace.qbo.advancedConfig.autoSyncDescription'), - isActive: Boolean(autoSync), - onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.AUTO_SYNC, !autoSync), + isActive: Boolean(autoSync?.enabled), + onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.AUTO_SYNC, !autoSync?.enabled), pendingAction: pendingFields?.autoSync, }, { @@ -116,7 +116,7 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR.getRoute(policyID)))} From c5ccafe95cc58fde48d4d102ff2be07183016fd4 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 17 Apr 2024 14:33:16 +0100 Subject: [PATCH 183/339] use otherCurrentAssetAccounts and bankAccounts --- .../qbo/advanced/QuickbooksAdvancedPage.tsx | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index e83cab15a433..333566cdff41 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -26,9 +26,10 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? ''; - const {autoSync, syncPeople, autoCreateVendor, reimbursementAccountID, collectionAccountID, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {}; - const {bankAccounts, creditCards} = policy?.connections?.quickbooksOnline?.data ?? {}; + const {autoSync, syncPeople, autoCreateVendor, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {}; + const {bankAccounts, creditCards, otherCurrentAssetAccounts} = policy?.connections?.quickbooksOnline?.data ?? {}; const accountOptions = [...(bankAccounts ?? []), ...(creditCards ?? [])]; + const invoiceAccountOptions = [...(bankAccounts ?? []), ...(otherCurrentAssetAccounts ?? [])]; const qboToggleSettingItems: ToggleSettingOptionRowProps[] = [ { @@ -96,8 +97,15 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { wrapperStyle={styles.mv3} // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing pendingAction={pendingFields?.reimbursementAccountID || pendingFields?.collectionAccountID} - isActive={Boolean(reimbursementAccountID && collectionAccountID)} - onToggle={() => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, accountOptions[0].id)} + isActive={Boolean(accountOptions[0]?.id)} // TODO + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + onToggle={() => + Policy.updatePolicyConnectionConfig( + policyID, + CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID || CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, + accountOptions[0]?.id, + ) + } /> Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, !collectionAccountID)} + isActive={Boolean(invoiceAccountOptions[0]?.id)} // TODO + onToggle={() => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, invoiceAccountOptions[0]?.id)} /> Date: Wed, 17 Apr 2024 14:35:35 +0100 Subject: [PATCH 184/339] fix lint --- .../qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index af5b17fe04f5..392288861eb5 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -41,7 +41,7 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const qboOnlineSelectorOptions = useMemo( () => - accountOptions?.map(({id,name}) => ({ + accountOptions?.map(({id, name}) => ({ value: id, text: name, keyForList: id, From 9e42ed8bc6905ff73a6c8c1299147386326f82f1 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Wed, 17 Apr 2024 16:42:24 +0300 Subject: [PATCH 185/339] add errors for out of pockets, design review, remove redundant screen --- src/ROUTES.ts | 4 -- src/SCREENS.ts | 1 - src/languages/en.ts | 3 ++ src/languages/es.ts | 3 ++ .../ModalStackNavigators/index.tsx | 2 - .../FULL_SCREEN_TO_RHP_MAPPING.ts | 1 - src/libs/Navigation/linkingConfig/config.ts | 1 - src/libs/Navigation/types.ts | 3 -- ...oksCompanyCardExpenseAccountSelectPage.tsx | 7 +-- ...oksCompanyCardExpenseConfigurationPage.tsx | 45 ------------------- .../QuickbooksExportConfigurationPage.tsx | 8 ++-- ...oksOutOfPocketExpenseConfigurationPage.tsx | 13 ++++-- ...ooksOutOfPocketExpenseEntitySelectPage.tsx | 26 +++++++---- src/styles/index.ts | 6 +++ 14 files changed, 47 insertions(+), 76 deletions(-) delete mode 100644 src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 4b822d4c4f77..3e42e4db5251 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -491,10 +491,6 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE: { - route: 'settings/workspaces/:policyID/accounting/quickbooks-online/company-card-expense', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/company-card-expense` as const, - }, WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/company-card-expense-account-select', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/company-card-expense-account-select` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index ae49bcf47fde..6fdb1bcd2fd8 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -264,7 +264,6 @@ const SCREENS = { QUICKBOOKS_ONLINE_EXPORT: 'Workspace_Accounting_Quickbooks_Online_Export', QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Date_Select', QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Invoice_Account_Select', - QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE: 'Workspace_Accounting_Quickbooks_Online_Export_Company_Card_Expense', QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Company_Card_Expense_Select', QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter', QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses', diff --git a/src/languages/en.ts b/src/languages/en.ts index bd75454fff47..1ba43084ad40 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1920,6 +1920,9 @@ export default { accountsPayableDescription: 'This is your chosen A/P account, against which vendor bills for each report are created.', journalEntry: 'Journal Entry', optionBelow: 'Choose an option below:', + vendorBillError: 'Vendor Bills are not available when locations are enabled. Please select a different export option.', + checkError: 'Check is not available when locations are enabled. Please select a different export option.', + journalEntryError: 'Journal entry is not available when taxes enabled. please select a different export option.', companyCardsLocationEnabledDescription: 'Note: QuickBooks Online does not support a field for Locations as Tags on Vendor Bills exports. As you import Locations from, this this export option is unavailable.', outOfPocketTaxEnabledDescription: diff --git a/src/languages/es.ts b/src/languages/es.ts index f630b70a36f0..d3dc7efeffd4 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1947,6 +1947,9 @@ export default { 'Puede ser cualquier administrador del espacio de trabajo, pero debe ser un administrador de dominio si configura diferentes cuentas de exportación para tarjetas de empresa individuales en la configuración del dominio.', exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en su cuenta.', journalEntry: 'Asiento contable', + vendorBillError: 'Las facturas de proveedores no están disponibles cuando las ubicaciones están habilitadas. Seleccione una opción de exportación diferente.', + checkError: 'La verificación no está disponible cuando las ubicaciones están habilitadas. Seleccione una opción de exportación diferente.', + journalEntryError: 'El asiento de diario no está disponible cuando los impuestos están habilitados. seleccione una opción de exportación diferente.', exportOutOfPocketExpensesDescription: 'Establezca cómo se exportan los gastos de bolsillo a QuickBooks Online.', exportVendorBillDescription: 'Crearemos una única factura de proveedor detallada para cada informe de Expensify. Si el período de la factura está cerrado, lo publicaremos en el día 1 del siguiente período abierto. Puede agregar la factura del proveedor a la cuenta A/P de su elección (a continuación).', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 82e266984a11..301a55e70e20 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -266,8 +266,6 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE]: () => - require('../../../../pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: () => require('../../../../pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: () => diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 53e03a4e751d..9f2a9808ed12 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -29,7 +29,6 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER, SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 7d610ffd7310..ce111f69435d 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -279,7 +279,6 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: { path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.route, }, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE.route}, [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: { path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 42b3c288f37e..10b4f96d4594 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -718,9 +718,6 @@ type WorkspacesCentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_COMPANY_CARD_EXPENSE]: { - policyID: string; - }; [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: { policyID: string; }; diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index 71dc3118ecc7..9b207868e83b 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -70,7 +70,7 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps if (row.value !== exportCompanyCard) { Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_COMPANY_CARD, row.value); } - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE.getRoute(policyID)); + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.getRoute(policyID)); }, [exportCompanyCard, policyID], ); @@ -81,14 +81,15 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps shouldEnableMaxHeight testID={QuickbooksCompanyCardExpenseAccountSelectPage.displayName} > - + {translate('workspace.qbo.exportCompanyCardsDescription')}} sections={sections} ListItem={RadioListItem} onSelectRow={onSelectRow} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - footerContent={isLocationEnabled && {translate('workspace.qbo.companyCardsLocationEnabledDescription')}} + footerContent={isLocationEnabled && {translate('workspace.qbo.companyCardsLocationEnabledDescription')}} /> diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage.tsx deleted file mode 100644 index 3a1f40a0de32..000000000000 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseConfigurationPage.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import React from 'react'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; -import ScreenWrapper from '@components/ScreenWrapper'; -import ScrollView from '@components/ScrollView'; -import Text from '@components/Text'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import Navigation from '@navigation/Navigation'; -import withPolicy from '@pages/workspace/withPolicy'; -import type {WithPolicyProps} from '@pages/workspace/withPolicy'; -import CONST from '@src/CONST'; -import ROUTES from '@src/ROUTES'; - -function QuickbooksCompanyCardExpenseConfigurationPage({policy}: WithPolicyProps) { - const {translate} = useLocalize(); - const styles = useThemeStyles(); - const policyID = policy?.id ?? ''; - const {exportCompanyCard, errors} = policy?.connections?.quickbooksOnline?.config ?? {}; - return ( - - - - {translate('workspace.qbo.exportCompanyCardsDescription')} - - Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID))} - brickRoadIndicator={errors?.exportCompanyCard ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - shouldShowRightIcon - /> - - - - ); -} - -QuickbooksCompanyCardExpenseConfigurationPage.displayName = 'QuickbooksCompanyCardExpenseConfigurationPage'; - -export default withPolicy(QuickbooksCompanyCardExpenseConfigurationPage); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx index 1a51d36c9ec2..cff82c6cad6a 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx @@ -49,7 +49,7 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { }, { description: translate('workspace.qbo.exportCompany'), - onPress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE.getRoute(policyID)), + onPress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID)), brickRoadIndicator: errors?.exportCompanyCard ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportCompanyCard, }, @@ -80,11 +80,11 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { /> ))} - - {`${translate('workspace.qbo.deepDiveExpensifyCard')} `} + + {`${translate('workspace.qbo.deepDiveExpensifyCard')} `} Link.openExternalLink(CONST.DEEP_DIVE_EXPENSIFY_CARD)} - style={[styles.optionAlternateText, styles.textLabelSupporting, styles.link]} + style={[styles.mutedNormalTextLabel, styles.link]} > {translate('workspace.qbo.deepDiveExpensifyCardIntegration')} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx index 9151afcca9d3..8741843066e3 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx @@ -17,8 +17,12 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; - const {syncLocations, exportAccount, exportEntity, errors} = policy?.connections?.quickbooksOnline?.config ?? {}; + const {syncLocations, exportAccount, exportEntity, errors, syncTaxes} = policy?.connections?.quickbooksOnline?.config ?? {}; const isLocationEnabled = Boolean(syncLocations && syncLocations !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); + const isTaxesEnabled = Boolean(syncTaxes && syncTaxes !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); + const showTaxError = isTaxesEnabled && exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY; + const showLocationError = isLocationEnabled && exportEntity !== CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY; + const brickEntityRoadIndicator = Boolean(errors?.exportEntity) || showTaxError || showLocationError; return ( Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.getRoute(policyID))} - brickRoadIndicator={errors?.exportEntity ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + brickRoadIndicator={brickEntityRoadIndicator ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} shouldShowRightIcon /> {exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL && !isLocationEnabled && ( - {translate('workspace.qbo.exportVendorBillDescription')} + {translate('workspace.qbo.exportVendorBillDescription')} )} - {isLocationEnabled && {translate('workspace.qbo.outOfPocketLocationEnabledDescription')}} + {isLocationEnabled && {translate('workspace.qbo.outOfPocketLocationEnabledDescription')}} {!isLocationEnabled && ( >; function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const {exportEntity, syncTaxes} = policy?.connections?.quickbooksOnline?.config ?? {}; + const {exportEntity, syncTaxes, syncLocations} = policy?.connections?.quickbooksOnline?.config ?? {}; + const isLocationsEnabled = Boolean(syncLocations && syncLocations !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); const isTaxesEnabled = Boolean(syncTaxes && syncTaxes !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); - + const isTaxError = isTaxesEnabled && exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY; + const isLocationError = isLocationsEnabled && exportEntity !== CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY; const policyID = policy?.id ?? ''; + + useEffect(() => { + if (!isTaxError && !isLocationError) { + return; + } + Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY, ''); + }, [policyID, isTaxError, isLocationError]); + const data: CardListItem[] = useMemo( () => [ { @@ -37,24 +47,24 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) text: translate(`workspace.qbo.check`), keyForList: CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK, isSelected: exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.CHECK, - isShown: true, + isShown: !isLocationsEnabled, }, { value: CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY, text: translate(`workspace.qbo.journalEntry`), keyForList: CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY, isSelected: exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY, - isShown: !isTaxesEnabled, + isShown: !isTaxesEnabled || isLocationsEnabled, }, { value: CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL, text: translate(`workspace.qbo.vendorBill`), keyForList: CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL, isSelected: exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL, - isShown: true, + isShown: !isLocationsEnabled, }, ], - [exportEntity, isTaxesEnabled, translate], + [exportEntity, isTaxesEnabled, translate, isLocationsEnabled], ); const sections: CardsSection[] = useMemo(() => [{data: data.filter((item) => item.isShown)}], [data]); @@ -82,8 +92,8 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) ListItem={RadioListItem} onSelectRow={onSelectRow} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + footerContent={isTaxesEnabled && {translate('workspace.qbo.outOfPocketTaxEnabledDescription')}} /> - {translate('workspace.qbo.outOfPocketTaxEnabledDescription')} ); diff --git a/src/styles/index.ts b/src/styles/index.ts index 537038d9f2e1..18b3f0b84bb9 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -378,6 +378,12 @@ const styles = (theme: ThemeColors) => lineHeight: variables.lineHeightLarge, }, + mutedNormalTextLabel: { + color: theme.textSupporting, + fontSize: variables.fontSizeLabel, + lineHeight: variables.lineHeightNormal, + }, + textMicro: { fontFamily: FontUtils.fontFamily.platform.EXP_NEUE, fontSize: variables.fontSizeSmall, From 9ea39ff0fb101df8850ad777610d550bf4f89e00 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 17 Apr 2024 15:07:00 +0100 Subject: [PATCH 186/339] remove enabled from autoSync --- .../accounting/qbo/advanced/QuickbooksAdvancedPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index 333566cdff41..a4f63d5c06f4 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -35,8 +35,8 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { { title: translate('workspace.qbo.advancedConfig.autoSync'), subtitle: translate('workspace.qbo.advancedConfig.autoSyncDescription'), - isActive: Boolean(autoSync?.enabled), - onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.AUTO_SYNC, !autoSync?.enabled), + isActive: Boolean(autoSync), + onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.AUTO_SYNC, !autoSync), pendingAction: pendingFields?.autoSync, }, { From 8086aaf6b2de14ba1183da260ff578183c547631 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 17 Apr 2024 19:05:05 +0100 Subject: [PATCH 187/339] remove qbo selector options --- src/CONST.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index a8163ab38591..b72824e8a2ea 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1207,12 +1207,6 @@ const CONST = { EXPENSIFY_EMAIL_DOMAIN: '@expensify.com', }, - QBO_SELECTOR_OPTIONS: { - CROISSANT_CO_PAYROLL_ACCOUNT: 'CroissantCoPayrollAccount', - CROISSANT_CO_MONEY_IN_CLEARING: 'CroissantCoMoneyInClearing', - CROISSANT_CO_DEBTS_AND_LOANS: 'CroissantCoDebtsAndLoans', - }, - INTEGRATION_ENTITY_MAP_TYPES: { DEFAULT: 'DEFAULT', NONE: 'NONE', From b84211342c3762c915bb6aa5aff66154795bdeb5 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Wed, 17 Apr 2024 12:52:49 -0700 Subject: [PATCH 188/339] fix: the issue with fetching --- src/libs/actions/PolicyConnections.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/PolicyConnections.ts b/src/libs/actions/PolicyConnections.ts index 7ccf9f2506bd..4ea65a79352b 100644 --- a/src/libs/actions/PolicyConnections.ts +++ b/src/libs/actions/PolicyConnections.ts @@ -15,13 +15,20 @@ function openPolicyAccountingPage(policyID: string) { value: false, }, ]; - const finallyData: OnyxUpdate[] = [ + const successData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, key: hasConnectionsDataBeenFetchedKey, value: true, }, ]; + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: hasConnectionsDataBeenFetchedKey, + value: false, + }, + ]; const parameters: OpenPolicyAccountingPageParams = { policyID, @@ -29,7 +36,8 @@ function openPolicyAccountingPage(policyID: string) { API.read(READ_COMMANDS.OPEN_POLICY_ACCOUNTING_PAGE, parameters, { optimisticData, - finallyData, + successData, + failureData, }); } From 9b7ee08d4375347e54828c44ed503a59e54b911c Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 17 Apr 2024 17:28:39 -0700 Subject: [PATCH 189/339] Remove unused react-native-async-storage dependency --- ios/Podfile.lock | 44 +++++++++++++++++++------------------------- package-lock.json | 28 ---------------------------- package.json | 1 - 3 files changed, 19 insertions(+), 54 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 5a8c67088f16..ed387a8d522f 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1697,25 +1697,6 @@ PODS: - React-perflogger (= 0.73.4) - RNAppleAuthentication (2.2.2): - React-Core - - RNCAsyncStorage (1.21.0): - - glog - - hermes-engine - - RCT-Folly (= 2022.05.16.00) - - RCTRequired - - RCTTypeSafety - - React-Codegen - - React-Core - - React-debug - - React-Fabric - - React-graphics - - React-ImageManager - - React-NativeModulesApple - - React-RCTFabric - - React-rendererdebug - - React-utils - - ReactCommon/turbomodule/bridging - - ReactCommon/turbomodule/core - - Yoga - RNCClipboard (1.13.2): - glog - hermes-engine @@ -1793,7 +1774,24 @@ PODS: - React-Core - RNFBApp - RNFlashList (1.6.3): + - glog + - hermes-engine + - RCT-Folly (= 2022.05.16.00) + - RCTRequired + - RCTTypeSafety + - React-Codegen - React-Core + - React-debug + - React-Fabric + - React-graphics + - React-ImageManager + - React-NativeModulesApple + - React-RCTFabric + - React-rendererdebug + - React-utils + - ReactCommon/turbomodule/bridging + - ReactCommon/turbomodule/core + - Yoga - RNFS (2.20.0): - React-Core - RNGestureHandler (2.14.1): @@ -2137,7 +2135,6 @@ DEPENDENCIES: - React-utils (from `../node_modules/react-native/ReactCommon/react/utils`) - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) - "RNAppleAuthentication (from `../node_modules/@invertase/react-native-apple-authentication`)" - - "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)" - "RNCClipboard (from `../node_modules/@react-native-clipboard/clipboard`)" - "RNCPicker (from `../node_modules/@react-native-picker/picker`)" - RNDeviceInfo (from `../node_modules/react-native-device-info`) @@ -2368,8 +2365,6 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon" RNAppleAuthentication: :path: "../node_modules/@invertase/react-native-apple-authentication" - RNCAsyncStorage: - :path: "../node_modules/@react-native-async-storage/async-storage" RNCClipboard: :path: "../node_modules/@react-native-clipboard/clipboard" RNCPicker: @@ -2534,7 +2529,6 @@ SPEC CHECKSUMS: React-utils: 6e5ad394416482ae21831050928ae27348f83487 ReactCommon: 840a955d37b7f3358554d819446bffcf624b2522 RNAppleAuthentication: 0571c08da8c327ae2afc0261b48b4a515b0286a6 - RNCAsyncStorage: 559f22cc4b582414e783fd7255974b29e24b451c RNCClipboard: c73bbc2e9012120161f1012578418827983bfd0c RNCPicker: c77efa39690952647b83d8085520bf50ebf94ecb RNDeviceInfo: cbf78fdb515ae73e641ee7c6b474f77a0299e7e6 @@ -2543,7 +2537,7 @@ SPEC CHECKSUMS: RNFBApp: 729c0666395b1953198dc4a1ec6deb8fbe1c302e RNFBCrashlytics: 2061ca863e8e2fa1aae9b12477d7dfa8e88ca0f9 RNFBPerf: 389914cda4000fe0d996a752532a591132cbf3f9 - RNFlashList: 4b4b6b093afc0df60ae08f9cbf6ccd4c836c667a + RNFlashList: 5b0e8311e4cf1ad91e410fd7c8526a89fb5826d1 RNFS: 4ac0f0ea233904cb798630b3c077808c06931688 RNGestureHandler: 1190c218cdaaf029ee1437076a3fbbc3297d89fb RNGoogleSignin: ccaa4a81582cf713eea562c5dd9dc1961a715fd0 @@ -2564,7 +2558,7 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: 3033e0dd5272d46e97bcb406adea4ae0e6907abf - Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 + Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70 PODFILE CHECKSUM: a25a81f2b50270f0c0bd0aff2e2ebe4d0b4ec06d diff --git a/package-lock.json b/package-lock.json index 64dd4fb0c885..ceb39a48e287 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,6 @@ "@kie/act-js": "^2.6.0", "@kie/mock-github": "^1.0.0", "@onfido/react-native-sdk": "10.6.0", - "@react-native-async-storage/async-storage": "1.21.0", "@react-native-camera-roll/camera-roll": "7.4.0", "@react-native-clipboard/clipboard": "^1.13.2", "@react-native-community/geolocation": "3.2.1", @@ -7671,16 +7670,6 @@ } } }, - "node_modules/@react-native-async-storage/async-storage": { - "version": "1.21.0", - "license": "MIT", - "dependencies": { - "merge-options": "^3.0.4" - }, - "peerDependencies": { - "react-native": "^0.0.0-0 || >=0.60 <1.0" - } - }, "node_modules/@react-native-camera-roll/camera-roll": { "version": "7.4.0", "license": "MIT", @@ -23513,13 +23502,6 @@ "node": ">=6" } }, - "node_modules/is-plain-obj": { - "version": "2.1.0", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/is-plain-object": { "version": "5.0.0", "license": "MIT", @@ -27687,16 +27669,6 @@ "version": "1.0.1", "license": "MIT" }, - "node_modules/merge-options": { - "version": "3.0.4", - "license": "MIT", - "dependencies": { - "is-plain-obj": "^2.1.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/merge-refs": { "version": "1.2.1", "license": "MIT", diff --git a/package.json b/package.json index 78e1a3a13e2c..1803f1d180e4 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,6 @@ "@kie/act-js": "^2.6.0", "@kie/mock-github": "^1.0.0", "@onfido/react-native-sdk": "10.6.0", - "@react-native-async-storage/async-storage": "1.21.0", "@react-native-camera-roll/camera-roll": "7.4.0", "@react-native-clipboard/clipboard": "^1.13.2", "@react-native-community/geolocation": "3.2.1", From 035c5f5ea75792fe792e0c1aecb83cff7e683309 Mon Sep 17 00:00:00 2001 From: rory Date: Wed, 17 Apr 2024 17:30:19 -0700 Subject: [PATCH 190/339] Update docs --- tests/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/README.md b/tests/README.md index 08c750f75829..890697d80719 100644 --- a/tests/README.md +++ b/tests/README.md @@ -4,7 +4,7 @@ ## Asynchronous Testing -- Much of the logic in the app is asynchronous in nature. [`react-native-onyx`](https://github.com/expensify/react-native-onyx) relies on [`AsyncStorage`](https://github.com/react-native-async-storage/async-storage) and writes data async before updating subscribers. +- Much of the logic in the app is asynchronous in nature. [`react-native-onyx`](https://github.com/expensify/react-native-onyx) writes data async before updating subscribers. - [Actions](https://github.com/Expensify/App#actions) do not typically return a `Promise` and therefore can't always be "awaited" before running an assertion. - To test a result after some asynchronous code has run we can use [`Onyx.connect()`](https://github.com/Expensify/react-native-onyx/blob/2c94a94e51fab20330f7bd5381b72ea6c25553d9/lib/Onyx.js#L217-L231) and the helper method [`waitForBatchedUpdates()`](https://github.com/Expensify/ReactNativeChat/blob/ca2fa88a5789b82463d35eddc3d57f70a7286868/tests/utils/waitForBatchedUpdates.js#L1-L9) which returns a `Promise` and will ensure that all other `Promises` have finished running before resolving. - **Important Note:** When writing any asynchronous Jest test it's very important that your test itself **return a `Promise`**. From 81f4716ef5a0a8fca88473962d6961962566bbcb Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Apr 2024 11:13:10 +0800 Subject: [PATCH 191/339] remove unnecessary eslint disable --- src/components/FloatingActionButton.tsx | 2 -- src/libs/DateUtils.ts | 2 -- tests/ui/UnreadIndicatorsTest.tsx | 1 - 3 files changed, 5 deletions(-) diff --git a/src/components/FloatingActionButton.tsx b/src/components/FloatingActionButton.tsx index ee61beda74ae..93ffa52bc80b 100644 --- a/src/components/FloatingActionButton.tsx +++ b/src/components/FloatingActionButton.tsx @@ -27,12 +27,10 @@ type AdapterProps = { const adapter = createAnimatedPropAdapter( (props: AdapterProps) => { - // eslint-disable-next-line rulesdir/prefer-underscore-method if (Object.keys(props).includes('fill')) { // eslint-disable-next-line no-param-reassign props.fill = {type: 0, payload: processColor(props.fill)}; } - // eslint-disable-next-line rulesdir/prefer-underscore-method if (Object.keys(props).includes('stroke')) { // eslint-disable-next-line no-param-reassign props.stroke = {type: 0, payload: processColor(props.stroke)}; diff --git a/src/libs/DateUtils.ts b/src/libs/DateUtils.ts index 9b96bfa009dc..e0c414536c64 100644 --- a/src/libs/DateUtils.ts +++ b/src/libs/DateUtils.ts @@ -321,7 +321,6 @@ function getMonthNames(preferredLocale: Locale): string[] { end: new Date(fullYear, 11, 31), // December 31st of the current year }); - // eslint-disable-next-line rulesdir/prefer-underscore-method return monthsArray.map((monthDate) => format(monthDate, CONST.DATE.MONTH_FORMAT)); } @@ -337,7 +336,6 @@ function getDaysOfWeek(preferredLocale: Locale): string[] { const endOfCurrentWeek = endOfWeek(new Date(), {weekStartsOn}); const daysOfWeek = eachDayOfInterval({start: startOfCurrentWeek, end: endOfCurrentWeek}); - // eslint-disable-next-line rulesdir/prefer-underscore-method return daysOfWeek.map((date) => format(date, 'eeee')); } diff --git a/tests/ui/UnreadIndicatorsTest.tsx b/tests/ui/UnreadIndicatorsTest.tsx index 2aeee2cc77bf..a78423f3838d 100644 --- a/tests/ui/UnreadIndicatorsTest.tsx +++ b/tests/ui/UnreadIndicatorsTest.tsx @@ -82,7 +82,6 @@ const createAddListenerMock = (): ListenerMock => { transitionEndListeners.push(callback); } return () => { - // eslint-disable-next-line rulesdir/prefer-underscore-method transitionEndListeners.filter((cb) => cb !== callback); }; }); From 84ab150cfb3b9c76189906dd9a1151a636de0adc Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Apr 2024 11:20:45 +0800 Subject: [PATCH 192/339] remove unnecessary eslint disable --- src/libs/SidebarUtils.ts | 1 - src/libs/markAllPolicyReportsAsRead.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 9fc83d50f1e1..5c156add8e35 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -1,4 +1,3 @@ -/* eslint-disable rulesdir/prefer-underscore-method */ import Str from 'expensify-common/lib/str'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; diff --git a/src/libs/markAllPolicyReportsAsRead.ts b/src/libs/markAllPolicyReportsAsRead.ts index c3c719b1132e..49001a851cf5 100644 --- a/src/libs/markAllPolicyReportsAsRead.ts +++ b/src/libs/markAllPolicyReportsAsRead.ts @@ -1,4 +1,3 @@ -// eslint-disable-next-line you-dont-need-lodash-underscore/each import Onyx from 'react-native-onyx'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Report} from '@src/types/onyx'; From 7c9704bf69368452af0dd68a8725a067bca8ea3e Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Apr 2024 11:21:10 +0800 Subject: [PATCH 193/339] don't install underscore --- tests/unit/CIGitLogicTest.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/CIGitLogicTest.sh b/tests/unit/CIGitLogicTest.sh index 73fd01f5c0a0..ba26fcd45467 100755 --- a/tests/unit/CIGitLogicTest.sh +++ b/tests/unit/CIGitLogicTest.sh @@ -42,7 +42,6 @@ function init_git_server { setup_git_as_human npm init -y npm version --no-git-tag-version 1.0.0-0 - npm install underscore echo "node_modules/" >> .gitignore git add -A git commit -m "Initial commit" From ac5a4dd429e92d5617e2570b0191819c281127d5 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Apr 2024 11:24:26 +0800 Subject: [PATCH 194/339] replace underscore with lodash --- src/components/transactionPropTypes.js | 4 ++-- .../MoneyRequestParticipantsSelector.js | 20 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/components/transactionPropTypes.js b/src/components/transactionPropTypes.js index f951837503f3..9ed443d6275e 100644 --- a/src/components/transactionPropTypes.js +++ b/src/components/transactionPropTypes.js @@ -1,5 +1,5 @@ import PropTypes from 'prop-types'; -import _ from 'underscore'; +import lodashValues from 'lodash/values' import {translatableTextPropTypes} from '@libs/Localize'; import CONST from '@src/CONST'; import sourcePropTypes from './Image/sourcePropTypes'; @@ -57,7 +57,7 @@ export default PropTypes.shape({ ]), /** The type of transaction */ - type: PropTypes.oneOf(_.values(CONST.TRANSACTION.TYPE)), + type: PropTypes.oneOf(lodashValues(CONST.TRANSACTION.TYPE)), /** Custom units attached to the transaction */ customUnits: PropTypes.arrayOf( diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js index 31ca7ba0098d..1c465a5ab925 100755 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js @@ -1,8 +1,10 @@ import lodashGet from 'lodash/get'; +import lodashMap from 'lodash/map'; +import lodashSome from 'lodash/some'; +import lodashReject from 'lodash/reject'; import PropTypes from 'prop-types'; import React, {useCallback, useMemo} from 'react'; import {useOnyx} from 'react-native-onyx'; -import _ from 'underscore'; import Button from '@components/Button'; import FormHelpMessage from '@components/FormHelpMessage'; import {usePersonalDetails} from '@components/OnyxProvider'; @@ -135,19 +137,19 @@ function MoneyRequestParticipantsSelector({participants, navigateToRequest, navi newSections.push({ title: translate('common.recents'), data: newChatOptions.recentReports, - shouldShow: !_.isEmpty(newChatOptions.recentReports), + shouldShow: newChatOptions.recentReports.length > 0, }); newSections.push({ title: translate('common.contacts'), data: newChatOptions.personalDetails, - shouldShow: !_.isEmpty(newChatOptions.personalDetails), + shouldShow: newChatOptions.personalDetails.length > 0, }); if (newChatOptions.userToInvite && !OptionsListUtils.isCurrentUser(newChatOptions.userToInvite)) { newSections.push({ title: undefined, - data: _.map([newChatOptions.userToInvite], (participant) => { + data: lodashMap([newChatOptions.userToInvite], (participant) => { const isPolicyExpenseChat = lodashGet(participant, 'isPolicyExpenseChat', false); return isPolicyExpenseChat ? OptionsListUtils.getPolicyExpenseReportOption(participant) : OptionsListUtils.getParticipantsOption(participant, personalDetails); }), @@ -203,11 +205,11 @@ function MoneyRequestParticipantsSelector({participants, navigateToRequest, navi return false; }; - const isOptionInList = _.some(participants, isOptionSelected); + const isOptionInList = lodashSome(participants, isOptionSelected); let newSelectedOptions; if (isOptionInList) { - newSelectedOptions = _.reject(participants, isOptionSelected); + newSelectedOptions = lodashReject(participants, isOptionSelected); } else { newSelectedOptions = [ ...participants, @@ -229,11 +231,11 @@ function MoneyRequestParticipantsSelector({participants, navigateToRequest, navi const headerMessage = useMemo( () => OptionsListUtils.getHeaderMessage( - _.get(newChatOptions, 'personalDetails', []).length + _.get(newChatOptions, 'recentReports', []).length !== 0, + lodashGet(newChatOptions, 'personalDetails', []).length + lodashGet(newChatOptions, 'recentReports', []).length !== 0, Boolean(newChatOptions.userToInvite), debouncedSearchTerm.trim(), maxParticipantsReached, - _.some(participants, (participant) => participant.searchText.toLowerCase().includes(debouncedSearchTerm.trim().toLowerCase())), + lodashSome(participants, (participant) => participant.searchText.toLowerCase().includes(debouncedSearchTerm.trim().toLowerCase())), ), [maxParticipantsReached, newChatOptions, participants, debouncedSearchTerm], ); @@ -241,7 +243,7 @@ function MoneyRequestParticipantsSelector({participants, navigateToRequest, navi // Right now you can't split a request with a workspace and other additional participants // This is getting properly fixed in https://github.com/Expensify/App/issues/27508, but as a stop-gap to prevent // the app from crashing on native when you try to do this, we'll going to show error message if you have a workspace and other participants - const hasPolicyExpenseChatParticipant = _.some(participants, (participant) => participant.isPolicyExpenseChat); + const hasPolicyExpenseChatParticipant = lodashSome(participants, (participant) => participant.isPolicyExpenseChat); const shouldShowSplitBillErrorMessage = participants.length > 1 && hasPolicyExpenseChatParticipant; // canUseP2PDistanceRequests is true if the iouType is track expense, but we don't want to allow splitting distance with track expense yet From 0cc0b12288398db476ccc6e4c7c46146c2e7bb68 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Apr 2024 11:37:15 +0800 Subject: [PATCH 195/339] fix lint --- .../OptionsSelector/BaseOptionsSelector.js | 16 ++++++++++------ ...raryForRefactorRequestParticipantsSelector.js | 10 ++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index 13ac5160b30b..a6ba72b5b9a6 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -1,6 +1,10 @@ import lodashDebounce from 'lodash/debounce'; import lodashGet from 'lodash/get'; import lodashIsEqual from 'lodash/isEqual'; +import lodashValues from 'lodash/values'; +import lodashFind from 'lodash/find'; +import lodashMap from 'lodash/map'; +import lodashFindIndex from 'lodash/findIndex'; import PropTypes from 'prop-types'; import React, {Component} from 'react'; import {View} from 'react-native'; @@ -80,7 +84,7 @@ class BaseOptionsSelector extends Component { this.handleFocusOut = this.handleFocusOut.bind(this); this.debouncedUpdateSearchValue = lodashDebounce(this.updateSearchValue, CONST.TIMING.SEARCH_OPTION_LIST_DEBOUNCE_TIME); this.relatedTarget = null; - this.accessibilityRoles = Object.values(CONST.ROLE); + this.accessibilityRoles = lodashValues(CONST.ROLE); this.isWebOrDesktop = [CONST.PLATFORM.DESKTOP, CONST.PLATFORM.WEB].includes(getPlatform()); const allOptions = this.flattenSections(); @@ -172,8 +176,8 @@ class BaseOptionsSelector extends Component { } const newFocusedIndex = this.props.selectedOptions.length; const isNewFocusedIndex = newFocusedIndex !== this.state.focusedIndex; - const prevFocusedOption = newOptions.find((option) => this.focusedOption && option.keyForList === this.focusedOption.keyForList); - const prevFocusedOptionIndex = prevFocusedOption ? newOptions.findIndex((option) => this.focusedOption && option.keyForList === this.focusedOption.keyForList) : undefined; + const prevFocusedOption = lodashFind(newOptions, (option) => this.focusedOption && option.keyForList === this.focusedOption.keyForList); + const prevFocusedOptionIndex = prevFocusedOption ? lodashFindIndex(newOptions, (option) => this.focusedOption && option.keyForList === this.focusedOption.keyForList) : undefined; // eslint-disable-next-line react/no-did-update-set-state this.setState( { @@ -235,7 +239,7 @@ class BaseOptionsSelector extends Component { return defaultIndex; } - const indexOfInitiallyFocusedOption = allOptions.findIndex((option) => option.keyForList === this.props.initiallyFocusedOptionKey); + const indexOfInitiallyFocusedOption = lodashFindIndex(allOptions, (option) => option.keyForList === this.props.initiallyFocusedOptionKey); return indexOfInitiallyFocusedOption; } @@ -246,7 +250,7 @@ class BaseOptionsSelector extends Component { * @returns {Objects[]} */ sliceSections() { - return this.props.sections.map((section) => { + return lodashMap(this.props.sections, (section) => { if (section.data.length === 0) { return section; } @@ -348,7 +352,7 @@ class BaseOptionsSelector extends Component { selectFocusedOption(e) { const focusedItemKey = lodashGet(e, ['target', 'attributes', 'id', 'value']); - const focusedOption = focusedItemKey ? this.state.allOptions.find((option) => option.keyForList === focusedItemKey) : this.state.allOptions[this.state.focusedIndex]; + const focusedOption = focusedItemKey ? lodashFind(this.state.allOptions, (option) => option.keyForList === focusedItemKey) : this.state.allOptions[this.state.focusedIndex]; if (!focusedOption || !this.props.isFocused) { return; diff --git a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js index 80f43059dad0..b4e36778202e 100644 --- a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js +++ b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js @@ -2,6 +2,8 @@ import lodashGet from 'lodash/get'; import lodashIsEqual from 'lodash/isEqual'; import lodashPick from 'lodash/pick'; import lodashReject from 'lodash/reject'; +import lodashValues from 'lodash/values'; +import lodashMap from 'lodash/map'; import PropTypes from 'prop-types'; import React, {memo, useCallback, useEffect, useMemo} from 'react'; import {useOnyx} from 'react-native-onyx'; @@ -53,13 +55,13 @@ const propTypes = { ), /** The type of IOU report, i.e. split, request, send, track */ - iouType: PropTypes.oneOf(Object.values(CONST.IOU.TYPE)).isRequired, + iouType: PropTypes.oneOf(lodashValues(CONST.IOU.TYPE)).isRequired, /** The expense type, ie. manual, scan, distance */ - iouRequestType: PropTypes.oneOf(Object.values(CONST.IOU.REQUEST_TYPE)).isRequired, + iouRequestType: PropTypes.oneOf(lodashValues(CONST.IOU.REQUEST_TYPE)).isRequired, /** The action of the IOU, i.e. create, split, move */ - action: PropTypes.oneOf(Object.values(CONST.IOU.ACTION)), + action: PropTypes.oneOf(lodashValues(CONST.IOU.ACTION)), }; const defaultProps = { @@ -157,7 +159,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF if (chatOptions.userToInvite && !OptionsListUtils.isCurrentUser(chatOptions.userToInvite)) { newSections.push({ title: undefined, - data: [chatOptions.userToInvite].map((participant) => { + data: lodashMap([chatOptions.userToInvite], (participant) => { const isPolicyExpenseChat = lodashGet(participant, 'isPolicyExpenseChat', false); return isPolicyExpenseChat ? OptionsListUtils.getPolicyExpenseReportOption(participant) : OptionsListUtils.getParticipantsOption(participant, personalDetails); }), From 861ea798f60bb4fa726fde6c60ebb6867327a937 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Apr 2024 11:37:58 +0800 Subject: [PATCH 196/339] prettier --- src/components/OptionsSelector/BaseOptionsSelector.js | 6 +++--- src/components/transactionPropTypes.js | 2 +- .../MoneyTemporaryForRefactorRequestParticipantsSelector.js | 2 +- .../MoneyRequestParticipantsSelector.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index a6ba72b5b9a6..767fe27cbfe8 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -1,10 +1,10 @@ import lodashDebounce from 'lodash/debounce'; +import lodashFind from 'lodash/find'; +import lodashFindIndex from 'lodash/findIndex'; import lodashGet from 'lodash/get'; import lodashIsEqual from 'lodash/isEqual'; -import lodashValues from 'lodash/values'; -import lodashFind from 'lodash/find'; import lodashMap from 'lodash/map'; -import lodashFindIndex from 'lodash/findIndex'; +import lodashValues from 'lodash/values'; import PropTypes from 'prop-types'; import React, {Component} from 'react'; import {View} from 'react-native'; diff --git a/src/components/transactionPropTypes.js b/src/components/transactionPropTypes.js index 9ed443d6275e..d1626b75d6cd 100644 --- a/src/components/transactionPropTypes.js +++ b/src/components/transactionPropTypes.js @@ -1,5 +1,5 @@ +import lodashValues from 'lodash/values'; import PropTypes from 'prop-types'; -import lodashValues from 'lodash/values' import {translatableTextPropTypes} from '@libs/Localize'; import CONST from '@src/CONST'; import sourcePropTypes from './Image/sourcePropTypes'; diff --git a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js index b4e36778202e..395fcebcab79 100644 --- a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js +++ b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js @@ -1,9 +1,9 @@ import lodashGet from 'lodash/get'; import lodashIsEqual from 'lodash/isEqual'; +import lodashMap from 'lodash/map'; import lodashPick from 'lodash/pick'; import lodashReject from 'lodash/reject'; import lodashValues from 'lodash/values'; -import lodashMap from 'lodash/map'; import PropTypes from 'prop-types'; import React, {memo, useCallback, useEffect, useMemo} from 'react'; import {useOnyx} from 'react-native-onyx'; diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js index 1c465a5ab925..1bcaba0c691f 100755 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js @@ -1,7 +1,7 @@ import lodashGet from 'lodash/get'; import lodashMap from 'lodash/map'; -import lodashSome from 'lodash/some'; import lodashReject from 'lodash/reject'; +import lodashSome from 'lodash/some'; import PropTypes from 'prop-types'; import React, {useCallback, useMemo} from 'react'; import {useOnyx} from 'react-native-onyx'; From cca7dd711a087fac625d882440da1a81421422a3 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Apr 2024 11:40:11 +0800 Subject: [PATCH 197/339] uninstall underscore --- package-lock.json | 9 +-------- package.json | 4 +--- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0884041f2268..e0d5cd158774 100644 --- a/package-lock.json +++ b/package-lock.json @@ -132,8 +132,7 @@ "react-webcam": "^7.1.1", "react-window": "^1.8.9", "semver": "^7.5.2", - "shim-keyboard-event-key": "^1.0.3", - "underscore": "^1.13.1" + "shim-keyboard-event-key": "^1.0.3" }, "devDependencies": { "@actions/core": "1.10.0", @@ -182,7 +181,6 @@ "@types/react-test-renderer": "^18.0.0", "@types/semver": "^7.5.4", "@types/setimmediate": "^1.0.2", - "@types/underscore": "^1.11.5", "@types/webpack": "^5.28.5", "@types/webpack-bundle-analyzer": "^4.7.0", "@typescript-eslint/eslint-plugin": "^6.13.2", @@ -12676,11 +12674,6 @@ "version": "4.0.2", "license": "MIT" }, - "node_modules/@types/underscore": { - "version": "1.11.5", - "dev": true, - "license": "MIT" - }, "node_modules/@types/unist": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", diff --git a/package.json b/package.json index 71276370dfe7..0df218a6b167 100644 --- a/package.json +++ b/package.json @@ -183,8 +183,7 @@ "react-webcam": "^7.1.1", "react-window": "^1.8.9", "semver": "^7.5.2", - "shim-keyboard-event-key": "^1.0.3", - "underscore": "^1.13.1" + "shim-keyboard-event-key": "^1.0.3" }, "devDependencies": { "@actions/core": "1.10.0", @@ -233,7 +232,6 @@ "@types/react-test-renderer": "^18.0.0", "@types/semver": "^7.5.4", "@types/setimmediate": "^1.0.2", - "@types/underscore": "^1.11.5", "@types/webpack": "^5.28.5", "@types/webpack-bundle-analyzer": "^4.7.0", "@typescript-eslint/eslint-plugin": "^6.13.2", From c95933b2257187b7f3cfcf9abd522f7756d1bda7 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Apr 2024 11:41:30 +0800 Subject: [PATCH 198/339] update comment --- src/libs/E2E/tests/appStartTimeTest.e2e.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/E2E/tests/appStartTimeTest.e2e.ts b/src/libs/E2E/tests/appStartTimeTest.e2e.ts index 5720af8b3641..321fc3773d51 100644 --- a/src/libs/E2E/tests/appStartTimeTest.e2e.ts +++ b/src/libs/E2E/tests/appStartTimeTest.e2e.ts @@ -20,7 +20,7 @@ const test = () => { // collect performance metrics and submit const metrics: PerformanceEntry[] = Performance.getPerformanceMetrics(); - // underscore promises in sequence without for-loop + // promises in sequence without for-loop Promise.all( metrics.map((metric) => E2EClient.submitTestResults({ From 5995e6c83add215c790ecae0a4820c4da14c7b3c Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Apr 2024 11:48:48 +0800 Subject: [PATCH 199/339] fix lint --- ...yTemporaryForRefactorRequestParticipantsSelector.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js index 395fcebcab79..09520a9c710f 100644 --- a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js +++ b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js @@ -4,6 +4,8 @@ import lodashMap from 'lodash/map'; import lodashPick from 'lodash/pick'; import lodashReject from 'lodash/reject'; import lodashValues from 'lodash/values'; +import lodashSome from 'lodash/some'; +import lodashEvery from 'lodash/every'; import PropTypes from 'prop-types'; import React, {memo, useCallback, useEffect, useMemo} from 'react'; import {useOnyx} from 'react-native-onyx'; @@ -222,7 +224,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF return false; }; - const isOptionInList = participants.some(isOptionSelected); + const isOptionInList = lodashSome(participants, isOptionSelected); let newSelectedOptions; if (isOptionInList) { @@ -255,7 +257,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF Boolean(newChatOptions.userToInvite), debouncedSearchTerm.trim(), maxParticipantsReached, - participants.some((participant) => participant.searchText.toLowerCase().includes(debouncedSearchTerm.trim().toLowerCase())), + lodashSome(participants, (participant) => participant.searchText.toLowerCase().includes(debouncedSearchTerm.trim().toLowerCase())), ), [maxParticipantsReached, newChatOptions, participants, debouncedSearchTerm], ); @@ -263,7 +265,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF // Right now you can't split an expense with a workspace and other additional participants // This is getting properly fixed in https://github.com/Expensify/App/issues/27508, but as a stop-gap to prevent // the app from crashing on native when you try to do this, we'll going to hide the button if you have a workspace and other participants - const hasPolicyExpenseChatParticipant = participants.some((participant) => participant.isPolicyExpenseChat); + const hasPolicyExpenseChatParticipant = lodashSome(participants, (participant) => participant.isPolicyExpenseChat); const shouldShowSplitBillErrorMessage = participants.length > 1 && hasPolicyExpenseChatParticipant; // canUseP2PDistanceRequests is true if the iouType is track expense, but we don't want to allow splitting distance with track expense yet @@ -381,7 +383,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF ); - const isAllSectionsEmpty = sections.every((section) => section.data.length === 0); + const isAllSectionsEmpty = lodashEvery(sections, (section) => section.data.length === 0); if ([CONST.IOU.ACTION.CATEGORIZE, CONST.IOU.ACTION.SHARE].includes(action) && isAllSectionsEmpty && didScreenTransitionEnd && searchTerm.trim() === '') { return renderEmptyWorkspaceView(); } From 612b3242c8fea0b674112a91337527ee2779482d Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Apr 2024 11:53:52 +0800 Subject: [PATCH 200/339] remove underscore rule --- .eslintrc.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 56a5236a7899..320289fb95d9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -238,7 +238,6 @@ module.exports = { 'jsdoc/no-types': 'error', 'rulesdir/no-default-props': 'error', 'import/no-extraneous-dependencies': 'off', - 'rulesdir/prefer-underscore-method': 'off', 'rulesdir/prefer-import-module-contents': 'off', 'react/require-default-props': 'off', 'react/prop-types': 'off', @@ -260,13 +259,7 @@ module.exports = { 'no-restricted-imports': [ 'error', { - paths: [ - ...restrictedImportPaths, - { - name: 'underscore', - message: 'Please use the corresponding method from lodash instead', - }, - ], + paths: restrictedImportPaths, patterns: restrictedImportPatterns, }, ], From 81026f0bce3945de042ded4fe372b9c1464972a9 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Thu, 18 Apr 2024 11:20:22 +0300 Subject: [PATCH 201/339] resolve merge conflicts --- src/ROUTES.ts | 16 +++--- src/SCREENS.ts | 16 +++--- .../UpdatePolicyConnectionConfigParams.ts | 2 +- .../ModalStackNavigators/index.tsx | 19 +++---- .../FULL_SCREEN_TO_RHP_MAPPING.ts | 16 +++--- src/libs/Navigation/linkingConfig/config.ts | 24 ++++----- src/libs/Navigation/types.ts | 49 +++++++++---------- src/libs/actions/connections/index.ts | 2 +- .../accounting/PolicyAccountingPage.tsx | 2 +- .../qbo/QuickbooksChartOfAccountsPage.tsx | 2 +- .../accounting/qbo/QuickbooksClassesPage.tsx | 2 +- .../qbo/QuickbooksCustomersPage.tsx | 2 +- .../qbo/QuickbooksLocationsPage.tsx | 2 +- .../accounting/qbo/QuickbooksTaxesPage.tsx | 2 +- ...oksCompanyCardExpenseAccountSelectPage.tsx | 7 ++- .../QuickbooksExportConfigurationPage.tsx | 10 ++-- .../export/QuickbooksExportDateSelectPage.tsx | 6 +-- ...ickbooksExportInvoiceAccountSelectPage.tsx | 6 +-- ...oksOutOfPocketExpenseAccountSelectPage.tsx | 6 +-- ...oksOutOfPocketExpenseConfigurationPage.tsx | 4 +- ...ooksOutOfPocketExpenseEntitySelectPage.tsx | 8 +-- ...ooksPreferredExporterConfigurationPage.tsx | 6 +-- 22 files changed, 105 insertions(+), 104 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 46c0500dbabc..058159d52693 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -487,35 +487,35 @@ const ROUTES = { route: 'settings/workspaces/:policyID/profile/currency', getRoute: (policyID: string) => `settings/workspaces/${policyID}/profile/currency` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT: { + POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT: { + POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/company-card-expense-account-select', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/company-card-expense-account-select` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT: { + POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/invoice-account-select', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/invoice-account-select` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER: { + POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/preferred-exporter', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/preferred-exporter` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES: { + POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/out-of-pocket-expense', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/out-of-pocket-expense` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT: { + POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/out-of-pocket-expense/account-select', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/out-of-pocket-expense/account-select` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT: { + POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/out-of-pocket-expense/entity-select', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/out-of-pocket-expense/entity-select` as const, }, - WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT: { + POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT: { route: 'settings/workspaces/:policyID/accounting/quickbooks-online/export/date-select', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/export/date-select` as const, }, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index ceed7d5eb8fe..dc51d4b8149d 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -211,6 +211,14 @@ const SCREENS = { QUICKBOOKS_ONLINE_CUSTOMERS: 'Policy_Accounting_Quickbooks_Online_Import_Customers', QUICKBOOKS_ONLINE_LOCATIONS: 'Policy_Accounting_Quickbooks_Online_Import_Locations', QUICKBOOKS_ONLINE_TAXES: 'Policy_Accounting_Quickbooks_Online_Import_Taxes', + QUICKBOOKS_ONLINE_EXPORT: 'Workspace_Accounting_Quickbooks_Online_Export', + QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Date_Select', + QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Invoice_Account_Select', + QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Company_Card_Expense_Select', + QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter', + QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses', + QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses_Select', + QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses_Account_Select', }, INITIAL: 'Workspace_Initial', PROFILE: 'Workspace_Profile', @@ -263,14 +271,6 @@ const SCREENS = { CREATE_DISTANCE_RATE: 'Create_Distance_Rate', DISTANCE_RATES_SETTINGS: 'Distance_Rates_Settings', DISTANCE_RATE_DETAILS: 'Distance_Rate_Details', - QUICKBOOKS_ONLINE_EXPORT: 'Workspace_Accounting_Quickbooks_Online_Export', - QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Date_Select', - QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Invoice_Account_Select', - QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Company_Card_Expense_Select', - QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER: 'Workspace_Accounting_Quickbooks_Online_Export_Preferred_Exporter', - QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses', - QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses_Select', - QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT: 'Workspace_Accounting_Quickbooks_Online_Export_Out_Of_Pocket_Expenses_Account_Select', DISTANCE_RATE_EDIT: 'Distance_Rate_Edit', }, diff --git a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts index c720fe0059c1..32146ec5322f 100644 --- a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts +++ b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts @@ -4,7 +4,7 @@ type UpdatePolicyConnectionConfigParams require('../../../../pages/settings/Profile/Contacts/ContactMethodDetailsPage').default as React.ComponentType, [SCREENS.SETTINGS.PROFILE.NEW_CONTACT_METHOD]: () => require('../../../../pages/settings/Profile/Contacts/NewContactMethodPage').default as React.ComponentType, [SCREENS.SETTINGS.PREFERENCES.PRIORITY_MODE]: () => require('../../../../pages/settings/Preferences/PriorityModePage').default as React.ComponentType, - [SCREENS.WORKSPACE.ACCOUNTING]: () => require('@pages/workspace/accounting/WorkspaceAccountingPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.ROOT]: () => require('../../../../pages/workspace/accounting/PolicyAccountingPage').default as React.ComponentType, [SCREENS.SETTINGS.PREFERENCES.LANGUAGE]: () => require('../../../../pages/settings/Preferences/LanguagePage').default as React.ComponentType, [SCREENS.SETTINGS.PREFERENCES.THEME]: () => require('../../../../pages/settings/Preferences/ThemePage').default as React.ComponentType, [SCREENS.SETTINGS.CLOSE]: () => require('../../../../pages/settings/Security/CloseAccountPage').default as React.ComponentType, @@ -255,20 +255,21 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsCustomTaxName').default as React.ComponentType, [SCREENS.WORKSPACE.TAXES_SETTINGS_FOREIGN_CURRENCY_DEFAULT]: () => require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsForeignCurrency').default as React.ComponentType, [SCREENS.WORKSPACE.TAXES_SETTINGS_WORKSPACE_CURRENCY_DEFAULT]: () => require('../../../../pages/workspace/taxes/WorkspaceTaxesSettingsWorkspaceCurrency').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: () => require('../../../../pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: () => + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT]: () => + require('../../../../pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: () => require('../../../../pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: () => + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: () => require('../../../../pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT]: () => + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT]: () => require('../../../../pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: () => + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: () => require('../../../../pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: () => + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: () => require('../../../../pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: () => + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: () => require('../../../../pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: () => + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: () => require('../../../../pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage').default as React.ComponentType, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType, [SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index f09e5383d6d6..7bb1a82fc465 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -25,14 +25,14 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_TAXES, SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_LOCATIONS, SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_CUSTOMERS, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT, + SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT, + SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT, + SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT, + SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT, + SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT, + SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER, + SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES, + SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT, ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index bd43fa52a6c7..6d9548370ba1 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -269,20 +269,22 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_CUSTOMERS]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_CUSTOMERS.route}, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_LOCATIONS]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_LOCATIONS.route}, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_TAXES]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_TAXES.route}, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.route}, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.route}, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.route}, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT]: { - path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.route, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.route}, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.route}, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.route}, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT]: { + path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.route, }, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.route}, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: { - path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.route, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: { + path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.route, }, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: { - path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.route, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: { + path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.route, }, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: {path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.route}, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: { + path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.route, + }, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 4b2fbc439468..b394f1b98968 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -262,6 +262,30 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_TAXES]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT]: { + policyID: string; + }; + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: { + policyID: string; + }; + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: { + policyID: string; + }; + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT]: { + policyID: string; + }; + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: { + policyID: string; + }; + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: { + policyID: string; + }; + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: { + policyID: string; + }; + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: { + policyID: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; @@ -681,9 +705,6 @@ type WorkspacesCentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.MEMBERS]: { policyID: string; }; - [SCREENS.WORKSPACE.ACCOUNTING.ROOT]: { - policyID: string; - }; [SCREENS.WORKSPACE.CATEGORIES]: { policyID: string; }; @@ -701,28 +722,6 @@ type WorkspacesCentralPaneNavigatorParamList = { policyID: string; }; [SCREENS.WORKSPACE.ACCOUNTING.ROOT]: { - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT]: { - policyID: string; - }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT]: { - policyID: string; - }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_INVOICE_ACCOUNT_SELECT]: { - policyID: string; - }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT]: { - policyID: string; - }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES]: { - policyID: string; - }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT]: { - policyID: string; - }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT]: { - policyID: string; - }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_EXPORT_PREFERRED_EXPORTER]: { policyID: string; }; }; diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index 154036ba70e1..dd8234bf8800 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -46,7 +46,7 @@ function updatePolicyConnectionConfig Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.getRoute(policyID)), + onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.getRoute(policyID)), }, { icon: Expensicons.Gear, diff --git a/src/pages/workspace/accounting/qbo/QuickbooksChartOfAccountsPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksChartOfAccountsPage.tsx index 10f7500b3ca1..723ac4822424 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksChartOfAccountsPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksChartOfAccountsPage.tsx @@ -50,7 +50,7 @@ function QuickbooksChartOfAccountsPage({policy}: WithPolicyProps) { Connections.updatePolicyConnectionConfig( policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, - CONST.QUICKBOOKS_IMPORTS.ENABLE_NEW_CATEGORIES, + CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } diff --git a/src/pages/workspace/accounting/qbo/QuickbooksClassesPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksClassesPage.tsx index 62a0a65ac91c..42f4e7e3f728 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksClassesPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksClassesPage.tsx @@ -52,7 +52,7 @@ function QuickbooksClassesPage({policy}: WithPolicyProps) { Connections.updatePolicyConnectionConfig( policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, - CONST.QUICKBOOKS_IMPORTS.SYNC_CLASSES, + CONST.QUICK_BOOKS_CONFIG.SYNC_CLASSES, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } diff --git a/src/pages/workspace/accounting/qbo/QuickbooksCustomersPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksCustomersPage.tsx index 3192ff4d83a9..644bd070327c 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksCustomersPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksCustomersPage.tsx @@ -51,7 +51,7 @@ function QuickbooksCustomersPage({policy}: WithPolicyProps) { Connections.updatePolicyConnectionConfig( policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, - CONST.QUICKBOOKS_IMPORTS.SYNC_CUSTOMERS, + CONST.QUICK_BOOKS_CONFIG.SYNC_CUSTOMERS, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } diff --git a/src/pages/workspace/accounting/qbo/QuickbooksLocationsPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksLocationsPage.tsx index fa573b813585..06635b1fe7db 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksLocationsPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksLocationsPage.tsx @@ -52,7 +52,7 @@ function QuickbooksLocationsPage({policy}: WithPolicyProps) { Connections.updatePolicyConnectionConfig( policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, - CONST.QUICKBOOKS_IMPORTS.SYNC_LOCATIONS, + CONST.QUICK_BOOKS_CONFIG.SYNC_LOCATIONS, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } diff --git a/src/pages/workspace/accounting/qbo/QuickbooksTaxesPage.tsx b/src/pages/workspace/accounting/qbo/QuickbooksTaxesPage.tsx index 215d8397b7ec..714e2638583e 100644 --- a/src/pages/workspace/accounting/qbo/QuickbooksTaxesPage.tsx +++ b/src/pages/workspace/accounting/qbo/QuickbooksTaxesPage.tsx @@ -49,7 +49,7 @@ function QuickbooksTaxesPage({policy}: WithPolicyProps) { Connections.updatePolicyConnectionConfig( policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, - CONST.QUICKBOOKS_IMPORTS.SYNC_TAXES, + CONST.QUICK_BOOKS_CONFIG.SYNC_TAXES, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, ) } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index 9b207868e83b..58b58163d4ab 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -9,10 +9,10 @@ import type {ListItem, Section} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; -import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -68,9 +68,9 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps const onSelectRow = useCallback( (row: CardListItem) => { if (row.value !== exportCompanyCard) { - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_COMPANY_CARD, row.value); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_COMPANY_CARD, row.value); } - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.getRoute(policyID)); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT.getRoute(policyID)); }, [exportCompanyCard, policyID], ); @@ -78,7 +78,6 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps return ( diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx index cff82c6cad6a..db1fa57047c8 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx @@ -25,31 +25,31 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { const menuItems: MenuItemProps[] = [ { description: translate('workspace.qbo.preferredExporter'), - onPress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)), + onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)), brickRoadIndicator: errors?.exporter ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exporter ?? policyOwner, }, { description: translate('workspace.qbo.date'), - onPress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.getRoute(policyID)), + onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.getRoute(policyID)), brickRoadIndicator: errors?.exportDate ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportDate ? translate(`workspace.qbo.${exportDate}.label`) : undefined, }, { description: translate('workspace.qbo.exportExpenses'), - onPress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)), + onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)), brickRoadIndicator: errors?.exportExpenses ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportEntity ? translate(`workspace.qbo.${exportEntity}`) : undefined, }, { description: translate('workspace.qbo.exportInvoices'), - onPress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.getRoute(policyID)), + onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.getRoute(policyID)), brickRoadIndicator: errors?.exportInvoice ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportInvoice, }, { description: translate('workspace.qbo.exportCompany'), - onPress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID)), + onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID)), brickRoadIndicator: errors?.exportCompanyCard ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportCompanyCard, }, diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx index 38e326ff6694..3b92ec196628 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx @@ -9,10 +9,10 @@ import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; -import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -35,9 +35,9 @@ function QuickbooksExportDateSelectPage({policy}: WithPolicyProps) { const onSelectRow = useCallback( (row: CardListItem) => { if (row.value !== exportDate) { - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_DATE, row.value); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_DATE, row.value); } - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.getRoute(policyID)); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.getRoute(policyID)); }, [exportDate, policyID], ); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx index 51ec82f65d0a..857e4ca871ae 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx @@ -8,10 +8,10 @@ import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; -import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -50,9 +50,9 @@ function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyProps) { const onSelectRow = useCallback( (row: CardListItem) => { if (row.value !== exportInvoice) { - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_INVOICE, row.value); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_INVOICE, row.value); } - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.getRoute(policyID)); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.getRoute(policyID)); }, [exportInvoice, policyID], ); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx index 4af0e8ad4261..07b6347f9497 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx @@ -8,10 +8,10 @@ import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; -import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -65,9 +65,9 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps const onSelectRow = useCallback( (row: CardListItem) => { if (row.value !== exportAccount) { - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_ACCOUNT, row.value); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_ACCOUNT, row.value); } - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)); }, [exportAccount, policyID], ); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx index 8741843066e3..c36f6725e0d1 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx @@ -37,7 +37,7 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps title={exportEntity ? translate(`workspace.qbo.${exportEntity}`) : undefined} description={translate('workspace.qbo.exportAs')} error={exportEntity && (showTaxError || showLocationError) ? translate(`workspace.qbo.${exportEntity}Error`) : undefined} - onPress={() => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.getRoute(policyID))} + onPress={() => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.getRoute(policyID))} brickRoadIndicator={brickEntityRoadIndicator ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} shouldShowRightIcon /> @@ -51,7 +51,7 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.getRoute(policyID))} + onPress={() => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.getRoute(policyID))} brickRoadIndicator={errors?.exportAccount ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} shouldShowRightIcon /> diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx index 7ec7fe632d96..fb85a4f7518d 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx @@ -10,10 +10,10 @@ import type {ListItem, Section} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; -import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -37,7 +37,7 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) if (!isTaxError && !isLocationError) { return; } - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY, ''); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY, null); }, [policyID, isTaxError, isLocationError]); const data: CardListItem[] = useMemo( @@ -72,9 +72,9 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) const onSelectRow = useCallback( (row: CardListItem) => { if (row.value !== exportEntity) { - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY, row.value); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY, row.value); } - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)); }, [exportEntity, policyID], ); diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx index d86ed1e8d783..d9a151888269 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx @@ -8,11 +8,11 @@ import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; import {getAdminEmailList} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; -import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -51,9 +51,9 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { const onSelectRow = useCallback( (row: CardListItem) => { if (row.value !== exporter) { - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.PREFERRED_EXPORTER, row.value); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.PREFERRED_EXPORTER, row.value); } - Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)); }, [policyID, exporter], ); From aee7789c3f72ed71041d1a9b98c12d309e0ae37e Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Thu, 18 Apr 2024 11:58:53 +0300 Subject: [PATCH 202/339] address c+ comments --- src/libs/PolicyUtils.ts | 16 ++++------ ...oksCompanyCardExpenseAccountSelectPage.tsx | 6 ++-- .../QuickbooksExportConfigurationPage.tsx | 1 + .../export/QuickbooksExportDateSelectPage.tsx | 17 +++++------ ...ickbooksExportInvoiceAccountSelectPage.tsx | 18 +++++------- ...oksOutOfPocketExpenseAccountSelectPage.tsx | 18 +++++------- ...oksOutOfPocketExpenseConfigurationPage.tsx | 11 +++---- ...ooksOutOfPocketExpenseEntitySelectPage.tsx | 7 ++--- ...ooksPreferredExporterConfigurationPage.tsx | 29 +++++++++---------- 9 files changed, 54 insertions(+), 69 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 85a20ceaf512..503f853409e9 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -319,17 +319,11 @@ function getPolicyIDFromNavigationState() { } function getAdminEmailList(policy: Policy | null) { - const adminEmailList: Array<{email: string}> = []; - if (!policy?.employeeList) { - return adminEmailList; - } - Object.keys(policy.employeeList).forEach((email: string) => { - if (policy?.employeeList?.[email].role !== CONST.POLICY.ROLE.ADMIN) { - return; - } - adminEmailList.push({email}); - }); - return adminEmailList; + return Object.values(policy?.employeeList ?? {}) + .filter((employee) => employee.email && employee.role === CONST.POLICY.ROLE.ADMIN) + .map((employee) => ({ + email: employee.email as string, + })); } export { diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index 58b58163d4ab..06bc3172019d 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -1,5 +1,5 @@ import React, {useCallback, useMemo} from 'react'; -import type {SectionListData} from 'react-native'; +import {SectionListData, View} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; @@ -81,7 +81,7 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps testID={QuickbooksCompanyCardExpenseAccountSelectPage.displayName} > - + {translate('workspace.qbo.exportCompanyCardsDescription')}} sections={sections} @@ -90,7 +90,7 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} footerContent={isLocationEnabled && {translate('workspace.qbo.companyCardsLocationEnabledDescription')}} /> - + ); } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx index db1fa57047c8..f8e03f816df6 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx @@ -57,6 +57,7 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { description: translate('workspace.qbo.exportExpensifyCard'), title: translate('workspace.qbo.creditCard'), shouldShowRightIcon: false, + interactive: false, }, ]; diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx index 3b92ec196628..f3ee8f58a6f0 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx @@ -2,7 +2,6 @@ import React, {useCallback} from 'react'; import type {ValueOf} from 'type-fest'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; -import ScrollView from '@components/ScrollView'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; @@ -48,15 +47,13 @@ function QuickbooksExportDateSelectPage({policy}: WithPolicyProps) { testID={QuickbooksExportDateSelectPage.displayName} > - - {translate('workspace.qbo.exportDateDescription')}} - sections={[{data}]} - ListItem={RadioListItem} - onSelectRow={onSelectRow} - initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - /> - + {translate('workspace.qbo.exportDateDescription')}} + sections={[{data}]} + ListItem={RadioListItem} + onSelectRow={onSelectRow} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + /> ); } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx index 857e4ca871ae..5914ee33fc44 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx @@ -1,7 +1,6 @@ import React, {useCallback, useMemo} from 'react'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; -import ScrollView from '@components/ScrollView'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; @@ -63,15 +62,14 @@ function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyProps) { testID={QuickbooksExportInvoiceAccountSelectPage.displayName} > - - {translate('workspace.qbo.exportInvoicesDescription')}} - sections={[{data}]} - ListItem={RadioListItem} - onSelectRow={onSelectRow} - initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - /> - + {translate('workspace.qbo.exportInvoicesDescription')}} + sections={[{data}]} + ListItem={RadioListItem} + onSelectRow={onSelectRow} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + /> ); } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx index 07b6347f9497..a364b1d173e5 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx @@ -1,7 +1,6 @@ import React, {useCallback, useMemo} from 'react'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; -import ScrollView from '@components/ScrollView'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; @@ -78,15 +77,14 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps testID={QuickbooksOutOfPocketExpenseAccountSelectPage.displayName} > - - {translate('workspace.qbo.accountsPayableDescription')}} - sections={[{data}]} - ListItem={RadioListItem} - onSelectRow={onSelectRow} - initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - /> - + {translate('workspace.qbo.accountsPayableDescription')}} + sections={[{data}]} + ListItem={RadioListItem} + onSelectRow={onSelectRow} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + /> ); } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx index c36f6725e0d1..263b66a87ebf 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx @@ -20,9 +20,9 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps const {syncLocations, exportAccount, exportEntity, errors, syncTaxes} = policy?.connections?.quickbooksOnline?.config ?? {}; const isLocationEnabled = Boolean(syncLocations && syncLocations !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); const isTaxesEnabled = Boolean(syncTaxes && syncTaxes !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); - const showTaxError = isTaxesEnabled && exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY; - const showLocationError = isLocationEnabled && exportEntity !== CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY; - const brickEntityRoadIndicator = Boolean(errors?.exportEntity) || showTaxError || showLocationError; + const shouldShowTaxError = isTaxesEnabled && exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY; + const shouldShowLocationError = isLocationEnabled && exportEntity !== CONST.QUICKBOOKS_EXPORT_ENTITY.JOURNAL_ENTRY; + const hasErrors = Boolean(errors?.exportEntity) || shouldShowTaxError || shouldShowLocationError; return ( Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.getRoute(policyID))} - brickRoadIndicator={brickEntityRoadIndicator ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + brickRoadIndicator={hasErrors ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} shouldShowRightIcon /> @@ -54,6 +54,7 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps onPress={() => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.getRoute(policyID))} brickRoadIndicator={errors?.exportAccount ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} shouldShowRightIcon + error={errors?.exportAccount ? translate('common.genericErrorMessage') : undefined} /> )} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx index fb85a4f7518d..cbf3593e5895 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx @@ -1,9 +1,8 @@ import React, {useCallback, useEffect, useMemo} from 'react'; -import type {SectionListData} from 'react-native'; +import {SectionListData, View} from 'react-native'; import type {ValueOf} from 'type-fest'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; -import ScrollView from '@components/ScrollView'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem, Section} from '@components/SelectionList/types'; @@ -85,7 +84,7 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) testID={QuickbooksOutOfPocketExpenseEntitySelectPage.displayName} > - + {translate('workspace.qbo.optionBelow')}} sections={sections} @@ -94,7 +93,7 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} footerContent={isTaxesEnabled && {translate('workspace.qbo.outOfPocketTaxEnabledDescription')}} /> - + ); } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx index d9a151888269..7008822f0e2d 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx @@ -1,7 +1,6 @@ import React, {useCallback, useMemo} from 'react'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; -import ScrollView from '@components/ScrollView'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem} from '@components/SelectionList/types'; @@ -64,21 +63,19 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { testID={QuickBooksExportPreferredExporterPage.displayName} > - - - {translate('workspace.qbo.exportPreferredExporterNote')} - {translate('workspace.qbo.exportPreferredExporterSubNote')} - - } - shouldStopPropagation - sections={[{data}]} - ListItem={RadioListItem} - onSelectRow={onSelectRow} - initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - /> - + + {translate('workspace.qbo.exportPreferredExporterNote')} + {translate('workspace.qbo.exportPreferredExporterSubNote')} + + } + sections={[{data}]} + ListItem={RadioListItem} + onSelectRow={onSelectRow} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + /> ); } From 3984f0c75be3f11e652aedc965a1f317a371aa81 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Thu, 18 Apr 2024 12:13:22 +0300 Subject: [PATCH 203/339] add offline pending actions --- src/libs/PolicyUtils.ts | 4 ++-- ...ooksCompanyCardExpenseAccountSelectPage.tsx | 1 - .../QuickbooksExportConfigurationPage.tsx | 18 ++++++++++++++---- ...ooksOutOfPocketExpenseConfigurationPage.tsx | 6 +++--- ...booksOutOfPocketExpenseEntitySelectPage.tsx | 3 ++- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 503f853409e9..6594aeb49baf 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -320,9 +320,9 @@ function getPolicyIDFromNavigationState() { function getAdminEmailList(policy: Policy | null) { return Object.values(policy?.employeeList ?? {}) - .filter((employee) => employee.email && employee.role === CONST.POLICY.ROLE.ADMIN) + .filter((employee) => employee.role === CONST.POLICY.ROLE.ADMIN) .map((employee) => ({ - email: employee.email as string, + email: employee.email ?? '', })); } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index 06bc3172019d..5395c80f2e8a 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -2,7 +2,6 @@ import React, {useCallback, useMemo} from 'react'; import {SectionListData, View} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; -import ScrollView from '@components/ScrollView'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import type {ListItem, Section} from '@components/SelectionList/types'; diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx index f8e03f816df6..102c09efe1c9 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx @@ -2,7 +2,7 @@ import React from 'react'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import type {MenuItemProps} from '@components/MenuItem'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import OfflineWithFeedback, {OfflineWithFeedbackProps} from '@components/OfflineWithFeedback'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import Text from '@components/Text'; @@ -16,42 +16,49 @@ import * as Link from '@userActions/Link'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; +type MenuItem = MenuItemProps & {pendingAction?: OfflineWithFeedbackProps['pendingAction']}; + function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; const policyOwner = policy?.owner ?? ''; - const {exporter, exportDate, exportEntity, exportInvoice, exportCompanyCard, errors} = policy?.connections?.quickbooksOnline?.config ?? {}; - const menuItems: MenuItemProps[] = [ + const {exporter, exportDate, exportEntity, exportInvoice, exportCompanyCard, errors, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {}; + const menuItems: MenuItem[] = [ { description: translate('workspace.qbo.preferredExporter'), onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)), brickRoadIndicator: errors?.exporter ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exporter ?? policyOwner, + pendingAction: pendingFields?.exporter, }, { description: translate('workspace.qbo.date'), onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_DATE_SELECT.getRoute(policyID)), brickRoadIndicator: errors?.exportDate ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportDate ? translate(`workspace.qbo.${exportDate}.label`) : undefined, + pendingAction: pendingFields?.exportDate, }, { description: translate('workspace.qbo.exportExpenses'), onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)), brickRoadIndicator: errors?.exportExpenses ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportEntity ? translate(`workspace.qbo.${exportEntity}`) : undefined, + pendingAction: pendingFields?.exportEntity, }, { description: translate('workspace.qbo.exportInvoices'), onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECT.getRoute(policyID)), brickRoadIndicator: errors?.exportInvoice ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportInvoice, + pendingAction: pendingFields?.exportInvoice, }, { description: translate('workspace.qbo.exportCompany'), onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_COMPANY_CARD_EXPENSE_ACCOUNT_SELECT.getRoute(policyID)), brickRoadIndicator: errors?.exportCompanyCard ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportCompanyCard, + pendingAction: pendingFields?.exportCompanyCard, }, { description: translate('workspace.qbo.exportExpensifyCard'), @@ -70,7 +77,10 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { {translate('workspace.qbo.exportDescription')} {menuItems.map((menuItem) => ( - + {!isLocationEnabled && {translate('workspace.qbo.exportOutOfPocketExpensesDescription')}} - + {translate('workspace.qbo.outOfPocketLocationEnabledDescription')}} {!isLocationEnabled && ( - + Date: Thu, 18 Apr 2024 12:26:11 +0300 Subject: [PATCH 204/339] lint --- .../export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx | 3 ++- .../qbo/export/QuickbooksExportConfigurationPage.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index 5395c80f2e8a..ee797f9e4bd9 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -1,5 +1,6 @@ import React, {useCallback, useMemo} from 'react'; -import {SectionListData, View} from 'react-native'; +import {View} from 'react-native'; +import type {SectionListData} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx index 102c09efe1c9..e2f8b3ee3352 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx @@ -2,7 +2,8 @@ import React from 'react'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import type {MenuItemProps} from '@components/MenuItem'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; -import OfflineWithFeedback, {OfflineWithFeedbackProps} from '@components/OfflineWithFeedback'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import type {OfflineWithFeedbackProps} from '@components/OfflineWithFeedback'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import Text from '@components/Text'; From fb4f6daa7e7f885f5c1ac0559151608e59e4bf5b Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Thu, 18 Apr 2024 13:38:02 +0300 Subject: [PATCH 205/339] updates after design review --- src/languages/en.ts | 4 ++-- .../qbo/export/QuickbooksExportConfigurationPage.tsx | 3 ++- .../export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 68ba2b6378a3..979580c4e6d3 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1894,7 +1894,7 @@ export default { exportPreferredExporterSubNote: 'Once set, the preferred exporter will see reports for export in their account.', exportOutOfPocketExpensesDescription: 'Set how out-of-pocket expenses export to QuickBooks Online.', exportVendorBillDescription: - 'We`ll create a single itemized vendor bill for each Expensify report. If the period of the bill is closed, we`ll post to the 1st of the next open period. You can add the vendor bill to your A/P account of choice (below).', + "We'll create a single itemized vendor bill for each Expensify report. If the period of the bill is closed, we'll post to the 1st of the next open period. You can add the vendor bill to your A/P account of choice (below).", check: 'Check', accountsPayable: 'Accounts Payable', accountsPayableDescription: 'This is your chosen A/P account, against which vendor bills for each report are created.', @@ -1906,7 +1906,7 @@ export default { companyCardsLocationEnabledDescription: 'Note: QuickBooks Online does not support a field for Locations as Tags on Vendor Bills exports. As you import Locations from, this this export option is unavailable.', outOfPocketTaxEnabledDescription: - 'Note: QuickBooks Online doesn`t support a field for tax on Journal Entry exports. Because you have tax tracking enabled on your workspace, this export option is unavailable.', + "Note: QuickBooks Online doesn't support a field for tax on Journal Entry exports. Because you have tax tracking enabled on your workspace, this export option is unavailable.", outOfPocketTaxEnabledError: 'Journal entry is not available when taxes enabled. please select a different export option.', outOfPocketLocationEnabledError: 'Vendor Bills are not available when locations are enabled. Please select a different export option.', outOfPocketLocationEnabledDescription: diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx index e2f8b3ee3352..439c5e6cadbb 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx @@ -88,7 +88,8 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { description={menuItem.description} shouldShowRightIcon={menuItem?.shouldShowRightIcon ?? true} onPress={menuItem?.onPress} - brickRoadIndicator={menuItem.brickRoadIndicator} + brickRoadIndicator={menuItem?.brickRoadIndicator} + error={menuItem?.brickRoadIndicator ? translate('common.genericErrorMessage') : undefined} /> ))} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx index 47715388dddb..ab7c5f1816f0 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx @@ -43,9 +43,9 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps /> {exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL && !isLocationEnabled && ( - {translate('workspace.qbo.exportVendorBillDescription')} + {translate('workspace.qbo.exportVendorBillDescription')} )} - {isLocationEnabled && {translate('workspace.qbo.outOfPocketLocationEnabledDescription')}} + {isLocationEnabled && {translate('workspace.qbo.outOfPocketLocationEnabledDescription')}} {!isLocationEnabled && ( Date: Thu, 18 Apr 2024 17:33:31 +0300 Subject: [PATCH 206/339] add wrappers for permission checks --- ...oksCompanyCardExpenseAccountSelectPage.tsx | 43 ++++++---- .../QuickbooksExportConfigurationPage.tsx | 77 ++++++++++-------- .../export/QuickbooksExportDateSelectPage.tsx | 35 +++++--- ...ickbooksExportInvoiceAccountSelectPage.tsx | 37 +++++---- ...oksOutOfPocketExpenseAccountSelectPage.tsx | 37 +++++---- ...oksOutOfPocketExpenseConfigurationPage.tsx | 79 +++++++++++-------- ...ooksOutOfPocketExpenseEntitySelectPage.tsx | 43 ++++++---- ...ooksPreferredExporterConfigurationPage.tsx | 47 ++++++----- 8 files changed, 237 insertions(+), 161 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx index ee797f9e4bd9..05bd303bfa3a 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksCompanyCardExpenseAccountSelectPage.tsx @@ -11,6 +11,8 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; +import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; +import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; @@ -76,22 +78,31 @@ function QuickbooksCompanyCardExpenseAccountSelectPage({policy}: WithPolicyProps ); return ( - - - - {translate('workspace.qbo.exportCompanyCardsDescription')}} - sections={sections} - ListItem={RadioListItem} - onSelectRow={onSelectRow} - initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - footerContent={isLocationEnabled && {translate('workspace.qbo.companyCardsLocationEnabledDescription')}} - /> - - + + + + + + {translate('workspace.qbo.exportCompanyCardsDescription')}} + sections={sections} + ListItem={RadioListItem} + onSelectRow={onSelectRow} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + footerContent={ + isLocationEnabled && {translate('workspace.qbo.companyCardsLocationEnabledDescription')} + } + /> + + + + ); } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx index 439c5e6cadbb..ba87111d8f8a 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx @@ -11,6 +11,8 @@ import TextLink from '@components/TextLink'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@navigation/Navigation'; +import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; +import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import * as Link from '@userActions/Link'; @@ -70,40 +72,47 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { ]; return ( - - - - {translate('workspace.qbo.exportDescription')} - {menuItems.map((menuItem) => ( - - - - ))} - - {`${translate('workspace.qbo.deepDiveExpensifyCard')} `} - Link.openExternalLink(CONST.DEEP_DIVE_EXPENSIFY_CARD)} - style={[styles.mutedNormalTextLabel, styles.link]} - > - {translate('workspace.qbo.deepDiveExpensifyCardIntegration')} - - - - + + + + + + {translate('workspace.qbo.exportDescription')} + {menuItems.map((menuItem) => ( + + + + ))} + + {`${translate('workspace.qbo.deepDiveExpensifyCard')} `} + Link.openExternalLink(CONST.DEEP_DIVE_EXPENSIFY_CARD)} + style={[styles.mutedNormalTextLabel, styles.link]} + > + {translate('workspace.qbo.deepDiveExpensifyCardIntegration')} + + + + + + ); } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx index f3ee8f58a6f0..5db9126f1860 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportDateSelectPage.tsx @@ -10,6 +10,8 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; +import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; +import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; @@ -42,19 +44,26 @@ function QuickbooksExportDateSelectPage({policy}: WithPolicyProps) { ); return ( - - - {translate('workspace.qbo.exportDateDescription')}} - sections={[{data}]} - ListItem={RadioListItem} - onSelectRow={onSelectRow} - initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - /> - + + + + + {translate('workspace.qbo.exportDateDescription')}} + sections={[{data}]} + ListItem={RadioListItem} + onSelectRow={onSelectRow} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + /> + + + ); } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx index 5914ee33fc44..7f41f2af8824 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx @@ -9,6 +9,8 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; +import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; +import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; @@ -57,20 +59,27 @@ function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyProps) { ); return ( - - - {translate('workspace.qbo.exportInvoicesDescription')}} - sections={[{data}]} - ListItem={RadioListItem} - onSelectRow={onSelectRow} - initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - /> - + + + + + {translate('workspace.qbo.exportInvoicesDescription')}} + sections={[{data}]} + ListItem={RadioListItem} + onSelectRow={onSelectRow} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + /> + + + ); } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx index a364b1d173e5..fead7836442b 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx @@ -9,6 +9,8 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; +import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; +import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; @@ -72,20 +74,27 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps ); return ( - - - {translate('workspace.qbo.accountsPayableDescription')}} - sections={[{data}]} - ListItem={RadioListItem} - onSelectRow={onSelectRow} - initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - /> - + + + + + {translate('workspace.qbo.accountsPayableDescription')}} + sections={[{data}]} + ListItem={RadioListItem} + onSelectRow={onSelectRow} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + /> + + + ); } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx index ab7c5f1816f0..f1fe2052913c 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx @@ -8,6 +8,8 @@ import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@navigation/Navigation'; +import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; +import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; @@ -25,41 +27,48 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps const hasErrors = Boolean(errors?.exportEntity) || shouldShowTaxError || shouldShowLocationError; return ( - - - - {!isLocationEnabled && {translate('workspace.qbo.exportOutOfPocketExpensesDescription')}} - - Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.getRoute(policyID))} - brickRoadIndicator={hasErrors ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - shouldShowRightIcon - /> - - {exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL && !isLocationEnabled && ( - {translate('workspace.qbo.exportVendorBillDescription')} - )} - {isLocationEnabled && {translate('workspace.qbo.outOfPocketLocationEnabledDescription')}} - {!isLocationEnabled && ( - - Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.getRoute(policyID))} - brickRoadIndicator={errors?.exportAccount ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - shouldShowRightIcon - error={errors?.exportAccount ? translate('common.genericErrorMessage') : undefined} - /> - - )} - - + + + + + + {!isLocationEnabled && {translate('workspace.qbo.exportOutOfPocketExpensesDescription')}} + + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.getRoute(policyID))} + brickRoadIndicator={hasErrors ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + shouldShowRightIcon + /> + + {exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL && !isLocationEnabled && ( + {translate('workspace.qbo.exportVendorBillDescription')} + )} + {isLocationEnabled && {translate('workspace.qbo.outOfPocketLocationEnabledDescription')}} + {!isLocationEnabled && ( + + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.getRoute(policyID))} + brickRoadIndicator={errors?.exportAccount ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + shouldShowRightIcon + error={errors?.exportAccount ? translate('common.genericErrorMessage') : undefined} + /> + + )} + + + + ); } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx index 9c7c9a84465b..63c96e25bb31 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx @@ -12,6 +12,8 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; import Navigation from '@navigation/Navigation'; +import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; +import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; @@ -80,22 +82,31 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) ); return ( - - - - {translate('workspace.qbo.optionBelow')}} - sections={sections} - ListItem={RadioListItem} - onSelectRow={onSelectRow} - initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - footerContent={isTaxesEnabled && {translate('workspace.qbo.outOfPocketTaxEnabledDescription')}} - /> - - + + + + + + {translate('workspace.qbo.optionBelow')}} + sections={sections} + ListItem={RadioListItem} + onSelectRow={onSelectRow} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + footerContent={ + isTaxesEnabled && {translate('workspace.qbo.outOfPocketTaxEnabledDescription')} + } + /> + + + + ); } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx index 7008822f0e2d..b0bba1a4e7e7 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx @@ -10,6 +10,8 @@ import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; import {getAdminEmailList} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; +import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; +import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; @@ -58,25 +60,32 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { ); return ( - - - - {translate('workspace.qbo.exportPreferredExporterNote')} - {translate('workspace.qbo.exportPreferredExporterSubNote')} - - } - sections={[{data}]} - ListItem={RadioListItem} - onSelectRow={onSelectRow} - initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - /> - + + + + + + {translate('workspace.qbo.exportPreferredExporterNote')} + {translate('workspace.qbo.exportPreferredExporterSubNote')} + + } + sections={[{data}]} + ListItem={RadioListItem} + onSelectRow={onSelectRow} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + /> + + + ); } From dc6a7ac0d8285b5cabd2ffe3cdc7d1792e0c8d28 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 18 Apr 2024 16:42:55 +0100 Subject: [PATCH 207/339] update advanced config accounting routes and navigation types --- src/SCREENS.ts | 6 +++--- .../Navigation/AppNavigator/ModalStackNavigators/index.tsx | 6 +++--- .../Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts | 6 +++--- src/libs/Navigation/linkingConfig/config.ts | 6 +++--- src/libs/Navigation/types.ts | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 91d852136a25..d7835f800603 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -211,6 +211,9 @@ const SCREENS = { QUICKBOOKS_ONLINE_CUSTOMERS: 'Policy_Accounting_Quickbooks_Online_Import_Customers', QUICKBOOKS_ONLINE_LOCATIONS: 'Policy_Accounting_Quickbooks_Online_Import_Locations', QUICKBOOKS_ONLINE_TAXES: 'Policy_Accounting_Quickbooks_Online_Import_Taxes', + QUICKBOOKS_ONLINE_ADVANCED: 'Policy_Accounting_Quickbooks_Online_Advanced', + QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR: 'Policy_Accounting_Quickbooks_Online_Account_Selector', + QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR: 'Policy_Accounting_Quickbooks_Online_Invoice_Account_Selector', }, INITIAL: 'Workspace_Initial', PROFILE: 'Workspace_Profile', @@ -260,9 +263,6 @@ const SCREENS = { OWNER_CHANGE_SUCCESS: 'Workspace_Owner_Change_Success', OWNER_CHANGE_ERROR: 'Workspace_Owner_Change_Error', DISTANCE_RATES: 'Distance_Rates', - QUICKBOOKS_ONLINE_ADVANCED: 'Policy_Accounting_Quickbooks_Online_Advanced', - QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR: 'Policy_Accounting_Quickbooks_Online_Account_Selector', - QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR: 'Policy_Accounting_Quickbooks_Online_Invoice_Account_Selector', CREATE_DISTANCE_RATE: 'Create_Distance_Rate', DISTANCE_RATES_SETTINGS: 'Distance_Rates_Settings', DISTANCE_RATE_DETAILS: 'Distance_Rate_Details', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index e65b3d558042..6d8345f84a56 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -269,9 +269,9 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/qbo/import/QuickbooksTaxesPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_LOCATIONS]: () => require('../../../../pages/workspace/accounting/qbo/import/QuickbooksLocationsPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_CLASSES]: () => require('../../../../pages/workspace/accounting/qbo/import/QuickbooksClassesPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED]: () => require('../../../../pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: () => require('../../../../pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage').default as React.ComponentType, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR]: () => + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_ADVANCED]: () => require('../../../../pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: () => require('../../../../pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR]: () => require('../../../../pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 6d62c976d689..4027d817f4de 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -25,9 +25,9 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_TAXES, SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_LOCATIONS, SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_CUSTOMERS, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR, - SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR, + SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_ADVANCED, + SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR, + SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR, ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 1ca3fc7d567d..38b641168634 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -269,13 +269,13 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_CUSTOMERS]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_CUSTOMERS.route}, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_LOCATIONS]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_LOCATIONS.route}, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_TAXES]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_TAXES.route}, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED]: { + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_ADVANCED]: { path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ADVANCED.route, }, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: { + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: { path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.route, }, - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR]: { + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR]: { path: ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR.route, }, [SCREENS.WORKSPACE.DESCRIPTION]: { diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index d811c445d8a2..1cae7a5410ef 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -704,13 +704,13 @@ type WorkspacesCentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.ROOT]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ADVANCED]: { + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_ADVANCED]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: { + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: { policyID: string; }; - [SCREENS.WORKSPACE.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR]: { + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR]: { policyID: string; }; }; From 47f20923ac31784a6aa6b3d4dd9ae72665f76f50 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 18 Apr 2024 16:44:08 +0100 Subject: [PATCH 208/339] use prettier --- .../Navigation/AppNavigator/ModalStackNavigators/index.tsx | 3 ++- src/libs/Navigation/types.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 6d8345f84a56..341b0fd4fdf9 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -270,7 +270,8 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/qbo/import/QuickbooksLocationsPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_CLASSES]: () => require('../../../../pages/workspace/accounting/qbo/import/QuickbooksClassesPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_ADVANCED]: () => require('../../../../pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage').default as React.ComponentType, - [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: () => require('../../../../pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR]: () => + require('../../../../pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR]: () => require('../../../../pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 1cae7a5410ef..f96ee653b3ab 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -700,7 +700,7 @@ type WorkspacesCentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.DISTANCE_RATES]: { policyID: string; }; - + [SCREENS.WORKSPACE.ACCOUNTING.ROOT]: { policyID: string; }; From 1e7a98a71d587f20a860d2f3e13e2657888f1996 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Thu, 18 Apr 2024 18:45:52 +0300 Subject: [PATCH 209/339] updates after review --- .../UpdatePolicyConnectionConfigParams.ts | 2 +- src/libs/PolicyUtils.ts | 4 +- src/libs/actions/connections/index.ts | 2 +- ...oksCompanyCardExpenseAccountSelectPage.tsx | 8 +- .../QuickbooksExportConfigurationPage.tsx | 89 ++++++++++--------- ...ickbooksExportInvoiceAccountSelectPage.tsx | 6 +- ...oksOutOfPocketExpenseAccountSelectPage.tsx | 6 +- ...oksOutOfPocketExpenseConfigurationPage.tsx | 2 +- ...ooksOutOfPocketExpenseEntitySelectPage.tsx | 5 +- ...ooksPreferredExporterConfigurationPage.tsx | 6 +- src/types/onyx/Policy.ts | 2 +- 11 files changed, 62 insertions(+), 70 deletions(-) diff --git a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts index 32146ec5322f..dd1a2edec089 100644 --- a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts +++ b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts @@ -4,7 +4,7 @@ type UpdatePolicyConnectionConfigParams); } -function getAdminEmailList(policy: Policy | null) { +function getAdminEmailList(policy: Policy | null): Array<{email: string}> { return Object.values(policy?.employeeList ?? {}) - .filter((employee) => employee.role === CONST.POLICY.ROLE.ADMIN) + .filter((employee) => employee.email && employee.role === CONST.POLICY.ROLE.ADMIN) .map((employee) => ({ email: employee.email ?? '', })); diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index dd8234bf8800..72048dc4a60d 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -46,7 +46,7 @@ function updatePolicyConnectionConfig - + - + {translate('workspace.qbo.exportCompanyCardsDescription')}} sections={sections} ListItem={RadioListItem} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx index ba87111d8f8a..4b2bb919b832 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx @@ -34,6 +34,7 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { brickRoadIndicator: errors?.exporter ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exporter ?? policyOwner, pendingAction: pendingFields?.exporter, + errorText: errors?.exporter, }, { description: translate('workspace.qbo.date'), @@ -41,13 +42,15 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { brickRoadIndicator: errors?.exportDate ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportDate ? translate(`workspace.qbo.${exportDate}.label`) : undefined, pendingAction: pendingFields?.exportDate, + errorText: errors?.exportDate, }, { description: translate('workspace.qbo.exportExpenses'), onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES.getRoute(policyID)), - brickRoadIndicator: errors?.exportExpenses ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, + brickRoadIndicator: errors?.exportEntity ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportEntity ? translate(`workspace.qbo.${exportEntity}`) : undefined, pendingAction: pendingFields?.exportEntity, + errorText: errors?.exportEntity, }, { description: translate('workspace.qbo.exportInvoices'), @@ -55,6 +58,7 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { brickRoadIndicator: errors?.exportInvoice ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportInvoice, pendingAction: pendingFields?.exportInvoice, + errorText: errors?.exportInvoice, }, { description: translate('workspace.qbo.exportCompany'), @@ -62,6 +66,7 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { brickRoadIndicator: errors?.exportCompanyCard ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, title: exportCompanyCard, pendingAction: pendingFields?.exportCompanyCard, + errorText: errors?.exportCompanyCard, }, { description: translate('workspace.qbo.exportExpensifyCard'), @@ -72,47 +77,47 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { ]; return ( - - - - - - {translate('workspace.qbo.exportDescription')} - {menuItems.map((menuItem) => ( - - - - ))} - - {`${translate('workspace.qbo.deepDiveExpensifyCard')} `} - Link.openExternalLink(CONST.DEEP_DIVE_EXPENSIFY_CARD)} - style={[styles.mutedNormalTextLabel, styles.link]} - > - {translate('workspace.qbo.deepDiveExpensifyCardIntegration')} - - - - - - + // + // + + + + {translate('workspace.qbo.exportDescription')} + {menuItems.map((menuItem) => ( + + + + ))} + + {`${translate('workspace.qbo.deepDiveExpensifyCard')} `} + Link.openExternalLink(CONST.DEEP_DIVE_EXPENSIFY_CARD)} + style={[styles.mutedNormalTextLabel, styles.link]} + > + {translate('workspace.qbo.deepDiveExpensifyCardIntegration')} + + + + + // + // ); } diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx index 7f41f2af8824..de47ca90527e 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportInvoiceAccountSelectPage.tsx @@ -64,13 +64,9 @@ function QuickbooksExportInvoiceAccountSelectPage({policy}: WithPolicyProps) { policyID={policyID} featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} > - + {translate('workspace.qbo.exportInvoicesDescription')}} sections={[{data}]} ListItem={RadioListItem} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx index fead7836442b..659e42556fcc 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseAccountSelectPage.tsx @@ -79,13 +79,9 @@ function QuickbooksOutOfPocketExpenseAccountSelectPage({policy}: WithPolicyProps policyID={policyID} featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} > - + {translate('workspace.qbo.accountsPayableDescription')}} sections={[{data}]} ListItem={RadioListItem} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx index f1fe2052913c..7232cf890536 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx @@ -61,7 +61,7 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps onPress={() => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.getRoute(policyID))} brickRoadIndicator={errors?.exportAccount ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} shouldShowRightIcon - error={errors?.exportAccount ? translate('common.genericErrorMessage') : undefined} + errorText={errors?.exportAccount} /> )} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx index 63c96e25bb31..ddfe6e9bdecf 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx @@ -39,7 +39,7 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) if (!isTaxError && !isLocationError) { return; } - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY, null); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY); }, [policyID, isTaxError, isLocationError]); const data: CardListItem[] = useMemo( @@ -92,8 +92,9 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) testID={QuickbooksOutOfPocketExpenseEntitySelectPage.displayName} > - + {translate('workspace.qbo.optionBelow')}} sections={sections} ListItem={RadioListItem} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx index b0bba1a4e7e7..38a8b68a222c 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx @@ -65,13 +65,9 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { policyID={policyID} featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} > - + {translate('workspace.qbo.exportPreferredExporterNote')} diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 63d7810d902f..53ac83dfc306 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -157,7 +157,7 @@ type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ syncItems: boolean; markChecksToBePrinted: boolean; reimbursableExpensesExportDestination: IntegrationEntityMap; - nonReimbursableExpensesExportDestination: string; + nonReimbursableExpensesExportDestination: IntegrationEntityMap; reimbursableExpensesAccount?: string; nonReimbursableExpensesAccount?: string; From c9ded6fdb7d5d8ad94e9b254bdbb9ac2d2ec04b0 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Thu, 18 Apr 2024 18:52:24 +0300 Subject: [PATCH 210/339] lint --- .../QuickbooksExportConfigurationPage.tsx | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx index 4b2bb919b832..372319e3095a 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksExportConfigurationPage.tsx @@ -77,47 +77,47 @@ function QuickbooksExportConfigurationPage({policy}: WithPolicyProps) { ]; return ( - // - // - - - - {translate('workspace.qbo.exportDescription')} - {menuItems.map((menuItem) => ( - - - - ))} - - {`${translate('workspace.qbo.deepDiveExpensifyCard')} `} - Link.openExternalLink(CONST.DEEP_DIVE_EXPENSIFY_CARD)} - style={[styles.mutedNormalTextLabel, styles.link]} - > - {translate('workspace.qbo.deepDiveExpensifyCardIntegration')} - - - - - // - // + + + + + + {translate('workspace.qbo.exportDescription')} + {menuItems.map((menuItem) => ( + + + + ))} + + {`${translate('workspace.qbo.deepDiveExpensifyCard')} `} + Link.openExternalLink(CONST.DEEP_DIVE_EXPENSIFY_CARD)} + style={[styles.mutedNormalTextLabel, styles.link]} + > + {translate('workspace.qbo.deepDiveExpensifyCardIntegration')} + + + + + + ); } From fdf28bb89d13f3a130eee0e49bffeae663592af7 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 18 Apr 2024 16:55:15 +0100 Subject: [PATCH 211/339] update connection values --- .../qbo/advanced/QuickbooksAdvancedPage.tsx | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index a4f63d5c06f4..e93ad02d0633 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -8,6 +8,7 @@ import SpacerView from '@components/SpacerView'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import useWaitForNavigation from '@hooks/useWaitForNavigation'; +import * as Connections from '@libs/actions/connections'; import Navigation from '@libs/Navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; @@ -16,7 +17,6 @@ import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import type {ToggleSettingOptionRowProps} from '@pages/workspace/workflows/ToggleSettingsOptionRow'; -import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -35,22 +35,26 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { { title: translate('workspace.qbo.advancedConfig.autoSync'), subtitle: translate('workspace.qbo.advancedConfig.autoSyncDescription'), - isActive: Boolean(autoSync), - onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.AUTO_SYNC, !autoSync), + isActive: Boolean(autoSync?.enabled), + onToggle: () => + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.AUTO_SYNC, { + jobID: autoSync?.jobID ?? '', + enabled: !autoSync?.enabled, + }), pendingAction: pendingFields?.autoSync, }, { title: translate('workspace.qbo.advancedConfig.inviteEmployees'), subtitle: translate('workspace.qbo.advancedConfig.inviteEmployeesDescription'), isActive: Boolean(syncPeople), - onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.SYNCE_PEOPLE, !syncPeople), + onToggle: () => Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.SYNCE_PEOPLE, !syncPeople), pendingAction: pendingFields?.syncPeople, }, { title: translate('workspace.qbo.advancedConfig.createEntities'), subtitle: translate('workspace.qbo.advancedConfig.createEntitiesDescription'), isActive: Boolean(autoCreateVendor), - onToggle: () => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR, !autoCreateVendor), + onToggle: () => Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR, !autoCreateVendor), pendingAction: pendingFields?.autoCreateVendor, }, ]; @@ -100,8 +104,9 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { isActive={Boolean(accountOptions[0]?.id)} // TODO // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing onToggle={() => - Policy.updatePolicyConnectionConfig( + Connections.updatePolicyConnectionConfig( policyID, + CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID || CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, accountOptions[0]?.id, ) @@ -130,7 +135,14 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { wrapperStyle={styles.mv3} pendingAction={pendingFields?.collectionAccountID} isActive={Boolean(invoiceAccountOptions[0]?.id)} // TODO - onToggle={() => Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, invoiceAccountOptions[0]?.id)} + onToggle={() => + Connections.updatePolicyConnectionConfig( + policyID, + CONST.POLICY.CONNECTIONS.NAME.QBO, + CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, + invoiceAccountOptions[0]?.id, + ) + } /> Date: Thu, 18 Apr 2024 17:03:37 +0100 Subject: [PATCH 212/339] remove key in toggle settings --- src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index e6adc6f451c6..071115b32c0e 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -10,8 +10,6 @@ import type {Errors, PendingAction} from '@src/types/onyx/OnyxCommon'; import type IconAsset from '@src/types/utils/IconAsset'; type ToggleSettingOptionRowProps = { - // Key used internally by React - key?: string; /** Icon to be shown for the option */ icon?: IconAsset; /** Title of the option */ @@ -40,7 +38,6 @@ type ToggleSettingOptionRowProps = { const ICON_SIZE = 48; function ToggleSettingOptionRow({ - key, icon, title, subtitle, @@ -63,7 +60,6 @@ function ToggleSettingOptionRow({ return ( Date: Thu, 18 Apr 2024 19:05:00 +0300 Subject: [PATCH 213/339] add more space between items --- .../export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx index 7232cf890536..79f9426a9de8 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx @@ -50,7 +50,7 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps /> {exportEntity === CONST.QUICKBOOKS_EXPORT_ENTITY.VENDOR_BILL && !isLocationEnabled && ( - {translate('workspace.qbo.exportVendorBillDescription')} + {translate('workspace.qbo.exportVendorBillDescription')} )} {isLocationEnabled && {translate('workspace.qbo.outOfPocketLocationEnabledDescription')}} {!isLocationEnabled && ( From 1e3a1e1d7fc8f3652d8f96a9c7606c3fe1cf249f Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 18 Apr 2024 17:10:37 +0100 Subject: [PATCH 214/339] update more connection values --- .../accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx | 4 ++-- .../qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 5449b8f6f905..6b93bebfaaff 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -8,13 +8,13 @@ import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; import Navigation from '@libs/Navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; -import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; type SelectorType = ListItem & { @@ -62,7 +62,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const saveSelection = useCallback( ({value}: SelectorType) => { - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, value); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, value); Navigation.goBack(); }, [policyID], diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 392288861eb5..21864e582774 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -8,13 +8,13 @@ import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; import Navigation from '@libs/Navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; -import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; type SelectorType = ListItem & { @@ -63,7 +63,7 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const updateMode = useCallback( ({value}: SelectorType) => { - Policy.updatePolicyConnectionConfig(policyID, CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, value); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, value); Navigation.goBack(); }, [policyID], From c3fd4b6face86dc3c4b8fbda3887f2b05be2f53f Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 18 Apr 2024 17:19:29 +0100 Subject: [PATCH 215/339] add fallback routes --- .../accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx | 3 ++- .../qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx index 6b93bebfaaff..cf23c98c0895 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAccountSelectPage.tsx @@ -16,6 +16,7 @@ import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccess import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; type SelectorType = ListItem & { value: string; @@ -63,7 +64,7 @@ function QuickbooksAccountSelectPage({policy}: WithPolicyProps) { const saveSelection = useCallback( ({value}: SelectorType) => { Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID, value); - Navigation.goBack(); + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ADVANCED.getRoute(policyID)); }, [policyID], ); diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx index 21864e582774..ecee5fee40bc 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksInvoiceAccountSelectPage.tsx @@ -16,6 +16,7 @@ import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccess import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; type SelectorType = ListItem & { value: string; @@ -64,7 +65,7 @@ function QuickbooksInvoiceAccountSelectPage({policy}: WithPolicyProps) { const updateMode = useCallback( ({value}: SelectorType) => { Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, value); - Navigation.goBack(); + Navigation.goBack(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ADVANCED.getRoute(policyID)); }, [policyID], ); From d9f1a4e50357d643c225af4c7cea0c9bc1dc63c9 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Thu, 18 Apr 2024 20:10:52 +0300 Subject: [PATCH 216/339] updates --- .../API/parameters/UpdatePolicyConnectionConfigParams.ts | 2 +- src/libs/PolicyUtils.ts | 9 +++------ src/libs/actions/connections/index.ts | 2 +- .../QuickbooksOutOfPocketExpenseConfigurationPage.tsx | 2 +- .../QuickbooksOutOfPocketExpenseEntitySelectPage.tsx | 2 +- .../QuickbooksPreferredExporterConfigurationPage.tsx | 4 ++-- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts index dd1a2edec089..75a5f6360a15 100644 --- a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts +++ b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts @@ -4,7 +4,7 @@ type UpdatePolicyConnectionConfigParams); } -function getAdminEmailList(policy: Policy | null): Array<{email: string}> { - return Object.values(policy?.employeeList ?? {}) - .filter((employee) => employee.email && employee.role === CONST.POLICY.ROLE.ADMIN) - .map((employee) => ({ - email: employee.email ?? '', - })); +function getAdminEmailList(policy: Policy | null): PolicyEmployee[] { + return Object.values(policy?.employeeList ?? {}).filter((employee) => employee.email && employee.role === CONST.POLICY.ROLE.ADMIN); } export { diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index 72048dc4a60d..d1c46242ba9e 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -46,7 +46,7 @@ function updatePolicyConnectionConfig Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_SELECT.getRoute(policyID))} brickRoadIndicator={hasErrors ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} shouldShowRightIcon diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx index ddfe6e9bdecf..24713a03860c 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx @@ -39,7 +39,7 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) if (!isTaxError && !isLocationError) { return; } - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY, ''); }, [policyID, isTaxError, isLocationError]); const data: CardListItem[] = useMemo( diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx index 38a8b68a222c..ab31b15ddcba 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx @@ -27,7 +27,7 @@ const draft = [ ]; type CardListItem = ListItem & { - value: string; + value?: string; }; function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { @@ -51,7 +51,7 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { const onSelectRow = useCallback( (row: CardListItem) => { - if (row.value !== exporter) { + if (row.value && row.value !== exporter) { Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.PREFERRED_EXPORTER, row.value); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)); From 6d286da8ec63c9096435199f485d56a8868256d8 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 18 Apr 2024 21:09:23 +0100 Subject: [PATCH 217/339] fix review comments --- .../qbo/advanced/QuickbooksAdvancedPage.tsx | 79 +++++++++---------- 1 file changed, 37 insertions(+), 42 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index e93ad02d0633..c3c50269c5e2 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -1,6 +1,7 @@ import React from 'react'; import {View} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import MenuItem from '@components/MenuItem'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; @@ -26,10 +27,9 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? ''; - const {autoSync, syncPeople, autoCreateVendor, pendingFields} = policy?.connections?.quickbooksOnline?.config ?? {}; - const {bankAccounts, creditCards, otherCurrentAssetAccounts} = policy?.connections?.quickbooksOnline?.data ?? {}; - const accountOptions = [...(bankAccounts ?? []), ...(creditCards ?? [])]; - const invoiceAccountOptions = [...(bankAccounts ?? []), ...(otherCurrentAssetAccounts ?? [])]; + const {autoSync, syncPeople, autoCreateVendor, pendingFields, collectionAccountID} = policy?.connections?.quickbooksOnline?.config ?? {}; + const isSyncReimbursedSwitchOn = Boolean(collectionAccountID !== ''); + const selectedAccount = '92345'; // TODO: use fake selected account temporarily. const qboToggleSettingItems: ToggleSettingOptionRowProps[] = [ { @@ -101,56 +101,51 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { wrapperStyle={styles.mv3} // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing pendingAction={pendingFields?.reimbursementAccountID || pendingFields?.collectionAccountID} - isActive={Boolean(accountOptions[0]?.id)} // TODO + isActive={isSyncReimbursedSwitchOn} // TODO // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing onToggle={() => Connections.updatePolicyConnectionConfig( policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, - CONST.QUICK_BOOKS_CONFIG.REIMBURSEMENT_ACCOUNT_ID || CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, - accountOptions[0]?.id, + CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, + isSyncReimbursedSwitchOn ? '' : selectedAccount, ) } /> - Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.getRoute(policyID)))} - /> + {collectionAccountID && ( + <> + Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.getRoute(policyID)))} + /> - - - + + + - - Connections.updatePolicyConnectionConfig( - policyID, - CONST.POLICY.CONNECTIONS.NAME.QBO, - CONST.QUICK_BOOKS_CONFIG.COLLECTION_ACCOUNT_ID, - invoiceAccountOptions[0]?.id, - ) - } - /> + - Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR.getRoute(policyID)))} - /> + Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR.getRoute(policyID)))} + /> + + )} From 939e20499c11aa9cee5b92e0d82061df6ec03b39 Mon Sep 17 00:00:00 2001 From: Anusha Date: Fri, 19 Apr 2024 07:28:28 +0500 Subject: [PATCH 218/339] enable tooltip for group title --- src/pages/home/HeaderView.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index 7f2bdbf9ed1e..9b2b835792f9 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -202,7 +202,7 @@ function HeaderView({report, personalDetails, parentReport, parentReportAction, const brickRoadIndicator = ReportUtils.hasReportNameError(report) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; const shouldShowBorderBottom = !isTaskReport || !isSmallScreenWidth; const shouldDisableDetailPage = ReportUtils.shouldDisableDetailPage(report); - + const shouldUseGroupTitle = report?.reportName !== '' const isLoading = !report.reportID || !title; return ( @@ -264,7 +264,7 @@ function HeaderView({report, personalDetails, parentReport, parentReportAction, tooltipEnabled numberOfLines={1} textStyles={[styles.headerText, styles.pre]} - shouldUseFullTitle={isChatRoom || isPolicyExpenseChat || isChatThread || isTaskReport || isGroupChat} + shouldUseFullTitle={isChatRoom || isPolicyExpenseChat || isChatThread || isTaskReport || shouldUseGroupTitle} renderAdditionalText={renderAdditionalText} /> {!isEmptyObject(parentNavigationSubtitleData) && ( From 7ca577a8db9f87607b613f15a1985d26f05030f5 Mon Sep 17 00:00:00 2001 From: Anusha Date: Fri, 19 Apr 2024 08:28:52 +0500 Subject: [PATCH 219/339] run prettier --- src/pages/home/HeaderView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index 9b2b835792f9..a0105b36b264 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -202,7 +202,7 @@ function HeaderView({report, personalDetails, parentReport, parentReportAction, const brickRoadIndicator = ReportUtils.hasReportNameError(report) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; const shouldShowBorderBottom = !isTaskReport || !isSmallScreenWidth; const shouldDisableDetailPage = ReportUtils.shouldDisableDetailPage(report); - const shouldUseGroupTitle = report?.reportName !== '' + const shouldUseGroupTitle = report?.reportName !== ''; const isLoading = !report.reportID || !title; return ( From 305d84928bd483e1ab6c7cf83a59797e54f2d4dc Mon Sep 17 00:00:00 2001 From: narefyev91 Date: Fri, 19 Apr 2024 09:38:51 +0300 Subject: [PATCH 220/339] Update src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> --- .../qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx index ab31b15ddcba..b95f9d56f2dd 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx @@ -51,7 +51,7 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { const onSelectRow = useCallback( (row: CardListItem) => { - if (row.value && row.value !== exporter) { + if (row.value !== exporter) { Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.PREFERRED_EXPORTER, row.value); } Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_PREFERRED_EXPORTER.getRoute(policyID)); From 756066376d32e41a42af1eceedca01471256e7d1 Mon Sep 17 00:00:00 2001 From: narefyev91 Date: Fri, 19 Apr 2024 09:39:01 +0300 Subject: [PATCH 221/339] Update src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> --- ...kbooksPreferredExporterConfigurationPage.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx index b95f9d56f2dd..b982809c82fc 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx @@ -40,12 +40,17 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { const policyID = policy?.id ?? ''; const data: CardListItem[] = useMemo( () => - result?.map((vendor) => ({ - value: vendor.email, - text: vendor.email, - keyForList: vendor.email, - isSelected: exporter === vendor.email, - })) ?? [], + result.reduce((vendors, vendor) => { + if (vendor.email) { + vendors.push({ + value: vendor.email, + text: vendor.email, + keyForList: vendor.email, + isSelected: exporter === vendor.email, + }); + } + return vendors; + }, []), [result, exporter], ); From 04166d60e6917a8e0f10a30bbdbb0f920f3e5e7a Mon Sep 17 00:00:00 2001 From: narefyev91 Date: Fri, 19 Apr 2024 09:39:14 +0300 Subject: [PATCH 222/339] Update src/libs/PolicyUtils.ts Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> --- src/libs/PolicyUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 59c711aefaf1..698b557a80a0 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -320,7 +320,7 @@ function getPolicyIDFromNavigationState() { } function getAdminEmailList(policy: Policy | null): PolicyEmployee[] { - return Object.values(policy?.employeeList ?? {}).filter((employee) => employee.email && employee.role === CONST.POLICY.ROLE.ADMIN); + return Object.values(policy?.employeeList ?? {}).filter((employee) => employee.role === CONST.POLICY.ROLE.ADMIN); } export { From 7866e3c30446de3696232735b56d3b39b0bc6d7d Mon Sep 17 00:00:00 2001 From: narefyev91 Date: Fri, 19 Apr 2024 09:39:26 +0300 Subject: [PATCH 223/339] Update src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> --- .../qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx index b982809c82fc..2b7f05f8cf64 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx @@ -27,7 +27,7 @@ const draft = [ ]; type CardListItem = ListItem & { - value?: string; + value: string; }; function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { From df7fa2bf80e11bfa377cc6713486859355791633 Mon Sep 17 00:00:00 2001 From: narefyev91 Date: Fri, 19 Apr 2024 09:39:33 +0300 Subject: [PATCH 224/339] Update src/libs/PolicyUtils.ts Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> --- src/libs/PolicyUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 698b557a80a0..56c907e6a7b5 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -319,7 +319,7 @@ function getPolicyIDFromNavigationState() { return getPolicyIDFromState(navigationRef.getRootState() as State); } -function getAdminEmailList(policy: Policy | null): PolicyEmployee[] { +function getAdminEmployees(policy: OnyxEntry): PolicyEmployee[] { return Object.values(policy?.employeeList ?? {}).filter((employee) => employee.role === CONST.POLICY.ROLE.ADMIN); } From 96c66d8efd4db3d301547402e563d9918154c6e2 Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Fri, 19 Apr 2024 10:01:17 +0300 Subject: [PATCH 225/339] updates --- src/libs/PolicyUtils.ts | 2 +- .../export/QuickbooksPreferredExporterConfigurationPage.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 56c907e6a7b5..ac2b8b10ce6d 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -362,7 +362,7 @@ export { getTaxByID, hasPolicyCategoriesError, getPolicyIDFromNavigationState, - getAdminEmailList, + getAdminEmployees, }; export type {MemberEmailsToAccountIDs}; diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx index 2b7f05f8cf64..5bad9caca706 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksPreferredExporterConfigurationPage.tsx @@ -8,7 +8,7 @@ import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; -import {getAdminEmailList} from '@libs/PolicyUtils'; +import {getAdminEmployees} from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper'; import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper'; @@ -34,7 +34,7 @@ function QuickBooksExportPreferredExporterPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const {exporter} = policy?.connections?.quickbooksOnline?.config ?? {}; - const exporters = getAdminEmailList(policy); + const exporters = getAdminEmployees(policy); const result = exporters?.length ? exporters : draft; const policyID = policy?.id ?? ''; From 03f5bfe8178356e9b9bd254844342e86d49ae65c Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 19 Apr 2024 08:26:37 +0100 Subject: [PATCH 226/339] update pendingAction and isActive --- .../accounting/qbo/advanced/QuickbooksAdvancedPage.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index c3c50269c5e2..10ad79889e8b 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -27,8 +27,8 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? ''; - const {autoSync, syncPeople, autoCreateVendor, pendingFields, collectionAccountID} = policy?.connections?.quickbooksOnline?.config ?? {}; - const isSyncReimbursedSwitchOn = Boolean(collectionAccountID !== ''); + const {autoSync, syncPeople, autoCreateVendor, pendingFields, collectionAccountID, errors} = policy?.connections?.quickbooksOnline?.config ?? {}; + const isSyncReimbursedSwitchOn = !!collectionAccountID; const selectedAccount = '92345'; // TODO: use fake selected account temporarily. const qboToggleSettingItems: ToggleSettingOptionRowProps[] = [ @@ -99,10 +99,8 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { subtitle={translate('workspace.qbo.advancedConfig.reimbursedReportsDescription')} shouldPlaceSubtitleBelowSwitch wrapperStyle={styles.mv3} - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - pendingAction={pendingFields?.reimbursementAccountID || pendingFields?.collectionAccountID} - isActive={isSyncReimbursedSwitchOn} // TODO - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + pendingAction={pendingFields?.collectionAccountID} + isActive={isSyncReimbursedSwitchOn} onToggle={() => Connections.updatePolicyConnectionConfig( policyID, From fee6469a7804ac054c77241183ee84d1e7bae808 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 19 Apr 2024 08:40:18 +0100 Subject: [PATCH 227/339] add offline with feedback, brickroadIndicator and errorText --- .../qbo/advanced/QuickbooksAdvancedPage.tsx | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index 10ad79889e8b..248ee6c3602a 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -3,6 +3,7 @@ import {View} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import MenuItem from '@components/MenuItem'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import SpacerView from '@components/SpacerView'; @@ -113,13 +114,17 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { {collectionAccountID && ( <> - Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.getRoute(policyID)))} - /> + + Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_ACCOUNT_SELECTOR.getRoute(policyID)))} + errorText={errors?.collectionAccountID} + brickRoadIndicator={errors?.collectionAccountID ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + /> + - Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR.getRoute(policyID)))} - /> + + Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_ONLINE_INVOICE_ACCOUNT_SELECTOR.getRoute(policyID)))} + errorText={errors?.collectionAccountID} + brickRoadIndicator={errors?.collectionAccountID ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + /> + )} From bb18bf8dd2b1a68b706c903ed751650336d7fc47 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 19 Apr 2024 08:51:08 +0100 Subject: [PATCH 228/339] update updatePolicyConnectionConfig types and stringify autosync --- .../parameters/UpdatePolicyConnectionConfigParams.ts | 8 ++++---- src/libs/actions/connections/index.ts | 10 +++++----- .../qbo/advanced/QuickbooksAdvancedPage.tsx | 12 ++++++++---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts index c720fe0059c1..34d7a9ddd628 100644 --- a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts +++ b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts @@ -2,10 +2,10 @@ import type {ConnectionName, Connections} from '@src/types/onyx/Policy'; type UpdatePolicyConnectionConfigParams = { policyID: string; - connectionName: TConnectionName; - settingName: TSettingName; - settingValue: Connections[TConnectionName]['config'][TSettingName]; - idempotencyKey: string; + connectionName: string; + settingName: string; + settingValue: string | boolean; + idempotencyKey: string ; }; export default UpdatePolicyConnectionConfigParams; diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index 154036ba70e1..f54e5c2b7ba8 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -42,11 +42,11 @@ function removePolicyConnection(policyID: string, connectionName: PolicyConnecti }; API.write(WRITE_COMMANDS.REMOVE_POLICY_CONNECTION, parameters, {optimisticData, failureData}); } -function updatePolicyConnectionConfig( +function updatePolicyConnectionConfig( policyID: string, - connectionName: TConnectionName, - settingName: TSettingName, - settingValue: Connections[TConnectionName]['config'][TSettingName], + connectionName: string, + settingName: string, + settingValue: Partial, ) { const optimisticData: OnyxUpdate[] = [ { @@ -114,7 +114,7 @@ function updatePolicyConnectionConfig = { + const parameters = { policyID, connectionName, settingName, diff --git a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx index 248ee6c3602a..04c0dd234478 100644 --- a/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx +++ b/src/pages/workspace/accounting/qbo/advanced/QuickbooksAdvancedPage.tsx @@ -38,10 +38,14 @@ function QuickbooksAdvancedPage({policy}: WithPolicyProps) { subtitle: translate('workspace.qbo.advancedConfig.autoSyncDescription'), isActive: Boolean(autoSync?.enabled), onToggle: () => - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.AUTO_SYNC, { - jobID: autoSync?.jobID ?? '', - enabled: !autoSync?.enabled, - }), + Connections.updatePolicyConnectionConfig( + policyID, + CONST.POLICY.CONNECTIONS.NAME.QBO, + CONST.QUICK_BOOKS_CONFIG.AUTO_SYNC, + JSON.stringify({ + enabled: !autoSync?.enabled, + }), + ), pendingAction: pendingFields?.autoSync, }, { From 6e9e3112bcd5b1d497714602554ec5d96a1afe7f Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 19 Apr 2024 08:53:51 +0100 Subject: [PATCH 229/339] fix lint --- .../parameters/UpdatePolicyConnectionConfigParams.ts | 6 ++---- src/libs/actions/connections/index.ts | 11 +++-------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts index 34d7a9ddd628..0e5475f1a27d 100644 --- a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts +++ b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts @@ -1,11 +1,9 @@ -import type {ConnectionName, Connections} from '@src/types/onyx/Policy'; - -type UpdatePolicyConnectionConfigParams = { +type UpdatePolicyConnectionConfigParams = { policyID: string; connectionName: string; settingName: string; settingValue: string | boolean; - idempotencyKey: string ; + idempotencyKey: string; }; export default UpdatePolicyConnectionConfigParams; diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index f54e5c2b7ba8..d4b3a3ded722 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -1,12 +1,12 @@ import Onyx from 'react-native-onyx'; import type {OnyxUpdate} from 'react-native-onyx'; import * as API from '@libs/API'; -import type {RemovePolicyConnectionParams, UpdatePolicyConnectionConfigParams} from '@libs/API/parameters'; +import type {RemovePolicyConnectionParams} from '@libs/API/parameters'; import {WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {ConnectionName, Connections, PolicyConnectionName} from '@src/types/onyx/Policy'; +import type {PolicyConnectionName} from '@src/types/onyx/Policy'; function removePolicyConnection(policyID: string, connectionName: PolicyConnectionName) { const optimisticData: OnyxUpdate[] = [ @@ -42,12 +42,7 @@ function removePolicyConnection(policyID: string, connectionName: PolicyConnecti }; API.write(WRITE_COMMANDS.REMOVE_POLICY_CONNECTION, parameters, {optimisticData, failureData}); } -function updatePolicyConnectionConfig( - policyID: string, - connectionName: string, - settingName: string, - settingValue: Partial, -) { +function updatePolicyConnectionConfig(policyID: string, connectionName: string, settingName: string, settingValue: Partial) { const optimisticData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, From adf5dff12331caa732551f12d2b3dc703c4842b9 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 19 Apr 2024 09:00:04 +0100 Subject: [PATCH 230/339] fix tsc --- src/libs/API/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index f91b694548ba..e84bbf2d5926 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -412,7 +412,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.SET_POLICY_DISTANCE_RATES_DEFAULT_CATEGORY]: Parameters.SetPolicyDistanceRatesDefaultCategoryParams; // eslint-disable-next-line @typescript-eslint/no-explicit-any - [WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG]: Parameters.UpdatePolicyConnectionConfigParams; + [WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG]: Parameters.UpdatePolicyConnectionConfigParams; [WRITE_COMMANDS.REMOVE_POLICY_CONNECTION]: Parameters.RemovePolicyConnectionParams; [WRITE_COMMANDS.UPDATE_POLICY_DISTANCE_RATE_VALUE]: Parameters.UpdatePolicyDistanceRateValueParams; [WRITE_COMMANDS.SET_POLICY_DISTANCE_RATES_ENABLED]: Parameters.SetPolicyDistanceRatesEnabledParams; From 21db4523919b0dab2221a3276c6361ca6ed4c8ba Mon Sep 17 00:00:00 2001 From: Nicolay Arefyeu Date: Fri, 19 Apr 2024 11:41:11 +0300 Subject: [PATCH 231/339] update api usage --- .../API/parameters/UpdatePolicyConnectionConfigParams.ts | 2 +- src/libs/actions/connections/index.ts | 8 ++++---- .../qbo/export/QuickbooksExportConfigurationPage.tsx | 4 +++- .../QuickbooksOutOfPocketExpenseConfigurationPage.tsx | 4 +++- .../QuickbooksOutOfPocketExpenseEntitySelectPage.tsx | 2 +- src/types/onyx/Policy.ts | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts index 75a5f6360a15..dd1a2edec089 100644 --- a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts +++ b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts @@ -4,7 +4,7 @@ type UpdatePolicyConnectionConfigParams ))} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx index 44aa7aea243e..ffa0699f9b76 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseConfigurationPage.tsx @@ -61,7 +61,9 @@ function QuickbooksOutOfPocketExpenseConfigurationPage({policy}: WithPolicyProps onPress={() => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_ONLINE_EXPORT_OUT_OF_POCKET_EXPENSES_ACCOUNT_SELECT.getRoute(policyID))} brickRoadIndicator={errors?.exportAccount ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} shouldShowRightIcon - errorText={errors?.exportAccount} + error={errors?.exportAccount ? translate('common.genericErrorMessage') : undefined} + // TODO uncomment when errorText will be fixed + // errorText={errors?.exportAccount} /> )} diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx index 24713a03860c..ddfe6e9bdecf 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx @@ -39,7 +39,7 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) if (!isTaxError && !isLocationError) { return; } - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY, ''); + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.QBO, CONST.QUICK_BOOKS_CONFIG.EXPORT_ENTITY); }, [policyID, isTaxError, isLocationError]); const data: CardListItem[] = useMemo( diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 53ac83dfc306..4071625c683d 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -177,7 +177,7 @@ type QBOConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ outOfPocketExpenses: string; exportInvoice: string; exportAccount: string; - exportEntity: ValueOf; + exportEntity?: ValueOf; exportCompanyCard: string; errorFields?: OnyxCommon.ErrorFields; }>; From 78d8049af319bdd01e535144c4540eed5a237b41 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 19 Apr 2024 15:56:45 +0700 Subject: [PATCH 232/339] fix: full screen not found page --- ios/Podfile.lock | 10 +++++----- .../AdminPolicyAccessOrNotFoundWrapper.tsx | 14 +++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index f564bfd931e4..85a42f745b6a 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1835,7 +1835,7 @@ PODS: - RNGoogleSignin (10.0.1): - GoogleSignIn (~> 7.0) - React-Core - - RNLiveMarkdown (0.1.62): + - RNLiveMarkdown (0.1.47): - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -1853,9 +1853,9 @@ PODS: - React-utils - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNLiveMarkdown/common (= 0.1.62) + - RNLiveMarkdown/common (= 0.1.47) - Yoga - - RNLiveMarkdown/common (0.1.62): + - RNLiveMarkdown/common (0.1.47): - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -2564,7 +2564,7 @@ SPEC CHECKSUMS: RNFS: 4ac0f0ea233904cb798630b3c077808c06931688 RNGestureHandler: 1190c218cdaaf029ee1437076a3fbbc3297d89fb RNGoogleSignin: ccaa4a81582cf713eea562c5dd9dc1961a715fd0 - RNLiveMarkdown: 47dfb50244f9ba1caefbc0efc6404ba41bf6620a + RNLiveMarkdown: f172c7199283dc9d21bccf7e21ea10741fd19e1d RNLocalize: d4b8af4e442d4bcca54e68fc687a2129b4d71a81 rnmapbox-maps: 3e273e0e867a079ec33df9ee33bb0482434b897d RNPermissions: 8990fc2c10da3640938e6db1647cb6416095b729 @@ -2585,4 +2585,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: a25a81f2b50270f0c0bd0aff2e2ebe4d0b4ec06d -COCOAPODS: 1.13.0 +COCOAPODS: 1.14.3 diff --git a/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx b/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx index 5723595b7141..1fc4b51aca21 100644 --- a/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx +++ b/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx @@ -4,6 +4,7 @@ import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; +import ScreenWrapper from '@components/ScreenWrapper'; import Navigation from '@libs/Navigation/Navigation'; import * as PolicyUtils from '@libs/PolicyUtils'; import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; @@ -55,11 +56,13 @@ function AdminPolicyAccessOrNotFoundComponent(props: AdminPolicyAccessOrNotFound if (isPolicyNotAccessible) { return ( - Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} - /> + + Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} + /> + ); } return Navigation.goBack(ROUTES.WORKSPACE_PROFILE.getRoute(props.policyID))} />; @@ -67,6 +70,7 @@ function AdminPolicyAccessOrNotFoundComponent(props: AdminPolicyAccessOrNotFound return typeof props.children === 'function' ? props.children(props) : props.children; } +AdminPolicyAccessOrNotFoundComponent.displayName = 'AdminPolicyAccessOrNotFoundComponent'; export default withOnyx({ policy: { From 76f33631147b9ab189205bf2ee402cf3fe7e8795 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 19 Apr 2024 15:57:35 +0700 Subject: [PATCH 233/339] Revert "fix: full screen not found page" This reverts commit 78d8049af319bdd01e535144c4540eed5a237b41. --- ios/Podfile.lock | 10 +++++----- .../AdminPolicyAccessOrNotFoundWrapper.tsx | 14 +++++--------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 85a42f745b6a..f564bfd931e4 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1835,7 +1835,7 @@ PODS: - RNGoogleSignin (10.0.1): - GoogleSignIn (~> 7.0) - React-Core - - RNLiveMarkdown (0.1.47): + - RNLiveMarkdown (0.1.62): - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -1853,9 +1853,9 @@ PODS: - React-utils - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNLiveMarkdown/common (= 0.1.47) + - RNLiveMarkdown/common (= 0.1.62) - Yoga - - RNLiveMarkdown/common (0.1.47): + - RNLiveMarkdown/common (0.1.62): - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -2564,7 +2564,7 @@ SPEC CHECKSUMS: RNFS: 4ac0f0ea233904cb798630b3c077808c06931688 RNGestureHandler: 1190c218cdaaf029ee1437076a3fbbc3297d89fb RNGoogleSignin: ccaa4a81582cf713eea562c5dd9dc1961a715fd0 - RNLiveMarkdown: f172c7199283dc9d21bccf7e21ea10741fd19e1d + RNLiveMarkdown: 47dfb50244f9ba1caefbc0efc6404ba41bf6620a RNLocalize: d4b8af4e442d4bcca54e68fc687a2129b4d71a81 rnmapbox-maps: 3e273e0e867a079ec33df9ee33bb0482434b897d RNPermissions: 8990fc2c10da3640938e6db1647cb6416095b729 @@ -2585,4 +2585,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: a25a81f2b50270f0c0bd0aff2e2ebe4d0b4ec06d -COCOAPODS: 1.14.3 +COCOAPODS: 1.13.0 diff --git a/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx b/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx index 1fc4b51aca21..5723595b7141 100644 --- a/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx +++ b/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx @@ -4,7 +4,6 @@ import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; -import ScreenWrapper from '@components/ScreenWrapper'; import Navigation from '@libs/Navigation/Navigation'; import * as PolicyUtils from '@libs/PolicyUtils'; import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; @@ -56,13 +55,11 @@ function AdminPolicyAccessOrNotFoundComponent(props: AdminPolicyAccessOrNotFound if (isPolicyNotAccessible) { return ( - - Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} - /> - + Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} + /> ); } return Navigation.goBack(ROUTES.WORKSPACE_PROFILE.getRoute(props.policyID))} />; @@ -70,7 +67,6 @@ function AdminPolicyAccessOrNotFoundComponent(props: AdminPolicyAccessOrNotFound return typeof props.children === 'function' ? props.children(props) : props.children; } -AdminPolicyAccessOrNotFoundComponent.displayName = 'AdminPolicyAccessOrNotFoundComponent'; export default withOnyx({ policy: { From 68f258f3a064814ba8445cd9f7ee63da670dbb9b Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 19 Apr 2024 15:58:09 +0700 Subject: [PATCH 234/339] fix: full screen not found page --- .../AdminPolicyAccessOrNotFoundWrapper.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx b/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx index 5723595b7141..1fc4b51aca21 100644 --- a/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx +++ b/src/pages/workspace/AdminPolicyAccessOrNotFoundWrapper.tsx @@ -4,6 +4,7 @@ import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; +import ScreenWrapper from '@components/ScreenWrapper'; import Navigation from '@libs/Navigation/Navigation'; import * as PolicyUtils from '@libs/PolicyUtils'; import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; @@ -55,11 +56,13 @@ function AdminPolicyAccessOrNotFoundComponent(props: AdminPolicyAccessOrNotFound if (isPolicyNotAccessible) { return ( - Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} - /> + + Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} + /> + ); } return Navigation.goBack(ROUTES.WORKSPACE_PROFILE.getRoute(props.policyID))} />; @@ -67,6 +70,7 @@ function AdminPolicyAccessOrNotFoundComponent(props: AdminPolicyAccessOrNotFound return typeof props.children === 'function' ? props.children(props) : props.children; } +AdminPolicyAccessOrNotFoundComponent.displayName = 'AdminPolicyAccessOrNotFoundComponent'; export default withOnyx({ policy: { From fb442ddc130631b9aed553793f96481f9e1fb71a Mon Sep 17 00:00:00 2001 From: Riya Shete <156463907+codinggeek2023@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:41:27 +0530 Subject: [PATCH 235/339] Update ReceiptDropUI.tsx --- src/pages/iou/ReceiptDropUI.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/ReceiptDropUI.tsx b/src/pages/iou/ReceiptDropUI.tsx index f1f25f80bc57..76479a55412e 100644 --- a/src/pages/iou/ReceiptDropUI.tsx +++ b/src/pages/iou/ReceiptDropUI.tsx @@ -22,7 +22,7 @@ function ReceiptDropUI({onDrop, receiptImageTopPosition = 0}: ReceiptDropUIProps return ( - + Date: Fri, 19 Apr 2024 18:24:09 +0800 Subject: [PATCH 236/339] turn off prefer underscore lint back --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.js b/.eslintrc.js index 320289fb95d9..4df9493b2e8c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -238,6 +238,7 @@ module.exports = { 'jsdoc/no-types': 'error', 'rulesdir/no-default-props': 'error', 'import/no-extraneous-dependencies': 'off', + 'rulesdir/prefer-underscore-method': 'off', 'rulesdir/prefer-import-module-contents': 'off', 'react/require-default-props': 'off', 'react/prop-types': 'off', From 880ef459545cc3321f916a5d13e3e8dcd9f8900a Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 19 Apr 2024 18:26:40 +0800 Subject: [PATCH 237/339] add back underscore --- tests/unit/CIGitLogicTest.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/CIGitLogicTest.sh b/tests/unit/CIGitLogicTest.sh index ba26fcd45467..73fd01f5c0a0 100755 --- a/tests/unit/CIGitLogicTest.sh +++ b/tests/unit/CIGitLogicTest.sh @@ -42,6 +42,7 @@ function init_git_server { setup_git_as_human npm init -y npm version --no-git-tag-version 1.0.0-0 + npm install underscore echo "node_modules/" >> .gitignore git add -A git commit -m "Initial commit" From 99760ff57b85d401391d8d5a801587454e1e30b0 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 19 Apr 2024 18:41:48 +0800 Subject: [PATCH 238/339] prettier --- .../MoneyTemporaryForRefactorRequestParticipantsSelector.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js index adde23a22a2f..9cfa4ba2ac5a 100644 --- a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js +++ b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js @@ -1,11 +1,11 @@ +import lodashEvery from 'lodash/every'; import lodashGet from 'lodash/get'; import lodashIsEqual from 'lodash/isEqual'; import lodashMap from 'lodash/map'; import lodashPick from 'lodash/pick'; import lodashReject from 'lodash/reject'; -import lodashValues from 'lodash/values'; import lodashSome from 'lodash/some'; -import lodashEvery from 'lodash/every'; +import lodashValues from 'lodash/values'; import PropTypes from 'prop-types'; import React, {memo, useCallback, useEffect, useMemo} from 'react'; import {useOnyx} from 'react-native-onyx'; From e07ee7d81b7e15137713dd6633e81f5db93624a8 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 19 Apr 2024 17:51:46 +0700 Subject: [PATCH 239/339] fix: add failure data to track expense --- src/libs/actions/IOU.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index b7141545409f..585594af2178 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1056,6 +1056,12 @@ function buildOnyxDataForTrackExpense( const failureData: OnyxUpdate[] = []; + failureData.push({ + onyxMethod: Onyx.METHOD.SET, + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + value: quickAction, + }); + if (iouReport) { failureData.push( { From 3de0402353f29f5ac6e3a7dd5d22205c6d85b9bf Mon Sep 17 00:00:00 2001 From: Riya Shete <156463907+codinggeek2023@users.noreply.github.com> Date: Fri, 19 Apr 2024 17:12:35 +0530 Subject: [PATCH 240/339] Update index.tsx --- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 8bca59b11580..b95d91cbb571 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -486,7 +486,9 @@ function IOURequestStepScan({ const desktopUploadView = () => ( <> - setReceiptImageTopPosition(PixelRatio.roundToNearestPixel(nativeEvent.layout.y))}> + setReceiptImageTopPosition(PixelRatio.roundToNearestPixel(nativeEvent.layout.top))}> Date: Fri, 19 Apr 2024 17:12:58 +0530 Subject: [PATCH 241/339] Update ReceiptDropUI.tsx --- src/pages/iou/ReceiptDropUI.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/ReceiptDropUI.tsx b/src/pages/iou/ReceiptDropUI.tsx index 76479a55412e..f1f25f80bc57 100644 --- a/src/pages/iou/ReceiptDropUI.tsx +++ b/src/pages/iou/ReceiptDropUI.tsx @@ -22,7 +22,7 @@ function ReceiptDropUI({onDrop, receiptImageTopPosition = 0}: ReceiptDropUIProps return ( - + Date: Fri, 19 Apr 2024 17:22:21 +0530 Subject: [PATCH 242/339] Update index.tsx From c678929813d0d93886fab63028afec020ed466af Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 19 Apr 2024 14:06:42 +0200 Subject: [PATCH 243/339] Check didScreenTransitionEnd in BaseSelectionList --- src/components/SelectionList/BaseSelectionList.tsx | 4 +++- tests/perf-test/SelectionList.perf-test.tsx | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/SelectionList/BaseSelectionList.tsx b/src/components/SelectionList/BaseSelectionList.tsx index 9ab89aa73f86..c8b898021592 100644 --- a/src/components/SelectionList/BaseSelectionList.tsx +++ b/src/components/SelectionList/BaseSelectionList.tsx @@ -20,6 +20,7 @@ import useKeyboardShortcut from '@hooks/useKeyboardShortcut'; import useKeyboardState from '@hooks/useKeyboardState'; import useLocalize from '@hooks/useLocalize'; import usePrevious from '@hooks/usePrevious'; +import useScreenWrapperTranstionStatus from '@hooks/useScreenWrapperTransitionStatus'; import useThemeStyles from '@hooks/useThemeStyles'; import getSectionsWithIndexOffset from '@libs/getSectionsWithIndexOffset'; import Log from '@libs/Log'; @@ -94,6 +95,7 @@ function BaseSelectionList( const itemFocusTimeoutRef = useRef(null); const [currentPage, setCurrentPage] = useState(1); const isTextInputFocusedRef = useRef(false); + const {didScreenTransitionEnd} = useScreenWrapperTranstionStatus(); const incrementPage = () => setCurrentPage((prev) => prev + 1); @@ -356,7 +358,7 @@ function BaseSelectionList( keyForList={item.keyForList ?? ''} isMultilineSupported={isRowMultilineSupported} onFocus={() => setFocusedIndex(normalizedIndex)} - shouldSyncFocus={!isTextInputFocusedRef.current} + shouldSyncFocus={!isTextInputFocusedRef.current && didScreenTransitionEnd} /> ); }; diff --git a/tests/perf-test/SelectionList.perf-test.tsx b/tests/perf-test/SelectionList.perf-test.tsx index a29b66d680b0..07a9a4d6ce22 100644 --- a/tests/perf-test/SelectionList.perf-test.tsx +++ b/tests/perf-test/SelectionList.perf-test.tsx @@ -57,6 +57,10 @@ jest.mock('@components/withKeyboardState', () => ({ + useCardAnimation: () => {}, +})); + jest.mock('@react-navigation/native', () => ({ useFocusEffect: () => {}, useIsFocused: () => true, From 78fac915cbf3012bbda5670548fc983da87eafe1 Mon Sep 17 00:00:00 2001 From: Riya Shete Date: Fri, 19 Apr 2024 17:38:04 +0530 Subject: [PATCH 244/339] Fix lint --- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index b95d91cbb571..46b16822cb93 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -486,9 +486,10 @@ function IOURequestStepScan({ const desktopUploadView = () => ( <> - setReceiptImageTopPosition(PixelRatio.roundToNearestPixel(nativeEvent.layout.top))}> + setReceiptImageTopPosition(PixelRatio.roundToNearestPixel(nativeEvent.layout.top))} + > Date: Fri, 19 Apr 2024 16:32:38 +0300 Subject: [PATCH 245/339] updates --- .../export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx index ddfe6e9bdecf..ee191a9575ca 100644 --- a/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx +++ b/src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocketExpenseEntitySelectPage.tsx @@ -100,9 +100,7 @@ function QuickbooksOutOfPocketExpenseEntitySelectPage({policy}: WithPolicyProps) ListItem={RadioListItem} onSelectRow={onSelectRow} initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} - footerContent={ - isTaxesEnabled && {translate('workspace.qbo.outOfPocketTaxEnabledDescription')} - } + footerContent={isTaxesEnabled && {translate('workspace.qbo.outOfPocketTaxEnabledDescription')}} /> From ad215c4622d59e7df5db0761ad6ba084122439e5 Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Fri, 19 Apr 2024 20:36:05 +0530 Subject: [PATCH 246/339] Changed route related to money request --- .well-known/apple-app-site-association | 8 +++ android/app/src/main/AndroidManifest.xml | 4 ++ src/CONST.ts | 6 +- src/ROUTES.ts | 17 ++--- src/components/AttachmentModal.tsx | 2 +- .../MoneyRequestConfirmationList.tsx | 16 ++--- .../ReportActionItem/MoneyRequestView.tsx | 20 +++--- src/components/ReportWelcomeText.tsx | 8 +-- src/languages/en.ts | 7 +- src/languages/es.ts | 7 +- src/libs/IOUUtils.ts | 16 ++++- src/libs/MoneyRequestUtils.ts | 2 +- src/libs/Navigation/Navigation.ts | 4 +- src/libs/Navigation/types.ts | 18 ++--- src/libs/Permissions.ts | 2 +- src/libs/ReportUtils.ts | 29 ++++++-- src/libs/actions/IOU.ts | 4 +- .../AttachmentPickerWithMenuItems.tsx | 16 ++--- src/pages/home/report/ReportActionItem.tsx | 2 +- .../FloatingActionButtonAndPopover.tsx | 20 +++--- src/pages/iou/request/IOURequestStartPage.tsx | 6 +- ...yForRefactorRequestParticipantsSelector.js | 14 ++-- .../iou/request/step/IOURequestStepAmount.tsx | 36 ++++++++-- .../step/IOURequestStepConfirmation.tsx | 14 ++-- .../iou/request/step/IOURequestStepDate.tsx | 2 +- .../request/step/IOURequestStepDistance.tsx | 49 +++++++++++-- .../step/IOURequestStepParticipants.tsx | 23 ++---- .../step/IOURequestStepRoutePropTypes.js | 29 -------- .../step/IOURequestStepScan/index.native.tsx | 48 +++++++++++-- .../request/step/IOURequestStepScan/index.tsx | 48 +++++++++++-- .../iou/steps/MoneyRequestAmountForm.tsx | 4 +- tests/perf-test/ReportUtils.perf-test.ts | 2 +- tests/unit/IOUUtilsTest.ts | 9 +-- tests/unit/ReportUtilsTest.ts | 70 +++++++++---------- 34 files changed, 352 insertions(+), 210 deletions(-) delete mode 100644 src/pages/iou/request/step/IOURequestStepRoutePropTypes.js diff --git a/.well-known/apple-app-site-association b/.well-known/apple-app-site-association index a2c7365f7de8..394e45f8d9ae 100644 --- a/.well-known/apple-app-site-association +++ b/.well-known/apple-app-site-association @@ -52,6 +52,10 @@ "/": "/split/*", "comment": "Split Expense" }, + { + "/": "/submit/*", + "comment": "Submit Expense" + }, { "/": "/request/*", "comment": "Submit Expense" @@ -76,6 +80,10 @@ "/": "/search/*", "comment": "Search" }, + { + "/": "/pay/*", + "comment": "Pay someone" + }, { "/": "/send/*", "comment": "Pay someone" diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 84364f2ef7ff..520602a28a02 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -62,6 +62,7 @@ + @@ -70,6 +71,7 @@ + @@ -81,6 +83,7 @@ + @@ -89,6 +92,7 @@ + diff --git a/src/CONST.ts b/src/CONST.ts index a840cb481a1a..b5ffcc9c07e8 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1411,16 +1411,18 @@ const CONST = { ACTION: { EDIT: 'edit', CREATE: 'create', - REQUEST: 'request', + SUBMIT: 'submit', CATEGORIZE: 'categorize', SHARE: 'share', }, DEFAULT_AMOUNT: 0, TYPE: { SEND: 'send', + PAY: 'pay', SPLIT: 'split', REQUEST: 'request', - TRACK_EXPENSE: 'track-expense', + SUBMIT: 'submit', + TRACK: 'track', }, REQUEST_TYPE: { DISTANCE: 'distance', diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 94bd1c2b612d..8233cdea6001 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -418,20 +418,20 @@ const ROUTES = { }, MONEY_REQUEST_STATE_SELECTOR: { - route: 'request/state', + route: 'submit/state', getRoute: (state?: string, backTo?: string, label?: string) => - `${getUrlWithBackToParam(`request/state${state ? `?state=${encodeURIComponent(state)}` : ''}`, backTo)}${ + `${getUrlWithBackToParam(`submit/state${state ? `?state=${encodeURIComponent(state)}` : ''}`, backTo)}${ // the label param can be an empty string so we cannot use a nullish ?? operator // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing label ? `${backTo || state ? '&' : '?'}label=${encodeURIComponent(label)}` : '' }` as const, }, - IOU_REQUEST: 'request/new', - IOU_SEND: 'send/new', - IOU_SEND_ADD_BANK_ACCOUNT: 'send/new/add-bank-account', - IOU_SEND_ADD_DEBIT_CARD: 'send/new/add-debit-card', - IOU_SEND_ENABLE_PAYMENTS: 'send/new/enable-payments', + IOU_REQUEST: 'submit/new', + IOU_SEND: 'pay/new', + IOU_SEND_ADD_BANK_ACCOUNT: 'pay/new/add-bank-account', + IOU_SEND_ADD_DEBIT_CARD: 'pay/new/add-debit-card', + IOU_SEND_ENABLE_PAYMENTS: 'pay/new/enable-payments', NEW_TASK: 'new/task', NEW_TASK_ASSIGNEE: 'new/task/assignee', @@ -690,7 +690,7 @@ const ROUTES = { route: 'referral/:contentType', getRoute: (contentType: string, backTo?: string) => getUrlWithBackToParam(`referral/${contentType}`, backTo), }, - PROCESS_MONEY_REQUEST_HOLD: 'hold-request-educational', + PROCESS_MONEY_REQUEST_HOLD: 'hold-expense-educational', ONBOARDING_ROOT: 'onboarding', ONBOARDING_PERSONAL_DETAILS: 'onboarding/personal-details', ONBOARDING_PURPOSE: 'onboarding/purpose', @@ -733,6 +733,7 @@ const ROUTES = { */ const HYBRID_APP_ROUTES = { MONEY_REQUEST_CREATE: '/request/new/scan', + MONEY_REQUEST_SUBMIT_CREATE: '/submit/new/scan', } as const; export {HYBRID_APP_ROUTES, getUrlWithBackToParam}; diff --git a/src/components/AttachmentModal.tsx b/src/components/AttachmentModal.tsx index 7d13524b78df..1612e97c4903 100644 --- a/src/components/AttachmentModal.tsx +++ b/src/components/AttachmentModal.tsx @@ -422,7 +422,7 @@ function AttachmentModal({ Navigation.navigate( ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( CONST.IOU.ACTION.EDIT, - CONST.IOU.TYPE.REQUEST, + CONST.IOU.TYPE.SUBMIT, transaction?.transactionID ?? '', report?.reportID ?? '', Navigation.getActiveRouteWithoutParams(), diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index e90cb7584c43..1e95d644f3d8 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -91,7 +91,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & iouCurrencyCode?: string; /** IOU type */ - iouType?: IOUType; + iouType?: Exclude; /** IOU date */ iouCreated?: string; @@ -176,7 +176,7 @@ function MoneyRequestConfirmationList({ onSendMoney, onConfirm, onSelectParticipant, - iouType = CONST.IOU.TYPE.REQUEST, + iouType = CONST.IOU.TYPE.SUBMIT, isScanRequest = false, iouAmount, policyCategories, @@ -216,10 +216,10 @@ function MoneyRequestConfirmationList({ const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const {canUseViolations} = usePermissions(); - const isTypeRequest = iouType === CONST.IOU.TYPE.REQUEST; + const isTypeRequest = iouType === CONST.IOU.TYPE.SUBMIT; const isTypeSplit = iouType === CONST.IOU.TYPE.SPLIT; - const isTypeSend = iouType === CONST.IOU.TYPE.SEND; - const isTypeTrackExpense = iouType === CONST.IOU.TYPE.TRACK_EXPENSE; + const isTypeSend = iouType === CONST.IOU.TYPE.PAY; + const isTypeTrackExpense = iouType === CONST.IOU.TYPE.TRACK; const {unit, rate, currency} = mileageRate ?? { unit: CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES, @@ -557,7 +557,7 @@ function MoneyRequestConfirmationList({ return; } - if (iouType === CONST.IOU.TYPE.SEND) { + if (iouType === CONST.IOU.TYPE.PAY) { if (!paymentMethod) { return; } @@ -608,7 +608,7 @@ function MoneyRequestConfirmationList({ return; } - const shouldShowSettlementButton = iouType === CONST.IOU.TYPE.SEND; + const shouldShowSettlementButton = iouType === CONST.IOU.TYPE.PAY; const shouldDisableButton = selectedParticipants.length === 0; const button = shouldShowSettlementButton ? ( @@ -944,7 +944,7 @@ function MoneyRequestConfirmationList({ : // The empty receipt component should only show for IOU Requests of a paid policy ("Team" or "Corporate") PolicyUtils.isPaidGroupPolicy(policy) && !isDistanceRequest && - iouType === CONST.IOU.TYPE.REQUEST && ( + iouType === CONST.IOU.TYPE.SUBMIT && ( Navigation.navigate( diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index c5cad0eccdeb..7c4b055c71ba 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -297,7 +297,7 @@ function MoneyRequestView({ Navigation.navigate( ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( CONST.IOU.ACTION.EDIT, - CONST.IOU.TYPE.REQUEST, + CONST.IOU.TYPE.SUBMIT, transaction?.transactionID ?? '', report.reportID, Navigation.getActiveRouteWithoutParams(), @@ -317,7 +317,7 @@ function MoneyRequestView({ interactive={canEditAmount} shouldShowRightIcon={canEditAmount} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID)) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.SUBMIT, transaction?.transactionID ?? '', report.reportID)) } brickRoadIndicator={getErrorForField('amount') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} error={getErrorForField('amount')} @@ -333,7 +333,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.SUBMIT, transaction?.transactionID ?? '', report.reportID), ) } wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]} @@ -352,7 +352,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.SUBMIT, transaction?.transactionID ?? '', report.reportID), ) } /> @@ -367,7 +367,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.SUBMIT, transaction?.transactionID ?? '', report.reportID), ) } brickRoadIndicator={getErrorForField('merchant') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} @@ -383,7 +383,7 @@ function MoneyRequestView({ shouldShowRightIcon={canEditDate} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID)) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.SUBMIT, transaction?.transactionID ?? '', report.reportID)) } brickRoadIndicator={getErrorForField('date') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} error={getErrorForField('date')} @@ -399,7 +399,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.SUBMIT, transaction?.transactionID ?? '', report.reportID), ) } brickRoadIndicator={getErrorForField('category') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} @@ -421,7 +421,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, orderWeight, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.SUBMIT, orderWeight, transaction?.transactionID ?? '', report.reportID), ) } brickRoadIndicator={getErrorForField('tag', {tagListIndex: index, tagListName: name}) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} @@ -448,7 +448,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.SUBMIT, transaction?.transactionID ?? '', report.reportID), ) } /> @@ -465,7 +465,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.SUBMIT, transaction?.transactionID ?? '', report.reportID), ) } /> diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index 219199c25bc3..d61bd5186ecc 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -44,7 +44,7 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails), isMultipleParticipant); const isUserPolicyAdmin = PolicyUtils.isPolicyAdmin(policy); const roomWelcomeMessage = ReportUtils.getRoomWelcomeMessage(report, isUserPolicyAdmin); - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, policy, participantAccountIDs, canUseTrackExpense); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, policy, participantAccountIDs, canUseTrackExpense); const additionalText = moneyRequestOptions.map((item) => translate(`reportActionsView.iouTypes.${item}`)).join(', '); const canEditPolicyDescription = ReportUtils.canEditPolicyDescription(policy); const reportName = ReportUtils.getReportName(report); @@ -160,9 +160,9 @@ function ReportWelcomeText({report, policy, personalDetails}: ReportWelcomeTextP ))} )} - {(moneyRequestOptions.includes(CONST.IOU.TYPE.SEND) || - moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST) || - moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK_EXPENSE)) && {translate('reportActionsView.usePlusButton', {additionalText})}} + {(moneyRequestOptions.includes(CONST.IOU.TYPE.PAY) || moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT) || moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)) && ( + {translate('reportActionsView.usePlusButton', {additionalText})} + )} ); diff --git a/src/languages/en.ts b/src/languages/en.ts index ed2587e5e2c6..fd018f5f5800 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -509,11 +509,10 @@ export default { welcomeToRoom: ({roomName}: WelcomeToRoomParams) => `Welcome to ${roomName}!`, usePlusButton: ({additionalText}: UsePlusButtonParams) => `\nYou can also use the + button to ${additionalText}, or assign a task!`, iouTypes: { - send: 'pay expenses', + pay: 'pay expenses', split: 'split an expense', - request: 'submit an expense', - // eslint-disable-next-line @typescript-eslint/naming-convention - 'track-expense': 'track an expense', + submit: 'submit an expense', + track: 'track an expense', }, }, reportAction: { diff --git a/src/languages/es.ts b/src/languages/es.ts index beb654cf0bc4..cf0b0eea1799 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -502,11 +502,10 @@ export default { welcomeToRoom: ({roomName}: WelcomeToRoomParams) => `¡Bienvenido a ${roomName}!`, usePlusButton: ({additionalText}: UsePlusButtonParams) => `\n¡También puedes usar el botón + de abajo para ${additionalText}, o asignar una tarea!`, iouTypes: { - send: 'pagar gastos', + pay: 'pagar gastos', split: 'dividir un gasto', - request: 'presentar un gasto', - // eslint-disable-next-line @typescript-eslint/naming-convention - 'track-expense': 'rastrear un gasto', + submit: 'presentar un gasto', + track: 'rastrear un gasto', }, }, reportAction: { diff --git a/src/libs/IOUUtils.ts b/src/libs/IOUUtils.ts index 63930ffd7131..cfc8e7064453 100644 --- a/src/libs/IOUUtils.ts +++ b/src/libs/IOUUtils.ts @@ -9,7 +9,7 @@ import Navigation from './Navigation/Navigation'; import * as TransactionUtils from './TransactionUtils'; function navigateToStartMoneyRequestStep(requestType: IOURequestType, iouType: IOUType, transactionID: string, reportID: string, iouAction?: IOUAction): void { - if (iouAction === CONST.IOU.ACTION.CATEGORIZE || iouAction === CONST.IOU.ACTION.REQUEST) { + if (iouAction === CONST.IOU.ACTION.CATEGORIZE || iouAction === CONST.IOU.ACTION.SUBMIT) { Navigation.goBack(); return; } @@ -109,7 +109,16 @@ function isIOUReportPendingCurrencyConversion(iouReport: Report): boolean { * Checks if the iou type is one of request, send, or split. */ function isValidMoneyRequestType(iouType: string): boolean { - const moneyRequestType: string[] = [CONST.IOU.TYPE.REQUEST, CONST.IOU.TYPE.SPLIT, CONST.IOU.TYPE.SEND, CONST.IOU.TYPE.TRACK_EXPENSE]; + const moneyRequestType: string[] = [CONST.IOU.TYPE.REQUEST, CONST.IOU.TYPE.SUBMIT, CONST.IOU.TYPE.SPLIT, CONST.IOU.TYPE.SEND, CONST.IOU.TYPE.PAY, CONST.IOU.TYPE.TRACK]; + return moneyRequestType.includes(iouType); +} + +/** + * Checks if the iou type is one of submit, pat, track, or split. + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +function temporary_isValidMoneyRequestType(iouType: string): boolean { + const moneyRequestType: string[] = [CONST.IOU.TYPE.SUBMIT, CONST.IOU.TYPE.SPLIT, CONST.IOU.TYPE.PAY, CONST.IOU.TYPE.TRACK]; return moneyRequestType.includes(iouType); } @@ -129,7 +138,7 @@ function insertTagIntoTransactionTagsString(transactionTags: string, tag: string } function isMovingTransactionFromTrackExpense(action?: IOUAction) { - if (action === CONST.IOU.ACTION.REQUEST || action === CONST.IOU.ACTION.SHARE || action === CONST.IOU.ACTION.CATEGORIZE) { + if (action === CONST.IOU.ACTION.SUBMIT || action === CONST.IOU.ACTION.SHARE || action === CONST.IOU.ACTION.CATEGORIZE) { return true; } @@ -144,4 +153,5 @@ export { isValidMoneyRequestType, navigateToStartMoneyRequestStep, updateIOUOwnerAndTotal, + temporary_isValidMoneyRequestType, }; diff --git a/src/libs/MoneyRequestUtils.ts b/src/libs/MoneyRequestUtils.ts index 4e681e016b6b..2da048ffab4f 100644 --- a/src/libs/MoneyRequestUtils.ts +++ b/src/libs/MoneyRequestUtils.ts @@ -81,7 +81,7 @@ function replaceAllDigits(text: string, convertFn: (char: string) => string): st * Check if distance expense or not */ function isDistanceRequest(iouType: IOUType, selectedTab: OnyxEntry): boolean { - return iouType === CONST.IOU.TYPE.REQUEST && selectedTab === CONST.TAB_REQUEST.DISTANCE; + return (iouType === CONST.IOU.TYPE.REQUEST || iouType === CONST.IOU.TYPE.SUBMIT) && selectedTab === CONST.TAB_REQUEST.DISTANCE; } /** diff --git a/src/libs/Navigation/Navigation.ts b/src/libs/Navigation/Navigation.ts index b94c2c5fad4a..ce92c169812b 100644 --- a/src/libs/Navigation/Navigation.ts +++ b/src/libs/Navigation/Navigation.ts @@ -94,7 +94,9 @@ function getActiveRouteIndex(stateOrRoute: StateOrRoute, index?: number): number function parseHybridAppUrl(url: HybridAppRoute | Route): Route { switch (url) { case HYBRID_APP_ROUTES.MONEY_REQUEST_CREATE: - return ROUTES.MONEY_REQUEST_CREATE.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.REQUEST, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, ReportUtils.generateReportID()); + return ROUTES.MONEY_REQUEST_CREATE.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, ReportUtils.generateReportID()); + case HYBRID_APP_ROUTES.MONEY_REQUEST_SUBMIT_CREATE: + return ROUTES.MONEY_REQUEST_CREATE.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, ReportUtils.generateReportID()); default: return url; } diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 4f58a2f690a1..b0aef04d7abb 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -371,21 +371,21 @@ type RoomInviteNavigatorParamList = { type MoneyRequestNavigatorParamList = { [SCREENS.MONEY_REQUEST.STEP_PARTICIPANTS]: { action: IOUAction; - iouType: ValueOf; + iouType: Exclude; transactionID: string; reportID: string; backTo: string; }; [SCREENS.MONEY_REQUEST.STEP_DATE]: { action: IOUAction; - iouType: IOUType; + iouType: Exclude; transactionID: string; reportID: string; backTo: Routes; }; [SCREENS.MONEY_REQUEST.STEP_DESCRIPTION]: { action: IOUAction; - iouType: IOUType; + iouType: Exclude; transactionID: string; reportID: string; backTo: Routes; @@ -393,7 +393,7 @@ type MoneyRequestNavigatorParamList = { }; [SCREENS.MONEY_REQUEST.STEP_CATEGORY]: { action: IOUAction; - iouType: IOUType; + iouType: Exclude; transactionID: string; reportActionID: string; reportID: string; @@ -401,7 +401,7 @@ type MoneyRequestNavigatorParamList = { }; [SCREENS.MONEY_REQUEST.STEP_TAX_AMOUNT]: { action: IOUAction; - iouType: IOUType; + iouType: Exclude; transactionID: string; reportID: string; backTo: Routes; @@ -409,7 +409,7 @@ type MoneyRequestNavigatorParamList = { }; [SCREENS.MONEY_REQUEST.STEP_TAG]: { action: IOUAction; - iouType: IOUType; + iouType: Exclude; transactionID: string; reportID: string; backTo: Routes; @@ -418,7 +418,7 @@ type MoneyRequestNavigatorParamList = { }; [SCREENS.MONEY_REQUEST.STEP_TAX_RATE]: { action: IOUAction; - iouType: IOUType; + iouType: Exclude; transactionID: string; reportID: string; backTo: Routes; @@ -433,7 +433,7 @@ type MoneyRequestNavigatorParamList = { }; [SCREENS.MONEY_REQUEST.STEP_MERCHANT]: { action: IOUAction; - iouType: IOUType; + iouType: Exclude; transactionID: string; reportID: string; backTo: Routes; @@ -485,7 +485,7 @@ type MoneyRequestNavigatorParamList = { }; [SCREENS.MONEY_REQUEST.STEP_CONFIRMATION]: { action: IOUAction; - iouType: IOUType; + iouType: Exclude; transactionID: string; reportID: string; pageIndex?: string; diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 105736faeba0..c79e9011386f 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -29,7 +29,7 @@ function canUseTrackExpense(betas: OnyxEntry): boolean { function canUseP2PDistanceRequests(betas: OnyxEntry, iouType: IOUType | undefined): boolean { // Allow using P2P distance request for TrackExpense outside of the beta, because that project doesn't want to be limited by the more cautious P2P distance beta - return !!betas?.includes(CONST.BETAS.P2P_DISTANCE_REQUESTS) || canUseAllBetas(betas) || iouType === CONST.IOU.TYPE.TRACK_EXPENSE; + return !!betas?.includes(CONST.BETAS.P2P_DISTANCE_REQUESTS) || canUseAllBetas(betas) || iouType === CONST.IOU.TYPE.TRACK; } function canUseWorkflowsDelayedSubmission(betas: OnyxEntry): boolean { diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a15e1937dbe2..f8e64fd8b0d7 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5040,7 +5040,7 @@ function isGroupChatAdmin(report: OnyxEntry, accountID: number) { * None of the options should show in chat threads or if there is some special Expensify account * as a participant of the report. */ -function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry, reportParticipants: number[], canUseTrackExpense = true): IOUType[] { +function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry, reportParticipants: number[], canUseTrackExpense = true, filterDeprecatedTypes = false): IOUType[] { // In any thread or task report, we do not allow any new expenses yet if (isChatThread(report) || isTaskReport(report) || (!canUseTrackExpense && isSelfDM(report))) { return []; @@ -5058,7 +5058,7 @@ function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry, policy: OnyxEntry, + policy: OnyxEntry, + reportParticipants: number[], + canUseTrackExpense = true, +): Array> { + return getMoneyRequestOptions(report, policy, reportParticipants, canUseTrackExpense, true) as Array>; +} + /** * Allows a user to leave a policy room according to the following conditions of the visibility or chatType rNVP: * `public` - Anyone can leave (because anybody can join) @@ -5957,7 +5973,7 @@ function createDraftTransactionAndNavigateToParticipantSelector(transactionID: s created: transactionCreated, } as Transaction); - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.REQUEST, transactionID, reportID, undefined, actionName)); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.SUBMIT, transactionID, reportID, undefined, actionName)); } /** @@ -6235,6 +6251,7 @@ export { sortReportsByLastRead, updateOptimisticParentReportAction, updateReportPreview, + temporary_getMoneyRequestOptions, }; export type { diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 5217be1686c2..2503a0d33f16 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -2573,7 +2573,7 @@ function convertTrackedExpenseToRequest( linkedTrackedExpenseReportAction, linkedTrackedExpenseReportID, transactionThreadReportID, - CONST.IOU.ACTION.REQUEST, + CONST.IOU.ACTION.SUBMIT, ); optimisticData?.push(...moveTransactionOptimisticData); @@ -2814,7 +2814,7 @@ function requestMoney( const activeReportID = isMoneyRequestReport ? report?.reportID : chatReport.reportID; switch (action) { - case CONST.IOU.ACTION.REQUEST: { + case CONST.IOU.ACTION.SUBMIT: { if (!linkedTrackedExpenseReportAction || !actionableWhisperReportActionID || !linkedTrackedExpenseReportID) { return; } diff --git a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx index 1294d2ca8aea..09f6e8598e6c 100644 --- a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx +++ b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx @@ -27,7 +27,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type * as OnyxTypes from '@src/types/onyx'; -type MoneyRequestOptions = Record; +type MoneyRequestOptions = Record, PopoverMenuItem>; type AttachmentPickerWithMenuItemsOnyxProps = { /** The policy tied to the report */ @@ -128,24 +128,24 @@ function AttachmentPickerWithMenuItems({ text: translate('iou.splitExpense'), onSelected: () => IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, report?.reportID ?? ''), }, - [CONST.IOU.TYPE.REQUEST]: { + [CONST.IOU.TYPE.SUBMIT]: { icon: Expensicons.MoneyCircle, text: translate('iou.submitExpense'), - onSelected: () => IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, report?.reportID ?? ''), + onSelected: () => IOU.startMoneyRequest(CONST.IOU.TYPE.SUBMIT, report?.reportID ?? ''), }, - [CONST.IOU.TYPE.SEND]: { + [CONST.IOU.TYPE.PAY]: { icon: Expensicons.Send, text: translate('iou.paySomeone', {name: ReportUtils.getPayeeName(report)}), - onSelected: () => IOU.startMoneyRequest(CONST.IOU.TYPE.SEND, report?.reportID ?? ''), + onSelected: () => IOU.startMoneyRequest(CONST.IOU.TYPE.PAY, report?.reportID ?? ''), }, - [CONST.IOU.TYPE.TRACK_EXPENSE]: { + [CONST.IOU.TYPE.TRACK]: { icon: Expensicons.DocumentPlus, text: translate('iou.trackExpense'), - onSelected: () => IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK_EXPENSE, report?.reportID ?? ''), + onSelected: () => IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK, report?.reportID ?? ''), }, }; - return ReportUtils.getMoneyRequestOptions(report, policy, reportParticipantIDs ?? [], canUseTrackExpense).map((option) => ({ + return ReportUtils.temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs ?? [], canUseTrackExpense).map((option) => ({ ...options[option], })); }, [translate, report, policy, reportParticipantIDs, canUseTrackExpense]); diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 8d11744740bd..7926647551d9 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -393,7 +393,7 @@ function ReportActionItem({ text: 'actionableMentionTrackExpense.submit', key: `${action.reportActionID}-actionableMentionTrackExpense-submit`, onPress: () => { - ReportUtils.createDraftTransactionAndNavigateToParticipantSelector(transactionID, report.reportID, CONST.IOU.ACTION.REQUEST, action.reportActionID); + ReportUtils.createDraftTransactionAndNavigateToParticipantSelector(transactionID, report.reportID, CONST.IOU.ACTION.SUBMIT, action.reportActionID); }, isMediumSized: true, }, diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index f9f069a2172a..04d82d8dc462 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -169,13 +169,13 @@ function FloatingActionButtonAndPopover( const navigateToQuickAction = () => { switch (quickAction?.action) { case CONST.QUICK_ACTIONS.REQUEST_MANUAL: - IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.MANUAL, true); + IOU.startMoneyRequest(CONST.IOU.TYPE.SUBMIT, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.MANUAL, true); return; case CONST.QUICK_ACTIONS.REQUEST_SCAN: - IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.SCAN, true); + IOU.startMoneyRequest(CONST.IOU.TYPE.SUBMIT, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.SCAN, true); return; case CONST.QUICK_ACTIONS.REQUEST_DISTANCE: - IOU.startMoneyRequest(CONST.IOU.TYPE.REQUEST, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.DISTANCE, true); + IOU.startMoneyRequest(CONST.IOU.TYPE.SUBMIT, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.DISTANCE, true); return; case CONST.QUICK_ACTIONS.SPLIT_MANUAL: IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.MANUAL, true); @@ -187,19 +187,19 @@ function FloatingActionButtonAndPopover( IOU.startMoneyRequest(CONST.IOU.TYPE.SPLIT, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.DISTANCE, true); return; case CONST.QUICK_ACTIONS.SEND_MONEY: - IOU.startMoneyRequest(CONST.IOU.TYPE.SEND, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.MANUAL, true); + IOU.startMoneyRequest(CONST.IOU.TYPE.PAY, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.MANUAL, true); return; case CONST.QUICK_ACTIONS.ASSIGN_TASK: Task.clearOutTaskInfoAndNavigate(quickAction?.chatReportID ?? '', quickActionReport, quickAction.targetAccountID ?? 0, true); break; case CONST.QUICK_ACTIONS.TRACK_MANUAL: - IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK_EXPENSE, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.MANUAL); + IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.MANUAL); break; case CONST.QUICK_ACTIONS.TRACK_SCAN: - IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK_EXPENSE, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.SCAN); + IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.SCAN); break; case CONST.QUICK_ACTIONS.TRACK_DISTANCE: - IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK_EXPENSE, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.DISTANCE); + IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.DISTANCE); break; default: } @@ -293,7 +293,7 @@ function FloatingActionButtonAndPopover( onSelected: () => interceptAnonymousUser(() => IOU.startMoneyRequest( - CONST.IOU.TYPE.TRACK_EXPENSE, + CONST.IOU.TYPE.TRACK, // When starting to create a track expense from the global FAB, we need to retrieve selfDM reportID. // If it doesn't exist, we generate a random optimistic reportID and use it for all of the routes in the creation flow. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing @@ -309,7 +309,7 @@ function FloatingActionButtonAndPopover( onSelected: () => interceptAnonymousUser(() => IOU.startMoneyRequest( - CONST.IOU.TYPE.REQUEST, + CONST.IOU.TYPE.SUBMIT, // When starting to create an expense from the global FAB, there is not an existing report yet. A random optimistic reportID is generated and used // for all of the routes in the creation flow. ReportUtils.generateReportID(), @@ -335,7 +335,7 @@ function FloatingActionButtonAndPopover( onSelected: () => interceptAnonymousUser(() => IOU.startMoneyRequest( - CONST.IOU.TYPE.SEND, + CONST.IOU.TYPE.PAY, // When starting to pay someone from the global FAB, there is not an existing report yet. A random optimistic reportID is generated and used // for all of the routes in the creation flow. ReportUtils.generateReportID(), diff --git a/src/pages/iou/request/IOURequestStartPage.tsx b/src/pages/iou/request/IOURequestStartPage.tsx index f807038d9cd1..4a401d7de988 100644 --- a/src/pages/iou/request/IOURequestStartPage.tsx +++ b/src/pages/iou/request/IOURequestStartPage.tsx @@ -62,9 +62,11 @@ function IOURequestStartPage({ const [isDraggingOver, setIsDraggingOver] = useState(false); const tabTitles = { [CONST.IOU.TYPE.REQUEST]: translate('iou.submitExpense'), + [CONST.IOU.TYPE.SUBMIT]: translate('iou.submitExpense'), [CONST.IOU.TYPE.SEND]: translate('iou.paySomeone', {name: ReportUtils.getPayeeName(report)}), + [CONST.IOU.TYPE.PAY]: translate('iou.paySomeone', {name: ReportUtils.getPayeeName(report)}), [CONST.IOU.TYPE.SPLIT]: translate('iou.splitExpense'), - [CONST.IOU.TYPE.TRACK_EXPENSE]: translate('iou.trackExpense'), + [CONST.IOU.TYPE.TRACK]: translate('iou.trackExpense'), }; const transactionRequestType = useRef(TransactionUtils.getRequestType(transaction)); const {canUseP2PDistanceRequests} = usePermissions(iouType); @@ -136,7 +138,7 @@ function IOURequestStartPage({ title={tabTitles[iouType]} onBackButtonPress={navigateBack} /> - {iouType !== CONST.IOU.TYPE.SEND ? ( + {iouType !== CONST.IOU.TYPE.SEND && iouType !== CONST.IOU.TYPE.PAY ? ( { diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 2cc59bf0af14..460d5f902051 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -85,7 +85,7 @@ function IOURequestStepAmount({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace request, as // the user will have to add a merchant. const shouldSkipConfirmation: boolean = useMemo(() => { - if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK) { return false; } @@ -132,6 +132,32 @@ function IOURequestStepAmount({ ); }; + const navigateToParticipantPage = () => { + switch (iouType) { + case CONST.IOU.TYPE.REQUEST: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.SUBMIT, transactionID, reportID)); + break; + case CONST.IOU.TYPE.SEND: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.PAY, transactionID, reportID)); + break; + default: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); + } + }; + + const navigateToConfirmationPage = () => { + switch (iouType) { + case CONST.IOU.TYPE.REQUEST: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, transactionID, reportID)); + break; + case CONST.IOU.TYPE.SEND: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.PAY, transactionID, reportID)); + break; + default: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); + } + }; + const navigateToNextPage = ({amount, paymentMethod}: AmountParams) => { isSaveButtonPressed.current = true; const amountInSmallestCurrencyUnits = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); @@ -173,7 +199,7 @@ function IOURequestStepAmount({ }); return; } - if (iouType === CONST.IOU.TYPE.SEND) { + if (iouType === CONST.IOU.TYPE.PAY || iouType === CONST.IOU.TYPE.SEND) { if (paymentMethod && paymentMethod === CONST.IOU.PAYMENT_TYPE.EXPENSIFY) { IOU.sendMoneyWithWallet(report, backendAmount, currency, '', currentUserPersonalDetails.accountID, participants[0]); return; @@ -182,7 +208,7 @@ function IOURequestStepAmount({ IOU.sendMoneyElsewhere(report, backendAmount, currency, '', currentUserPersonalDetails.accountID, participants[0]); return; } - if (iouType === CONST.IOU.TYPE.REQUEST) { + if (iouType === CONST.IOU.TYPE.SUBMIT || iouType === CONST.IOU.TYPE.REQUEST) { IOU.requestMoney( report, backendAmount, @@ -199,13 +225,13 @@ function IOURequestStepAmount({ } } IOU.setMoneyRequestParticipantsFromReport(transactionID, report); - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); + navigateToConfirmationPage(); return; } // If there was no reportID, then that means the user started this flow from the global + menu // and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense. - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); + navigateToParticipantPage(); }; const saveAmountAndCurrency = ({amount, paymentMethod}: AmountParams) => { diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 057b3e027243..b7622d784c39 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -77,7 +77,7 @@ function IOURequestStepConfirmation({ const transactionTaxAmount = transaction?.taxAmount; const isSharingTrackExpense = action === CONST.IOU.ACTION.SHARE; const isCategorizingTrackExpense = action === CONST.IOU.ACTION.CATEGORIZE; - const isRequestingFromTrackExpense = action === CONST.IOU.ACTION.REQUEST; + const isSubmittingFromTrackExpense = action === CONST.IOU.ACTION.SUBMIT; const requestType = TransactionUtils.getRequestType(transaction); @@ -85,7 +85,7 @@ function IOURequestStepConfirmation({ if (isSharingTrackExpense) { return translate('iou.categorize'); } - if (isRequestingFromTrackExpense) { + if (isSubmittingFromTrackExpense) { return translate('iou.submitExpense'); } if (isCategorizingTrackExpense) { @@ -94,14 +94,14 @@ function IOURequestStepConfirmation({ if (iouType === CONST.IOU.TYPE.SPLIT) { return translate('iou.splitExpense'); } - if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + if (iouType === CONST.IOU.TYPE.TRACK) { return translate('iou.trackExpense'); } - if (iouType === CONST.IOU.TYPE.SEND) { + if (iouType === CONST.IOU.TYPE.PAY) { return translate('iou.paySomeone', {name: ReportUtils.getPayeeName(report)}); } return translate(TransactionUtils.getHeaderTitleTranslationKey(transaction)); - }, [iouType, report, transaction, translate, isSharingTrackExpense, isCategorizingTrackExpense, isRequestingFromTrackExpense]); + }, [iouType, report, transaction, translate, isSharingTrackExpense, isCategorizingTrackExpense, isSubmittingFromTrackExpense]); const participants = useMemo( () => @@ -352,7 +352,7 @@ function IOURequestStepConfirmation({ return; } - if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE || isCategorizingTrackExpense || isSharingTrackExpense) { + if (iouType === CONST.IOU.TYPE.TRACK || isCategorizingTrackExpense || isSharingTrackExpense) { if (receiptFile && transaction) { // If the transaction amount is zero, then the money is being requested through the "Scan" flow and the GPS coordinates need to be included. if (transaction.amount === 0 && !isSharingTrackExpense && !isCategorizingTrackExpense) { @@ -494,7 +494,7 @@ function IOURequestStepConfirmation({ diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 0602c2184365..57fc77e05fed 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -105,7 +105,7 @@ function IOURequestStepDistance({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag const shouldSkipConfirmation: boolean = useMemo(() => { - if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK) { return false; } @@ -176,12 +176,38 @@ function IOURequestStepDistance({ const navigateToWaypointEditPage = useCallback( (index: number) => { Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_WAYPOINT.getRoute(action, CONST.IOU.TYPE.REQUEST, transactionID, report?.reportID, index.toString(), Navigation.getActiveRouteWithoutParams()), + ROUTES.MONEY_REQUEST_STEP_WAYPOINT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, report?.reportID, index.toString(), Navigation.getActiveRouteWithoutParams()), ); }, [action, transactionID, report?.reportID], ); + const navigateToParticipantPage = useCallback(() => { + switch (iouType) { + case CONST.IOU.TYPE.REQUEST: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.SUBMIT, transactionID, reportID)); + break; + case CONST.IOU.TYPE.SEND: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.PAY, transactionID, reportID)); + break; + default: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); + } + }, [iouType, reportID, transactionID]); + + const navigateToConfirmationPage = useCallback(() => { + switch (iouType) { + case CONST.IOU.TYPE.REQUEST: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, transactionID, reportID)); + break; + case CONST.IOU.TYPE.SEND: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.PAY, transactionID, reportID)); + break; + default: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); + } + }, [iouType, reportID, transactionID]); + const navigateToNextStep = useCallback(() => { if (backTo) { Navigation.goBack(backTo); @@ -233,14 +259,27 @@ function IOURequestStepDistance({ return; } IOU.setMoneyRequestParticipantsFromReport(transactionID, report); - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); + navigateToConfirmationPage(); return; } // If there was no reportID, then that means the user started this flow from the global menu // and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense. - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); - }, [report, iouType, reportID, transactionID, backTo, waypoints, currentUserPersonalDetails, personalDetails, shouldSkipConfirmation, transaction, translate]); + navigateToParticipantPage(); + }, [ + report, + iouType, + transactionID, + backTo, + waypoints, + currentUserPersonalDetails, + personalDetails, + shouldSkipConfirmation, + transaction, + translate, + navigateToParticipantPage, + navigateToConfirmationPage, + ]); const getError = () => { // Get route error if available else show the invalid number of waypoints error. diff --git a/src/pages/iou/request/step/IOURequestStepParticipants.tsx b/src/pages/iou/request/step/IOURequestStepParticipants.tsx index 28126c71faaa..bcd03fe038bf 100644 --- a/src/pages/iou/request/step/IOURequestStepParticipants.tsx +++ b/src/pages/iou/request/step/IOURequestStepParticipants.tsx @@ -6,7 +6,6 @@ import Navigation from '@libs/Navigation/Navigation'; import * as TransactionUtils from '@libs/TransactionUtils'; import MoneyRequestParticipantsSelector from '@pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector'; import * as IOU from '@userActions/IOU'; -import type {IOUType} from '@src/CONST'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; @@ -27,8 +26,6 @@ type IOURequestStepParticipantsProps = IOURequestStepParticipantsOnyxProps & WithWritableReportOrNotFoundProps & WithFullTransactionOrNotFoundProps; -type IOURef = IOUType | null; - function IOURequestStepParticipants({ route: { params: {iouType, reportID, transactionID, action}, @@ -45,7 +42,7 @@ function IOURequestStepParticipants({ if (action === CONST.IOU.ACTION.CATEGORIZE) { return translate('iou.categorize'); } - if (action === CONST.IOU.ACTION.REQUEST) { + if (action === CONST.IOU.ACTION.SUBMIT) { return translate('iou.submitExpense'); } if (action === CONST.IOU.ACTION.SHARE) { @@ -54,7 +51,7 @@ function IOURequestStepParticipants({ if (isSplitRequest) { return translate('iou.splitExpense'); } - if (iouType === CONST.IOU.TYPE.SEND) { + if (iouType === CONST.IOU.TYPE.PAY) { return translate('iou.paySomeone', {}); } return translate(TransactionUtils.getHeaderTitleTranslationKey(transaction)); @@ -63,7 +60,6 @@ function IOURequestStepParticipants({ const receiptFilename = transaction?.filename; const receiptPath = transaction?.receipt?.source; const receiptType = transaction?.receipt?.type; - const newIouType = useRef(); // When the component mounts, if there is a receipt, see if the image can be read from the disk. If not, redirect the user to the starting step of the flow. // This is because until the expense is saved, the receipt file is only stored in the browsers memory as a blob:// and if the browser is refreshed, then @@ -77,18 +73,7 @@ function IOURequestStepParticipants({ }, [receiptType, receiptPath, receiptFilename, iouRequestType, iouType, transactionID, reportID, action]); const addParticipant = useCallback( - (val: Participant[], selectedIouType: IOUType) => { - const isSplit = selectedIouType === CONST.IOU.TYPE.SPLIT; - // It's only possible to switch between REQUEST and SPLIT. - // We want to update the IOU type only if it's not updated yet to prevent unnecessary updates. - if (isSplit && iouType !== CONST.IOU.TYPE.SPLIT) { - newIouType.current = CONST.IOU.TYPE.SPLIT; - } else if (!isSplit && iouType === CONST.IOU.TYPE.SPLIT) { - // Non-split can be either REQUEST or SEND. Instead of checking whether - // the current IOU type is not a REQUEST (true for SEND), we check whether the current IOU type is a SPLIT. - newIouType.current = CONST.IOU.TYPE.REQUEST; - } - + (val: Participant[]) => { IOU.setMoneyRequestParticipants_temporaryForRefactor(transactionID, val); numberOfParticipants.current = val.length; @@ -102,7 +87,7 @@ function IOURequestStepParticipants({ // When a participant is selected, the reportID needs to be saved because that's the reportID that will be used in the confirmation step. selectedReportID.current = val[0]?.reportID ?? reportID; }, - [reportID, transactionID, iouType], + [reportID, transactionID], ); const goToNextStep = useCallback(() => { diff --git a/src/pages/iou/request/step/IOURequestStepRoutePropTypes.js b/src/pages/iou/request/step/IOURequestStepRoutePropTypes.js deleted file mode 100644 index f69e2b122c24..000000000000 --- a/src/pages/iou/request/step/IOURequestStepRoutePropTypes.js +++ /dev/null @@ -1,29 +0,0 @@ -import PropTypes from 'prop-types'; -import _ from 'underscore'; -import CONST from '@src/CONST'; - -export default PropTypes.shape({ - /** Route specific parameters used on this screen via route :iouType/new/category/:reportID? */ - params: PropTypes.shape({ - /** What action is being performed, ie. create, edit */ - action: PropTypes.oneOf(_.values(CONST.IOU.ACTION)), - - /** The type of IOU report, i.e. split, request, send, track */ - iouType: PropTypes.oneOf(_.values(CONST.IOU.TYPE)).isRequired, - - /** The ID of the transaction being configured */ - transactionID: PropTypes.string.isRequired, - - /** The report ID of the IOU */ - reportID: PropTypes.string.isRequired, - - /** Index of the waypoint being edited */ - pageIndex: PropTypes.string, - - /** A path to go to when the user presses the back button */ - backTo: PropTypes.string, - - /** Indicates which tag list index was selected */ - tagIndex: PropTypes.string, - }), -}); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 84c2137dafda..4c396a1e70b7 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -65,7 +65,7 @@ function IOURequestStepScan({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag const shouldSkipConfirmation: boolean = useMemo(() => { - if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK) { return false; } @@ -179,6 +179,32 @@ function IOURequestStepScan({ Navigation.goBack(); }; + const navigateToParticipantPage = useCallback(() => { + switch (iouType) { + case CONST.IOU.TYPE.REQUEST: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.SUBMIT, transactionID, reportID)); + break; + case CONST.IOU.TYPE.SEND: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.PAY, transactionID, reportID)); + break; + default: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); + } + }, [iouType, reportID, transactionID]); + + const navigateToConfirmationPage = useCallback(() => { + switch (iouType) { + case CONST.IOU.TYPE.REQUEST: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, transactionID, reportID)); + break; + case CONST.IOU.TYPE.SEND: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.PAY, transactionID, reportID)); + break; + default: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); + } + }, [iouType, reportID, transactionID]); + const navigateToConfirmationStep = useCallback( (file: FileObject, source: string) => { if (backTo) { @@ -187,8 +213,8 @@ function IOURequestStepScan({ } // If the transaction was created from the global create, the person needs to select participants, so take them there. - if (transaction?.isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE && !report?.reportID) { - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); + if (transaction?.isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK && !report?.reportID) { + navigateToParticipantPage(); return; } @@ -233,9 +259,21 @@ function IOURequestStepScan({ ); return; } - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); + navigateToConfirmationPage(); }, - [iouType, report, reportID, transactionID, backTo, currentUserPersonalDetails, personalDetails, shouldSkipConfirmation, transaction], + [ + iouType, + report, + reportID, + transactionID, + backTo, + currentUserPersonalDetails, + personalDetails, + shouldSkipConfirmation, + transaction, + navigateToConfirmationPage, + navigateToParticipantPage, + ], ); const updateScanAndNavigate = useCallback( diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 8bca59b11580..adfad2385aeb 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -80,7 +80,7 @@ function IOURequestStepScan({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag const shouldSkipConfirmation: boolean = useMemo(() => { - if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK) { return false; } @@ -219,6 +219,32 @@ function IOURequestStepScan({ Navigation.goBack(backTo); }; + const navigateToParticipantPage = useCallback(() => { + switch (iouType) { + case CONST.IOU.TYPE.REQUEST: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.SUBMIT, transactionID, reportID)); + break; + case CONST.IOU.TYPE.SEND: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.PAY, transactionID, reportID)); + break; + default: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); + } + }, [iouType, reportID, transactionID]); + + const navigateToConfirmationPage = useCallback(() => { + switch (iouType) { + case CONST.IOU.TYPE.REQUEST: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.SUBMIT, transactionID, reportID)); + break; + case CONST.IOU.TYPE.SEND: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, CONST.IOU.TYPE.PAY, transactionID, reportID)); + break; + default: + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); + } + }, [iouType, reportID, transactionID]); + const navigateToConfirmationStep = useCallback( (file: FileObject, source: string) => { if (backTo) { @@ -227,8 +253,8 @@ function IOURequestStepScan({ } // If the transaction was created from the global create, the person needs to select participants, so take them there. - if (transaction?.isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK_EXPENSE && !report?.reportID) { - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); + if (transaction?.isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK && !report?.reportID) { + navigateToParticipantPage(); return; } @@ -273,9 +299,21 @@ function IOURequestStepScan({ ); return; } - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); + navigateToConfirmationPage(); }, - [iouType, report, reportID, transactionID, backTo, currentUserPersonalDetails, personalDetails, shouldSkipConfirmation, transaction], + [ + iouType, + report, + reportID, + transactionID, + backTo, + currentUserPersonalDetails, + personalDetails, + shouldSkipConfirmation, + transaction, + navigateToConfirmationPage, + navigateToParticipantPage, + ], ); const updateScanAndNavigate = useCallback( diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index a5ed35374e00..5727351f45da 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -97,7 +97,7 @@ function MoneyRequestAmountForm( isCurrencyPressable = true, isEditing = false, skipConfirmation = false, - iouType = CONST.IOU.TYPE.REQUEST, + iouType = CONST.IOU.TYPE.SUBMIT, policyID = '', bankAccountRoute = '', onCurrencyButtonPress, @@ -387,7 +387,7 @@ function MoneyRequestAmountForm( longPressHandlerStateChanged={updateLongPressHandlerState} /> ) : null} - {iouType === CONST.IOU.TYPE.SEND && skipConfirmation ? ( + {iouType === CONST.IOU.TYPE.PAY && skipConfirmation ? ( { const reportParticipants = Array.from({length: 1000}, (v, i) => i + 1); await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.getMoneyRequestOptions(report, policy, reportParticipants)); + await measureFunction(() => ReportUtils.temporary_getMoneyRequestOptions(report, policy, reportParticipants)); }); test('[ReportUtils] getWorkspaceAvatar on 1k policies', async () => { diff --git a/tests/unit/IOUUtilsTest.ts b/tests/unit/IOUUtilsTest.ts index ddc220449e2f..b8640e4ecdf1 100644 --- a/tests/unit/IOUUtilsTest.ts +++ b/tests/unit/IOUUtilsTest.ts @@ -118,12 +118,13 @@ describe('IOUUtils', () => { describe('isValidMoneyRequestType', () => { test('Return true for valid iou type', () => { - expect(IOUUtils.isValidMoneyRequestType('request')).toBe(true); - expect(IOUUtils.isValidMoneyRequestType('split')).toBe(true); - expect(IOUUtils.isValidMoneyRequestType('send')).toBe(true); + expect(IOUUtils.temporary_isValidMoneyRequestType('submit')).toBe(true); + expect(IOUUtils.temporary_isValidMoneyRequestType('split')).toBe(true); + expect(IOUUtils.temporary_isValidMoneyRequestType('pay')).toBe(true); + expect(IOUUtils.temporary_isValidMoneyRequestType('track')).toBe(true); }); test('Return false for invalid iou type', () => { - expect(IOUUtils.isValidMoneyRequestType('money')).toBe(false); + expect(IOUUtils.temporary_isValidMoneyRequestType('money')).toBe(false); }); }); diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 0ed28ea84fcb..d0ea948bdb6c 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -359,7 +359,7 @@ describe('ReportUtils', () => { describe('return empty iou options if', () => { it('participants array contains excluded expensify iou emails', () => { const allEmpty = CONST.EXPENSIFY_ACCOUNT_IDS.every((accountID) => { - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(null, null, [currentUserAccountID, accountID]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(null, null, [currentUserAccountID, accountID]); return moneyRequestOptions.length === 0; }); expect(allEmpty).toBe(true); @@ -370,7 +370,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(0); }); @@ -380,7 +380,7 @@ describe('ReportUtils', () => { chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, isOwnPolicyExpenseChat: false, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(0); }); @@ -390,7 +390,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.IOU, statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(0); }); @@ -401,7 +401,7 @@ describe('ReportUtils', () => { stateNum: CONST.REPORT.STATE_NUM.APPROVED, statusNum: CONST.REPORT.STATUS_NUM.APPROVED, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(0); }); @@ -411,7 +411,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.EXPENSE, statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(0); }); @@ -425,7 +425,7 @@ describe('ReportUtils', () => { parentReportID: '100', type: CONST.REPORT.TYPE.EXPENSE, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(0); }); }); @@ -456,7 +456,7 @@ describe('ReportUtils', () => { parentReportID: '101', policyID: paidPolicy.id, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs[0]]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs[0]]); expect(moneyRequestOptions.length).toBe(0); }); }); @@ -474,7 +474,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID, participantsAccountIDs[0]]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID, participantsAccountIDs[0]]); return moneyRequestOptions.length === 1 && moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT); }); expect(onlyHaveSplitOption).toBe(true); @@ -485,7 +485,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID, ...participantsAccountIDs]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID, ...participantsAccountIDs]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); }); @@ -495,7 +495,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID, ...participantsAccountIDs]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID, ...participantsAccountIDs]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); }); @@ -506,7 +506,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.CHAT, participantsAccountIDs: [currentUserAccountID, ...participantsAccountIDs], }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID, ...participantsAccountIDs.map(Number)]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID, ...participantsAccountIDs.map(Number)]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); }); @@ -520,9 +520,9 @@ describe('ReportUtils', () => { stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID, participantsAccountIDs[0]]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID, participantsAccountIDs[0]]); expect(moneyRequestOptions.length).toBe(1); - expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true); + expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); it('it is an IOU report in submitted state even with pay expense permissions', () => { @@ -532,9 +532,9 @@ describe('ReportUtils', () => { stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID, participantsAccountIDs[0]]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID, participantsAccountIDs[0]]); expect(moneyRequestOptions.length).toBe(1); - expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true); + expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); }); @@ -550,10 +550,10 @@ describe('ReportUtils', () => { parentReportID: '102', type: CONST.REPORT.TYPE.EXPENSE, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(2); - expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true); - expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK_EXPENSE)).toBe(true); + expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); + expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); }); }); @@ -579,10 +579,10 @@ describe('ReportUtils', () => { outputCurrency: '', isPolicyExpenseChatEnabled: false, } as const; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs[0]]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs[0]]); expect(moneyRequestOptions.length).toBe(2); - expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true); - expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK_EXPENSE)).toBe(true); + expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); + expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); }); }); @@ -593,9 +593,9 @@ describe('ReportUtils', () => { stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID, participantsAccountIDs[0]]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID, participantsAccountIDs[0]]); expect(moneyRequestOptions.length).toBe(1); - expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true); + expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); it('it is an IOU report in submitted state even with pay expense permissions', () => { @@ -605,9 +605,9 @@ describe('ReportUtils', () => { stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID, participantsAccountIDs[0]]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID, participantsAccountIDs[0]]); expect(moneyRequestOptions.length).toBe(1); - expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true); + expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); it("it is a submitted expense report in user's own policyExpenseChat and the policy has Instant Submit frequency", () => { @@ -638,10 +638,10 @@ describe('ReportUtils', () => { parentReportID: '101', policyID: paidPolicy.id, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs[0]]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs[0]]); expect(moneyRequestOptions.length).toBe(2); - expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true); - expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK_EXPENSE)).toBe(true); + expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); + expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); }); }); }); @@ -652,11 +652,11 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), type: CONST.REPORT.TYPE.CHAT, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID, participantsAccountIDs[0]]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID, participantsAccountIDs[0]]); expect(moneyRequestOptions.length).toBe(3); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); - expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true); - expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SEND)).toBe(true); + expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); + expect(moneyRequestOptions.includes(CONST.IOU.TYPE.PAY)).toBe(true); }); it("it is user's own policy expense chat", () => { @@ -665,11 +665,11 @@ describe('ReportUtils', () => { chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, isOwnPolicyExpenseChat: true, }; - const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, null, [currentUserAccountID, ...participantsAccountIDs]); + const moneyRequestOptions = ReportUtils.temporary_getMoneyRequestOptions(report, null, [currentUserAccountID, ...participantsAccountIDs]); expect(moneyRequestOptions.length).toBe(3); - expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true); + expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); - expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK_EXPENSE)).toBe(true); + expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); }); }); }); From b29bad72ec437d5f3816b85a25b53466b1e9ffec Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Fri, 19 Apr 2024 21:04:16 +0530 Subject: [PATCH 247/339] Protected some routes against problems --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 2 +- src/pages/iou/request/step/IOURequestStepDistance.tsx | 2 +- .../iou/request/step/IOURequestStepScan/index.native.tsx | 2 +- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 2 +- src/pages/iou/request/step/IOURequestStepWaypoint.tsx | 1 + src/pages/iou/request/step/withWritableReportOrNotFound.tsx | 5 ++++- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 460d5f902051..f55bebc7dd76 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -314,7 +314,7 @@ const IOURequestStepAmountWithOnyx = withOnyx = WithWr export default function , TRef>( WrappedComponent: ComponentType>, + shouldIncludeDeprecatedIOUType = false, ): React.ComponentType, keyof WithWritableReportOrNotFoundOnyxProps>> { // eslint-disable-next-line rulesdir/no-negated-variables function WithWritableReportOrNotFound(props: TProps, ref: ForwardedRef) { const {report = {reportID: ''}, route} = props; - const iouTypeParamIsInvalid = !Object.values(CONST.IOU.TYPE).includes(route.params?.iouType); + const iouTypeParamIsInvalid = !Object.values(CONST.IOU.TYPE) + .filter((type) => shouldIncludeDeprecatedIOUType || (type !== CONST.IOU.TYPE.REQUEST && type !== CONST.IOU.TYPE.SEND)) + .includes(route.params?.iouType); const canUserPerformWriteAction = ReportUtils.canUserPerformWriteAction(report); if (iouTypeParamIsInvalid || !canUserPerformWriteAction) { From b7bb995d2060fccaa9fa4114c7dcb750e398304f Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 19 Apr 2024 23:52:25 +0800 Subject: [PATCH 248/339] remove underscore guideline --- contributingGuides/STYLE.md | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/contributingGuides/STYLE.md b/contributingGuides/STYLE.md index 0a88ecd7bda8..2f2d136fa592 100644 --- a/contributingGuides/STYLE.md +++ b/contributingGuides/STYLE.md @@ -112,38 +112,9 @@ if (someCondition) { } ``` -## Object / Array Methods - -We have standardized on using [underscore.js](https://underscorejs.org/) methods for objects and collections instead of the native [Array instance methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#instance_methods). This is mostly to maintain consistency, but there are some type safety features and conveniences that underscore methods provide us e.g. the ability to iterate over an object and the lack of a `TypeError` thrown if a variable is `undefined`. - -```javascript -// Bad -myArray.forEach(item => doSomething(item)); -// Good -_.each(myArray, item => doSomething(item)); - -// Bad -const myArray = Object.keys(someObject).map(key => doSomething(someObject[key])); -// Good -const myArray = _.map(someObject, (value, key) => doSomething(value)); - -// Bad -myCollection.includes('item'); -// Good -_.contains(myCollection, 'item'); - -// Bad -const modifiedArray = someArray.filter(filterFunc).map(mapFunc); -// Good -const modifiedArray = _.chain(someArray) - .filter(filterFunc) - .map(mapFunc) - .value(); -``` - ## Accessing Object Properties and Default Values -Use `lodashGet()` to safely access object properties and `||` to short circuit null or undefined values that are not guaranteed to exist in a consistent way throughout the codebase. In the rare case that you want to consider a falsy value as usable and the `||` operator prevents this then be explicit about this in your code and check for the type using an underscore method e.g. `_.isBoolean(value)` or `_.isEqual(0)`. +Use `lodashGet()` to safely access object properties and `||` to short circuit null or undefined values that are not guaranteed to exist in a consistent way throughout the codebase. In the rare case that you want to consider a falsy value as usable and the `||` operator prevents this then be explicit about this in your code and check for the type. ```javascript // Bad From 57c59e8a4029eea4558f51bc5e211cc30311f233 Mon Sep 17 00:00:00 2001 From: dragnoir Date: Fri, 19 Apr 2024 17:56:23 +0100 Subject: [PATCH 249/339] Fix: align badge in workspace list --- src/pages/workspace/WorkspacesListPage.tsx | 2 +- src/pages/workspace/WorkspacesListRow.tsx | 20 +++++++++++++++++--- src/styles/index.ts | 14 ++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/WorkspacesListPage.tsx b/src/pages/workspace/WorkspacesListPage.tsx index 8e77da494ab3..3740630002f4 100755 --- a/src/pages/workspace/WorkspacesListPage.tsx +++ b/src/pages/workspace/WorkspacesListPage.tsx @@ -260,7 +260,7 @@ function WorkspacesListPage({policies, reimbursementAccount, reports, session}: {translate('workspace.common.workspaceType')} - + ); }, [isLessThanMediumScreen, styles, translate]); diff --git a/src/pages/workspace/WorkspacesListRow.tsx b/src/pages/workspace/WorkspacesListRow.tsx index e9963e5469c2..3991ee87f056 100644 --- a/src/pages/workspace/WorkspacesListRow.tsx +++ b/src/pages/workspace/WorkspacesListRow.tsx @@ -181,7 +181,7 @@ function WorkspacesListRow({ )} - + {isJoinRequestPending && ( - + - + { if (isSmallScreenWidth) { diff --git a/src/styles/index.ts b/src/styles/index.ts index 537038d9f2e1..2c29a840ec48 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -3207,6 +3207,20 @@ const styles = (theme: ThemeColors) => marginLeft: 3, }, + WorkspaceRightColumn: { + marginLeft: 99, + }, + + workspaceThreeDotMenu: { + marginLeft: 59, + }, + + workspaceListBadge: { + flexDirection: 'column', + justifyContent: 'flex-start', + marginTop: 6, + }, + autoGrowHeightMultilineInput: { maxHeight: 115, }, From bd0e9b01b1145480925a18425ed4821ae4dead8b Mon Sep 17 00:00:00 2001 From: Anusha Date: Fri, 19 Apr 2024 23:30:53 +0500 Subject: [PATCH 250/339] stop api call when user press save without changing name --- src/pages/GroupChatNameEditPage.tsx | 9 ++++++--- src/pages/home/HeaderView.tsx | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pages/GroupChatNameEditPage.tsx b/src/pages/GroupChatNameEditPage.tsx index 05d179fa552a..e2367b38a03b 100644 --- a/src/pages/GroupChatNameEditPage.tsx +++ b/src/pages/GroupChatNameEditPage.tsx @@ -65,12 +65,15 @@ function GroupChatNameEditPage({groupChatDraft, route}: GroupChatNameEditPagePro const editName = useCallback( (values: FormOnyxValues) => { if (isUpdatingExistingReport) { - Report.updateGroupChatName(reportID, values[INPUT_IDS.NEW_CHAT_NAME] ?? ''); + if (values[INPUT_IDS.NEW_CHAT_NAME] !== currentChatName) { + Report.updateGroupChatName(reportID, values[INPUT_IDS.NEW_CHAT_NAME] ?? ''); + } Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(reportID)); return; } - - Report.setGroupDraft({reportName: values[INPUT_IDS.NEW_CHAT_NAME]}); + if (values[INPUT_IDS.NEW_CHAT_NAME] !== currentChatName) { + Report.setGroupDraft({reportName: values[INPUT_IDS.NEW_CHAT_NAME]}); + } Navigation.goBack(ROUTES.NEW_CHAT_CONFIRM); }, [isUpdatingExistingReport, reportID], diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index a0105b36b264..32671dcd2e0d 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -202,7 +202,7 @@ function HeaderView({report, personalDetails, parentReport, parentReportAction, const brickRoadIndicator = ReportUtils.hasReportNameError(report) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; const shouldShowBorderBottom = !isTaskReport || !isSmallScreenWidth; const shouldDisableDetailPage = ReportUtils.shouldDisableDetailPage(report); - const shouldUseGroupTitle = report?.reportName !== ''; + const shouldUseGroupTitle = isGroupChat && !!report?.reportName; const isLoading = !report.reportID || !title; return ( From f09d6dec5c9061c9df88322d6762b76a75ecd8db Mon Sep 17 00:00:00 2001 From: Anusha Date: Fri, 19 Apr 2024 23:40:35 +0500 Subject: [PATCH 251/339] lint error fixed --- src/pages/GroupChatNameEditPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/GroupChatNameEditPage.tsx b/src/pages/GroupChatNameEditPage.tsx index e2367b38a03b..ee991d78d0af 100644 --- a/src/pages/GroupChatNameEditPage.tsx +++ b/src/pages/GroupChatNameEditPage.tsx @@ -76,7 +76,7 @@ function GroupChatNameEditPage({groupChatDraft, route}: GroupChatNameEditPagePro } Navigation.goBack(ROUTES.NEW_CHAT_CONFIRM); }, - [isUpdatingExistingReport, reportID], + [isUpdatingExistingReport, reportID, currentChatName], ); return ( From 2b4e55a7719d26b6f7b080e700a74fce9b035d7d Mon Sep 17 00:00:00 2001 From: dragnoir Date: Fri, 19 Apr 2024 20:13:43 +0100 Subject: [PATCH 252/339] make values base4 --- src/styles/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/styles/index.ts b/src/styles/index.ts index 2c29a840ec48..beb1b5a0f678 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -3208,11 +3208,11 @@ const styles = (theme: ThemeColors) => }, WorkspaceRightColumn: { - marginLeft: 99, + marginLeft: 100, }, workspaceThreeDotMenu: { - marginLeft: 59, + marginLeft: 60, }, workspaceListBadge: { From 36dae009c25c5d00455dc00287bbd5b87e04e129 Mon Sep 17 00:00:00 2001 From: Riya Shete <156463907+codinggeek2023@users.noreply.github.com> Date: Sat, 20 Apr 2024 02:10:44 +0530 Subject: [PATCH 253/339] Update index.tsx --- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 46b16822cb93..be0afca1fafa 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -487,7 +487,7 @@ function IOURequestStepScan({ const desktopUploadView = () => ( <> setReceiptImageTopPosition(PixelRatio.roundToNearestPixel(nativeEvent.layout.top))} > Date: Sat, 20 Apr 2024 06:31:14 +0530 Subject: [PATCH 254/339] Renaming some consts and minor updates to header title --- src/CONST.ts | 4 ++-- src/components/ReferralProgramCTA.tsx | 4 ++-- src/hooks/useDismissedReferralBanners.ts | 4 ++-- src/languages/en.ts | 4 ++-- src/languages/es.ts | 4 ++-- src/libs/TransactionUtils.ts | 15 --------------- ...oraryForRefactorRequestParticipantsSelector.js | 2 +- .../request/step/IOURequestStepConfirmation.tsx | 4 ++-- .../request/step/IOURequestStepParticipants.tsx | 4 ++-- .../MoneyRequestParticipantsSelector.js | 2 +- src/types/onyx/DismissedReferralBanners.ts | 4 ++-- 11 files changed, 18 insertions(+), 33 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index b5ffcc9c07e8..be5f778af37b 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3379,9 +3379,9 @@ const CONST = { REFERRAL_PROGRAM: { CONTENT_TYPES: { - MONEY_REQUEST: 'request', + SUBMIT_EXPENSE: 'submitExpense', START_CHAT: 'startChat', - SEND_MONEY: 'sendMoney', + PAY_SOMEONE: 'paySomeone', REFER_FRIEND: 'referralFriend', SHARE_CODE: 'shareCode', }, diff --git a/src/components/ReferralProgramCTA.tsx b/src/components/ReferralProgramCTA.tsx index 0588f31a0a8c..237fc8f955a3 100644 --- a/src/components/ReferralProgramCTA.tsx +++ b/src/components/ReferralProgramCTA.tsx @@ -15,9 +15,9 @@ import Tooltip from './Tooltip'; type ReferralProgramCTAProps = { referralContentType: - | typeof CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST + | typeof CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SUBMIT_EXPENSE | typeof CONST.REFERRAL_PROGRAM.CONTENT_TYPES.START_CHAT - | typeof CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SEND_MONEY + | typeof CONST.REFERRAL_PROGRAM.CONTENT_TYPES.PAY_SOMEONE | typeof CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND; style?: ViewStyle; onDismiss?: () => void; diff --git a/src/hooks/useDismissedReferralBanners.ts b/src/hooks/useDismissedReferralBanners.ts index 94ccd0a0b567..23a3ecefbbc9 100644 --- a/src/hooks/useDismissedReferralBanners.ts +++ b/src/hooks/useDismissedReferralBanners.ts @@ -5,9 +5,9 @@ import ONYXKEYS from '@src/ONYXKEYS'; type UseDismissedReferralBannersProps = { referralContentType: - | typeof CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST + | typeof CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SUBMIT_EXPENSE | typeof CONST.REFERRAL_PROGRAM.CONTENT_TYPES.START_CHAT - | typeof CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SEND_MONEY + | typeof CONST.REFERRAL_PROGRAM.CONTENT_TYPES.PAY_SOMEONE | typeof CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND; }; diff --git a/src/languages/en.ts b/src/languages/en.ts index fd018f5f5800..282650b185d4 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2645,13 +2645,13 @@ export default { header: `Start a chat, get $${CONST.REFERRAL_PROGRAM.REVENUE}`, body: `Get paid to talk to your friends! Start a chat with a new Expensify account and get $${CONST.REFERRAL_PROGRAM.REVENUE} when they become a customer.`, }, - [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST]: { + [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SUBMIT_EXPENSE]: { buttonText1: 'Submit expense, ', buttonText2: `get $${CONST.REFERRAL_PROGRAM.REVENUE}.`, header: `Submit an expense, get $${CONST.REFERRAL_PROGRAM.REVENUE}`, body: `It pays to get paid! Submit an expense to a new Expensify account and get $${CONST.REFERRAL_PROGRAM.REVENUE} when they become a customer.`, }, - [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SEND_MONEY]: { + [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.PAY_SOMEONE]: { buttonText1: 'Pay Someone, ', buttonText2: `get $${CONST.REFERRAL_PROGRAM.REVENUE}.`, header: `Pay Someone, get $${CONST.REFERRAL_PROGRAM.REVENUE}`, diff --git a/src/languages/es.ts b/src/languages/es.ts index cf0b0eea1799..802f1e3365dc 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -3135,13 +3135,13 @@ export default { header: `Inicia un chat y recibe $${CONST.REFERRAL_PROGRAM.REVENUE}`, body: `¡Gana dinero por hablar con tus amigos! Inicia un chat con una cuenta nueva de Expensify y recibe $${CONST.REFERRAL_PROGRAM.REVENUE} cuando se conviertan en clientes.`, }, - [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST]: { + [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SUBMIT_EXPENSE]: { buttonText1: 'Presentar gasto, ', buttonText2: `recibe $${CONST.REFERRAL_PROGRAM.REVENUE}`, header: `Presenta un gasto y consigue $${CONST.REFERRAL_PROGRAM.REVENUE}`, body: `¡Vale la pena cobrar! Envia un gasto a una cuenta nueva de Expensify y recibe $${CONST.REFERRAL_PROGRAM.REVENUE} cuando se conviertan en clientes.`, }, - [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SEND_MONEY]: { + [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.PAY_SOMEONE]: { buttonText1: 'Pagar a alguien, ', buttonText2: `recibe $${CONST.REFERRAL_PROGRAM.REVENUE}`, header: `Paga a alguien y recibe $${CONST.REFERRAL_PROGRAM.REVENUE}`, diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index a5b85b87e37e..fbe7edc960ba 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -3,7 +3,6 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import CONST from '@src/CONST'; -import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import type {RecentWaypoint, Report, TaxRate, TaxRates, TaxRatesWithDefault, Transaction, TransactionViolation} from '@src/types/onyx'; import type {Comment, Receipt, TransactionChanges, TransactionPendingFieldsKey, Waypoint, WaypointCollection} from '@src/types/onyx/Transaction'; @@ -450,19 +449,6 @@ function getCreated(transaction: OnyxEntry, dateFormat: string = CO return DateUtils.formatWithUTCTimeZone(created, dateFormat); } -/** - * Returns the translation key to use for the header title - */ -function getHeaderTitleTranslationKey(transaction: OnyxEntry): TranslationPaths { - const headerTitles: Record = { - [CONST.IOU.REQUEST_TYPE.DISTANCE]: 'tabSelector.distance', - [CONST.IOU.REQUEST_TYPE.MANUAL]: 'tabSelector.manual', - [CONST.IOU.REQUEST_TYPE.SCAN]: 'tabSelector.scan', - }; - - return headerTitles[getRequestType(transaction)]; -} - /** * Determine whether a transaction is made with an Expensify card. */ @@ -655,7 +641,6 @@ export { getEnabledTaxRateCount, getUpdatedTransaction, getDescription, - getHeaderTitleTranslationKey, getRequestType, isManualRequest, isScanRequest, diff --git a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js index bda8c25d9b18..e12269b93796 100644 --- a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js +++ b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js @@ -67,7 +67,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF const {translate} = useLocalize(); const styles = useThemeStyles(); const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState(''); - const referralContentType = iouType === CONST.IOU.TYPE.PAY ? CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SEND_MONEY : CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST; + const referralContentType = iouType === CONST.IOU.TYPE.PAY ? CONST.REFERRAL_PROGRAM.CONTENT_TYPES.PAY_SOMEONE : CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SUBMIT_EXPENSE; const {isOffline} = useNetwork(); const personalDetails = usePersonalDetails(); const {isDismissed} = useDismissedReferralBanners({referralContentType}); diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index b7622d784c39..f627c052ad90 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -100,8 +100,8 @@ function IOURequestStepConfirmation({ if (iouType === CONST.IOU.TYPE.PAY) { return translate('iou.paySomeone', {name: ReportUtils.getPayeeName(report)}); } - return translate(TransactionUtils.getHeaderTitleTranslationKey(transaction)); - }, [iouType, report, transaction, translate, isSharingTrackExpense, isCategorizingTrackExpense, isSubmittingFromTrackExpense]); + return translate('iou.submitExpense'); + }, [iouType, report, translate, isSharingTrackExpense, isCategorizingTrackExpense, isSubmittingFromTrackExpense]); const participants = useMemo( () => diff --git a/src/pages/iou/request/step/IOURequestStepParticipants.tsx b/src/pages/iou/request/step/IOURequestStepParticipants.tsx index bcd03fe038bf..b412704900e6 100644 --- a/src/pages/iou/request/step/IOURequestStepParticipants.tsx +++ b/src/pages/iou/request/step/IOURequestStepParticipants.tsx @@ -54,8 +54,8 @@ function IOURequestStepParticipants({ if (iouType === CONST.IOU.TYPE.PAY) { return translate('iou.paySomeone', {}); } - return translate(TransactionUtils.getHeaderTitleTranslationKey(transaction)); - }, [iouType, transaction, translate, isSplitRequest, action]); + return translate('iou.submitExpense'); + }, [iouType, translate, isSplitRequest, action]); const receiptFilename = transaction?.filename; const receiptPath = transaction?.receipt?.source; diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js index 31ca7ba0098d..58935cf04330 100755 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js @@ -66,7 +66,7 @@ function MoneyRequestParticipantsSelector({participants, navigateToRequest, navi const styles = useThemeStyles(); const [betas] = useOnyx(ONYXKEYS.BETAS); const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState(''); - const referralContentType = iouType === CONST.IOU.TYPE.SEND ? CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SEND_MONEY : CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST; + const referralContentType = iouType === CONST.IOU.TYPE.SEND ? CONST.REFERRAL_PROGRAM.CONTENT_TYPES.PAY_SOMEONE : CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SUBMIT_EXPENSE; const {isOffline} = useNetwork(); const personalDetails = usePersonalDetails(); const {options, areOptionsInitialized} = useOptionsList({shouldInitialize: didScreenTransitionEnd}); diff --git a/src/types/onyx/DismissedReferralBanners.ts b/src/types/onyx/DismissedReferralBanners.ts index 43fa6472a6ae..86937d3bfbaf 100644 --- a/src/types/onyx/DismissedReferralBanners.ts +++ b/src/types/onyx/DismissedReferralBanners.ts @@ -1,9 +1,9 @@ import type CONST from '@src/CONST'; type DismissedReferralBanners = { - [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST]?: boolean; + [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SUBMIT_EXPENSE]?: boolean; [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.START_CHAT]?: boolean; - [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SEND_MONEY]?: boolean; + [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.PAY_SOMEONE]?: boolean; [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND]?: boolean; [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SHARE_CODE]?: boolean; }; From 62ef4b8b524c9bb345a9978297c8e65db7143c59 Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Sat, 20 Apr 2024 06:37:28 +0530 Subject: [PATCH 255/339] Fixing routes after merge --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index d66be06671a8..f337f2f40c71 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -311,7 +311,7 @@ function MoneyRequestView({ shouldShowRightIcon={canEditDistance} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID)) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.SUBMIT, transaction?.transactionID ?? '', report.reportID)) } /> From b3acaa16b20e533351fa32a19879ac6060e1386e Mon Sep 17 00:00:00 2001 From: tienifr Date: Sat, 20 Apr 2024 11:16:01 +0700 Subject: [PATCH 256/339] fix add queue command length log --- src/libs/API/index.ts | 4 ++++ src/libs/Network/SequentialQueue.ts | 2 ++ src/libs/actions/PersistedRequests.ts | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libs/API/index.ts b/src/libs/API/index.ts index dbbcf790edf0..bfa1b95836f8 100644 --- a/src/libs/API/index.ts +++ b/src/libs/API/index.ts @@ -5,6 +5,7 @@ import * as Middleware from '@libs/Middleware'; import * as SequentialQueue from '@libs/Network/SequentialQueue'; import * as Pusher from '@libs/Pusher/pusher'; import * as Request from '@libs/Request'; +import * as PersistedRequests from '@userActions/PersistedRequests'; import CONST from '@src/CONST'; import type OnyxRequest from '@src/types/onyx/Request'; import type Response from '@src/types/onyx/Response'; @@ -159,6 +160,9 @@ function read(command: TCommand, apiCommandParamet // Ensure all write requests on the sequential queue have finished responding before running read requests. // Responses from read requests can overwrite the optimistic data inserted by // write requests that use the same Onyx keys and haven't responded yet. + if (PersistedRequests.getLength() > 0) { + Log.info(`[API] '${command}' is waiting on ${PersistedRequests.getLength()} write commands`); + } SequentialQueue.waitForIdle().then(() => makeRequestWithSideEffects(command, apiCommandParameters, onyxData, CONST.API_REQUEST_TYPE.READ)); } diff --git a/src/libs/Network/SequentialQueue.ts b/src/libs/Network/SequentialQueue.ts index 38b0549b28bc..0cfa8e17b589 100644 --- a/src/libs/Network/SequentialQueue.ts +++ b/src/libs/Network/SequentialQueue.ts @@ -1,5 +1,6 @@ import Onyx from 'react-native-onyx'; import * as ActiveClientManager from '@libs/ActiveClientManager'; +import Log from '@libs/Log'; import * as Request from '@libs/Request'; import * as RequestThrottle from '@libs/RequestThrottle'; import * as PersistedRequests from '@userActions/PersistedRequests'; @@ -162,6 +163,7 @@ NetworkStore.onReconnection(flush); function push(request: OnyxRequest) { // Add request to Persisted Requests so that it can be retried if it fails PersistedRequests.save(request); + Log.info(`[SequentialQueue] '${request.commandName}' command queued. Queue length is ${PersistedRequests.getLength()}`); // If we are offline we don't need to trigger the queue to empty as it will happen when we come back online if (NetworkStore.isOffline()) { diff --git a/src/libs/actions/PersistedRequests.ts b/src/libs/actions/PersistedRequests.ts index 8894af8c374f..410b8931d92a 100644 --- a/src/libs/actions/PersistedRequests.ts +++ b/src/libs/actions/PersistedRequests.ts @@ -48,4 +48,8 @@ function getAll(): Request[] { return persistedRequests; } -export {clear, save, getAll, remove, update}; +function getLength(): number { + return persistedRequests.length; +} + +export {clear, save, getAll, remove, update, getLength}; From 09b2e1295a8e6c0a8158e4d0024169195cf6c64c Mon Sep 17 00:00:00 2001 From: tienifr Date: Sat, 20 Apr 2024 11:25:00 +0700 Subject: [PATCH 257/339] fix use promise --- src/libs/Network/SequentialQueue.ts | 1 - src/libs/actions/PersistedRequests.ts | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libs/Network/SequentialQueue.ts b/src/libs/Network/SequentialQueue.ts index 0cfa8e17b589..d0b10a88388f 100644 --- a/src/libs/Network/SequentialQueue.ts +++ b/src/libs/Network/SequentialQueue.ts @@ -163,7 +163,6 @@ NetworkStore.onReconnection(flush); function push(request: OnyxRequest) { // Add request to Persisted Requests so that it can be retried if it fails PersistedRequests.save(request); - Log.info(`[SequentialQueue] '${request.commandName}' command queued. Queue length is ${PersistedRequests.getLength()}`); // If we are offline we don't need to trigger the queue to empty as it will happen when we come back online if (NetworkStore.isOffline()) { diff --git a/src/libs/actions/PersistedRequests.ts b/src/libs/actions/PersistedRequests.ts index 410b8931d92a..0bf51a500ce6 100644 --- a/src/libs/actions/PersistedRequests.ts +++ b/src/libs/actions/PersistedRequests.ts @@ -1,5 +1,7 @@ import isEqual from 'lodash/isEqual'; import Onyx from 'react-native-onyx'; +import Log from '@libs/Log'; +import * as PersistedRequests from '@userActions/PersistedRequests'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Request} from '@src/types/onyx'; @@ -19,7 +21,9 @@ function clear() { function save(requestToPersist: Request) { persistedRequests.push(requestToPersist); - Onyx.set(ONYXKEYS.PERSISTED_REQUESTS, persistedRequests); + Onyx.set(ONYXKEYS.PERSISTED_REQUESTS, persistedRequests).then(() => { + Log.info(`[SequentialQueue] '${requestToPersist.command}' command queued. Queue length is ${PersistedRequests.getLength()}`); + }); } function remove(requestToRemove: Request) { From a34d3baacc659e1d70299f8ed0b4709cc1b01d83 Mon Sep 17 00:00:00 2001 From: tienifr Date: Sat, 20 Apr 2024 11:26:42 +0700 Subject: [PATCH 258/339] fix lint --- src/libs/Network/SequentialQueue.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/Network/SequentialQueue.ts b/src/libs/Network/SequentialQueue.ts index d0b10a88388f..38b0549b28bc 100644 --- a/src/libs/Network/SequentialQueue.ts +++ b/src/libs/Network/SequentialQueue.ts @@ -1,6 +1,5 @@ import Onyx from 'react-native-onyx'; import * as ActiveClientManager from '@libs/ActiveClientManager'; -import Log from '@libs/Log'; import * as Request from '@libs/Request'; import * as RequestThrottle from '@libs/RequestThrottle'; import * as PersistedRequests from '@userActions/PersistedRequests'; From 1ecb38527325ca78f22c4427074a49ac766c5576 Mon Sep 17 00:00:00 2001 From: tienifr Date: Sat, 20 Apr 2024 11:35:25 +0700 Subject: [PATCH 259/339] fix lint --- src/libs/actions/PersistedRequests.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/actions/PersistedRequests.ts b/src/libs/actions/PersistedRequests.ts index 0bf51a500ce6..ab380a2ae1fa 100644 --- a/src/libs/actions/PersistedRequests.ts +++ b/src/libs/actions/PersistedRequests.ts @@ -1,7 +1,6 @@ import isEqual from 'lodash/isEqual'; import Onyx from 'react-native-onyx'; import Log from '@libs/Log'; -import * as PersistedRequests from '@userActions/PersistedRequests'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Request} from '@src/types/onyx'; @@ -22,7 +21,7 @@ function clear() { function save(requestToPersist: Request) { persistedRequests.push(requestToPersist); Onyx.set(ONYXKEYS.PERSISTED_REQUESTS, persistedRequests).then(() => { - Log.info(`[SequentialQueue] '${requestToPersist.command}' command queued. Queue length is ${PersistedRequests.getLength()}`); + Log.info(`[SequentialQueue] '${requestToPersist.command}' command queued. Queue length is ${getLength()}`); }); } From 3c4bcf80abfda02a296676b00d21372b7c40c5fa Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sat, 20 Apr 2024 12:39:46 +0800 Subject: [PATCH 260/339] remove unused files --- src/components/transactionPropTypes.js | 96 ----- .../MoneyRequestParticipantsSelector.js | 361 ------------------ 2 files changed, 457 deletions(-) delete mode 100644 src/components/transactionPropTypes.js delete mode 100755 src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js diff --git a/src/components/transactionPropTypes.js b/src/components/transactionPropTypes.js deleted file mode 100644 index d1626b75d6cd..000000000000 --- a/src/components/transactionPropTypes.js +++ /dev/null @@ -1,96 +0,0 @@ -import lodashValues from 'lodash/values'; -import PropTypes from 'prop-types'; -import {translatableTextPropTypes} from '@libs/Localize'; -import CONST from '@src/CONST'; -import sourcePropTypes from './Image/sourcePropTypes'; - -export default PropTypes.shape({ - /** The transaction id */ - transactionID: PropTypes.string, - - /** The iouReportID associated with the transaction */ - reportID: PropTypes.string, - - /** The original transaction amount */ - amount: PropTypes.number, - - /** The edited transaction amount */ - modifiedAmount: PropTypes.number, - - /** The original created data */ - created: PropTypes.string, - - /** The edited transaction date */ - modifiedCreated: PropTypes.string, - - /** The filename of the associated receipt */ - filename: PropTypes.string, - - /** The original merchant name */ - merchant: PropTypes.string, - - /** The edited merchant name */ - modifiedMerchant: PropTypes.string, - - /** The comment object on the transaction */ - comment: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.shape({ - /** The text of the comment */ - comment: PropTypes.string, - - /** The waypoints defining the distance expense */ - waypoints: PropTypes.shape({ - /** The latitude of the waypoint */ - lat: PropTypes.number, - - /** The longitude of the waypoint */ - lng: PropTypes.number, - - /** The address of the waypoint */ - address: PropTypes.string, - - /** The name of the waypoint */ - name: PropTypes.string, - }), - }), - ]), - - /** The type of transaction */ - type: PropTypes.oneOf(lodashValues(CONST.TRANSACTION.TYPE)), - - /** Custom units attached to the transaction */ - customUnits: PropTypes.arrayOf( - PropTypes.shape({ - /** The name of the custom unit */ - name: PropTypes.string, - }), - ), - - /** Selected participants */ - participants: PropTypes.arrayOf( - PropTypes.shape({ - accountID: PropTypes.number, - login: PropTypes.string, - isPolicyExpenseChat: PropTypes.bool, - isOwnPolicyExpenseChat: PropTypes.bool, - selected: PropTypes.bool, - }), - ), - - /** The original currency of the transaction */ - currency: PropTypes.string, - - /** The edited currency of the transaction */ - modifiedCurrency: PropTypes.string, - - /** The receipt object associated with the transaction */ - receipt: PropTypes.shape({ - receiptID: PropTypes.number, - source: PropTypes.oneOfType([PropTypes.number, PropTypes.string, sourcePropTypes]), - state: PropTypes.string, - }), - - /** Server side errors keyed by microtime */ - errorFields: PropTypes.objectOf(PropTypes.objectOf(translatableTextPropTypes)), -}); diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js deleted file mode 100755 index 1bcaba0c691f..000000000000 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js +++ /dev/null @@ -1,361 +0,0 @@ -import lodashGet from 'lodash/get'; -import lodashMap from 'lodash/map'; -import lodashReject from 'lodash/reject'; -import lodashSome from 'lodash/some'; -import PropTypes from 'prop-types'; -import React, {useCallback, useMemo} from 'react'; -import {useOnyx} from 'react-native-onyx'; -import Button from '@components/Button'; -import FormHelpMessage from '@components/FormHelpMessage'; -import {usePersonalDetails} from '@components/OnyxProvider'; -import {useOptionsList} from '@components/OptionListContextProvider'; -import {PressableWithFeedback} from '@components/Pressable'; -import ReferralProgramCTA from '@components/ReferralProgramCTA'; -import SelectCircle from '@components/SelectCircle'; -import SelectionList from '@components/SelectionList'; -import UserListItem from '@components/SelectionList/UserListItem'; -import useDebouncedState from '@hooks/useDebouncedState'; -import useDismissedReferralBanners from '@hooks/useDismissedReferralBanners'; -import useLocalize from '@hooks/useLocalize'; -import useNetwork from '@hooks/useNetwork'; -import usePermissions from '@hooks/usePermissions'; -import useSearchTermAndSearch from '@hooks/useSearchTermAndSearch'; -import useThemeStyles from '@hooks/useThemeStyles'; -import * as DeviceCapabilities from '@libs/DeviceCapabilities'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; - -const propTypes = { - /** Callback to request parent modal to go to next step, which should be request */ - navigateToRequest: PropTypes.func.isRequired, - - /** Callback to request parent modal to go to next step, which should be split */ - navigateToSplit: PropTypes.func.isRequired, - - /** Callback to add participants in MoneyRequestModal */ - onAddParticipants: PropTypes.func.isRequired, - - /** Selected participants from MoneyRequestModal with login */ - participants: PropTypes.arrayOf( - PropTypes.shape({ - accountID: PropTypes.number, - login: PropTypes.string, - isPolicyExpenseChat: PropTypes.bool, - isOwnPolicyExpenseChat: PropTypes.bool, - selected: PropTypes.bool, - }), - ), - - /** The type of IOU report, i.e. bill, request, send */ - iouType: PropTypes.string.isRequired, - - /** Whether the money request is a distance request or not */ - isDistanceRequest: PropTypes.bool, - - /** Whether the screen transition has ended */ - didScreenTransitionEnd: PropTypes.bool, -}; - -const defaultProps = { - participants: [], - isDistanceRequest: false, - didScreenTransitionEnd: false, -}; - -function MoneyRequestParticipantsSelector({participants, navigateToRequest, navigateToSplit, onAddParticipants, iouType, isDistanceRequest, didScreenTransitionEnd}) { - const {translate} = useLocalize(); - const styles = useThemeStyles(); - const [betas] = useOnyx(ONYXKEYS.BETAS); - const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState(''); - const referralContentType = iouType === CONST.IOU.TYPE.SEND ? CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SEND_MONEY : CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST; - const {isOffline} = useNetwork(); - const personalDetails = usePersonalDetails(); - const {options, areOptionsInitialized} = useOptionsList({shouldInitialize: didScreenTransitionEnd}); - const {canUseP2PDistanceRequests} = usePermissions(iouType); - - const maxParticipantsReached = participants.length === CONST.REPORT.MAXIMUM_PARTICIPANTS; - const setSearchTermAndSearchInServer = useSearchTermAndSearch(setSearchTerm, maxParticipantsReached); - - const offlineMessage = isOffline ? [`${translate('common.youAppearToBeOffline')} ${translate('search.resultsAreLimited')}`, {isTranslated: true}] : ''; - - const newChatOptions = useMemo(() => { - const chatOptions = OptionsListUtils.getFilteredOptions( - options.reports, - options.personalDetails, - betas, - debouncedSearchTerm, - participants, - CONST.EXPENSIFY_EMAILS, - - // If we are using this component in the "Request money" flow then we pass the includeOwnedWorkspaceChats argument so that the current user - // sees the option to request money from their admin on their own Workspace Chat. - iouType === CONST.IOU.TYPE.REQUEST, - - canUseP2PDistanceRequests || !isDistanceRequest, - false, - {}, - [], - false, - {}, - [], - // We don't want the user to be able to invite individuals when they are in the "Distance request" flow for now. - // This functionality is being built here: https://github.com/Expensify/App/issues/23291 - canUseP2PDistanceRequests || !isDistanceRequest, - true, - ); - return { - recentReports: chatOptions.recentReports, - personalDetails: chatOptions.personalDetails, - userToInvite: chatOptions.userToInvite, - }; - }, [options.reports, options.personalDetails, betas, debouncedSearchTerm, participants, iouType, canUseP2PDistanceRequests, isDistanceRequest]); - - /** - * Returns the sections needed for the OptionsSelector - * - * @returns {Array} - */ - const sections = useMemo(() => { - const newSections = []; - - const formatResults = OptionsListUtils.formatSectionsFromSearchTerm( - debouncedSearchTerm, - participants, - newChatOptions.recentReports, - newChatOptions.personalDetails, - maxParticipantsReached, - personalDetails, - true, - ); - newSections.push(formatResults.section); - - if (maxParticipantsReached) { - return newSections; - } - - newSections.push({ - title: translate('common.recents'), - data: newChatOptions.recentReports, - shouldShow: newChatOptions.recentReports.length > 0, - }); - - newSections.push({ - title: translate('common.contacts'), - data: newChatOptions.personalDetails, - shouldShow: newChatOptions.personalDetails.length > 0, - }); - - if (newChatOptions.userToInvite && !OptionsListUtils.isCurrentUser(newChatOptions.userToInvite)) { - newSections.push({ - title: undefined, - data: lodashMap([newChatOptions.userToInvite], (participant) => { - const isPolicyExpenseChat = lodashGet(participant, 'isPolicyExpenseChat', false); - return isPolicyExpenseChat ? OptionsListUtils.getPolicyExpenseReportOption(participant) : OptionsListUtils.getParticipantsOption(participant, personalDetails); - }), - shouldShow: true, - }); - } - - return newSections; - }, [maxParticipantsReached, newChatOptions.personalDetails, newChatOptions.recentReports, newChatOptions.userToInvite, participants, personalDetails, debouncedSearchTerm, translate]); - - /** - * Adds a single participant to the request - * - * @param {Object} option - */ - const addSingleParticipant = useCallback( - (option) => { - if (participants.length) { - return; - } - onAddParticipants( - [ - { - accountID: option.accountID, - login: option.login, - isPolicyExpenseChat: option.isPolicyExpenseChat, - reportID: option.reportID, - selected: true, - searchText: option.searchText, - }, - ], - false, - ); - navigateToRequest(); - }, - [navigateToRequest, onAddParticipants, participants.length], - ); - - /** - * Removes a selected option from list if already selected. If not already selected add this option to the list. - * @param {Object} option - */ - const addParticipantToSelection = useCallback( - (option) => { - const isOptionSelected = (selectedOption) => { - if (selectedOption.accountID && selectedOption.accountID === option.accountID) { - return true; - } - - if (selectedOption.reportID && selectedOption.reportID === option.reportID) { - return true; - } - - return false; - }; - const isOptionInList = lodashSome(participants, isOptionSelected); - let newSelectedOptions; - - if (isOptionInList) { - newSelectedOptions = lodashReject(participants, isOptionSelected); - } else { - newSelectedOptions = [ - ...participants, - { - accountID: option.accountID, - login: option.login, - isPolicyExpenseChat: option.isPolicyExpenseChat, - reportID: option.reportID, - selected: true, - searchText: option.searchText, - }, - ]; - } - onAddParticipants(newSelectedOptions, newSelectedOptions.length !== 0); - }, - [participants, onAddParticipants], - ); - - const headerMessage = useMemo( - () => - OptionsListUtils.getHeaderMessage( - lodashGet(newChatOptions, 'personalDetails', []).length + lodashGet(newChatOptions, 'recentReports', []).length !== 0, - Boolean(newChatOptions.userToInvite), - debouncedSearchTerm.trim(), - maxParticipantsReached, - lodashSome(participants, (participant) => participant.searchText.toLowerCase().includes(debouncedSearchTerm.trim().toLowerCase())), - ), - [maxParticipantsReached, newChatOptions, participants, debouncedSearchTerm], - ); - - // Right now you can't split a request with a workspace and other additional participants - // This is getting properly fixed in https://github.com/Expensify/App/issues/27508, but as a stop-gap to prevent - // the app from crashing on native when you try to do this, we'll going to show error message if you have a workspace and other participants - const hasPolicyExpenseChatParticipant = lodashSome(participants, (participant) => participant.isPolicyExpenseChat); - const shouldShowSplitBillErrorMessage = participants.length > 1 && hasPolicyExpenseChatParticipant; - - // canUseP2PDistanceRequests is true if the iouType is track expense, but we don't want to allow splitting distance with track expense yet - const isAllowedToSplit = (canUseP2PDistanceRequests || !isDistanceRequest) && (iouType !== CONST.IOU.TYPE.SEND || iouType !== CONST.IOU.TYPE.TRACK_EXPENSE); - - const handleConfirmSelection = useCallback( - (keyEvent, option) => { - const shouldAddSingleParticipant = option && !participants.length; - - if (shouldShowSplitBillErrorMessage || (!participants.length && !option)) { - return; - } - - if (shouldAddSingleParticipant) { - addSingleParticipant(option); - return; - } - - navigateToSplit(); - }, - [shouldShowSplitBillErrorMessage, navigateToSplit, addSingleParticipant, participants.length], - ); - - const {isDismissed} = useDismissedReferralBanners({referralContentType}); - - const footerContent = useMemo(() => { - if (isDismissed && !shouldShowSplitBillErrorMessage && !participants.length) { - return null; - } - return ( - <> - {!isDismissed && ( - - )} - - {shouldShowSplitBillErrorMessage && ( - - )} - - {!!participants.length && ( -