Skip to content

Commit

Permalink
when store location is not provided added handler
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Jan 3, 2025
1 parent 58eb692 commit 37c47ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/DeliveryRoutePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Pressable, StyleSheet } from 'react-native';
import { Text, YStack, XStack, useTheme } from 'tamagui';
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { faStore, faPerson } from '@fortawesome/free-solid-svg-icons';
import { restoreFleetbasePlace, getPlaceCoords } from '../utils/location';
import { restoreFleetbasePlace, getPlaceCoords, createFauxPlace } from '../utils/location';
import { config } from '../utils';
import { formattedAddressFromPlace } from '../utils/location';
import MapView, { Marker, Callout } from 'react-native-maps';
Expand Down Expand Up @@ -36,7 +36,7 @@ const DeliveryRoutePreview = ({ children, zoom = 1, width = '100%', height = '10
const { store, currentStoreLocation } = useStoreLocations();
const { currentLocation } = useCurrentLocation();
const mapRef = useRef(null);
const start = restoreFleetbasePlace(currentStoreLocation.getAttribute('place'));
const start = currentStoreLocation === undefined ? createFauxPlace() : restoreFleetbasePlace(currentStoreLocation.getAttribute('place'));
const end = restoreFleetbasePlace(currentLocation);
const origin = getPlaceCoords(start);
const destination = getPlaceCoords(end);
Expand Down
10 changes: 10 additions & 0 deletions src/utils/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,3 +948,13 @@ export function getDefaultCoordinates() {

return { latitude, longitude };
}

export function createFauxStoreLocation() {
return new StoreLocation({
place: new Place({ location: new Point(DEFAULT_LATITUDE, DEFAULT_LONGITUDE) }),
});
}

export function createFauxPlace() {
return new Place({ location: new Point(DEFAULT_LATITUDE, DEFAULT_LONGITUDE) });
}

0 comments on commit 37c47ad

Please sign in to comment.