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/26888: New design when adding stop waypoint #27657

Merged
merged 10 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
5 changes: 4 additions & 1 deletion src/components/DistanceRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken,
<Button
small
icon={Expensicons.Plus}
onPress={() => Transaction.addStop(iou.transactionID)}
onPress={() => {
const newIndex = _.size(lodashGet(transaction, 'comment.waypoints', {}));
Navigation.navigate(ROUTES.getMoneyRequestWaypointRoute('request', newIndex));
DylanDylann marked this conversation as resolved.
Show resolved Hide resolved
}}
text={translate('distance.addStop')}
isDisabled={numberOfWaypoints === MAX_WAYPOINTS}
innerStyles={[styles.ph10]}
Expand Down
18 changes: 13 additions & 5 deletions src/pages/iou/WaypointEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ function WaypointEditor({transactionID, route: {params: {iouType = '', waypointI
return errors;
};

const saveWaypoint = (waypoint) => {
if (parsedWaypointIndex < _.size(allWaypoints)) {
Transaction.saveWaypoint(transactionID, waypointIndex, waypoint);
} else {
const finishWaypoint = lodashGet(allWaypoints, `waypoint${_.size(allWaypoints) - 1}`, {});
Transaction.saveWaypoint(transactionID, waypointIndex, finishWaypoint);
Transaction.saveWaypoint(transactionID, waypointIndex - 1, waypoint);
}
};

const onSubmit = (values) => {
const waypointValue = values[`waypoint${waypointIndex}`] || '';

Expand All @@ -132,8 +142,7 @@ function WaypointEditor({transactionID, route: {params: {iouType = '', waypointI
lng: null,
address: waypointValue,
};

Transaction.saveWaypoint(transactionID, waypointIndex, waypoint);
saveWaypoint(waypoint);
}

// Other flows will be handled by selecting a waypoint with selectWaypoint as this is mainly for the offline flow
Expand All @@ -152,8 +161,7 @@ function WaypointEditor({transactionID, route: {params: {iouType = '', waypointI
lng: values.lng,
address: values.address,
};

Transaction.saveWaypoint(transactionID, waypointIndex, waypoint);
saveWaypoint(waypoint);
Navigation.goBack(ROUTES.getMoneyRequestDistanceTabRoute(iouType));
};

Expand All @@ -163,7 +171,7 @@ function WaypointEditor({transactionID, route: {params: {iouType = '', waypointI
onEntryTransitionEnd={() => textInput.current && textInput.current.focus()}
shouldEnableMaxHeight
>
<FullPageNotFoundView shouldShow={(Number.isNaN(parsedWaypointIndex) || parsedWaypointIndex < 0 || parsedWaypointIndex > waypointCount - 1) && isFocused}>
<FullPageNotFoundView shouldShow={(Number.isNaN(parsedWaypointIndex) || parsedWaypointIndex < 0 || parsedWaypointIndex > waypointCount) && isFocused}>
<HeaderWithBackButton
title={translate(wayPointDescriptionKey)}
shouldShowBackButton
Expand Down
Loading