Last active
September 5, 2019 19:00
-
-
Save trinadhkoya/455c2489a923e3f8d8f3ed1a13180f86 to your computer and use it in GitHub Desktop.
Revisions
-
Trinadh Koya revised this gist
Sep 5, 2019 . 1 changed file with 17 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,3 +36,20 @@ const convertOrdersToDeliveryTags = async (orders, address) => { return "hello"; }; const doGetTodayOrdersOfSellersByTags = (seller) => async dispatch => { dispatch(getTodayOrdersByTagsRequest()); const orderQuery = new Parse.Query(Order); const today = moment().set('hour', 1).toDate(); const tomorrow = moment().add(1, 'day').set('hour', 1).toDate(); orderQuery.equalTo('seller', seller).greaterThanOrEqualTo('date', today).lessThanOrEqualTo('date', tomorrow).include('user', 'product', 'address').equalTo('orderStatus', 'paid'); orderQuery.find().then((orders) => { dispatch(getTodayOrdersByTagsSuccess(sortOrdersByName(orders))); }).catch((err) => { dispatch(getTodayOrdersByTagsFailure(err)); }); }; -
Trinadh Koya renamed this gist
Sep 5, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Trinadh Koya created this gist
Sep 5, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ const convertOrdersToDeliveryTags = async (orders, address) => { const deliveryTags = _.map(orders, (order) => { return { userName: order.get('user').get('name'), productName: order.get('product').get('name'), orderNumber: order.get('orderNumber'), isPicked: !_.isEmpty(order.get('pickedAt')), isDelivered: !_.isEmpty(order.get('deliveredAt')), isReturned: !_.isEmpty(order.get('returnedAt')), address: order.get('address').get('address'), mapsAddress: order.get('address').get('mapsAddress'), latitude: order.get('address').get('latlong').latitude, longitude: order.get('address').get('latlong').longitude, order: order, chefLat: address[0].get('address').get('latlong')._latitude, chefLong: address[0].get('address').get('latlong')._longitude, }; }); let destinations = deliveryTags.map(order => { return `${order.latitude},${order.longitude}`; }); let origins = [`${deliveryTags[0].chefLat},${deliveryTags[0].chefLong}`]; await googleMapsClient.distanceMatrix({'origins': origins, 'destinations': destinations}, function (err, res) { const filteredArray = []; _.map(deliveryTags, (item) => { if (res.json.destination_addresses.indexOf(item.mapsAddress) !== -1) { filteredArray.push({...item}); } }); return filteredArray; }); return "hello"; };