@pinerohit11/testwidget 0.1.60 → 0.1.61

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.
Files changed (3) hide show
  1. package/dist/index.js +500 -492
  2. package/dist/index.mjs +374 -360
  3. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -17,10 +17,16 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
21
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
22
+ }) : x)(function(x) {
23
+ if (typeof require !== "undefined") return require.apply(this, arguments);
24
+ throw Error('Dynamic require of "' + x + '" is not supported');
25
+ });
20
26
 
21
27
  // src/app/components/RequestPayment/RequestPayment.tsx
22
28
  import "bootstrap/dist/js/bootstrap.bundle.min.js";
23
- import React3, { useState, useEffect } from "react";
29
+ import React4, { useState, useEffect as useEffect2 } from "react";
24
30
 
25
31
  // src/app/components/Loader/Loader.tsx
26
32
  import React2 from "react";
@@ -152,356 +158,12 @@ var Loader = (props) => {
152
158
  var Loader_default = Loader;
153
159
 
154
160
  // src/app/components/RequestPayment/RequestPayment.tsx
155
- import { Button, Form, Modal } from "react-bootstrap";
156
-
157
- // src/app/components/baseurl.ts
158
- var baseUrl = "https://staging-widget.fractalpay.com/";
159
-
160
- // src/app/components/Errortext.ts
161
- var ErrorText = {
162
- namerequired: "Full Name is required",
163
- amountrequired: "Amount is required",
164
- amountpositive: "Amount should be positive",
165
- amountzero: "Amount should not be zero",
166
- amountenter: "Please enter an amount",
167
- amountvalid: "Please enter a valid amount",
168
- phoneoremailrequired: "Phone or Email is required",
169
- invalidemail: "Invalid email",
170
- invalidemailformat: "Invalid email format",
171
- onlylettersallowed: "Only letters are allowed",
172
- phonenumberlength: "Phone number should be 10 digits",
173
- phonenumberrequired: "Please enter a phone number",
174
- // phonenumbervalid:'Please enter a valid 10-digit phone number',
175
- phonenumbervalid: "Please enter a valid phone number (max 10 digits)",
176
- phonenumbervalidnumberonly: "Please enter a valid phone number (numbers only)",
177
- orderidenter: "Please enter an order ID",
178
- networkresponseerror: "Network response was not ok",
179
- anerroroccured: "An error occurred. Please try again.",
180
- montherror: "Please write month only 1 to 12",
181
- fieldrequired: "This field is required",
182
- fractalpayclientidrequired: "Fractalpay client key is missing or empty."
183
- };
184
-
185
- // src/app/components/RequestPayment/RequestPayment.tsx
186
- function RequestPayment(props) {
187
- const fractalpayClientKey = props.fractalpayClientKey;
188
- const [show, setShow] = useState(false);
189
- const [loading, setLoading] = useState(false);
190
- const [errors, setErrors] = useState({});
191
- const [requestDetails, setRequestDetails] = useState({
192
- email: "",
193
- amount: "",
194
- phone_number: "",
195
- order_id: "",
196
- name: "",
197
- fractalpayPublicKey: fractalpayClientKey
198
- });
199
- const [showConfirmationModal, setShowConfirmationModal] = useState(false);
200
- const phoneNumberRegex = (value) => /^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(value);
201
- const amoutRegex = /[+-]?([0-9]*[.])?[0-9]+/;
202
- const positiveAmountRegex = /^[+]?\d+(\.\d+)?$/;
203
- const isValidEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
204
- const isAlpha = (value) => /^[A-Za-z\s]*$/.test(value);
205
- const handleClose = () => {
206
- setShow(false);
207
- emptyFields();
208
- setErrors({});
209
- };
210
- const handleShow = () => setShow(true);
211
- const handleCloseConfirmationModal = () => setShowConfirmationModal(false);
212
- const emptyFields = () => {
213
- setRequestDetails({
214
- email: "",
215
- amount: "",
216
- phone_number: "",
217
- order_id: "",
218
- name: "",
219
- fractalpayPublicKey: fractalpayClientKey
220
- });
221
- };
222
- const handleSubmit = (event) => {
223
- let message = {
224
- type: "preview.compiledcheck",
225
- other: __spreadProps(__spreadValues({}, event), { status: true })
226
- };
227
- console.log("message: ", message);
228
- window.parent.postMessage(message, "*");
229
- };
230
- const sendRequestPayment = async () => {
231
- setErrors({});
232
- if (!(requestDetails == null ? void 0 : requestDetails.email) && requestDetails.phone_number && !phoneNumberRegex(requestDetails.phone_number)) {
233
- setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
234
- phone_number: "Phone number should be 10 digits"
235
- }));
236
- return;
237
- }
238
- if (!validateForm()) {
239
- return;
240
- }
241
- try {
242
- setLoading(true);
243
- const formData = {
244
- fractalpayPublicKey: fractalpayClientKey,
245
- amount: requestDetails.amount,
246
- phone_number: requestDetails.phone_number,
247
- order_id: requestDetails.order_id,
248
- action: "request",
249
- name: requestDetails.name,
250
- email: requestDetails.email
251
- };
252
- const response = await fetch(`${baseUrl}create-widget-order`, {
253
- method: "POST",
254
- headers: {
255
- "Content-Type": "application/json"
256
- },
257
- body: JSON.stringify(formData)
258
- });
259
- if (!response.ok) {
260
- throw new Error("Failed to create widget order");
261
- }
262
- const data = await response.json();
263
- if (data) {
264
- setShowConfirmationModal(true);
265
- setShow(false);
266
- emptyFields();
267
- handleSubmit(data);
268
- }
269
- console.log(data);
270
- setLoading(false);
271
- } catch (error) {
272
- console.log(error);
273
- setLoading(false);
274
- }
275
- };
276
- const validateAmount = (amount) => amoutRegex.test(amount);
277
- const PositiveAmount = (amount) => positiveAmountRegex.test(amount);
278
- const handleChange = (e) => {
279
- const { value } = e.target;
280
- const token = e.target.dataset.token;
281
- setRequestDetails(__spreadProps(__spreadValues({}, requestDetails), { [token]: value }));
282
- if (token === "name" && !isAlpha(value)) {
283
- setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
284
- [token]: ErrorText.onlylettersallowed
285
- }));
286
- return;
287
- }
288
- if (token === "phone_number" && !phoneNumberRegex(value)) {
289
- setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
290
- [token]: ErrorText.phonenumberlength
291
- }));
292
- return;
293
- }
294
- if (token === "email" && !isValidEmail(value)) {
295
- setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
296
- email: ErrorText.invalidemailformat
297
- }));
298
- return;
299
- }
300
- if (token === "amount" && !value) {
301
- setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
302
- amount: ErrorText.amountrequired
303
- }));
304
- return;
305
- }
306
- if (token === "amount" && !PositiveAmount(value)) {
307
- setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
308
- amount: ErrorText.amountpositive
309
- }));
310
- return;
311
- }
312
- if (token === "amount" && parseFloat(value) === 0) {
313
- setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
314
- amount: ErrorText.amountzero
315
- }));
316
- return;
317
- }
318
- if (value) {
319
- setErrors(__spreadProps(__spreadValues({}, errors), { [token]: "" }));
320
- }
321
- };
322
- const handleAmountBlur = () => {
323
- const value = requestDetails.amount;
324
- if (value && !value.includes(".")) {
325
- setRequestDetails((prev) => __spreadProps(__spreadValues({}, prev), {
326
- amount: `${value}.00`
327
- }));
328
- }
329
- };
330
- const validateForm = () => {
331
- let newErrors = {};
332
- if (!requestDetails.name) newErrors.name = ErrorText.namerequired;
333
- if (!requestDetails.amount) newErrors.amount = ErrorText.amountrequired;
334
- if (!requestDetails.phone_number && !(requestDetails == null ? void 0 : requestDetails.email)) newErrors.phone_number = ErrorText.phoneoremailrequired;
335
- if (!requestDetails.email && !requestDetails.phone_number) newErrors.email = ErrorText.phoneoremailrequired;
336
- if (!requestDetails.phone_number && requestDetails.email && !isValidEmail(requestDetails == null ? void 0 : requestDetails.email)) newErrors.email = ErrorText.invalidemail;
337
- setErrors(newErrors);
338
- return Object.keys(newErrors).length === 0;
339
- };
340
- useEffect(() => {
341
- if (props.amount) {
342
- setRequestDetails((prev) => __spreadProps(__spreadValues({}, prev), { amount: props.amount }));
343
- }
344
- }, [props.amount]);
345
- const handleKeyDown = (e) => {
346
- if (e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight") {
347
- e.preventDefault();
348
- }
349
- };
350
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(Loader_default, { loading }), /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("button", { className: "paymentBtn", onClick: handleShow }, "Request Payment"), /* @__PURE__ */ React3.createElement(
351
- Modal,
352
- {
353
- show,
354
- onHide: handleClose,
355
- size: "lg",
356
- backdrop: "static",
357
- keyboard: false
358
- },
359
- /* @__PURE__ */ React3.createElement(Modal.Header, { closeButton: true }, /* @__PURE__ */ React3.createElement(Modal.Title, null, "Request Payment")),
360
- /* @__PURE__ */ React3.createElement(Modal.Body, { id: "Checkout" }, /* @__PURE__ */ React3.createElement(Form, null, /* @__PURE__ */ React3.createElement("div", { className: "mb-3" }, /* @__PURE__ */ React3.createElement("label", { htmlFor: "exampleFormControlInput2", className: "form-label" }, "FULL NAME *"), /* @__PURE__ */ React3.createElement(
361
- "input",
362
- {
363
- className: "form-control",
364
- type: "text",
365
- placeholder: "Full Name",
366
- "data-token": "name",
367
- onChange: handleChange
368
- }
369
- ), errors.name && /* @__PURE__ */ React3.createElement("small", { className: "text-danger" }, errors.name)), /* @__PURE__ */ React3.createElement("div", { className: "mb-3" }, /* @__PURE__ */ React3.createElement("label", { htmlFor: "requestPhoneNumber", className: "form-label" }, "Phone Number"), /* @__PURE__ */ React3.createElement(
370
- "input",
371
- {
372
- maxLength: 10,
373
- className: "form-control",
374
- onChange: (e) => {
375
- handleChange(e);
376
- },
377
- placeholder: "Phone Number",
378
- type: "text",
379
- "data-token": "phone_number"
380
- }
381
- ), errors.phone_number && /* @__PURE__ */ React3.createElement("small", { className: "text-danger" }, errors.phone_number)), /* @__PURE__ */ React3.createElement("div", { className: "mb-3" }, /* @__PURE__ */ React3.createElement("label", { htmlFor: "exampleFormControlInput2", className: "form-label" }, "EMAIL"), /* @__PURE__ */ React3.createElement(
382
- "input",
383
- {
384
- className: "form-control",
385
- type: "text",
386
- placeholder: "Email",
387
- onChange: handleChange,
388
- "data-token": "email"
389
- }
390
- ), errors.email && /* @__PURE__ */ React3.createElement("small", { className: "text-danger" }, errors.email)), /* @__PURE__ */ React3.createElement("div", { className: "mb-3" }, /* @__PURE__ */ React3.createElement("label", { htmlFor: "exampleFormControlInput2", className: "form-label" }, "AMOUNT *"), /* @__PURE__ */ React3.createElement("div", { className: "input-group" }, /* @__PURE__ */ React3.createElement("span", { className: "input-group-text" }, "$"), /* @__PURE__ */ React3.createElement(
391
- "input",
392
- {
393
- "data-token": "amount",
394
- placeholder: "Amount",
395
- min: 0,
396
- type: "number",
397
- className: "form-control",
398
- value: requestDetails.amount,
399
- onChange: handleChange,
400
- onBlur: handleAmountBlur,
401
- onKeyDown: handleKeyDown,
402
- onFocus: (e) => e.target.addEventListener("wheel", function(e2) {
403
- e2.preventDefault();
404
- }, { passive: false })
405
- }
406
- )), errors.amount && /* @__PURE__ */ React3.createElement("small", { className: "text-danger" }, errors.amount)), /* @__PURE__ */ React3.createElement("div", { className: "mb-3" }, /* @__PURE__ */ React3.createElement("label", { htmlFor: "exampleFormControlInput2", className: "form-label" }, "ORDER ID"), /* @__PURE__ */ React3.createElement(
407
- "input",
408
- {
409
- className: "form-control",
410
- type: "text",
411
- placeholder: "Order Id",
412
- onChange: handleChange,
413
- "data-token": "order_id"
414
- }
415
- ), errors.order_id && /* @__PURE__ */ React3.createElement("small", { className: "text-danger" }, errors.order_id)), /* @__PURE__ */ React3.createElement(
416
- Button,
417
- {
418
- type: "button",
419
- className: "PayButton",
420
- onClick: sendRequestPayment,
421
- disabled: loading
422
- },
423
- loading ? "Loading..." : "Send Request"
424
- )), /* @__PURE__ */ React3.createElement("div", { className: "powerd-by-part" }, /* @__PURE__ */ React3.createElement(
425
- "svg",
426
- {
427
- xmlns: "http://www.w3.org/2000/svg",
428
- width: "20",
429
- height: "20",
430
- viewBox: "0 0 26 26"
431
- },
432
- /* @__PURE__ */ React3.createElement(
433
- "path",
434
- {
435
- fill: "currentColor",
436
- d: "M23.633 5.028a1.074 1.074 0 0 0-.777-.366c-2.295-.06-5.199-2.514-7.119-3.477C14.551.592 13.768.201 13.18.098a1.225 1.225 0 0 0-.36.001c-.588.103-1.371.494-2.556 1.087c-1.92.962-4.824 3.416-7.119 3.476a1.08 1.08 0 0 0-.778.366a1.167 1.167 0 0 0-.291.834c.493 10.023 4.088 16.226 10.396 19.831c.164.093.346.141.527.141s.363-.048.528-.141c6.308-3.605 9.902-9.808 10.396-19.831a1.161 1.161 0 0 0-.29-.834zM18.617 8.97l-5.323 7.855c-.191.282-.491.469-.788.469c-.298 0-.629-.163-.838-.372l-3.752-3.753a.656.656 0 0 1 0-.926l.927-.929a.658.658 0 0 1 .926 0l2.44 2.44l4.239-6.257a.657.657 0 0 1 .91-.173l1.085.736a.657.657 0 0 1 .174.91z"
437
- }
438
- )
439
- ), "Secure payments powered by Fractal", /* @__PURE__ */ React3.createElement(
440
- "img",
441
- {
442
- src: "https://ui.fractalpay.com/favicon.ico",
443
- alt: "Fractal logo",
444
- className: "powered-logo"
445
- }
446
- )))
447
- ), /* @__PURE__ */ React3.createElement(
448
- Modal,
449
- {
450
- className: "payment-suc",
451
- show: showConfirmationModal,
452
- onHide: handleCloseConfirmationModal
453
- },
454
- /* @__PURE__ */ React3.createElement(Modal.Header, { closeButton: true }),
455
- /* @__PURE__ */ React3.createElement(Modal.Body, null, /* @__PURE__ */ React3.createElement(
456
- "svg",
457
- {
458
- width: "60",
459
- height: "60",
460
- viewBox: "0 0 60 60",
461
- fill: "none",
462
- xmlns: "http://www.w3.org/2000/svg"
463
- },
464
- /* @__PURE__ */ React3.createElement(
465
- "rect",
466
- {
467
- x: "0.5",
468
- y: "0.5",
469
- width: "59",
470
- height: "59",
471
- rx: "29.5",
472
- stroke: "#31B379"
473
- }
474
- ),
475
- /* @__PURE__ */ React3.createElement("g", { clipPath: "url(#clip0_2659_5018)" }, /* @__PURE__ */ React3.createElement(
476
- "path",
477
- {
478
- d: "M41.1778 22.248C40.7483 21.8184 40.0518 21.8184 39.6222 22.248L26.4435 35.4268L21.3778 30.3611C20.9483 29.9315 20.2518 29.9316 19.8222 30.3611C19.3926 30.7907 19.3926 31.4871 19.8222 31.9167L25.6657 37.7601C26.0951 38.1897 26.7921 38.1894 27.2213 37.7601L41.1778 23.8036C41.6074 23.3741 41.6074 22.6776 41.1778 22.248Z",
479
- fill: "#31B379"
480
- }
481
- )),
482
- /* @__PURE__ */ React3.createElement("defs", null, /* @__PURE__ */ React3.createElement("clipPath", { id: "clip0_2659_5018" }, /* @__PURE__ */ React3.createElement(
483
- "rect",
484
- {
485
- width: "22",
486
- height: "22",
487
- fill: "white",
488
- transform: "translate(19.5 19.0039)"
489
- }
490
- )))
491
- ), /* @__PURE__ */ React3.createElement("h2", null, "Payment link has been ", /* @__PURE__ */ React3.createElement("br", null), " sent successfully"))
492
- )));
493
- }
494
-
495
- // src/app/components/RequestPayment/RequestPaymentAllInput.tsx
496
- import React5, { useState as useState2 } from "react";
497
- import { Modal as Modal2 } from "react-bootstrap";
498
- import { toast, ToastContainer } from "react-toastify";
499
- import "react-toastify/dist/ReactToastify.css";
161
+ import { Button, Form, Modal, Stack } from "react-bootstrap";
500
162
 
501
163
  // src/app/components/RequestPayment/RequestPaymentstyles.tsx
502
- import React4 from "react";
164
+ import React3 from "react";
503
165
  var RequestPaymentstyles = (props) => {
504
- return /* @__PURE__ */ React4.createElement("style", null, `
166
+ return /* @__PURE__ */ React3.createElement("style", null, `
505
167
  .paymentBtn {
506
168
  background-color: black;
507
169
  border: none;
@@ -1323,11 +985,363 @@ input[type="number"] {
1323
985
  -moz-appearance: textfield;
1324
986
  }
1325
987
 
1326
- `);
1327
- };
1328
- var RequestPaymentstyles_default = RequestPaymentstyles;
1329
-
988
+ `);
989
+ };
990
+ var RequestPaymentstyles_default = RequestPaymentstyles;
991
+
992
+ // src/app/components/baseurl.ts
993
+ var baseUrl = "https://staging-widget.fractalpay.com/";
994
+
995
+ // src/app/components/Errortext.ts
996
+ var ErrorText = {
997
+ namerequired: "Full Name is required",
998
+ amountrequired: "Amount is required",
999
+ amountpositive: "Amount should be positive",
1000
+ amountzero: "Amount should not be zero",
1001
+ amountenter: "Please enter an amount",
1002
+ amountvalid: "Please enter a valid amount",
1003
+ phoneoremailrequired: "Phone or Email is required",
1004
+ invalidemail: "Invalid email",
1005
+ invalidemailformat: "Invalid email format",
1006
+ onlylettersallowed: "Only letters are allowed",
1007
+ phonenumberlength: "Phone number should be 10 digits",
1008
+ phonenumberrequired: "Please enter a phone number",
1009
+ // phonenumbervalid:'Please enter a valid 10-digit phone number',
1010
+ phonenumbervalid: "Please enter a valid phone number (max 10 digits)",
1011
+ phonenumbervalidnumberonly: "Please enter a valid phone number (numbers only)",
1012
+ orderidenter: "Please enter an order ID",
1013
+ networkresponseerror: "Network response was not ok",
1014
+ anerroroccured: "An error occurred. Please try again.",
1015
+ montherror: "Please write month only 1 to 12",
1016
+ fieldrequired: "This field is required",
1017
+ fractalpayclientidrequired: "Fractalpay client key is missing or empty."
1018
+ };
1019
+
1020
+ // src/app/components/Bootstrapclient.ts
1021
+ import { useEffect } from "react";
1022
+ function BootstrapClient() {
1023
+ useEffect(() => {
1024
+ __require("bootstrap/dist/js/bootstrap.bundle.min.js");
1025
+ }, []);
1026
+ return null;
1027
+ }
1028
+ var Bootstrapclient_default = BootstrapClient;
1029
+
1030
+ // src/app/components/RequestPayment/RequestPayment.tsx
1031
+ function RequestPayment(props) {
1032
+ const fractalpayClientKey = props.fractalpayClientKey;
1033
+ const [show, setShow] = useState(false);
1034
+ const [loading, setLoading] = useState(false);
1035
+ const [errors, setErrors] = useState({});
1036
+ const [requestDetails, setRequestDetails] = useState({
1037
+ email: "",
1038
+ amount: "",
1039
+ phone_number: "",
1040
+ order_id: "",
1041
+ name: "",
1042
+ fractalpayPublicKey: fractalpayClientKey
1043
+ });
1044
+ const [showConfirmationModal, setShowConfirmationModal] = useState(false);
1045
+ const phoneNumberRegex = (value) => /^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(value);
1046
+ const amoutRegex = /[+-]?([0-9]*[.])?[0-9]+/;
1047
+ const positiveAmountRegex = /^[+]?\d+(\.\d+)?$/;
1048
+ const isValidEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
1049
+ const isAlpha = (value) => /^[A-Za-z\s]*$/.test(value);
1050
+ const handleClose = () => {
1051
+ setShow(false);
1052
+ emptyFields();
1053
+ setErrors({});
1054
+ };
1055
+ const handleShow = () => setShow(true);
1056
+ const handleCloseConfirmationModal = () => setShowConfirmationModal(false);
1057
+ const emptyFields = () => {
1058
+ setRequestDetails({
1059
+ email: "",
1060
+ amount: "",
1061
+ phone_number: "",
1062
+ order_id: "",
1063
+ name: "",
1064
+ fractalpayPublicKey: fractalpayClientKey
1065
+ });
1066
+ };
1067
+ const handleSubmit = (event) => {
1068
+ let message = {
1069
+ type: "preview.compiledcheck",
1070
+ other: __spreadProps(__spreadValues({}, event), { status: true })
1071
+ };
1072
+ console.log("message: ", message);
1073
+ window.parent.postMessage(message, "*");
1074
+ };
1075
+ const sendRequestPayment = async () => {
1076
+ setErrors({});
1077
+ if (!(requestDetails == null ? void 0 : requestDetails.email) && requestDetails.phone_number && !phoneNumberRegex(requestDetails.phone_number)) {
1078
+ setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
1079
+ phone_number: "Phone number should be 10 digits"
1080
+ }));
1081
+ return;
1082
+ }
1083
+ if (!validateForm()) {
1084
+ return;
1085
+ }
1086
+ try {
1087
+ setLoading(true);
1088
+ const formData = {
1089
+ fractalpayPublicKey: fractalpayClientKey,
1090
+ amount: requestDetails.amount,
1091
+ phone_number: requestDetails.phone_number,
1092
+ order_id: requestDetails.order_id,
1093
+ action: "request",
1094
+ name: requestDetails.name,
1095
+ email: requestDetails.email
1096
+ };
1097
+ const response = await fetch(`${baseUrl}create-widget-order`, {
1098
+ method: "POST",
1099
+ headers: {
1100
+ "Content-Type": "application/json"
1101
+ },
1102
+ body: JSON.stringify(formData)
1103
+ });
1104
+ if (!response.ok) {
1105
+ throw new Error("Failed to create widget order");
1106
+ }
1107
+ const data = await response.json();
1108
+ if (data) {
1109
+ setShowConfirmationModal(true);
1110
+ setShow(false);
1111
+ emptyFields();
1112
+ handleSubmit(data);
1113
+ }
1114
+ console.log(data);
1115
+ setLoading(false);
1116
+ } catch (error) {
1117
+ console.log(error);
1118
+ setLoading(false);
1119
+ }
1120
+ };
1121
+ const validateAmount = (amount) => amoutRegex.test(amount);
1122
+ const PositiveAmount = (amount) => positiveAmountRegex.test(amount);
1123
+ const handleChange = (e) => {
1124
+ const { value } = e.target;
1125
+ const token = e.target.dataset.token;
1126
+ setRequestDetails(__spreadProps(__spreadValues({}, requestDetails), { [token]: value }));
1127
+ if (token === "name" && !isAlpha(value)) {
1128
+ setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
1129
+ [token]: ErrorText.onlylettersallowed
1130
+ }));
1131
+ return;
1132
+ }
1133
+ if (token === "phone_number" && !phoneNumberRegex(value)) {
1134
+ setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
1135
+ [token]: ErrorText.phonenumberlength
1136
+ }));
1137
+ return;
1138
+ }
1139
+ if (token === "email" && !isValidEmail(value)) {
1140
+ setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
1141
+ email: ErrorText.invalidemailformat
1142
+ }));
1143
+ return;
1144
+ }
1145
+ if (token === "amount" && !value) {
1146
+ setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
1147
+ amount: ErrorText.amountrequired
1148
+ }));
1149
+ return;
1150
+ }
1151
+ if (token === "amount" && !PositiveAmount(value)) {
1152
+ setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
1153
+ amount: ErrorText.amountpositive
1154
+ }));
1155
+ return;
1156
+ }
1157
+ if (token === "amount" && parseFloat(value) === 0) {
1158
+ setErrors((prevErrors) => __spreadProps(__spreadValues({}, prevErrors), {
1159
+ amount: ErrorText.amountzero
1160
+ }));
1161
+ return;
1162
+ }
1163
+ if (value) {
1164
+ setErrors(__spreadProps(__spreadValues({}, errors), { [token]: "" }));
1165
+ }
1166
+ };
1167
+ const handleAmountBlur = () => {
1168
+ const value = requestDetails.amount;
1169
+ if (value && !value.includes(".")) {
1170
+ setRequestDetails((prev) => __spreadProps(__spreadValues({}, prev), {
1171
+ amount: `${value}.00`
1172
+ }));
1173
+ }
1174
+ };
1175
+ const validateForm = () => {
1176
+ let newErrors = {};
1177
+ if (!requestDetails.name) newErrors.name = ErrorText.namerequired;
1178
+ if (!requestDetails.amount) newErrors.amount = ErrorText.amountrequired;
1179
+ if (!requestDetails.phone_number && !(requestDetails == null ? void 0 : requestDetails.email)) newErrors.phone_number = ErrorText.phoneoremailrequired;
1180
+ if (!requestDetails.email && !requestDetails.phone_number) newErrors.email = ErrorText.phoneoremailrequired;
1181
+ if (!requestDetails.phone_number && requestDetails.email && !isValidEmail(requestDetails == null ? void 0 : requestDetails.email)) newErrors.email = ErrorText.invalidemail;
1182
+ setErrors(newErrors);
1183
+ return Object.keys(newErrors).length === 0;
1184
+ };
1185
+ useEffect2(() => {
1186
+ if (props.amount) {
1187
+ setRequestDetails((prev) => __spreadProps(__spreadValues({}, prev), { amount: props.amount }));
1188
+ }
1189
+ }, [props.amount]);
1190
+ const handleKeyDown = (e) => {
1191
+ if (e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight") {
1192
+ e.preventDefault();
1193
+ }
1194
+ };
1195
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(Bootstrapclient_default, null), /* @__PURE__ */ React4.createElement(RequestPaymentstyles_default, null), /* @__PURE__ */ React4.createElement(Loader_default, { loading }), /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(Button, { className: "paymentBtn", onClick: handleShow }, "Request Payment"), /* @__PURE__ */ React4.createElement(
1196
+ Modal,
1197
+ {
1198
+ show,
1199
+ onHide: handleClose,
1200
+ size: "lg",
1201
+ backdrop: "static",
1202
+ keyboard: false
1203
+ },
1204
+ /* @__PURE__ */ React4.createElement(Modal.Header, { closeButton: true }, /* @__PURE__ */ React4.createElement(Modal.Title, null, "Request Payment")),
1205
+ /* @__PURE__ */ React4.createElement(Modal.Body, { id: "Checkout" }, /* @__PURE__ */ React4.createElement(Form, null, /* @__PURE__ */ React4.createElement(Stack, { gap: 3 }, /* @__PURE__ */ React4.createElement("div", null, /* @__PURE__ */ React4.createElement("label", { htmlFor: "exampleFormControlInput2", className: "form-label" }, "FULL NAME *"), /* @__PURE__ */ React4.createElement(
1206
+ "input",
1207
+ {
1208
+ className: "form-control",
1209
+ type: "text",
1210
+ placeholder: "Full Name",
1211
+ "data-token": "name",
1212
+ onChange: handleChange
1213
+ }
1214
+ ), errors.name && /* @__PURE__ */ React4.createElement("small", { className: "text-danger" }, errors.name)), /* @__PURE__ */ React4.createElement("div", { className: "mb-3" }, /* @__PURE__ */ React4.createElement("label", { htmlFor: "requestPhoneNumber", className: "form-label" }, "Phone Number"), /* @__PURE__ */ React4.createElement(
1215
+ "input",
1216
+ {
1217
+ maxLength: 10,
1218
+ className: "form-control",
1219
+ onChange: (e) => {
1220
+ handleChange(e);
1221
+ },
1222
+ placeholder: "Phone Number",
1223
+ type: "text",
1224
+ "data-token": "phone_number"
1225
+ }
1226
+ ), errors.phone_number && /* @__PURE__ */ React4.createElement("small", { className: "text-danger" }, errors.phone_number))), /* @__PURE__ */ React4.createElement("div", { className: "mb-3" }, /* @__PURE__ */ React4.createElement("label", { htmlFor: "exampleFormControlInput2", className: "form-label" }, "EMAIL"), /* @__PURE__ */ React4.createElement(
1227
+ "input",
1228
+ {
1229
+ className: "form-control",
1230
+ type: "text",
1231
+ placeholder: "Email",
1232
+ onChange: handleChange,
1233
+ "data-token": "email"
1234
+ }
1235
+ ), errors.email && /* @__PURE__ */ React4.createElement("small", { className: "text-danger" }, errors.email)), /* @__PURE__ */ React4.createElement("div", { className: "mb-3" }, /* @__PURE__ */ React4.createElement("label", { htmlFor: "exampleFormControlInput2", className: "form-label" }, "AMOUNT *"), /* @__PURE__ */ React4.createElement("div", { className: "input-group" }, /* @__PURE__ */ React4.createElement("span", { className: "input-group-text" }, "$"), /* @__PURE__ */ React4.createElement(
1236
+ "input",
1237
+ {
1238
+ "data-token": "amount",
1239
+ placeholder: "Amount",
1240
+ min: 0,
1241
+ type: "number",
1242
+ className: "form-control",
1243
+ value: requestDetails.amount,
1244
+ onChange: handleChange,
1245
+ onBlur: handleAmountBlur,
1246
+ onKeyDown: handleKeyDown,
1247
+ onFocus: (e) => e.target.addEventListener("wheel", function(e2) {
1248
+ e2.preventDefault();
1249
+ }, { passive: false })
1250
+ }
1251
+ )), errors.amount && /* @__PURE__ */ React4.createElement("small", { className: "text-danger" }, errors.amount)), /* @__PURE__ */ React4.createElement("div", { className: "mb-3" }, /* @__PURE__ */ React4.createElement("label", { htmlFor: "exampleFormControlInput2", className: "form-label" }, "ORDER ID"), /* @__PURE__ */ React4.createElement(
1252
+ "input",
1253
+ {
1254
+ className: "form-control",
1255
+ type: "text",
1256
+ placeholder: "Order Id",
1257
+ onChange: handleChange,
1258
+ "data-token": "order_id"
1259
+ }
1260
+ ), errors.order_id && /* @__PURE__ */ React4.createElement("small", { className: "text-danger" }, errors.order_id)), /* @__PURE__ */ React4.createElement(
1261
+ Button,
1262
+ {
1263
+ type: "button",
1264
+ className: "PayButton",
1265
+ onClick: sendRequestPayment,
1266
+ disabled: loading
1267
+ },
1268
+ loading ? "Loading..." : "Send Request"
1269
+ )), /* @__PURE__ */ React4.createElement("div", { className: "powerd-by-part" }, /* @__PURE__ */ React4.createElement(
1270
+ "svg",
1271
+ {
1272
+ xmlns: "http://www.w3.org/2000/svg",
1273
+ width: "20",
1274
+ height: "20",
1275
+ viewBox: "0 0 26 26"
1276
+ },
1277
+ /* @__PURE__ */ React4.createElement(
1278
+ "path",
1279
+ {
1280
+ fill: "currentColor",
1281
+ d: "M23.633 5.028a1.074 1.074 0 0 0-.777-.366c-2.295-.06-5.199-2.514-7.119-3.477C14.551.592 13.768.201 13.18.098a1.225 1.225 0 0 0-.36.001c-.588.103-1.371.494-2.556 1.087c-1.92.962-4.824 3.416-7.119 3.476a1.08 1.08 0 0 0-.778.366a1.167 1.167 0 0 0-.291.834c.493 10.023 4.088 16.226 10.396 19.831c.164.093.346.141.527.141s.363-.048.528-.141c6.308-3.605 9.902-9.808 10.396-19.831a1.161 1.161 0 0 0-.29-.834zM18.617 8.97l-5.323 7.855c-.191.282-.491.469-.788.469c-.298 0-.629-.163-.838-.372l-3.752-3.753a.656.656 0 0 1 0-.926l.927-.929a.658.658 0 0 1 .926 0l2.44 2.44l4.239-6.257a.657.657 0 0 1 .91-.173l1.085.736a.657.657 0 0 1 .174.91z"
1282
+ }
1283
+ )
1284
+ ), "Secure payments powered by Fractal", /* @__PURE__ */ React4.createElement(
1285
+ "img",
1286
+ {
1287
+ src: "https://ui.fractalpay.com/favicon.ico",
1288
+ alt: "Fractal logo",
1289
+ className: "powered-logo"
1290
+ }
1291
+ )))
1292
+ ), /* @__PURE__ */ React4.createElement(
1293
+ Modal,
1294
+ {
1295
+ className: "payment-suc",
1296
+ show: showConfirmationModal,
1297
+ onHide: handleCloseConfirmationModal
1298
+ },
1299
+ /* @__PURE__ */ React4.createElement(Modal.Header, { closeButton: true }),
1300
+ /* @__PURE__ */ React4.createElement(Modal.Body, null, /* @__PURE__ */ React4.createElement(
1301
+ "svg",
1302
+ {
1303
+ width: "60",
1304
+ height: "60",
1305
+ viewBox: "0 0 60 60",
1306
+ fill: "none",
1307
+ xmlns: "http://www.w3.org/2000/svg"
1308
+ },
1309
+ /* @__PURE__ */ React4.createElement(
1310
+ "rect",
1311
+ {
1312
+ x: "0.5",
1313
+ y: "0.5",
1314
+ width: "59",
1315
+ height: "59",
1316
+ rx: "29.5",
1317
+ stroke: "#31B379"
1318
+ }
1319
+ ),
1320
+ /* @__PURE__ */ React4.createElement("g", { clipPath: "url(#clip0_2659_5018)" }, /* @__PURE__ */ React4.createElement(
1321
+ "path",
1322
+ {
1323
+ d: "M41.1778 22.248C40.7483 21.8184 40.0518 21.8184 39.6222 22.248L26.4435 35.4268L21.3778 30.3611C20.9483 29.9315 20.2518 29.9316 19.8222 30.3611C19.3926 30.7907 19.3926 31.4871 19.8222 31.9167L25.6657 37.7601C26.0951 38.1897 26.7921 38.1894 27.2213 37.7601L41.1778 23.8036C41.6074 23.3741 41.6074 22.6776 41.1778 22.248Z",
1324
+ fill: "#31B379"
1325
+ }
1326
+ )),
1327
+ /* @__PURE__ */ React4.createElement("defs", null, /* @__PURE__ */ React4.createElement("clipPath", { id: "clip0_2659_5018" }, /* @__PURE__ */ React4.createElement(
1328
+ "rect",
1329
+ {
1330
+ width: "22",
1331
+ height: "22",
1332
+ fill: "white",
1333
+ transform: "translate(19.5 19.0039)"
1334
+ }
1335
+ )))
1336
+ ), /* @__PURE__ */ React4.createElement("h2", null, "Payment link has been ", /* @__PURE__ */ React4.createElement("br", null), " sent successfully"))
1337
+ )));
1338
+ }
1339
+
1330
1340
  // src/app/components/RequestPayment/RequestPaymentAllInput.tsx
1341
+ import React5, { useState as useState2 } from "react";
1342
+ import { Modal as Modal2 } from "react-bootstrap";
1343
+ import { toast, ToastContainer } from "react-toastify";
1344
+ import "react-toastify/dist/ReactToastify.css";
1331
1345
  function RequestPaymentAllInput({ fractalpayClientKey }) {
1332
1346
  const [isLoading, setIsLoading] = useState2(false);
1333
1347
  const [show, setShow] = useState2(false);
@@ -3119,7 +3133,7 @@ function Payment() {
3119
3133
  }
3120
3134
 
3121
3135
  // src/app/components/Transaction/CompletedTransactions.tsx
3122
- import React12, { useEffect as useEffect3, useState as useState8 } from "react";
3136
+ import React12, { useEffect as useEffect4, useState as useState8 } from "react";
3123
3137
  import { Col, Row, Table } from "react-bootstrap";
3124
3138
  import {
3125
3139
  DatatableWrapper,
@@ -3133,14 +3147,14 @@ import "react-datepicker/dist/react-datepicker.css";
3133
3147
  import { toast as toast4 } from "react-toastify";
3134
3148
 
3135
3149
  // src/app/components/Pagination/Pagination.tsx
3136
- import React11, { useState as useState7, useEffect as useEffect2 } from "react";
3150
+ import React11, { useState as useState7, useEffect as useEffect3 } from "react";
3137
3151
  function PaginationPg({ totalPages, onPageChange, current }) {
3138
3152
  const [currentPage, setCurrentPage] = useState7(current);
3139
3153
  const [showPages, setShowPages] = useState7(false);
3140
- useEffect2(() => {
3154
+ useEffect3(() => {
3141
3155
  setCurrentPage(current);
3142
3156
  }, [current]);
3143
- useEffect2(() => {
3157
+ useEffect3(() => {
3144
3158
  setTimeout(() => {
3145
3159
  setShowPages(true);
3146
3160
  }, 1e3);
@@ -3358,7 +3372,7 @@ function CompletedTransactions(props) {
3358
3372
  }
3359
3373
  }
3360
3374
  };
3361
- useEffect3(() => {
3375
+ useEffect4(() => {
3362
3376
  fetchData(state.page, startDate, endDate);
3363
3377
  }, [state.page]);
3364
3378
  const handlePageChange = (pageNumber) => {
@@ -3804,7 +3818,7 @@ function TockenizPay() {
3804
3818
  }
3805
3819
 
3806
3820
  // src/app/components/Payment/GetPaymentDynamic.tsx
3807
- import React15, { useEffect as useEffect4, useState as useState10 } from "react";
3821
+ import React15, { useEffect as useEffect5, useState as useState10 } from "react";
3808
3822
  import { Modal as Modal8 } from "react-bootstrap";
3809
3823
 
3810
3824
  // src/app/components/Loader/MyLoadingAnimation.tsx
@@ -3837,7 +3851,7 @@ function GetPaymentDynamic(props) {
3837
3851
  console.error(ErrorText.fractalpayclientidrequired);
3838
3852
  }
3839
3853
  };
3840
- useEffect4(() => {
3854
+ useEffect5(() => {
3841
3855
  if (!fractalpayClientKey) {
3842
3856
  console.error(ErrorText.fractalpayclientidrequired);
3843
3857
  }
@@ -3860,7 +3874,7 @@ function GetPaymentDynamic(props) {
3860
3874
  const handleLoad = () => {
3861
3875
  setLoading(false);
3862
3876
  };
3863
- useEffect4(() => {
3877
+ useEffect5(() => {
3864
3878
  const messageListener = (event) => {
3865
3879
  var _a, _b;
3866
3880
  const response = (_b = (_a = event == null ? void 0 : event.data) == null ? void 0 : _a.other) == null ? void 0 : _b.data;