From 09c8a238bdd7bcc0a93151fe832f987e24697001 Mon Sep 17 00:00:00 2001 From: Saagar Date: Tue, 18 May 2021 15:12:51 -0700 Subject: [PATCH 1/2] Send Bot on path on done --- src/containers/Map/MapScreen.tsx | 25 +++++++++++++++++++++++++ src/containers/Map/MapView.tsx | 3 ++- src/containers/Map/mapTypes.ts | 1 + src/services/BotService.ts | 19 ++++++++++++++++++- 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/containers/Map/MapScreen.tsx b/src/containers/Map/MapScreen.tsx index b614fdd..0e57317 100644 --- a/src/containers/Map/MapScreen.tsx +++ b/src/containers/Map/MapScreen.tsx @@ -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); + } + }} /> {selectedMarker && ( diff --git a/src/containers/Map/MapView.tsx b/src/containers/Map/MapView.tsx index 77465fb..029ece6 100644 --- a/src/containers/Map/MapView.tsx +++ b/src/containers/Map/MapView.tsx @@ -56,6 +56,7 @@ const MapComponent = ({ onSelect, onNodeSelect, isMapPath, + onDone, }: PropTypes) => { const mapRef = useRef(null); const doneButtonBackgroundColor = isMapPath @@ -304,7 +305,7 @@ const MapComponent = ({ backgroundColor: doneButtonBackgroundColor, }} containerStyle={styles.buttonContainer} - onPress={() => {}} + onPress={() => onDone()} /> )} {/* diff --git a/src/containers/Map/mapTypes.ts b/src/containers/Map/mapTypes.ts index d3b5321..eebc931 100644 --- a/src/containers/Map/mapTypes.ts +++ b/src/containers/Map/mapTypes.ts @@ -31,6 +31,7 @@ export interface PropTypes { refresh(): any; selected?: MarkerData; isMapPath?: boolean; + onDone?: any; /** * Function for when a marker is selected diff --git a/src/services/BotService.ts b/src/services/BotService.ts index c82f00d..33d7774 100644 --- a/src/services/BotService.ts +++ b/src/services/BotService.ts @@ -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 }; From ed1ec5713808978dd8fa682b63170757fd7e0e59 Mon Sep 17 00:00:00 2001 From: Saagar Date: Tue, 1 Jun 2021 20:16:01 -0700 Subject: [PATCH 2/2] Change map marker size --- src/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index 1ee28a3..7d0d24f 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,4 +1,4 @@ const NAV_HEIGHT = 90; -const MAP_MARKER_SIZE = 42; +const MAP_MARKER_SIZE = 30; export { NAV_HEIGHT, MAP_MARKER_SIZE };