Skip to content

Commit

Permalink
Merge pull request #38026 from abzokhattab/fix-offline-address-selection
Browse files Browse the repository at this point in the history
Fix: Unable to save manually entered address after selecting address while offline
  • Loading branch information
amyevans authored Mar 19, 2024
2 parents 860cca6 + 4ec035c commit fcbef7c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/pages/iou/request/step/IOURequestStepWaypoint.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {useNavigation} from '@react-navigation/native';
import React, {useMemo, useRef, useState} from 'react';
import {View} from 'react-native';
import type {TextInput} from 'react-native';
import {View} from 'react-native';
import type {Place} from 'react-native-google-places-autocomplete';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import AddressSearch from '@components/AddressSearch';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
Expand Down Expand Up @@ -124,8 +124,10 @@ function IOURequestStepWaypoint({
// Therefore, we're going to save the waypoint as just the address, and the lat/long will be filled in on the backend
if (isOffline && waypointValue) {
const waypoint = {
address: waypointValue,
name: values.name,
address: waypointValue ?? '',
name: values.name ?? '',
lat: values.lat ?? 0,
lng: values.lng ?? 0,
};
saveWaypoint(waypoint);
}
Expand All @@ -142,10 +144,10 @@ function IOURequestStepWaypoint({

const selectWaypoint = (values: Waypoint) => {
const waypoint = {
lat: values.lat,
lng: values.lng,
address: values.address,
name: values.name,
lat: values.lat ?? 0,
lng: values.lng ?? 0,
address: values.address ?? '',
name: values.name ?? '',
};

Transaction.saveWaypoint(transactionID, pageIndex, waypoint, action === CONST.IOU.ACTION.CREATE);
Expand Down

0 comments on commit fcbef7c

Please sign in to comment.