Skip to content
Open
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
25 changes: 25 additions & 0 deletions src/containers/Map/MapScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,31 @@ const MapScreen = ({ route, navigation }: MapScreenProps) => {
addToRoute(marker);
}}
isMapPath={!botRoute || botRoute.length === 0 ? false : true}
onDone={async () => {
if (botRoute) {
setLoading(true);
let lats: number[] = [];
let longs: number[] = [];
botRoute.splice(1).map((marker) => {
lats.push(marker.location.latitude);
longs.push(marker.location.longitude);
});
await BotService.sendBot(
selectedBotForOrder._id,
botRoute[0]._id
);
await BotService.updateQueue(
selectedBotForOrder._id,
lats,
longs
);
setTimeout(() => {
setLoading(false);
setShowMapNodes(false);
setSelectedBotForOrder(null);
}, 1000);
}
}}
/>
</View>
{selectedMarker && (
Expand Down
3 changes: 2 additions & 1 deletion src/containers/Map/MapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const MapComponent = ({
onSelect,
onNodeSelect,
isMapPath,
onDone,
}: PropTypes) => {
const mapRef = useRef<MapView>(null);
const doneButtonBackgroundColor = isMapPath
Expand Down Expand Up @@ -304,7 +305,7 @@ const MapComponent = ({
backgroundColor: doneButtonBackgroundColor,
}}
containerStyle={styles.buttonContainer}
onPress={() => {}}
onPress={() => onDone()}
/>
)}
{/*<TouchableOpacity style={{...styles.button, ...styles.smallerButton, top: '7.9%', left: 18,}}>
Expand Down
1 change: 1 addition & 0 deletions src/containers/Map/mapTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface PropTypes {
refresh(): any;
selected?: MarkerData;
isMapPath?: boolean;
onDone?: any;

/**
* Function for when a marker is selected
Expand Down
19 changes: 18 additions & 1 deletion src/services/BotService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,21 @@ async function sendBot(botId: string, nodeId: string) {
}
}

export default { getEventBots, getAllBots, getOneBot, sendBot };
async function updateQueue(botId: string, lats: number[], longs: number[]) {
try {
let data: Bot = (
await axios.put('/bots/replaceQueue', {
botId: botId,
latitudeArray: lats,
longitudeArray: longs,
})
).data;
console.log(data);
return data;
} catch (e) {
console.log(e);
throw e;
}
}

export default { getEventBots, getAllBots, getOneBot, sendBot, updateQueue };