shift-payment-form 1.0.0 → 1.0.1
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/index.cjs.js +105 -73
- package/dist/index.esm.js +105 -73
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -194,7 +194,7 @@ function PaymentForm(_ref) {
|
|
|
194
194
|
_ref$inputpadding = _ref.inputpadding,
|
|
195
195
|
inputpadding = _ref$inputpadding === void 0 ? 12 : _ref$inputpadding,
|
|
196
196
|
baseUrl = _ref.baseUrl,
|
|
197
|
-
|
|
197
|
+
subscriptionId = _ref.subscriptionId,
|
|
198
198
|
successPage = _ref.successPage,
|
|
199
199
|
errorPage = _ref.errorPage,
|
|
200
200
|
description = _ref.description;
|
|
@@ -208,115 +208,148 @@ function PaymentForm(_ref) {
|
|
|
208
208
|
setIsSubmitting = _useState2[1];
|
|
209
209
|
var _useState3 = React.useState(false),
|
|
210
210
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
var _useState5 = React.useState(false),
|
|
214
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
215
|
-
isReady = _useState6[0],
|
|
216
|
-
setIsReady = _useState6[1];
|
|
211
|
+
isReady = _useState4[0],
|
|
212
|
+
setIsReady = _useState4[1];
|
|
217
213
|
React.useEffect(function () {
|
|
218
214
|
if (initializedRef.current) return;
|
|
219
215
|
initializedRef.current = true;
|
|
220
216
|
var initPayment = /*#__PURE__*/function () {
|
|
221
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
222
|
-
var response, _yield$response$json, publicKeys, isProd, script,
|
|
223
|
-
return _regenerator().w(function (
|
|
224
|
-
while (1) switch (
|
|
217
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
218
|
+
var response, _yield$response$json, publicKeys, isProd, script, _t2;
|
|
219
|
+
return _regenerator().w(function (_context2) {
|
|
220
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
225
221
|
case 0:
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return fetch(baseUrl +
|
|
222
|
+
_context2.p = 0;
|
|
223
|
+
_context2.n = 1;
|
|
224
|
+
return fetch(baseUrl + "/api/Subscription/public/" + subscriptionId);
|
|
229
225
|
case 1:
|
|
230
|
-
response =
|
|
226
|
+
response = _context2.v;
|
|
231
227
|
if (!response.ok) errorPage("Failed to fetch public key");
|
|
232
|
-
|
|
228
|
+
_context2.n = 2;
|
|
233
229
|
return response.json();
|
|
234
230
|
case 2:
|
|
235
|
-
_yield$response$json =
|
|
231
|
+
_yield$response$json = _context2.v;
|
|
236
232
|
publicKeys = _yield$response$json.publicKeys;
|
|
237
233
|
isProd = _yield$response$json.isProd;
|
|
238
234
|
if (!publicKeys) errorPage("Public key is empty");
|
|
239
235
|
script = document.createElement("script");
|
|
240
236
|
script.src = isProd ? "https://js.shift4.com/shift4.js" : "https://js.dev.shift4.com/shift4.js";
|
|
241
237
|
script.async = true;
|
|
242
|
-
script.onload = function () {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
238
|
+
script.onload = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
239
|
+
var _token, paymentData, _t;
|
|
240
|
+
return _regenerator().w(function (_context) {
|
|
241
|
+
while (1) switch (_context.p = _context.n) {
|
|
242
|
+
case 0:
|
|
243
|
+
if (window.Shift4) {
|
|
244
|
+
_context.n = 1;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
return _context.a(2);
|
|
248
|
+
case 1:
|
|
249
|
+
shift4Ref.current = window.Shift4(publicKeys);
|
|
250
|
+
componentsRef.current = shift4Ref.current.createComponentGroup().automount("#payment-form");
|
|
251
|
+
_context.p = 2;
|
|
252
|
+
_context.n = 3;
|
|
253
|
+
return shift4Ref.current.createToken(componentsRef.current);
|
|
254
|
+
case 3:
|
|
255
|
+
_token = _context.v;
|
|
256
|
+
if (!(_token !== null && _token !== void 0 && _token.id)) {
|
|
257
|
+
errorPage("Card tokenization failed. Please check your details and try again.");
|
|
258
|
+
}
|
|
259
|
+
paymentData = {
|
|
260
|
+
currency: currency,
|
|
261
|
+
amount: amount,
|
|
262
|
+
cardId: _token === null || _token === void 0 ? void 0 : _token.id,
|
|
263
|
+
description: description
|
|
264
|
+
};
|
|
265
|
+
_context.n = 4;
|
|
266
|
+
return fetch(baseUrl + "/api/Payment/" + subscriptionId, {
|
|
267
|
+
method: "POST",
|
|
268
|
+
headers: {
|
|
269
|
+
"Content-Type": "application/json",
|
|
270
|
+
"Accept": "*/*"
|
|
271
|
+
},
|
|
272
|
+
body: JSON.stringify(paymentData)
|
|
273
|
+
});
|
|
274
|
+
case 4:
|
|
275
|
+
_context.n = 6;
|
|
276
|
+
break;
|
|
277
|
+
case 5:
|
|
278
|
+
_context.p = 5;
|
|
279
|
+
_t = _context.v;
|
|
280
|
+
console.error("Payment init request failed:", _t);
|
|
281
|
+
case 6:
|
|
282
|
+
setIsReady(true);
|
|
283
|
+
case 7:
|
|
284
|
+
return _context.a(2);
|
|
285
|
+
}
|
|
286
|
+
}, _callee, null, [[2, 5]]);
|
|
287
|
+
}));
|
|
248
288
|
script.onerror = function () {
|
|
249
289
|
setError("Payment provider script failed to load.");
|
|
250
290
|
};
|
|
251
291
|
document.body.appendChild(script);
|
|
252
|
-
|
|
292
|
+
_context2.n = 4;
|
|
253
293
|
break;
|
|
254
294
|
case 3:
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
console.error(
|
|
295
|
+
_context2.p = 3;
|
|
296
|
+
_t2 = _context2.v;
|
|
297
|
+
console.error(_t2);
|
|
258
298
|
setError("Payment initialization failed. Please try again.");
|
|
259
299
|
case 4:
|
|
260
|
-
return
|
|
300
|
+
return _context2.a(2);
|
|
261
301
|
}
|
|
262
|
-
},
|
|
302
|
+
}, _callee2, null, [[0, 3]]);
|
|
263
303
|
}));
|
|
264
304
|
return function initPayment() {
|
|
265
305
|
return _ref2.apply(this, arguments);
|
|
266
306
|
};
|
|
267
307
|
}();
|
|
268
308
|
initPayment();
|
|
269
|
-
}, [
|
|
309
|
+
}, []);
|
|
270
310
|
var handleSubmit = /*#__PURE__*/function () {
|
|
271
|
-
var
|
|
272
|
-
var
|
|
273
|
-
return _regenerator().w(function (
|
|
274
|
-
while (1) switch (
|
|
311
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(e) {
|
|
312
|
+
var request, threeDSecureToken, apiBase, response, result, _t3;
|
|
313
|
+
return _regenerator().w(function (_context3) {
|
|
314
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
275
315
|
case 0:
|
|
276
316
|
e.preventDefault();
|
|
277
317
|
if (!isSubmitting) {
|
|
278
|
-
|
|
318
|
+
_context3.n = 1;
|
|
279
319
|
break;
|
|
280
320
|
}
|
|
281
|
-
return
|
|
321
|
+
return _context3.a(2);
|
|
282
322
|
case 1:
|
|
283
323
|
if (formRef.current) {
|
|
284
|
-
|
|
324
|
+
_context3.n = 2;
|
|
285
325
|
break;
|
|
286
326
|
}
|
|
287
|
-
return
|
|
327
|
+
return _context3.a(2);
|
|
288
328
|
case 2:
|
|
289
329
|
if (!(!shift4Ref.current || !componentsRef.current)) {
|
|
290
|
-
|
|
330
|
+
_context3.n = 3;
|
|
291
331
|
break;
|
|
292
332
|
}
|
|
293
333
|
errorPage("Payment form is not ready yet. Please try again.");
|
|
294
|
-
return
|
|
334
|
+
return _context3.a(2);
|
|
295
335
|
case 3:
|
|
296
336
|
setIsSubmitting(true);
|
|
297
|
-
|
|
298
|
-
_context2.n = 5;
|
|
299
|
-
return shift4Ref.current.createToken(componentsRef.current);
|
|
300
|
-
case 5:
|
|
301
|
-
token = _context2.v;
|
|
302
|
-
if (!(token !== null && token !== void 0 && token.id)) {
|
|
303
|
-
errorPage("Card tokenization failed. Please check your details and try again.");
|
|
304
|
-
}
|
|
337
|
+
_context3.p = 4;
|
|
305
338
|
request = {
|
|
306
339
|
amount: amount,
|
|
307
340
|
currency: currency,
|
|
308
341
|
card: token.id,
|
|
309
342
|
description: description
|
|
310
343
|
};
|
|
311
|
-
|
|
344
|
+
_context3.n = 5;
|
|
312
345
|
return shift4Ref.current.verifyThreeDSecure(request);
|
|
313
|
-
case
|
|
314
|
-
threeDSecureToken =
|
|
346
|
+
case 5:
|
|
347
|
+
threeDSecureToken = _context3.v;
|
|
315
348
|
if (!(threeDSecureToken !== null && threeDSecureToken !== void 0 && threeDSecureToken.id)) {
|
|
316
349
|
errorPage("3D Secure verification failed. Please try again.");
|
|
317
350
|
}
|
|
318
|
-
apiBase = baseUrl + "charge/" + userId;
|
|
319
|
-
|
|
351
|
+
apiBase = baseUrl + "/api/Payment/charge/" + userId;
|
|
352
|
+
_context3.n = 6;
|
|
320
353
|
return fetch("".concat(apiBase), {
|
|
321
354
|
method: "POST",
|
|
322
355
|
headers: {
|
|
@@ -329,38 +362,37 @@ function PaymentForm(_ref) {
|
|
|
329
362
|
description: description
|
|
330
363
|
})
|
|
331
364
|
});
|
|
332
|
-
case
|
|
333
|
-
response =
|
|
334
|
-
|
|
365
|
+
case 6:
|
|
366
|
+
response = _context3.v;
|
|
367
|
+
_context3.n = 7;
|
|
335
368
|
return response.json();
|
|
336
|
-
case
|
|
337
|
-
result =
|
|
369
|
+
case 7:
|
|
370
|
+
result = _context3.v;
|
|
338
371
|
if (response.ok) {
|
|
339
|
-
|
|
372
|
+
_context3.n = 8;
|
|
340
373
|
break;
|
|
341
374
|
}
|
|
342
375
|
if (typeof errorPage === "function") errorPage(result);
|
|
343
|
-
return
|
|
344
|
-
case
|
|
376
|
+
return _context3.a(2);
|
|
377
|
+
case 8:
|
|
345
378
|
if (typeof successPage === "function") successPage(result.message);
|
|
346
|
-
|
|
379
|
+
_context3.n = 10;
|
|
347
380
|
break;
|
|
381
|
+
case 9:
|
|
382
|
+
_context3.p = 9;
|
|
383
|
+
_t3 = _context3.v;
|
|
384
|
+
if (typeof errorPage === "function") errorPage(_t3.message);
|
|
348
385
|
case 10:
|
|
349
|
-
|
|
350
|
-
_t2 = _context2.v;
|
|
351
|
-
if (typeof errorPage === "function") errorPage(_t2.message);
|
|
352
|
-
case 11:
|
|
353
|
-
_context2.p = 11;
|
|
386
|
+
_context3.p = 10;
|
|
354
387
|
setIsSubmitting(false);
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return _context2.a(2);
|
|
388
|
+
return _context3.f(10);
|
|
389
|
+
case 11:
|
|
390
|
+
return _context3.a(2);
|
|
359
391
|
}
|
|
360
|
-
},
|
|
392
|
+
}, _callee3, null, [[4, 9, 10, 11]]);
|
|
361
393
|
}));
|
|
362
394
|
return function handleSubmit(_x) {
|
|
363
|
-
return
|
|
395
|
+
return _ref4.apply(this, arguments);
|
|
364
396
|
};
|
|
365
397
|
}();
|
|
366
398
|
return /*#__PURE__*/React.createElement("div", {
|
package/dist/index.esm.js
CHANGED
|
@@ -192,7 +192,7 @@ function PaymentForm(_ref) {
|
|
|
192
192
|
_ref$inputpadding = _ref.inputpadding,
|
|
193
193
|
inputpadding = _ref$inputpadding === void 0 ? 12 : _ref$inputpadding,
|
|
194
194
|
baseUrl = _ref.baseUrl,
|
|
195
|
-
|
|
195
|
+
subscriptionId = _ref.subscriptionId,
|
|
196
196
|
successPage = _ref.successPage,
|
|
197
197
|
errorPage = _ref.errorPage,
|
|
198
198
|
description = _ref.description;
|
|
@@ -206,115 +206,148 @@ function PaymentForm(_ref) {
|
|
|
206
206
|
setIsSubmitting = _useState2[1];
|
|
207
207
|
var _useState3 = useState(false),
|
|
208
208
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
var _useState5 = useState(false),
|
|
212
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
213
|
-
isReady = _useState6[0],
|
|
214
|
-
setIsReady = _useState6[1];
|
|
209
|
+
isReady = _useState4[0],
|
|
210
|
+
setIsReady = _useState4[1];
|
|
215
211
|
useEffect(function () {
|
|
216
212
|
if (initializedRef.current) return;
|
|
217
213
|
initializedRef.current = true;
|
|
218
214
|
var initPayment = /*#__PURE__*/function () {
|
|
219
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
220
|
-
var response, _yield$response$json, publicKeys, isProd, script,
|
|
221
|
-
return _regenerator().w(function (
|
|
222
|
-
while (1) switch (
|
|
215
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
216
|
+
var response, _yield$response$json, publicKeys, isProd, script, _t2;
|
|
217
|
+
return _regenerator().w(function (_context2) {
|
|
218
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
223
219
|
case 0:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return fetch(baseUrl +
|
|
220
|
+
_context2.p = 0;
|
|
221
|
+
_context2.n = 1;
|
|
222
|
+
return fetch(baseUrl + "/api/Subscription/public/" + subscriptionId);
|
|
227
223
|
case 1:
|
|
228
|
-
response =
|
|
224
|
+
response = _context2.v;
|
|
229
225
|
if (!response.ok) errorPage("Failed to fetch public key");
|
|
230
|
-
|
|
226
|
+
_context2.n = 2;
|
|
231
227
|
return response.json();
|
|
232
228
|
case 2:
|
|
233
|
-
_yield$response$json =
|
|
229
|
+
_yield$response$json = _context2.v;
|
|
234
230
|
publicKeys = _yield$response$json.publicKeys;
|
|
235
231
|
isProd = _yield$response$json.isProd;
|
|
236
232
|
if (!publicKeys) errorPage("Public key is empty");
|
|
237
233
|
script = document.createElement("script");
|
|
238
234
|
script.src = isProd ? "https://js.shift4.com/shift4.js" : "https://js.dev.shift4.com/shift4.js";
|
|
239
235
|
script.async = true;
|
|
240
|
-
script.onload = function () {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
236
|
+
script.onload = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
237
|
+
var _token, paymentData, _t;
|
|
238
|
+
return _regenerator().w(function (_context) {
|
|
239
|
+
while (1) switch (_context.p = _context.n) {
|
|
240
|
+
case 0:
|
|
241
|
+
if (window.Shift4) {
|
|
242
|
+
_context.n = 1;
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
return _context.a(2);
|
|
246
|
+
case 1:
|
|
247
|
+
shift4Ref.current = window.Shift4(publicKeys);
|
|
248
|
+
componentsRef.current = shift4Ref.current.createComponentGroup().automount("#payment-form");
|
|
249
|
+
_context.p = 2;
|
|
250
|
+
_context.n = 3;
|
|
251
|
+
return shift4Ref.current.createToken(componentsRef.current);
|
|
252
|
+
case 3:
|
|
253
|
+
_token = _context.v;
|
|
254
|
+
if (!(_token !== null && _token !== void 0 && _token.id)) {
|
|
255
|
+
errorPage("Card tokenization failed. Please check your details and try again.");
|
|
256
|
+
}
|
|
257
|
+
paymentData = {
|
|
258
|
+
currency: currency,
|
|
259
|
+
amount: amount,
|
|
260
|
+
cardId: _token === null || _token === void 0 ? void 0 : _token.id,
|
|
261
|
+
description: description
|
|
262
|
+
};
|
|
263
|
+
_context.n = 4;
|
|
264
|
+
return fetch(baseUrl + "/api/Payment/" + subscriptionId, {
|
|
265
|
+
method: "POST",
|
|
266
|
+
headers: {
|
|
267
|
+
"Content-Type": "application/json",
|
|
268
|
+
"Accept": "*/*"
|
|
269
|
+
},
|
|
270
|
+
body: JSON.stringify(paymentData)
|
|
271
|
+
});
|
|
272
|
+
case 4:
|
|
273
|
+
_context.n = 6;
|
|
274
|
+
break;
|
|
275
|
+
case 5:
|
|
276
|
+
_context.p = 5;
|
|
277
|
+
_t = _context.v;
|
|
278
|
+
console.error("Payment init request failed:", _t);
|
|
279
|
+
case 6:
|
|
280
|
+
setIsReady(true);
|
|
281
|
+
case 7:
|
|
282
|
+
return _context.a(2);
|
|
283
|
+
}
|
|
284
|
+
}, _callee, null, [[2, 5]]);
|
|
285
|
+
}));
|
|
246
286
|
script.onerror = function () {
|
|
247
287
|
setError("Payment provider script failed to load.");
|
|
248
288
|
};
|
|
249
289
|
document.body.appendChild(script);
|
|
250
|
-
|
|
290
|
+
_context2.n = 4;
|
|
251
291
|
break;
|
|
252
292
|
case 3:
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
console.error(
|
|
293
|
+
_context2.p = 3;
|
|
294
|
+
_t2 = _context2.v;
|
|
295
|
+
console.error(_t2);
|
|
256
296
|
setError("Payment initialization failed. Please try again.");
|
|
257
297
|
case 4:
|
|
258
|
-
return
|
|
298
|
+
return _context2.a(2);
|
|
259
299
|
}
|
|
260
|
-
},
|
|
300
|
+
}, _callee2, null, [[0, 3]]);
|
|
261
301
|
}));
|
|
262
302
|
return function initPayment() {
|
|
263
303
|
return _ref2.apply(this, arguments);
|
|
264
304
|
};
|
|
265
305
|
}();
|
|
266
306
|
initPayment();
|
|
267
|
-
}, [
|
|
307
|
+
}, []);
|
|
268
308
|
var handleSubmit = /*#__PURE__*/function () {
|
|
269
|
-
var
|
|
270
|
-
var
|
|
271
|
-
return _regenerator().w(function (
|
|
272
|
-
while (1) switch (
|
|
309
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(e) {
|
|
310
|
+
var request, threeDSecureToken, apiBase, response, result, _t3;
|
|
311
|
+
return _regenerator().w(function (_context3) {
|
|
312
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
273
313
|
case 0:
|
|
274
314
|
e.preventDefault();
|
|
275
315
|
if (!isSubmitting) {
|
|
276
|
-
|
|
316
|
+
_context3.n = 1;
|
|
277
317
|
break;
|
|
278
318
|
}
|
|
279
|
-
return
|
|
319
|
+
return _context3.a(2);
|
|
280
320
|
case 1:
|
|
281
321
|
if (formRef.current) {
|
|
282
|
-
|
|
322
|
+
_context3.n = 2;
|
|
283
323
|
break;
|
|
284
324
|
}
|
|
285
|
-
return
|
|
325
|
+
return _context3.a(2);
|
|
286
326
|
case 2:
|
|
287
327
|
if (!(!shift4Ref.current || !componentsRef.current)) {
|
|
288
|
-
|
|
328
|
+
_context3.n = 3;
|
|
289
329
|
break;
|
|
290
330
|
}
|
|
291
331
|
errorPage("Payment form is not ready yet. Please try again.");
|
|
292
|
-
return
|
|
332
|
+
return _context3.a(2);
|
|
293
333
|
case 3:
|
|
294
334
|
setIsSubmitting(true);
|
|
295
|
-
|
|
296
|
-
_context2.n = 5;
|
|
297
|
-
return shift4Ref.current.createToken(componentsRef.current);
|
|
298
|
-
case 5:
|
|
299
|
-
token = _context2.v;
|
|
300
|
-
if (!(token !== null && token !== void 0 && token.id)) {
|
|
301
|
-
errorPage("Card tokenization failed. Please check your details and try again.");
|
|
302
|
-
}
|
|
335
|
+
_context3.p = 4;
|
|
303
336
|
request = {
|
|
304
337
|
amount: amount,
|
|
305
338
|
currency: currency,
|
|
306
339
|
card: token.id,
|
|
307
340
|
description: description
|
|
308
341
|
};
|
|
309
|
-
|
|
342
|
+
_context3.n = 5;
|
|
310
343
|
return shift4Ref.current.verifyThreeDSecure(request);
|
|
311
|
-
case
|
|
312
|
-
threeDSecureToken =
|
|
344
|
+
case 5:
|
|
345
|
+
threeDSecureToken = _context3.v;
|
|
313
346
|
if (!(threeDSecureToken !== null && threeDSecureToken !== void 0 && threeDSecureToken.id)) {
|
|
314
347
|
errorPage("3D Secure verification failed. Please try again.");
|
|
315
348
|
}
|
|
316
|
-
apiBase = baseUrl + "charge/" + userId;
|
|
317
|
-
|
|
349
|
+
apiBase = baseUrl + "/api/Payment/charge/" + userId;
|
|
350
|
+
_context3.n = 6;
|
|
318
351
|
return fetch("".concat(apiBase), {
|
|
319
352
|
method: "POST",
|
|
320
353
|
headers: {
|
|
@@ -327,38 +360,37 @@ function PaymentForm(_ref) {
|
|
|
327
360
|
description: description
|
|
328
361
|
})
|
|
329
362
|
});
|
|
330
|
-
case
|
|
331
|
-
response =
|
|
332
|
-
|
|
363
|
+
case 6:
|
|
364
|
+
response = _context3.v;
|
|
365
|
+
_context3.n = 7;
|
|
333
366
|
return response.json();
|
|
334
|
-
case
|
|
335
|
-
result =
|
|
367
|
+
case 7:
|
|
368
|
+
result = _context3.v;
|
|
336
369
|
if (response.ok) {
|
|
337
|
-
|
|
370
|
+
_context3.n = 8;
|
|
338
371
|
break;
|
|
339
372
|
}
|
|
340
373
|
if (typeof errorPage === "function") errorPage(result);
|
|
341
|
-
return
|
|
342
|
-
case
|
|
374
|
+
return _context3.a(2);
|
|
375
|
+
case 8:
|
|
343
376
|
if (typeof successPage === "function") successPage(result.message);
|
|
344
|
-
|
|
377
|
+
_context3.n = 10;
|
|
345
378
|
break;
|
|
379
|
+
case 9:
|
|
380
|
+
_context3.p = 9;
|
|
381
|
+
_t3 = _context3.v;
|
|
382
|
+
if (typeof errorPage === "function") errorPage(_t3.message);
|
|
346
383
|
case 10:
|
|
347
|
-
|
|
348
|
-
_t2 = _context2.v;
|
|
349
|
-
if (typeof errorPage === "function") errorPage(_t2.message);
|
|
350
|
-
case 11:
|
|
351
|
-
_context2.p = 11;
|
|
384
|
+
_context3.p = 10;
|
|
352
385
|
setIsSubmitting(false);
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
return _context2.a(2);
|
|
386
|
+
return _context3.f(10);
|
|
387
|
+
case 11:
|
|
388
|
+
return _context3.a(2);
|
|
357
389
|
}
|
|
358
|
-
},
|
|
390
|
+
}, _callee3, null, [[4, 9, 10, 11]]);
|
|
359
391
|
}));
|
|
360
392
|
return function handleSubmit(_x) {
|
|
361
|
-
return
|
|
393
|
+
return _ref4.apply(this, arguments);
|
|
362
394
|
};
|
|
363
395
|
}();
|
|
364
396
|
return /*#__PURE__*/React.createElement("div", {
|