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 waypoint id #37

Merged
merged 4 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/components/OrderMapPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import tailwind from 'tailwind';
import { deepGet, getColorCode, isEmpty, translate } from 'utils';

function waypointMustHaveId(waypoint) {
return typeof waypoint.id === 'string' && waypoint.id.startsWith('place_');
return typeof waypoint?.id === 'string' && waypoint.id.startsWith('place_');
}

function getOrderDestination(order) {
Expand Down Expand Up @@ -113,4 +113,4 @@ const OrderMapPicker = ({ title = 'Select Navigator', wrapperStyle, order, butto
);
};

export default OrderMapPicker;
export default OrderMapPicker;
2 changes: 1 addition & 1 deletion src/components/OrderWaypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const OrderWaypoints = ({ order, onPress, wrapperStyle, containerStyle, textStyl
</View>
</View>
<View style={tailwind('w-full')}>
<Text style={(tailwind(`text-xs text-gray-50 ${waypoint.completed ? 'line-through' : ''}`), textStyle)}>{waypoint.address}</Text>
<Text style={[tailwind(`text-xs text-gray-50 ${waypoint.completed ? 'line-through' : ''}`), textStyle]}>{waypoint.address}</Text>
{waypoint.phone && (
<TouchableOpacity onPress={() => startCall(waypoint.phone)}>
<Text style={[tailwind('text-xs text-gray-50'), textStyle]}>{waypoint.phone}</Text>
Expand Down
27 changes: 13 additions & 14 deletions src/features/Shared/OrderScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
const isObjectEmpty = obj => isEmpty(obj) || Object.values(obj).length === 0;

const getOrderCurrency = order => {
console.log('order_', JSON.stringify(order));
let currency = order.getAttribute('meta.currency');

// check order for currency attribute too
if (!currency) {
currency = order.getAttribute('currency');
Expand All @@ -44,7 +42,6 @@ const getOrderCurrency = order => {
currency = entities[0].currency;
}
}

return currency ?? 'USD';
};

Expand Down Expand Up @@ -126,7 +123,7 @@ const OrderScreen = ({ navigation, route }) => {
for (let index = 0; index < waypoints.length; index++) {
const waypoint = waypoints[index];

if (!waypoint?.tracking_number || statusesToSkip.includes(waypoint.tracking_number.status_code?.toLowerCase())) {
if (!waypoint?.tracking || statusesToSkip.includes(waypoint.tracking?.toLowerCase())) {
continue;
}

Expand Down Expand Up @@ -565,20 +562,22 @@ const OrderScreen = ({ navigation, route }) => {
<View style={tailwind('px-4 py-2 flex-1 border-b border-blue-700')}>
<Text style={tailwind('font-bold text-white mb-1')}>Current Destination</Text>
<Text style={tailwind('text-blue-50')}>{destination.address}</Text>
{destination?.tracking_number?.status_code && (
{destination?.tracking && (
<View style={tailwind('my-2 flex flex-row')}>
<OrderStatusBadge status={destination?.tracking_number?.status_code ?? 'pending'} wrapperStyle={tailwind('flex-grow-0')} />
<OrderStatusBadge status={destination?.tracking ?? 'pending'} wrapperStyle={tailwind('flex-grow-0')} />
</View>
)}
</View>
<View style={tailwind('flex flex-row')}>
<TouchableOpacity
onPress={toggleChangeDestinationWaypoint}
style={tailwind('flex-1 px-2 py-2 border-r border-blue-700 flex items-center justify-center')}>
<FontAwesomeIcon icon={faRoute} style={tailwind('text-blue-50 mb-1')} />
<Text style={tailwind('text-blue-50')}>Change</Text>
</TouchableOpacity>
</View>
{waypointsInProgress.length > 0 && (
<View style={tailwind('flex flex-row')}>
<TouchableOpacity
onPress={toggleChangeDestinationWaypoint}
style={tailwind('flex-1 px-2 py-2 border-r border-blue-700 flex items-center justify-center')}>
<FontAwesomeIcon icon={faRoute} style={tailwind('text-blue-50 mb-1')} />
<Text style={tailwind('text-blue-50')}>Change</Text>
</TouchableOpacity>
</View>
)}
</View>
</View>
)}
Expand Down
11 changes: 6 additions & 5 deletions src/features/Shared/ProofScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import OrderStatusBadge from 'components/OrderStatusBadge';
import { useFleetbase, useLocale, useMountedState } from 'hooks';
import React, { useRef, useState } from 'react';
import { ActivityIndicator, Alert, Dimensions, Text, TouchableOpacity, View, StyleSheet } from 'react-native';
import { ActivityIndicator, Alert, Dimensions, Text, TouchableOpacity, View } from 'react-native';
import FastImage from 'react-native-fast-image';
import { Camera, useCodeScanner, useCameraDevice } from 'react-native-vision-camera';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import SignatureScreen from 'react-native-signature-canvas';
import { Camera, useCameraDevice, useCodeScanner } from 'react-native-vision-camera';
import tailwind from 'tailwind';
import { getColorCode, isEmpty, logError } from 'utils';

const { width, height } = Dimensions.get('window');

const ProofScreen = ({ navigation, route }) => {
const { _order, _waypoint, _entity, activity } = route.params;

const signatureScreenRef = useRef();
const qrCodeScannerRef = useRef();
const insets = useSafeAreaInsets();
Expand All @@ -27,12 +26,14 @@ const ProofScreen = ({ navigation, route }) => {
const [order, setOrder] = useState(new Order(_order, fleetbase.getAdapter()));
const [waypoint, setWaypoint] = useState(new Place(_waypoint, fleetbase.getAdapter()));
const [entity, setEntity] = useState(new Entity(_entity, fleetbase.getAdapter()));

const [isLoading, setIsLoading] = useState(false);
const [isCapturingCode, setIsCapturingCode] = useState(false);

const isMultiDropOrder = !isEmpty(order.getAttribute('payload.waypoints', []));
const isScanningProof = activity?.pod_method === 'scan';
const isSigningProof = activity?.pod_method === 'signature';

const isScanningProof = _order?.pod_method === 'scan' || activity?.pod_method === 'scan';
const isSigningProof = _order?.pod_method === 'signature' || activity?.pod_method === 'signature';
const isWaypoint = !isEmpty(_waypoint);
const isEntity = !isEmpty(_entity);
const isOrder = !isWaypoint && !isEntity;
Expand Down
Loading