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

Added 'name' field to waypoint #29931

Merged
merged 12 commits into from
Oct 25, 2023
11 changes: 3 additions & 8 deletions src/components/AddressSearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ function AddressSearch(props) {
// amount of data massaging needs to happen for what the parent expects to get from this function.
if (_.size(details)) {
props.onPress({
address: lodashGet(details, 'description', ''),
address: lodashGet(details, 'description'),
lat: lodashGet(details, 'geometry.location.lat', 0),
lng: lodashGet(details, 'geometry.location.lng', 0),
name: lodashGet(details, 'name', ''),
name: lodashGet(details, 'name'),
});
}
return;
Expand Down Expand Up @@ -395,12 +395,7 @@ function AddressSearch(props) {
return (
<View>
<Text style={[styles.googleSearchText]}>{title || subtitle}</Text>
<Text
style={[styles.textLabelSupporting]}
numberOfLines={2}
>
{title && subtitle ? subtitle : ''}
</Text>
{title && subtitle && <Text style={[styles.textLabelSupporting]}>{subtitle}</Text>}
</View>
);
}}
Expand Down
6 changes: 4 additions & 2 deletions src/components/DistanceEReceipt.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,16 @@ function DistanceEReceipt({transaction}) {
} else {
descriptionKey += 'stop';
}
const title = waypoint.name || waypoint.address;
const subtitle = waypoint.name && waypoint.address ? waypoint.address : undefined;
return (
<View
style={styles.gap1}
key={key}
>
<Text style={styles.eReceiptWaypointTitle}>{translate(descriptionKey)}</Text>
<Text style={styles.eReceiptWaypointAddress}>{waypoint.name || ''}</Text>
<Text style={styles.textLabelSupporting}>{waypoint.address || ''}</Text>
<Text style={styles.eReceiptWaypointAddress}>{title}</Text>
{subtitle && <Text style={styles.textLabelSupporting}>{subtitle}</Text>}
</View>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ function DistanceRequestRenderItem({waypoints, item, onSecondaryInteraction, get
waypointIcon = Expensicons.DotIndicator;
}

const waypoint = lodashGet(waypoints, [`waypoint${index}`], {});
const title = waypoint.name || waypoint.address;

return (
<MenuItemWithTopDescription
description={translate(descriptionKey)}
title={lodashGet(waypoints, [`waypoint${index}`, 'name'], '')}
title={title}
icon={Expensicons.DragHandles}
iconFill={theme.icon}
secondaryIcon={waypointIcon}
Expand Down
6 changes: 1 addition & 5 deletions src/libs/TransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,6 @@ function waypointHasValidAddress(waypoint: RecentWaypoint | Waypoint): boolean {
return !!waypoint?.address?.trim();
}

function waypointHasValidName(waypoint: RecentWaypoint | Waypoint): boolean {
return !!waypoint?.name?.trim();
}

/**
* Converts the key of a waypoint to its index
*/
Expand All @@ -428,7 +424,7 @@ function getValidWaypoints(waypoints: WaypointCollection, reArrangeIndexes = fal
const previousWaypoint = waypointValues[lastWaypointIndex];

// Check if the waypoint has a valid address
if (!waypointHasValidName(currentWaypoint) || !waypointHasValidAddress(currentWaypoint)) {
if (!waypointHasValidAddress(currentWaypoint)) {
return acc;
}

Expand Down
3 changes: 1 addition & 2 deletions src/pages/iou/WaypointEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ function WaypointEditor({route: {params: {iouType = '', transactionID = '', wayp
const waypoint = {
lat: null,
lng: null,
name: waypointValue,
address: waypointValue,
};
saveWaypoint(waypoint);
Expand Down Expand Up @@ -235,7 +234,7 @@ function WaypointEditor({route: {params: {iouType = '', transactionID = '', wayp
maxInputLength={CONST.FORM_CHARACTER_LIMIT}
renamedInputKeys={{
address: `waypoint${waypointIndex}`,
name: `waypoint${waypointIndex}`,
name: null,
esh-g marked this conversation as resolved.
Show resolved Hide resolved
city: null,
country: null,
street: null,
Expand Down
4 changes: 2 additions & 2 deletions src/types/onyx/RecentWaypoint.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type RecentWaypoint = {
/** The name of the waypoint */
name: string;
/** The name associated with the address of the waypoint */
name?: string;

/** The full address of the waypoint */
address: string;
Expand Down
2 changes: 1 addition & 1 deletion src/types/onyx/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import CONST from '../../CONST';
import RecentWaypoint from './RecentWaypoint';

type Waypoint = {
/** The name of the waypoint */
/** The name associated with the address of the waypoint */
name?: string;

/** The full address of the waypoint */
Expand Down