@pelcro/react-pelcro-js 4.0.0-alpha.16 → 4.0.0-alpha.18
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.
- package/dist/components.js +35851 -4
- package/package.json +3 -4
- package/dist/SubscriptionCancelView-2bdb2b25.js +0 -248
- package/dist/components-0f4ebe18.js +0 -32568
- package/dist/index-242ce79e.js +0 -4649
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pelcro/react-pelcro-js",
|
|
3
3
|
"description": "Pelcro's React UI Elements",
|
|
4
|
-
"version": "4.0.0-alpha.
|
|
4
|
+
"version": "4.0.0-alpha.18",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
|
-
"main": "dist/index.js",
|
|
8
|
-
"module": "dist/index.js",
|
|
7
|
+
"main": "dist/index.esm.js",
|
|
8
|
+
"module": "dist/index.esm.js",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
@@ -80,7 +80,6 @@
|
|
|
80
80
|
"react": "^16.6.1",
|
|
81
81
|
"react-dom": "^16.6.1",
|
|
82
82
|
"react-ga": "^2.7.0",
|
|
83
|
-
"react-ga4": "^1.4.1",
|
|
84
83
|
"react-refresh": "^0.9.0",
|
|
85
84
|
"react-test-renderer": "^17.0.2",
|
|
86
85
|
"request": "^2.88.2",
|
|
@@ -1,248 +0,0 @@
|
|
|
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';
|
|
5
|
-
|
|
6
|
-
const initialState = {
|
|
7
|
-
cancelationReason: ""
|
|
8
|
-
};
|
|
9
|
-
const store = /*#__PURE__*/createContext(initialState);
|
|
10
|
-
const {
|
|
11
|
-
Provider
|
|
12
|
-
} = store;
|
|
13
|
-
|
|
14
|
-
const SubscriptionCancelContainer = ({
|
|
15
|
-
style,
|
|
16
|
-
className = "",
|
|
17
|
-
onSuccess = () => {},
|
|
18
|
-
onFailure = () => {},
|
|
19
|
-
children,
|
|
20
|
-
...props
|
|
21
|
-
}) => {
|
|
22
|
-
useTranslation("verifyEmail");
|
|
23
|
-
const [state, dispatch] = useReducerWithSideEffects((state, action) => {
|
|
24
|
-
switch (action.type) {
|
|
25
|
-
case SET_CANCEL_SUBSCRIPTION_REASON:
|
|
26
|
-
return lib_7({ ...state,
|
|
27
|
-
cancelationReason: action.payload
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
default:
|
|
31
|
-
return state;
|
|
32
|
-
}
|
|
33
|
-
}, initialState);
|
|
34
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
35
|
-
style: { ...style
|
|
36
|
-
},
|
|
37
|
-
className: `pelcro-container pelcro-subscription-cancel-container ${className}`
|
|
38
|
-
}, /*#__PURE__*/React__default.createElement(Provider, {
|
|
39
|
-
value: {
|
|
40
|
-
state,
|
|
41
|
-
dispatch
|
|
42
|
-
}
|
|
43
|
-
}, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
|
|
44
|
-
store,
|
|
45
|
-
key: i
|
|
46
|
-
})) : /*#__PURE__*/React__default.cloneElement(children, {
|
|
47
|
-
store
|
|
48
|
-
})));
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const SubscriptionCancelReason = props => {
|
|
52
|
-
const {
|
|
53
|
-
t
|
|
54
|
-
} = useTranslation("subscriptionCancel");
|
|
55
|
-
const {
|
|
56
|
-
dispatch,
|
|
57
|
-
state
|
|
58
|
-
} = useContext(store);
|
|
59
|
-
|
|
60
|
-
const handleOnTextAreaBlur = e => {
|
|
61
|
-
dispatch({
|
|
62
|
-
type: SET_CANCEL_SUBSCRIPTION_REASON,
|
|
63
|
-
payload: e.target.value.trim()
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
return /*#__PURE__*/React__default.createElement(TextArea, Object.assign({
|
|
68
|
-
label: t("labels.cancelReason"),
|
|
69
|
-
onBlur: e => handleOnTextAreaBlur(e)
|
|
70
|
-
}, props));
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
var _window$1, _window$Pelcro$1, _window$Pelcro$uiSett$1;
|
|
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;
|
|
75
|
-
const SubscriptionCancelNowButton = ({
|
|
76
|
-
subscription,
|
|
77
|
-
onClick,
|
|
78
|
-
className
|
|
79
|
-
}) => {
|
|
80
|
-
const {
|
|
81
|
-
switchView
|
|
82
|
-
} = usePelcro();
|
|
83
|
-
const {
|
|
84
|
-
state: {
|
|
85
|
-
cancelationReason
|
|
86
|
-
},
|
|
87
|
-
dispatch
|
|
88
|
-
} = useContext(store);
|
|
89
|
-
const {
|
|
90
|
-
t
|
|
91
|
-
} = useTranslation("subscriptionCancel");
|
|
92
|
-
|
|
93
|
-
const cancelSubscription = (payload, onSuccess, onFailure) => {
|
|
94
|
-
window.Pelcro.subscription.cancel({
|
|
95
|
-
auth_token: window.Pelcro.user.read().auth_token,
|
|
96
|
-
subscription_id: payload.subscription_id,
|
|
97
|
-
mode: payload.mode,
|
|
98
|
-
...(payload.reason && {
|
|
99
|
-
reason: payload.reason
|
|
100
|
-
})
|
|
101
|
-
}, (err, res) => {
|
|
102
|
-
var _ReactGA$event;
|
|
103
|
-
|
|
104
|
-
if (err) {
|
|
105
|
-
return onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
ReactGA$1 === null || ReactGA$1 === void 0 ? void 0 : (_ReactGA$event = ReactGA$1.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA$1, {
|
|
109
|
-
category: "ACTIONS",
|
|
110
|
-
action: "Canceled",
|
|
111
|
-
nonInteraction: true
|
|
112
|
-
});
|
|
113
|
-
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(res);
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const handleCancelNowClick = () => {
|
|
118
|
-
const payload = {
|
|
119
|
-
subscription_id: subscription.id,
|
|
120
|
-
mode: "now",
|
|
121
|
-
...(cancelationReason && {
|
|
122
|
-
reason: cancelationReason
|
|
123
|
-
})
|
|
124
|
-
};
|
|
125
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(); //Close the modal
|
|
126
|
-
|
|
127
|
-
switchView(null); //Show confirmation alert after closing the modal
|
|
128
|
-
|
|
129
|
-
notify.confirm((onSuccess, onFailure) => {
|
|
130
|
-
cancelSubscription(payload, onSuccess, onFailure);
|
|
131
|
-
}, {
|
|
132
|
-
confirmMessage: t("messages.subCancellation.isSureToCancelNow"),
|
|
133
|
-
loadingMessage: t("messages.subCancellation.loading"),
|
|
134
|
-
successMessage: t("messages.subCancellation.success"),
|
|
135
|
-
errorMessage: t("messages.subCancellation.error")
|
|
136
|
-
}, {
|
|
137
|
-
closeButtonLabel: t("labels.subCancellation.goBack")
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
return /*#__PURE__*/React__default.createElement(Button, {
|
|
142
|
-
onClick: handleCancelNowClick,
|
|
143
|
-
className: `${className}`
|
|
144
|
-
}, t("messages.cancelNow"));
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
var _window, _window$Pelcro, _window$Pelcro$uiSett;
|
|
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;
|
|
149
|
-
const SubscriptionCancelLaterButton = ({
|
|
150
|
-
subscription,
|
|
151
|
-
onClick,
|
|
152
|
-
className
|
|
153
|
-
}) => {
|
|
154
|
-
const {
|
|
155
|
-
switchView
|
|
156
|
-
} = usePelcro();
|
|
157
|
-
const {
|
|
158
|
-
state: {
|
|
159
|
-
cancelationReason
|
|
160
|
-
},
|
|
161
|
-
dispatch
|
|
162
|
-
} = useContext(store);
|
|
163
|
-
const {
|
|
164
|
-
t
|
|
165
|
-
} = useTranslation("subscriptionCancel");
|
|
166
|
-
|
|
167
|
-
const cancelSubscription = (payload, onSuccess, onFailure) => {
|
|
168
|
-
window.Pelcro.subscription.cancel({
|
|
169
|
-
auth_token: window.Pelcro.user.read().auth_token,
|
|
170
|
-
subscription_id: payload.subscription_id,
|
|
171
|
-
mode: payload.mode,
|
|
172
|
-
...(payload.reason && {
|
|
173
|
-
reason: payload.reason
|
|
174
|
-
})
|
|
175
|
-
}, (err, res) => {
|
|
176
|
-
var _ReactGA$event;
|
|
177
|
-
|
|
178
|
-
if (err) {
|
|
179
|
-
return onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
|
|
183
|
-
category: "ACTIONS",
|
|
184
|
-
action: "Canceled",
|
|
185
|
-
nonInteraction: true
|
|
186
|
-
});
|
|
187
|
-
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(res);
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const handleCancelNowClick = () => {
|
|
192
|
-
const payload = {
|
|
193
|
-
subscription_id: subscription.id,
|
|
194
|
-
mode: "period_end",
|
|
195
|
-
...(cancelationReason && {
|
|
196
|
-
reason: cancelationReason
|
|
197
|
-
})
|
|
198
|
-
};
|
|
199
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(); //Close the modal
|
|
200
|
-
|
|
201
|
-
switchView(null); //Show confirmation alert after closing the modal
|
|
202
|
-
|
|
203
|
-
notify.confirm((onSuccess, onFailure) => {
|
|
204
|
-
cancelSubscription(payload, onSuccess, onFailure);
|
|
205
|
-
}, {
|
|
206
|
-
confirmMessage: t("messages.subCancellation.isSureToCancel"),
|
|
207
|
-
loadingMessage: t("messages.subCancellation.loading"),
|
|
208
|
-
successMessage: t("messages.subCancellation.success"),
|
|
209
|
-
errorMessage: t("messages.subCancellation.error")
|
|
210
|
-
}, {
|
|
211
|
-
closeButtonLabel: t("labels.subCancellation.goBack")
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
return /*#__PURE__*/React__default.createElement(Button, {
|
|
216
|
-
onClick: handleCancelNowClick,
|
|
217
|
-
className: `${className}`
|
|
218
|
-
}, t("messages.cancelLater"));
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
const SubscriptionCancelView = props => {
|
|
222
|
-
const {
|
|
223
|
-
subscriptionToCancel
|
|
224
|
-
} = usePelcro();
|
|
225
|
-
const {
|
|
226
|
-
t
|
|
227
|
-
} = useTranslation("subscriptionCancel");
|
|
228
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
229
|
-
id: "pelcro-subscription-cancel-view"
|
|
230
|
-
}, /*#__PURE__*/React__default.createElement(SubscriptionCancelContainer, props, /*#__PURE__*/React__default.createElement("div", {
|
|
231
|
-
className: "plc-flex plc-flex-col plc-items-center plc-justify-center plc-mt-4"
|
|
232
|
-
}, /*#__PURE__*/React__default.createElement(SvgSubscription, {
|
|
233
|
-
className: "plc-w-32 plc-h-32"
|
|
234
|
-
}), /*#__PURE__*/React__default.createElement("p", {
|
|
235
|
-
className: "plc-mb-3 plc-text-gray-900 plc-text-center plc-whitespace-pre-line"
|
|
236
|
-
}, t("messages.subscriptionEnd"), " ", new Date(subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : subscriptionToCancel.current_period_end).toLocaleDateString("en-CA", {
|
|
237
|
-
year: "numeric",
|
|
238
|
-
month: "short",
|
|
239
|
-
day: "numeric"
|
|
240
|
-
}), "."), /*#__PURE__*/React__default.createElement(SubscriptionCancelReason, null), /*#__PURE__*/React__default.createElement(SubscriptionCancelNowButton, {
|
|
241
|
-
className: "plc-mb-2",
|
|
242
|
-
subscription: subscriptionToCancel
|
|
243
|
-
}), subscriptionToCancel.cancel_at_period_end === 0 && /*#__PURE__*/React__default.createElement(SubscriptionCancelLaterButton, {
|
|
244
|
-
subscription: subscriptionToCancel
|
|
245
|
-
}))));
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
export { SubscriptionCancelView };
|