Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - Distance request thumbnail is different in reports preview when created offline #39243

Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
087cbcd
implemented confirmed route for report preview
FitseTLT Mar 20, 2024
46ac65e
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT Mar 28, 2024
cd70586
minor fixes
FitseTLT Mar 28, 2024
cbc5f9c
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT Apr 8, 2024
4828b62
Changed empty state route pending icon
FitseTLT Apr 8, 2024
77e3ca4
add icon fill color
FitseTLT Apr 8, 2024
420850d
down sized icon for multiple previews
FitseTLT Apr 8, 2024
e16cde5
change ultra large icon size
FitseTLT Apr 9, 2024
3a7f04c
changed background color
FitseTLT Apr 9, 2024
fc8f34f
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT Apr 10, 2024
85a48d7
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT Apr 11, 2024
23d62ea
fix border radius
FitseTLT Apr 11, 2024
cd719c1
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT Apr 12, 2024
bb3c43e
fixed border radius problem
FitseTLT Apr 12, 2024
0461c1f
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT Apr 15, 2024
4026391
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT Apr 19, 2024
649e85d
centralized map view display inside ReportActionItemImages
FitseTLT Apr 19, 2024
a96484f
added pending waypoints case to display map view
FitseTLT Apr 19, 2024
0cbef95
remove unnecessary condition
FitseTLT Apr 19, 2024
7e280da
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT Apr 25, 2024
3c9d5bd
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT Apr 25, 2024
d04f1a3
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT May 2, 2024
118f065
disable map interactiveness
FitseTLT May 2, 2024
17dbb41
changed variable name
FitseTLT May 2, 2024
de71096
changed variable name to isSmallerIcon
FitseTLT May 2, 2024
b2e5791
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT May 8, 2024
b0cb6bc
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT May 9, 2024
4460deb
remove redundant variable
FitseTLT May 9, 2024
95924c6
changed map pending subtitle color to supporting text
FitseTLT May 9, 2024
927e82f
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT May 13, 2024
b8612b8
minor fix
FitseTLT May 13, 2024
a6c6ebc
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT May 15, 2024
cba14d8
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT May 16, 2024
b988fe0
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT May 24, 2024
6f58d86
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT May 29, 2024
5bd900a
remove duplicate helper
FitseTLT May 29, 2024
f488ecb
remove dupe
FitseTLT May 29, 2024
aad7ac8
fix displaying map without route
FitseTLT May 29, 2024
e5f1df3
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT May 30, 2024
363d425
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT May 31, 2024
a3819ee
changed variable name
FitseTLT Jun 3, 2024
bc2fa19
Merge branch 'main' into fix-distance-request-thumbnail-mismatch
FitseTLT Jun 3, 2024
b288702
minor fix
FitseTLT Jun 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/components/ConfirmedRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ type ConfirmedRouteProps = ConfirmedRoutePropsOnyxProps & {
/** Whether it should have border radius */
shouldHaveBorderRadius?: boolean;

/** Whether it should display the Mapbox map only when the route/coordinates exist otherwise
* it will display pending map icon */
shouldDisplayMapOnlyIfCoordinatesExist?: boolean;

FitseTLT marked this conversation as resolved.
Show resolved Hide resolved
/** Whether the map is interactable or not */
interactive?: boolean;
};

function ConfirmedRoute({mapboxAccessToken, transaction, isSmallerIcon, shouldHaveBorderRadius = true, interactive}: ConfirmedRouteProps) {
function ConfirmedRoute({mapboxAccessToken, transaction, isSmallerIcon, shouldHaveBorderRadius = true, shouldDisplayMapOnlyIfCoordinatesExist = false, interactive}: ConfirmedRouteProps) {
const {isOffline} = useNetwork();
const {route0: route} = transaction?.routes ?? {};
const waypoints = transaction?.comment?.waypoints ?? {};
Expand Down Expand Up @@ -98,7 +102,9 @@ function ConfirmedRoute({mapboxAccessToken, transaction, isSmallerIcon, shouldHa
return MapboxToken.stop;
}, []);

return !isOffline && Boolean(mapboxAccessToken?.token) ? (
const shouldDisplayMap = !shouldDisplayMapOnlyIfCoordinatesExist || (shouldDisplayMapOnlyIfCoordinatesExist && !!coordinates.length);
FitseTLT marked this conversation as resolved.
Show resolved Hide resolved

return !isOffline && Boolean(mapboxAccessToken?.token) && shouldDisplayMap ? (
<DistanceMapView
interactive={interactive}
accessToken={mapboxAccessToken?.token ?? ''}
Expand Down
19 changes: 14 additions & 5 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,20 @@ function MoneyRequestView({
</OfflineWithFeedback>
);

const shouldShowReceiptEmptyState = !hasReceipt && !isInvoice && (canEditReceipt || isAdmin || isApprover);
const noticeTypeViolations = transactionViolations?.filter((violation) => violation.type === 'notice').map((v) => ViolationsUtils.getViolationTranslation(v, translate)) ?? [];
const isReceiptAllowed = !isPaidReport && !isInvoice;
const shouldShowReceiptEmptyState =
isReceiptAllowed && !hasReceipt && !isApproved && !isSettled && (canEditReceipt || isAdmin || isApprover) && (canEditReceipt || ReportUtils.isPaidGroupPolicy(report));
const receiptViolationNames: OnyxTypes.ViolationName[] = [
CONST.VIOLATIONS.RECEIPT_REQUIRED,
CONST.VIOLATIONS.RECEIPT_NOT_SMART_SCANNED,
CONST.VIOLATIONS.MODIFIED_DATE,
CONST.VIOLATIONS.CASH_EXPENSE_WITH_NO_RECEIPT,
CONST.VIOLATIONS.SMARTSCAN_FAILED,
];
const receiptViolations =
transactionViolations?.filter((violation) => receiptViolationNames.includes(violation.name)).map((violation) => ViolationsUtils.getViolationTranslation(violation, translate)) ?? [];
const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && ReportUtils.isPaidGroupPolicy(report);
const shouldShowReceiptHeader = isReceiptAllowed && (shouldShowReceiptEmptyState || shouldShowMapOrReceipt) && canUseViolations && ReportUtils.isPaidGroupPolicy(report);
const shouldShowReceiptHeader = isReceiptAllowed && (shouldShowReceiptEmptyState || hasReceipt) && canUseViolations && ReportUtils.isPaidGroupPolicy(report);

return (
<View style={styles.pRelative}>
Expand Down Expand Up @@ -371,8 +381,7 @@ function MoneyRequestView({
/>
)}
{!shouldShowReceiptEmptyState && !hasReceipt && <View style={{marginVertical: 6}} />}
{shouldShowNotesViolations && <ReceiptAuditMessages notes={noticeTypeViolations} />}
{canUseViolations && <ViolationMessages violations={getViolationsForField('receipt')} />}
{shouldShowNotesViolations && <ReceiptAuditMessages notes={receiptViolations} />}
<OfflineWithFeedback pendingAction={getPendingFieldAction('amount')}>
<MenuItemWithTopDescription
title={amountTitle}
Expand Down
3 changes: 2 additions & 1 deletion src/components/ReportActionItem/ReportActionItemImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function ReportActionItemImage({
}: ReportActionItemImageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const isDistanceRequest = Boolean(transaction && TransactionUtils.isDistanceRequest(transaction));
const isDistanceRequest = !!transaction && TransactionUtils.isDistanceRequest(transaction);
const hasPendingWaypoints = transaction && TransactionUtils.isFetchingWaypointsFromServer(transaction);
const showMapAsImage = isDistanceRequest && hasPendingWaypoints;

Expand All @@ -85,6 +85,7 @@ function ReportActionItemImage({
isSmallerIcon={!isSingleImage}
shouldHaveBorderRadius={shouldMapHaveBorderRadius}
interactive={false}
shouldDisplayMapOnlyIfCoordinatesExist
/>
</View>
);
Expand Down
49 changes: 25 additions & 24 deletions src/components/ReportActionItem/ReportActionItemImages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,30 +66,31 @@ function ReportActionItemImages({images, size, total, isHovered = false}: Report
return (
<View style={styles.reportActionItemImagesContainer}>
<View style={[styles.reportActionItemImages, hoverStyle, heightStyle]}>
{shownImages.map(({thumbnail, isThumbnail, image, transaction, isLocalFile, fileExtension, filename}, index) => {
// Show a border to separate multiple images. Shown to the right for each except the last.
const shouldShowBorder = shownImages.length > 1 && index < shownImages.length - 1;
const borderStyle = shouldShowBorder ? styles.reportActionItemImageBorder : {};

return (
<View
key={`${index}-${image}`}
style={[styles.reportActionItemImage, borderStyle, hoverStyle]}
>
<ReportActionItemImage
thumbnail={thumbnail}
fileExtension={fileExtension}
image={image}
isLocalFile={isLocalFile}
filename={filename}
transaction={transaction}
isThumbnail={isThumbnail}
isSingleImage={numberOfShownImages === 1}
shouldMapHaveBorderRadius={false}
/>
</View>
);
})}
<ImageBehaviorContextProvider shouldSetAspectRatioInStyle={false}>
{shownImages.map(({thumbnail, isThumbnail, image, transaction, isLocalFile, fileExtension, filename}, index) => {
// Show a border to separate multiple images. Shown to the right for each except the last.
const shouldShowBorder = shownImages.length > 1 && index < shownImages.length - 1;
const borderStyle = shouldShowBorder ? styles.reportActionItemImageBorder : {};
return (
<View
key={`${index}-${image}`}
style={[styles.reportActionItemImage, borderStyle, hoverStyle]}
>
<ReportActionItemImage
thumbnail={thumbnail}
fileExtension={fileExtension}
image={image}
isLocalFile={isLocalFile}
filename={filename}
transaction={transaction}
isThumbnail={isThumbnail}
isSingleImage={numberOfShownImages === 1}
shouldMapHaveBorderRadius={false}
/>
</View>
);
})}
</ImageBehaviorContextProvider>
</View>
{remaining > 0 && (
<View style={[styles.reportActionItemImagesMoreContainer]}>
Expand Down
3 changes: 3 additions & 0 deletions src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ function ReportPreview({
const hasErrors = hasMissingSmartscanFields || (canUseViolations && ReportUtils.hasViolations(iouReportID, transactionViolations)) || ReportUtils.hasActionsWithErrors(iouReportID);
const lastThreeTransactionsWithReceipts = transactionsWithReceipts.slice(-3);
const lastThreeReceipts = lastThreeTransactionsWithReceipts.map((transaction) => ({...ReceiptUtils.getThumbnailAndImageURIs(transaction), transaction}));
FitseTLT marked this conversation as resolved.
Show resolved Hide resolved
const showRTERViolationMessage =
numberOfRequests === 1 &&
TransactionUtils.hasPendingUI(allTransactions[0], TransactionUtils.getTransactionViolations(allTransactions[0]?.transactionID ?? '', transactionViolations));

let formattedMerchant = numberOfRequests === 1 ? TransactionUtils.getMerchant(allTransactions[0]) : null;
const formattedDescription = numberOfRequests === 1 ? TransactionUtils.getDescription(allTransactions[0]) : null;
Expand Down
8 changes: 0 additions & 8 deletions src/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,13 +428,6 @@ function getBackgroundAndBorderStyle(backgroundColor: ColorValue | undefined): V
};
}

/**
* Returns a style with the specified borderRadius
*/
function getBorderRadiusStyle(borderRadius: number): ViewStyle {
return {borderRadius};
}

/**
* Returns a style with the specified backgroundColor
*/
Expand Down Expand Up @@ -1141,7 +1134,6 @@ const staticStyleUtils = {
getAvatarSize,
getAvatarWidthStyle,
getBackgroundAndBorderStyle,
getBorderRadiusStyle,
getBackgroundColorStyle,
getBackgroundColorWithOpacityStyle,
getPaddingLeft,
Expand Down
Loading