New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vtex/pickup-points-modal

Package Overview
Dependencies
Maintainers
22
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vtex/pickup-points-modal - npm Package Compare versions

Comparing version 0.1.17 to 0.1.18

70

lib/components/AskForGeolocation.js

@@ -16,2 +16,4 @@ 'use strict';

var _CurrentPosition = require('../utils/CurrentPosition');
var _UserGeolocation = require('../components/UserGeolocation');

@@ -57,2 +59,58 @@

_this.getCurrentPositionSuccess = function (position) {
(0, _CurrentPosition.handleGetAddressByGeolocation)({
newPosition: {
lat: position.coords.latitude,
lng: position.coords.longitude
},
geocoder: _this.geocoder,
googleMaps: _this.props.googleMaps,
onChangeAddress: _this.props.onChangeAddress,
rules: _this.props.rules,
address: _this.address
});
_this.setState({ askForGeolocationStatus: _constants.SEARCHING });
searchPickupAddressByGeolocationEvent({
searchedAddressByGeolocation: true,
confirmedGeolocation: true
});
};
_this.getCurrentPositionError = function (error) {
switch (error.code) {
case 0:
// UNKNOWN ERROR
_this.props.onAskForGeolocation(false);
searchPickupAddressByGeolocationEvent({
confirmedGeolocation: true,
browserError: true
});
break;
case 1:
// PERMISSION_DENIED
_this.props.onAskForGeolocation(false);
searchPickupAddressByGeolocationEvent({
deniedGeolocation: true
});
break;
case 2:
// POSITION_UNAVAILABLE
_this.props.onAskForGeolocation(false);
searchPickupAddressByGeolocationEvent({
confirmedGeolocation: true,
positionUnavailable: true
});
break;
case 3:
// TIMEOUT
_this.props.onAskForGeolocation(false);
searchPickupAddressByGeolocationEvent({
dismissedGeolocation: true
});
break;
default:
return false;
}
};
_this.handleGeolocationStatus = function (status) {

@@ -78,2 +136,13 @@ _this.setState({ status: status || _constants.WAITING });

AskForGeolocation.prototype.componentDidMount = function componentDidMount() {
if (this.props.askForGeolocation) {
this.setState({ askForGeolocationStatus: _constants.WAITING });
if (window.location.protocol !== _constants.HTTPS) {
this.props.onAskForGeolocation(false);
return;
}
this.props.googleMaps && (0, _CurrentPosition.getCurrentPosition)(this.getCurrentPositionSuccess, this.getCurrentPositionError);
}
};
AskForGeolocation.prototype.render = function render() {

@@ -186,2 +255,3 @@ var status = this.state.status;

onAskForGeolocation: _propTypes2.default.func.isRequired,
askForGeolocation: _propTypes2.default.bool.isRequired,
pickupOptionGeolocations: _propTypes2.default.array,

@@ -188,0 +258,0 @@ rules: _propTypes2.default.object

72

lib/index.js

@@ -64,4 +64,2 @@ 'use strict';

var _CurrentPosition = require('./utils/CurrentPosition');
var _metrics = require('./utils/metrics');

@@ -91,58 +89,2 @@

_this.getCurrentPositionSuccess = function (position) {
(0, _CurrentPosition.handleGetAddressByGeolocation)({
newPosition: {
lat: position.coords.latitude,
lng: position.coords.longitude
},
geocoder: _this.geocoder,
googleMaps: _this.props.googleMaps,
onChangeAddress: _this.props.onChangeAddress,
rules: _this.props.rules,
address: _this.address
});
_this.setState({ askForGeolocationStatus: _constants.SEARCHING });
(0, _metrics.searchPickupAddressByGeolocationEvent)({
searchedAddressByGeolocation: true,
confirmedGeolocation: true
});
};
_this.getCurrentPositionError = function (error) {
switch (error.code) {
case 0:
// UNKNOWN ERROR
_this.handleAskForGeolocation(false);
(0, _metrics.searchPickupAddressByGeolocationEvent)({
confirmedGeolocation: true,
browserError: true
});
break;
case 1:
// PERMISSION_DENIED
_this.handleAskForGeolocation(false);
(0, _metrics.searchPickupAddressByGeolocationEvent)({
deniedGeolocation: true
});
break;
case 2:
// POSITION_UNAVAILABLE
_this.handleAskForGeolocation(false);
(0, _metrics.searchPickupAddressByGeolocationEvent)({
confirmedGeolocation: true,
positionUnavailable: true
});
break;
case 3:
// TIMEOUT
_this.handleAskForGeolocation(false);
(0, _metrics.searchPickupAddressByGeolocationEvent)({
dismissedGeolocation: true
});
break;
default:
return false;
}
};
_this.handleAskForGeolocation = function (ask) {

@@ -248,10 +190,2 @@ _this.setState({

PickupPointsModal.prototype.componentDidMount = function componentDidMount() {
if (this.props.askForGeolocation) {
this.setState({ askForGeolocationStatus: _constants.WAITING });
if (window.location.protocol !== _constants.HTTPS) {
this.handleAskForGeolocation(false);
return;
}
this.props.googleMaps && (0, _CurrentPosition.getCurrentPosition)(this.getCurrentPositionSuccess, this.getCurrentPositionError);
}
if (!!this.props.selectedPickupPoint && this.state.isPickupDetailsActive === null) {

@@ -291,3 +225,4 @@ this.setState({

logisticsInfo = _props.logisticsInfo,
activePickupPoint = _props.activePickupPoint;
activePickupPoint = _props.activePickupPoint,
askForGeolocation = _props.askForGeolocation;
var _state = this.state,

@@ -364,3 +299,4 @@ filteredPickupOptions = _state.filteredPickupOptions,

rules: rules,
status: askForGeolocationStatus
status: askForGeolocationStatus,
askForGeolocation: askForGeolocation
}) : _react2.default.createElement(

@@ -367,0 +303,0 @@ 'div',

{
"name": "@vtex/pickup-points-modal",
"version": "0.1.17",
"version": "0.1.18",
"description": "Pickup Points Modal React component",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc