@pelcro/react-pelcro-js 4.0.0-alpha.15 → 4.0.0-alpha.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +1,12 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var components = require('./components-f9c58ce2.js');
5
- require('react-dom');
6
- require('prop-types');
7
-
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
-
10
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
1
+ import React__default, { createContext, useContext } from 'react';
2
+ import { u as useTranslation, a as useReducerWithSideEffects, S as SET_CANCEL_SUBSCRIPTION_REASON, l as lib_7, T as TextArea, R as ReactGA4, b as ReactGA1, c as usePelcro, B as Button, n as notify, d as SvgSubscription } from './components-0f4ebe18.js';
3
+ import 'react-dom';
4
+ import 'prop-types';
11
5
 
12
6
  const initialState = {
13
7
  cancelationReason: ""
14
8
  };
15
- const store = /*#__PURE__*/React.createContext(initialState);
9
+ const store = /*#__PURE__*/createContext(initialState);
16
10
  const {
17
11
  Provider
18
12
  } = store;
@@ -25,11 +19,11 @@ const SubscriptionCancelContainer = ({
25
19
  children,
26
20
  ...props
27
21
  }) => {
28
- components.useTranslation("verifyEmail");
29
- const [state, dispatch] = components.useReducerWithSideEffects((state, action) => {
22
+ useTranslation("verifyEmail");
23
+ const [state, dispatch] = useReducerWithSideEffects((state, action) => {
30
24
  switch (action.type) {
31
- case components.SET_CANCEL_SUBSCRIPTION_REASON:
32
- return components.lib_7({ ...state,
25
+ case SET_CANCEL_SUBSCRIPTION_REASON:
26
+ return lib_7({ ...state,
33
27
  cancelationReason: action.payload
34
28
  });
35
29
 
@@ -37,19 +31,19 @@ const SubscriptionCancelContainer = ({
37
31
  return state;
38
32
  }
39
33
  }, initialState);
40
- return /*#__PURE__*/React__default['default'].createElement("div", {
34
+ return /*#__PURE__*/React__default.createElement("div", {
41
35
  style: { ...style
42
36
  },
43
37
  className: `pelcro-container pelcro-subscription-cancel-container ${className}`
44
- }, /*#__PURE__*/React__default['default'].createElement(Provider, {
38
+ }, /*#__PURE__*/React__default.createElement(Provider, {
45
39
  value: {
46
40
  state,
47
41
  dispatch
48
42
  }
49
- }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
43
+ }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
50
44
  store,
51
45
  key: i
52
- })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
46
+ })) : /*#__PURE__*/React__default.cloneElement(children, {
53
47
  store
54
48
  })));
55
49
  };
@@ -57,27 +51,27 @@ const SubscriptionCancelContainer = ({
57
51
  const SubscriptionCancelReason = props => {
58
52
  const {
59
53
  t
60
- } = components.useTranslation("subscriptionCancel");
54
+ } = useTranslation("subscriptionCancel");
61
55
  const {
62
56
  dispatch,
63
57
  state
64
- } = React.useContext(store);
58
+ } = useContext(store);
65
59
 
66
60
  const handleOnTextAreaBlur = e => {
67
61
  dispatch({
68
- type: components.SET_CANCEL_SUBSCRIPTION_REASON,
62
+ type: SET_CANCEL_SUBSCRIPTION_REASON,
69
63
  payload: e.target.value.trim()
70
64
  });
71
65
  };
72
66
 
73
- return /*#__PURE__*/React__default['default'].createElement(components.TextArea, Object.assign({
67
+ return /*#__PURE__*/React__default.createElement(TextArea, Object.assign({
74
68
  label: t("labels.cancelReason"),
75
69
  onBlur: e => handleOnTextAreaBlur(e)
76
70
  }, props));
77
71
  };
78
72
 
79
73
  var _window$1, _window$Pelcro$1, _window$Pelcro$uiSett$1;
80
- const ReactGA$1 = (_window$1 = window) !== null && _window$1 !== void 0 && (_window$Pelcro$1 = _window$1.Pelcro) !== null && _window$Pelcro$1 !== void 0 && (_window$Pelcro$uiSett$1 = _window$Pelcro$1.uiSettings) !== null && _window$Pelcro$uiSett$1 !== void 0 && _window$Pelcro$uiSett$1.enableReactGA4 ? components.ReactGA4 : components.ReactGA1;
74
+ const ReactGA$1 = (_window$1 = window) !== null && _window$1 !== void 0 && (_window$Pelcro$1 = _window$1.Pelcro) !== null && _window$Pelcro$1 !== void 0 && (_window$Pelcro$uiSett$1 = _window$Pelcro$1.uiSettings) !== null && _window$Pelcro$uiSett$1 !== void 0 && _window$Pelcro$uiSett$1.enableReactGA4 ? ReactGA4 : ReactGA1;
81
75
  const SubscriptionCancelNowButton = ({
82
76
  subscription,
83
77
  onClick,
@@ -85,16 +79,16 @@ const SubscriptionCancelNowButton = ({
85
79
  }) => {
86
80
  const {
87
81
  switchView
88
- } = components.usePelcro();
82
+ } = usePelcro();
89
83
  const {
90
84
  state: {
91
85
  cancelationReason
92
86
  },
93
87
  dispatch
94
- } = React.useContext(store);
88
+ } = useContext(store);
95
89
  const {
96
90
  t
97
- } = components.useTranslation("subscriptionCancel");
91
+ } = useTranslation("subscriptionCancel");
98
92
 
99
93
  const cancelSubscription = (payload, onSuccess, onFailure) => {
100
94
  window.Pelcro.subscription.cancel({
@@ -132,7 +126,7 @@ const SubscriptionCancelNowButton = ({
132
126
 
133
127
  switchView(null); //Show confirmation alert after closing the modal
134
128
 
135
- components.notify.confirm((onSuccess, onFailure) => {
129
+ notify.confirm((onSuccess, onFailure) => {
136
130
  cancelSubscription(payload, onSuccess, onFailure);
137
131
  }, {
138
132
  confirmMessage: t("messages.subCancellation.isSureToCancelNow"),
@@ -144,14 +138,14 @@ const SubscriptionCancelNowButton = ({
144
138
  });
145
139
  };
146
140
 
147
- return /*#__PURE__*/React__default['default'].createElement(components.Button, {
141
+ return /*#__PURE__*/React__default.createElement(Button, {
148
142
  onClick: handleCancelNowClick,
149
143
  className: `${className}`
150
144
  }, t("messages.cancelNow"));
151
145
  };
152
146
 
153
147
  var _window, _window$Pelcro, _window$Pelcro$uiSett;
154
- const ReactGA = (_window = window) !== null && _window !== void 0 && (_window$Pelcro = _window.Pelcro) !== null && _window$Pelcro !== void 0 && (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) !== null && _window$Pelcro$uiSett !== void 0 && _window$Pelcro$uiSett.enableReactGA4 ? components.ReactGA4 : components.ReactGA1;
148
+ const ReactGA = (_window = window) !== null && _window !== void 0 && (_window$Pelcro = _window.Pelcro) !== null && _window$Pelcro !== void 0 && (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) !== null && _window$Pelcro$uiSett !== void 0 && _window$Pelcro$uiSett.enableReactGA4 ? ReactGA4 : ReactGA1;
155
149
  const SubscriptionCancelLaterButton = ({
156
150
  subscription,
157
151
  onClick,
@@ -159,16 +153,16 @@ const SubscriptionCancelLaterButton = ({
159
153
  }) => {
160
154
  const {
161
155
  switchView
162
- } = components.usePelcro();
156
+ } = usePelcro();
163
157
  const {
164
158
  state: {
165
159
  cancelationReason
166
160
  },
167
161
  dispatch
168
- } = React.useContext(store);
162
+ } = useContext(store);
169
163
  const {
170
164
  t
171
- } = components.useTranslation("subscriptionCancel");
165
+ } = useTranslation("subscriptionCancel");
172
166
 
173
167
  const cancelSubscription = (payload, onSuccess, onFailure) => {
174
168
  window.Pelcro.subscription.cancel({
@@ -206,7 +200,7 @@ const SubscriptionCancelLaterButton = ({
206
200
 
207
201
  switchView(null); //Show confirmation alert after closing the modal
208
202
 
209
- components.notify.confirm((onSuccess, onFailure) => {
203
+ notify.confirm((onSuccess, onFailure) => {
210
204
  cancelSubscription(payload, onSuccess, onFailure);
211
205
  }, {
212
206
  confirmMessage: t("messages.subCancellation.isSureToCancel"),
@@ -218,7 +212,7 @@ const SubscriptionCancelLaterButton = ({
218
212
  });
219
213
  };
220
214
 
221
- return /*#__PURE__*/React__default['default'].createElement(components.Button, {
215
+ return /*#__PURE__*/React__default.createElement(Button, {
222
216
  onClick: handleCancelNowClick,
223
217
  className: `${className}`
224
218
  }, t("messages.cancelLater"));
@@ -227,28 +221,28 @@ const SubscriptionCancelLaterButton = ({
227
221
  const SubscriptionCancelView = props => {
228
222
  const {
229
223
  subscriptionToCancel
230
- } = components.usePelcro();
224
+ } = usePelcro();
231
225
  const {
232
226
  t
233
- } = components.useTranslation("subscriptionCancel");
234
- return /*#__PURE__*/React__default['default'].createElement("div", {
227
+ } = useTranslation("subscriptionCancel");
228
+ return /*#__PURE__*/React__default.createElement("div", {
235
229
  id: "pelcro-subscription-cancel-view"
236
- }, /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelContainer, props, /*#__PURE__*/React__default['default'].createElement("div", {
230
+ }, /*#__PURE__*/React__default.createElement(SubscriptionCancelContainer, props, /*#__PURE__*/React__default.createElement("div", {
237
231
  className: "plc-flex plc-flex-col plc-items-center plc-justify-center plc-mt-4"
238
- }, /*#__PURE__*/React__default['default'].createElement(components.SvgSubscription, {
232
+ }, /*#__PURE__*/React__default.createElement(SvgSubscription, {
239
233
  className: "plc-w-32 plc-h-32"
240
- }), /*#__PURE__*/React__default['default'].createElement("p", {
234
+ }), /*#__PURE__*/React__default.createElement("p", {
241
235
  className: "plc-mb-3 plc-text-gray-900 plc-text-center plc-whitespace-pre-line"
242
236
  }, t("messages.subscriptionEnd"), " ", new Date(subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : subscriptionToCancel.current_period_end).toLocaleDateString("en-CA", {
243
237
  year: "numeric",
244
238
  month: "short",
245
239
  day: "numeric"
246
- }), "."), /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelReason, null), /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelNowButton, {
240
+ }), "."), /*#__PURE__*/React__default.createElement(SubscriptionCancelReason, null), /*#__PURE__*/React__default.createElement(SubscriptionCancelNowButton, {
247
241
  className: "plc-mb-2",
248
242
  subscription: subscriptionToCancel
249
- }), subscriptionToCancel.cancel_at_period_end === 0 && /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelLaterButton, {
243
+ }), subscriptionToCancel.cancel_at_period_end === 0 && /*#__PURE__*/React__default.createElement(SubscriptionCancelLaterButton, {
250
244
  subscription: subscriptionToCancel
251
245
  }))));
252
246
  };
253
247
 
254
- exports.SubscriptionCancelView = SubscriptionCancelView;
248
+ export { SubscriptionCancelView };