@bigbinary/neeto-payments-frontend 6.3.5 → 6.3.6
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/app/javascript/src/translations/en.json +3 -3
- package/dist/ManualUpiPayment.js +96 -21
- package/dist/ManualUpiPayment.js.map +1 -1
- package/dist/ManualUpiPaymentConfirmButton.js +1 -1
- package/dist/ManualUpiPaymentRejectButton.js +1 -1
- package/dist/cjs/ManualUpiPayment.js +96 -21
- package/dist/cjs/ManualUpiPayment.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/v2/ManualUpiPayment.js +88 -14
- package/dist/cjs/v2/ManualUpiPayment.js.map +1 -1
- package/dist/cjs/v2/index.js +1 -0
- package/dist/cjs/v2/index.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/{usePaymentApi-C8fRdHmK.js → usePaymentApi-CjtkL3IU.js} +2 -2
- package/dist/{usePaymentApi-C8fRdHmK.js.map → usePaymentApi-CjtkL3IU.js.map} +1 -1
- package/dist/v2/ManualUpiPayment.js +88 -14
- package/dist/v2/ManualUpiPayment.js.map +1 -1
- package/dist/v2/ManualUpiPaymentConfirmButton.js +1 -1
- package/dist/v2/ManualUpiPaymentRejectButton.js +1 -1
- package/dist/v2/index.js +2 -1
- package/dist/v2/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -486,12 +486,12 @@
|
|
|
486
486
|
"screenshot": {
|
|
487
487
|
"label": "Upload payment screenshot",
|
|
488
488
|
"alt": "Payment screenshot",
|
|
489
|
-
"uploadText": "Click to upload payment screenshot",
|
|
489
|
+
"uploadText": "Click here to upload payment screenshot",
|
|
490
490
|
"formatHint": "PNG, JPG up to {{maxSize}}MB",
|
|
491
491
|
"tooLarge": "File size must be less than {{maxSize}}MB"
|
|
492
492
|
},
|
|
493
|
-
"vpaText": "
|
|
494
|
-
"vpaText_other": "
|
|
493
|
+
"vpaText": "Please pay the above-mentioned amount to the following UPI ID. Once the payment is completed, enter the UPI transaction ID or upload the payment screenshot.",
|
|
494
|
+
"vpaText_other": "Please pay the above-mentioned amount to any of the following UPI IDs. Once the payment is completed, enter the UPI transaction ID or upload the payment screenshot.",
|
|
495
495
|
"buttons": {
|
|
496
496
|
"submit": "Submit",
|
|
497
497
|
"back": "Back",
|
package/dist/ManualUpiPayment.js
CHANGED
|
@@ -2,16 +2,17 @@ import { useRef, useState, useMemo, useEffect } from 'react';
|
|
|
2
2
|
import { DirectUpload } from '@rails/activestorage';
|
|
3
3
|
import { isPresent, isNotPresent, noop } from 'neetocist';
|
|
4
4
|
import { Close } from '@bigbinary/neeto-icons';
|
|
5
|
-
import { Typography, Button, Toastr } from '@bigbinary/neetoui';
|
|
6
|
-
import { Form, Input, ActionBlock } from '@bigbinary/neetoui/formik';
|
|
7
5
|
import QRCodeImage from 'qrcode.react';
|
|
8
6
|
import { pluck } from 'ramda';
|
|
9
7
|
import { useTranslation } from 'react-i18next';
|
|
10
|
-
import {
|
|
8
|
+
import { a as useCreateUpiPayment } from './usePaymentApi-CjtkL3IU.js';
|
|
9
|
+
import { Typography, Button, Toastr } from '@bigbinary/neetoui';
|
|
10
|
+
import { Form, ActionBlock } from '@bigbinary/neetoui/formik';
|
|
11
11
|
import { k as getQrCodeValue } from './index-CajHy3NQ.js';
|
|
12
12
|
import { t } from 'i18next';
|
|
13
13
|
import * as yup from 'yup';
|
|
14
|
-
import {
|
|
14
|
+
import { useField } from 'formik';
|
|
15
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
15
16
|
import '@tanstack/react-query';
|
|
16
17
|
import 'neetocommons/react-utils';
|
|
17
18
|
import 'axios';
|
|
@@ -26,6 +27,7 @@ const DIRECT_UPLOAD_URL = "/rails/active_storage/direct_uploads";
|
|
|
26
27
|
const INITIAL_VALUES = {
|
|
27
28
|
identifier: ""
|
|
28
29
|
};
|
|
30
|
+
const UPI_TRANSACTION_ID_LENGTH = 12;
|
|
29
31
|
const buildValidationSchema = screenshotFile => yup.object({
|
|
30
32
|
identifier: yup.number().typeError(t("neetoPayments.validations.invalidField", {
|
|
31
33
|
entity: t("neetoPayments.common.transactionId")
|
|
@@ -36,6 +38,79 @@ const buildValidationSchema = screenshotFile => yup.object({
|
|
|
36
38
|
}), value => isNotPresent(value) || value?.toString().length === 12)
|
|
37
39
|
});
|
|
38
40
|
|
|
41
|
+
const toSlots = value => Array.from({
|
|
42
|
+
length: UPI_TRANSACTION_ID_LENGTH
|
|
43
|
+
}, (_, index) => value[index] ?? "");
|
|
44
|
+
const UpiTransactionIdInput = ({
|
|
45
|
+
name = "identifier"
|
|
46
|
+
}) => {
|
|
47
|
+
const {
|
|
48
|
+
t
|
|
49
|
+
} = useTranslation();
|
|
50
|
+
const [, meta, helpers] = useField(name);
|
|
51
|
+
const inputsRef = useRef([]);
|
|
52
|
+
const [slots, setSlots] = useState(() => toSlots((meta.initialValue ?? "").toString()));
|
|
53
|
+
const sync = nextSlots => {
|
|
54
|
+
setSlots(nextSlots);
|
|
55
|
+
helpers.setValue(nextSlots.join(""));
|
|
56
|
+
};
|
|
57
|
+
const setDigit = (index, digit) => sync(slots.map((slot, i) => i === index ? digit : slot));
|
|
58
|
+
const focusBox = index => inputsRef.current[index]?.focus();
|
|
59
|
+
const handleChange = (index, event) => {
|
|
60
|
+
const sanitized = event.target.value.replace(/\D/g, "");
|
|
61
|
+
setDigit(index, sanitized ? sanitized[sanitized.length - 1] : "");
|
|
62
|
+
if (sanitized && index < UPI_TRANSACTION_ID_LENGTH - 1) focusBox(index + 1);
|
|
63
|
+
};
|
|
64
|
+
const handleKeyDown = (index, event) => {
|
|
65
|
+
if (event.key === "Backspace" && !slots[index] && index > 0) {
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
setDigit(index - 1, "");
|
|
68
|
+
focusBox(index - 1);
|
|
69
|
+
} else if (event.key === "ArrowLeft" && index > 0) {
|
|
70
|
+
focusBox(index - 1);
|
|
71
|
+
} else if (event.key === "ArrowRight" && index < UPI_TRANSACTION_ID_LENGTH - 1) {
|
|
72
|
+
focusBox(index + 1);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const handlePaste = event => {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
const pasted = event.clipboardData.getData("text").replace(/\D/g, "").slice(0, UPI_TRANSACTION_ID_LENGTH);
|
|
78
|
+
if (!pasted) return;
|
|
79
|
+
sync(toSlots(pasted));
|
|
80
|
+
focusBox(Math.min(pasted.length, UPI_TRANSACTION_ID_LENGTH - 1));
|
|
81
|
+
};
|
|
82
|
+
const showError = meta.touched && meta.error;
|
|
83
|
+
return /*#__PURE__*/jsxs("div", {
|
|
84
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
85
|
+
className: "mb-2",
|
|
86
|
+
style: "body2",
|
|
87
|
+
weight: "medium",
|
|
88
|
+
children: t("neetoPayments.upi.payment.transaction.label")
|
|
89
|
+
}), /*#__PURE__*/jsx("div", {
|
|
90
|
+
className: "flex flex-wrap gap-2",
|
|
91
|
+
onPaste: handlePaste,
|
|
92
|
+
children: slots.map((slot, index) => /*#__PURE__*/jsx("input", {
|
|
93
|
+
autoComplete: "off",
|
|
94
|
+
className: "h-10 w-8 neeto-ui-rounded border neeto-ui-border-gray-300 text-center text-base focus:neeto-ui-border-gray-500 focus:outline-none",
|
|
95
|
+
"data-testid": `upi-transaction-id-box-${index}`,
|
|
96
|
+
inputMode: "numeric",
|
|
97
|
+
maxLength: 1,
|
|
98
|
+
ref: element => inputsRef.current[index] = element,
|
|
99
|
+
type: "text",
|
|
100
|
+
value: slot,
|
|
101
|
+
onBlur: () => helpers.setTouched(true),
|
|
102
|
+
onChange: event => handleChange(index, event),
|
|
103
|
+
onFocus: event => event.target.select(),
|
|
104
|
+
onKeyDown: event => handleKeyDown(index, event)
|
|
105
|
+
}, index))
|
|
106
|
+
}), showError && /*#__PURE__*/jsx(Typography, {
|
|
107
|
+
className: "neeto-ui-text-error-500 mt-1",
|
|
108
|
+
style: "body3",
|
|
109
|
+
children: meta.error
|
|
110
|
+
})]
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
|
|
39
114
|
const ManualUpiPayment = ({
|
|
40
115
|
fee,
|
|
41
116
|
payableId,
|
|
@@ -125,42 +200,41 @@ const ManualUpiPayment = ({
|
|
|
125
200
|
dirty
|
|
126
201
|
}) => /*#__PURE__*/jsxs(Fragment, {
|
|
127
202
|
children: [/*#__PURE__*/jsx(Typography, {
|
|
128
|
-
|
|
203
|
+
className: "neeto-ui-text-gray-600",
|
|
204
|
+
style: "body2",
|
|
129
205
|
children: t("neetoPayments.upi.payment.vpaText", {
|
|
130
206
|
count: vpaIds.length
|
|
131
207
|
})
|
|
132
208
|
}), isPresent(vpaIds) && /*#__PURE__*/jsx("div", {
|
|
133
|
-
className: "
|
|
209
|
+
className: "flex flex-wrap gap-8",
|
|
134
210
|
children: vpaIds.map(vpaId => /*#__PURE__*/jsxs("div", {
|
|
135
211
|
className: "flex flex-col items-center justify-center",
|
|
136
212
|
children: [/*#__PURE__*/jsx(QRCodeImage, {
|
|
137
213
|
size: 256,
|
|
138
214
|
style: {
|
|
139
|
-
width:
|
|
140
|
-
height:
|
|
215
|
+
width: 120,
|
|
216
|
+
height: 120
|
|
141
217
|
},
|
|
142
218
|
value: getQrCodeValue(vpaId, amountToUpi)
|
|
143
219
|
}), /*#__PURE__*/jsx(Typography, {
|
|
144
220
|
className: "w-full mt-2 text-center wrap-break-word",
|
|
145
221
|
style: "body2",
|
|
222
|
+
weight: "medium",
|
|
146
223
|
children: vpaId
|
|
147
224
|
})]
|
|
148
225
|
}, vpaId))
|
|
149
|
-
}), /*#__PURE__*/jsx(
|
|
150
|
-
|
|
151
|
-
name: "identifier",
|
|
152
|
-
placeholder: t("neetoPayments.upi.payment.transaction.placeholder"),
|
|
153
|
-
type: "number"
|
|
226
|
+
}), /*#__PURE__*/jsx(UpiTransactionIdInput, {
|
|
227
|
+
name: "identifier"
|
|
154
228
|
}), /*#__PURE__*/jsxs("div", {
|
|
155
229
|
className: "flex items-center gap-3",
|
|
156
230
|
children: [/*#__PURE__*/jsx("hr", {
|
|
157
|
-
className: "flex-1 border-gray-300"
|
|
231
|
+
className: "flex-1 neeto-ui-border-gray-300"
|
|
158
232
|
}), /*#__PURE__*/jsx(Typography, {
|
|
159
|
-
className: "text-gray-500 uppercase",
|
|
233
|
+
className: "neeto-ui-text-gray-500 uppercase",
|
|
160
234
|
style: "body2",
|
|
161
235
|
children: t("neetoPayments.common.or")
|
|
162
236
|
}), /*#__PURE__*/jsx("hr", {
|
|
163
|
-
className: "flex-1 border-gray-300"
|
|
237
|
+
className: "flex-1 neeto-ui-border-gray-300"
|
|
164
238
|
})]
|
|
165
239
|
}), /*#__PURE__*/jsxs("div", {
|
|
166
240
|
children: [/*#__PURE__*/jsx(Typography, {
|
|
@@ -172,7 +246,7 @@ const ManualUpiPayment = ({
|
|
|
172
246
|
className: "relative inline-block",
|
|
173
247
|
children: [/*#__PURE__*/jsx("img", {
|
|
174
248
|
alt: t("neetoPayments.upi.payment.screenshot.alt"),
|
|
175
|
-
className: "max-h-40 rounded border border-gray-200",
|
|
249
|
+
className: "max-h-40 neeto-ui-rounded border neeto-ui-border-gray-200",
|
|
176
250
|
src: screenshotPreview
|
|
177
251
|
}), /*#__PURE__*/jsx(Button, {
|
|
178
252
|
className: "absolute -right-2 -top-2 neeto-ui-rounded-full neeto-ui-bg-white neeto-ui-shadow-sm",
|
|
@@ -182,7 +256,7 @@ const ManualUpiPayment = ({
|
|
|
182
256
|
onClick: handleRemoveScreenshot
|
|
183
257
|
})]
|
|
184
258
|
}) : /*#__PURE__*/jsxs("div", {
|
|
185
|
-
className: "flex cursor-pointer flex-col items-center justify-center rounded border-2 border-dashed border-gray-300 p-6 transition-colors hover:border-gray-400",
|
|
259
|
+
className: "flex cursor-pointer flex-col items-center justify-center neeto-ui-rounded border-2 border-dashed neeto-ui-border-gray-300 p-6 transition-colors hover:neeto-ui-border-gray-400",
|
|
186
260
|
role: "button",
|
|
187
261
|
tabIndex: 0,
|
|
188
262
|
onClick: () => fileInputRef.current?.click(),
|
|
@@ -192,13 +266,14 @@ const ManualUpiPayment = ({
|
|
|
192
266
|
}
|
|
193
267
|
},
|
|
194
268
|
children: [/*#__PURE__*/jsx("i", {
|
|
195
|
-
className: "ri-upload-2-line text-2xl text-gray-400"
|
|
269
|
+
className: "ri-upload-2-line text-2xl neeto-ui-text-gray-400"
|
|
196
270
|
}), /*#__PURE__*/jsx(Typography, {
|
|
197
|
-
className: "mt-1 text-
|
|
271
|
+
className: "mt-1 text-blue-600 hover:underline",
|
|
198
272
|
style: "body3",
|
|
273
|
+
weight: "medium",
|
|
199
274
|
children: t("neetoPayments.upi.payment.screenshot.uploadText")
|
|
200
275
|
}), /*#__PURE__*/jsx(Typography, {
|
|
201
|
-
className: "text-gray-400",
|
|
276
|
+
className: "neeto-ui-text-gray-400",
|
|
202
277
|
style: "nano",
|
|
203
278
|
children: t("neetoPayments.upi.payment.screenshot.formatHint", {
|
|
204
279
|
maxSize: MAX_SCREENSHOT_SIZE_MB
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ManualUpiPayment.js","sources":["../app/javascript/src/components/ManualUpiPayment/constants.js","../app/javascript/src/components/ManualUpiPayment/index.jsx"],"sourcesContent":["import { t } from \"i18next\";\nimport { isPresent, isNotPresent } from \"neetocist\";\nimport * as yup from \"yup\";\n\nexport const ACCEPTED_SCREENSHOT_FORMATS = \"image/png,image/jpeg,image/jpg\";\n\nexport const MAX_SCREENSHOT_SIZE_MB = 5;\n\nexport const DIRECT_UPLOAD_URL = \"/rails/active_storage/direct_uploads\";\n\nexport const INITIAL_VALUES = { identifier: \"\" };\n\nexport const buildValidationSchema = screenshotFile =>\n yup.object({\n identifier: yup\n .number()\n .typeError(\n t(\"neetoPayments.validations.invalidField\", {\n entity: t(\"neetoPayments.common.transactionId\"),\n })\n )\n .nullable()\n .transform((value, originalValue) =>\n originalValue === \"\" ? null : value\n )\n .test(\n \"identifier-or-screenshot\",\n t(\"neetoPayments.upi.payment.transaction.identifierOrScreenshot\"),\n value => isPresent(value) || isPresent(screenshotFile)\n )\n .test(\n \"is-integer\",\n t(\"neetoPayments.validations.invalidField\", {\n entity: t(\"neetoPayments.common.transactionId\"),\n }),\n value => isNotPresent(value) || Number.isInteger(value)\n )\n .test(\n \"len\",\n t(\"neetoPayments.validations.length\", { length: 12 }),\n value => isNotPresent(value) || value?.toString().length === 12\n ),\n });\n","import { useRef, useState, useMemo, useEffect } from \"react\";\n\nimport { DirectUpload } from \"@rails/activestorage\";\nimport { noop, isPresent } from \"neetocist\";\nimport { Close } from \"neetoicons\";\nimport { Button, Toastr, Typography } from \"neetoui\";\nimport { ActionBlock, Form, Input } from \"neetoui/formik\";\nimport QRCodeImage from \"qrcode.react\";\nimport { pluck } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { useCreateUpiPayment } from \"hooks/reactQuery/manualUpi/usePaymentApi\";\nimport { getQrCodeValue } from \"utils\";\n\nimport {\n buildValidationSchema,\n ACCEPTED_SCREENSHOT_FORMATS,\n MAX_SCREENSHOT_SIZE_MB,\n DIRECT_UPLOAD_URL,\n INITIAL_VALUES,\n} from \"./constants\";\n\nconst ManualUpiPayment = ({\n fee,\n payableId,\n tip,\n amount,\n discountCode,\n customAmount,\n handleCancel,\n payableType = null,\n onBeforePayment = noop,\n onFailedPayment = noop,\n onSuccessfulPayment = noop,\n}) => {\n const { t } = useTranslation();\n const fileInputRef = useRef(null);\n const [screenshotFile, setScreenshotFile] = useState(null);\n const [isUploading, setIsUploading] = useState(false);\n\n const screenshotPreview = useMemo(\n () => (screenshotFile ? URL.createObjectURL(screenshotFile) : null),\n [screenshotFile]\n );\n\n useEffect(\n () => () => {\n if (screenshotPreview) URL.revokeObjectURL(screenshotPreview);\n },\n [screenshotPreview]\n );\n\n const vpaIds = pluck(\"address\", fee?.vpas);\n const amountToUpi = customAmount || amount;\n\n const { isPending, mutate: createPayment } = useCreateUpiPayment({\n onSuccess: onSuccessfulPayment,\n onError: onFailedPayment,\n });\n\n const validationSchema = useMemo(\n () => buildValidationSchema(screenshotFile),\n [screenshotFile]\n );\n\n const handleScreenshotSelect = event => {\n const file = event.target.files[0];\n if (!file) return;\n\n if (file.size > MAX_SCREENSHOT_SIZE_MB * 1024 * 1024) {\n Toastr.error(\n t(\"neetoPayments.upi.payment.screenshot.tooLarge\", {\n maxSize: MAX_SCREENSHOT_SIZE_MB,\n })\n );\n\n return;\n }\n\n setScreenshotFile(file);\n };\n\n const handleRemoveScreenshot = () => {\n setScreenshotFile(null);\n if (fileInputRef.current) fileInputRef.current.value = \"\";\n };\n\n const uploadScreenshot = file =>\n new Promise((resolve, reject) => {\n const upload = new DirectUpload(file, DIRECT_UPLOAD_URL);\n upload.create((error, blob) => {\n if (error) reject(error);\n else resolve(blob.signed_id);\n });\n });\n\n const handleSubmit = async values => {\n onBeforePayment();\n\n let paymentScreenshot = null;\n if (screenshotFile) {\n try {\n setIsUploading(true);\n paymentScreenshot = await uploadScreenshot(screenshotFile);\n } catch {\n onFailedPayment();\n\n return;\n } finally {\n setIsUploading(false);\n }\n }\n\n createPayment({\n ...values,\n payableId,\n customAmount,\n payableType,\n discountCode,\n tipAttributes: tip,\n paymentScreenshot,\n });\n };\n\n return (\n <Form\n className=\"space-y-4\"\n formikProps={{\n onSubmit: handleSubmit,\n initialValues: INITIAL_VALUES,\n validationSchema,\n }}\n >\n {({ dirty }) => (\n <>\n <Typography style=\"body1\">\n {t(\"neetoPayments.upi.payment.vpaText\", { count: vpaIds.length })}\n </Typography>\n {isPresent(vpaIds) && (\n <div className=\"grid grid-cols-1 gap-8 gap-y-4 sm:grid-cols-2\">\n {vpaIds.map(vpaId => (\n <div\n className=\"flex flex-col items-center justify-center\"\n key={vpaId}\n >\n <QRCodeImage\n size={256}\n style={{ width: 80, height: 80 }}\n value={getQrCodeValue(vpaId, amountToUpi)}\n />\n <Typography\n className=\"w-full mt-2 text-center wrap-break-word\"\n style=\"body2\"\n >\n {vpaId}\n </Typography>\n </div>\n ))}\n </div>\n )}\n <Input\n label={t(\"neetoPayments.upi.payment.transaction.label\")}\n name=\"identifier\"\n placeholder={t(\"neetoPayments.upi.payment.transaction.placeholder\")}\n type=\"number\"\n />\n <div className=\"flex items-center gap-3\">\n <hr className=\"flex-1 border-gray-300\" />\n <Typography className=\"text-gray-500 uppercase\" style=\"body2\">\n {t(\"neetoPayments.common.or\")}\n </Typography>\n <hr className=\"flex-1 border-gray-300\" />\n </div>\n <div>\n <Typography className=\"mb-2\" style=\"body2\" weight=\"medium\">\n {t(\"neetoPayments.upi.payment.screenshot.label\")}\n </Typography>\n {screenshotPreview ? (\n <div className=\"relative inline-block\">\n <img\n alt={t(\"neetoPayments.upi.payment.screenshot.alt\")}\n className=\"max-h-40 rounded border border-gray-200\"\n src={screenshotPreview}\n />\n <Button\n className=\"absolute -right-2 -top-2 neeto-ui-rounded-full neeto-ui-bg-white neeto-ui-shadow-sm\"\n icon={Close}\n size=\"small\"\n style=\"text\"\n onClick={handleRemoveScreenshot}\n />\n </div>\n ) : (\n <div\n className=\"flex cursor-pointer flex-col items-center justify-center rounded border-2 border-dashed border-gray-300 p-6 transition-colors hover:border-gray-400\"\n role=\"button\"\n tabIndex={0}\n onClick={() => fileInputRef.current?.click()}\n onKeyDown={e => {\n if (e.key === \"Enter\" || e.key === \" \") {\n fileInputRef.current?.click();\n }\n }}\n >\n <i className=\"ri-upload-2-line text-2xl text-gray-400\" />\n <Typography className=\"mt-1 text-gray-500\" style=\"body3\">\n {t(\"neetoPayments.upi.payment.screenshot.uploadText\")}\n </Typography>\n <Typography className=\"text-gray-400\" style=\"nano\">\n {t(\"neetoPayments.upi.payment.screenshot.formatHint\", {\n maxSize: MAX_SCREENSHOT_SIZE_MB,\n })}\n </Typography>\n </div>\n )}\n <input\n accept={ACCEPTED_SCREENSHOT_FORMATS}\n className=\"hidden\"\n data-testid=\"manual-upi-screenshot-upload-input-field\"\n ref={fileInputRef}\n type=\"file\"\n onChange={handleScreenshotSelect}\n />\n </div>\n <ActionBlock\n cancelButtonProps={{\n label: t(\"neetoPayments.upi.payment.buttons.back\"),\n onClick: handleCancel,\n disabled: isPending,\n }}\n submitButtonProps={{\n label: t(\"neetoPayments.upi.payment.buttons.submit\"),\n disabled: (!dirty && !screenshotFile) || isPending || isUploading,\n loading: isPending || isUploading,\n }}\n />\n </>\n )}\n </Form>\n );\n};\n\nexport default ManualUpiPayment;\n"],"names":["ACCEPTED_SCREENSHOT_FORMATS","MAX_SCREENSHOT_SIZE_MB","DIRECT_UPLOAD_URL","INITIAL_VALUES","identifier","buildValidationSchema","screenshotFile","yup","object","number","typeError","t","entity","nullable","transform","value","originalValue","test","isPresent","isNotPresent","Number","isInteger","length","toString","ManualUpiPayment","fee","payableId","tip","amount","discountCode","customAmount","handleCancel","payableType","onBeforePayment","noop","onFailedPayment","onSuccessfulPayment","useTranslation","fileInputRef","useRef","setScreenshotFile","useState","isUploading","setIsUploading","screenshotPreview","useMemo","URL","createObjectURL","useEffect","revokeObjectURL","vpaIds","pluck","vpas","amountToUpi","isPending","mutate","createPayment","useCreateUpiPayment","onSuccess","onError","validationSchema","handleScreenshotSelect","event","file","target","files","size","Toastr","error","maxSize","handleRemoveScreenshot","current","uploadScreenshot","Promise","resolve","reject","upload","DirectUpload","create","blob","signed_id","handleSubmit","values","paymentScreenshot","tipAttributes","_jsx","Form","className","formikProps","onSubmit","initialValues","children","dirty","_jsxs","_Fragment","Typography","style","count","map","vpaId","QRCodeImage","width","height","getQrCodeValue","Input","label","name","placeholder","type","weight","alt","src","Button","icon","Close","onClick","role","tabIndex","click","onKeyDown","e","key","accept","ref","onChange","ActionBlock","cancelButtonProps","disabled","submitButtonProps","loading"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIO,MAAMA,2BAA2B,GAAG,gCAAgC;AAEpE,MAAMC,sBAAsB,GAAG,CAAC;AAEhC,MAAMC,iBAA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AM;AACXgB,UAAAA,QAAQ,EAAE/D;AAAuB,SAClC,CAAC;AAAA,OACC,CAAC,eACNwB,GAAA,CAACwC,WAAW,EAAA;AACVC,QAAAA,iBAAiB,EAAE;AACjBrB,UAAAA,KAAK,EAAE9F,CAAC,CAAC,wCAAwC,CAAC;AAClDwG,UAAAA,OAAO,EAAEpF,YAAY;AACrBgG,UAAAA,QAAQ,EAAEzE;SACV;AACF0E,QAAAA,iBAAiB,EAAE;AACjBvB,UAAAA,KAAK,EAAE9F,CAAC,CAAC,0CAA0C,CAAC;UACpDoH,QAAQ,EAAG,CAACnC,KAAK,IAAI,CAACtF,cAAc,IAAKgD,SAAS,IAAIZ,WAAW;UACjEuF,OAAO,EAAE3E,SAAS,IAAIZ;AACxB;AAAE,OACH,CAAC;KACF;AACH,GACG,CAAC;AAEX;;;;"}
|
|
1
|
+
{"version":3,"file":"ManualUpiPayment.js","sources":["../app/javascript/src/components/ManualUpiPayment/constants.js","../app/javascript/src/components/ManualUpiPayment/UpiTransactionIdInput.jsx","../app/javascript/src/components/ManualUpiPayment/index.jsx"],"sourcesContent":["import { t } from \"i18next\";\nimport { isPresent, isNotPresent } from \"neetocist\";\nimport * as yup from \"yup\";\n\nexport const ACCEPTED_SCREENSHOT_FORMATS = \"image/png,image/jpeg,image/jpg\";\n\nexport const MAX_SCREENSHOT_SIZE_MB = 5;\n\nexport const DIRECT_UPLOAD_URL = \"/rails/active_storage/direct_uploads\";\n\nexport const INITIAL_VALUES = { identifier: \"\" };\n\nexport const UPI_TRANSACTION_ID_LENGTH = 12;\n\nexport const buildValidationSchema = screenshotFile =>\n yup.object({\n identifier: yup\n .number()\n .typeError(\n t(\"neetoPayments.validations.invalidField\", {\n entity: t(\"neetoPayments.common.transactionId\"),\n })\n )\n .nullable()\n .transform((value, originalValue) =>\n originalValue === \"\" ? null : value\n )\n .test(\n \"identifier-or-screenshot\",\n t(\"neetoPayments.upi.payment.transaction.identifierOrScreenshot\"),\n value => isPresent(value) || isPresent(screenshotFile)\n )\n .test(\n \"is-integer\",\n t(\"neetoPayments.validations.invalidField\", {\n entity: t(\"neetoPayments.common.transactionId\"),\n }),\n value => isNotPresent(value) || Number.isInteger(value)\n )\n .test(\n \"len\",\n t(\"neetoPayments.validations.length\", { length: 12 }),\n value => isNotPresent(value) || value?.toString().length === 12\n ),\n });\n","import { useRef, useState } from \"react\";\n\nimport { useField } from \"formik\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { Typography } from \"neetoui\";\n\nimport { UPI_TRANSACTION_ID_LENGTH as LENGTH } from \"./constants\";\n\nconst toSlots = value =>\n Array.from({ length: LENGTH }, (_, index) => value[index] ?? \"\");\n\nconst UpiTransactionIdInput = ({ name = \"identifier\" }) => {\n const { t } = useTranslation();\n const [, meta, helpers] = useField(name);\n const inputsRef = useRef([]);\n const [slots, setSlots] = useState(() =>\n toSlots((meta.initialValue ?? \"\").toString())\n );\n\n const sync = nextSlots => {\n setSlots(nextSlots);\n helpers.setValue(nextSlots.join(\"\"));\n };\n\n const setDigit = (index, digit) =>\n sync(slots.map((slot, i) => (i === index ? digit : slot)));\n\n const focusBox = index => inputsRef.current[index]?.focus();\n\n const handleChange = (index, event) => {\n const sanitized = event.target.value.replace(/\\D/g, \"\");\n setDigit(index, sanitized ? sanitized[sanitized.length - 1] : \"\");\n if (sanitized && index < LENGTH - 1) focusBox(index + 1);\n };\n\n const handleKeyDown = (index, event) => {\n if (event.key === \"Backspace\" && !slots[index] && index > 0) {\n event.preventDefault();\n setDigit(index - 1, \"\");\n focusBox(index - 1);\n } else if (event.key === \"ArrowLeft\" && index > 0) {\n focusBox(index - 1);\n } else if (event.key === \"ArrowRight\" && index < LENGTH - 1) {\n focusBox(index + 1);\n }\n };\n\n const handlePaste = event => {\n event.preventDefault();\n const pasted = event.clipboardData\n .getData(\"text\")\n .replace(/\\D/g, \"\")\n .slice(0, LENGTH);\n if (!pasted) return;\n\n sync(toSlots(pasted));\n focusBox(Math.min(pasted.length, LENGTH - 1));\n };\n\n const showError = meta.touched && meta.error;\n\n return (\n <div>\n <Typography className=\"mb-2\" style=\"body2\" weight=\"medium\">\n {t(\"neetoPayments.upi.payment.transaction.label\")}\n </Typography>\n <div className=\"flex flex-wrap gap-2\" onPaste={handlePaste}>\n {slots.map((slot, index) => (\n <input\n autoComplete=\"off\"\n className=\"h-10 w-8 neeto-ui-rounded border neeto-ui-border-gray-300 text-center text-base focus:neeto-ui-border-gray-500 focus:outline-none\"\n data-testid={`upi-transaction-id-box-${index}`}\n inputMode=\"numeric\"\n key={index}\n maxLength={1}\n ref={element => (inputsRef.current[index] = element)}\n type=\"text\"\n value={slot}\n onBlur={() => helpers.setTouched(true)}\n onChange={event => handleChange(index, event)}\n onFocus={event => event.target.select()}\n onKeyDown={event => handleKeyDown(index, event)}\n />\n ))}\n </div>\n {showError && (\n <Typography className=\"neeto-ui-text-error-500 mt-1\" style=\"body3\">\n {meta.error}\n </Typography>\n )}\n </div>\n );\n};\n\nexport default UpiTransactionIdInput;\n","import { useRef, useState, useMemo, useEffect } from \"react\";\n\nimport { DirectUpload } from \"@rails/activestorage\";\nimport { noop, isPresent } from \"neetocist\";\nimport { Close } from \"neetoicons\";\nimport QRCodeImage from \"qrcode.react\";\nimport { pluck } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { useCreateUpiPayment } from \"hooks/reactQuery/manualUpi/usePaymentApi\";\nimport { Button, Toastr, Typography } from \"neetoui\";\nimport { ActionBlock, Form } from \"neetoui/formik\";\nimport { getQrCodeValue } from \"utils\";\n\nimport {\n buildValidationSchema,\n ACCEPTED_SCREENSHOT_FORMATS,\n MAX_SCREENSHOT_SIZE_MB,\n DIRECT_UPLOAD_URL,\n INITIAL_VALUES,\n} from \"./constants\";\nimport UpiTransactionIdInput from \"./UpiTransactionIdInput\";\n\nconst ManualUpiPayment = ({\n fee,\n payableId,\n tip,\n amount,\n discountCode,\n customAmount,\n handleCancel,\n payableType = null,\n onBeforePayment = noop,\n onFailedPayment = noop,\n onSuccessfulPayment = noop,\n}) => {\n const { t } = useTranslation();\n const fileInputRef = useRef(null);\n const [screenshotFile, setScreenshotFile] = useState(null);\n const [isUploading, setIsUploading] = useState(false);\n\n const screenshotPreview = useMemo(\n () => (screenshotFile ? URL.createObjectURL(screenshotFile) : null),\n [screenshotFile]\n );\n\n useEffect(\n () => () => {\n if (screenshotPreview) URL.revokeObjectURL(screenshotPreview);\n },\n [screenshotPreview]\n );\n\n const vpaIds = pluck(\"address\", fee?.vpas);\n const amountToUpi = customAmount || amount;\n\n const { isPending, mutate: createPayment } = useCreateUpiPayment({\n onSuccess: onSuccessfulPayment,\n onError: onFailedPayment,\n });\n\n const validationSchema = useMemo(\n () => buildValidationSchema(screenshotFile),\n [screenshotFile]\n );\n\n const handleScreenshotSelect = event => {\n const file = event.target.files[0];\n if (!file) return;\n\n if (file.size > MAX_SCREENSHOT_SIZE_MB * 1024 * 1024) {\n Toastr.error(\n t(\"neetoPayments.upi.payment.screenshot.tooLarge\", {\n maxSize: MAX_SCREENSHOT_SIZE_MB,\n })\n );\n\n return;\n }\n\n setScreenshotFile(file);\n };\n\n const handleRemoveScreenshot = () => {\n setScreenshotFile(null);\n if (fileInputRef.current) fileInputRef.current.value = \"\";\n };\n\n const uploadScreenshot = file =>\n new Promise((resolve, reject) => {\n const upload = new DirectUpload(file, DIRECT_UPLOAD_URL);\n upload.create((error, blob) => {\n if (error) reject(error);\n else resolve(blob.signed_id);\n });\n });\n\n const handleSubmit = async values => {\n onBeforePayment();\n\n let paymentScreenshot = null;\n if (screenshotFile) {\n try {\n setIsUploading(true);\n paymentScreenshot = await uploadScreenshot(screenshotFile);\n } catch {\n onFailedPayment();\n\n return;\n } finally {\n setIsUploading(false);\n }\n }\n\n createPayment({\n ...values,\n payableId,\n customAmount,\n payableType,\n discountCode,\n tipAttributes: tip,\n paymentScreenshot,\n });\n };\n\n return (\n <Form\n className=\"space-y-4\"\n formikProps={{\n onSubmit: handleSubmit,\n initialValues: INITIAL_VALUES,\n validationSchema,\n }}\n >\n {({ dirty }) => (\n <>\n <Typography className=\"neeto-ui-text-gray-600\" style=\"body2\">\n {t(\"neetoPayments.upi.payment.vpaText\", { count: vpaIds.length })}\n </Typography>\n {isPresent(vpaIds) && (\n <div className=\"flex flex-wrap gap-8\">\n {vpaIds.map(vpaId => (\n <div\n className=\"flex flex-col items-center justify-center\"\n key={vpaId}\n >\n <QRCodeImage\n size={256}\n style={{ width: 120, height: 120 }}\n value={getQrCodeValue(vpaId, amountToUpi)}\n />\n <Typography\n className=\"w-full mt-2 text-center wrap-break-word\"\n style=\"body2\"\n weight=\"medium\"\n >\n {vpaId}\n </Typography>\n </div>\n ))}\n </div>\n )}\n <UpiTransactionIdInput name=\"identifier\" />\n <div className=\"flex items-center gap-3\">\n <hr className=\"flex-1 neeto-ui-border-gray-300\" />\n <Typography\n className=\"neeto-ui-text-gray-500 uppercase\"\n style=\"body2\"\n >\n {t(\"neetoPayments.common.or\")}\n </Typography>\n <hr className=\"flex-1 neeto-ui-border-gray-300\" />\n </div>\n <div>\n <Typography className=\"mb-2\" style=\"body2\" weight=\"medium\">\n {t(\"neetoPayments.upi.payment.screenshot.label\")}\n </Typography>\n {screenshotPreview ? (\n <div className=\"relative inline-block\">\n <img\n alt={t(\"neetoPayments.upi.payment.screenshot.alt\")}\n className=\"max-h-40 neeto-ui-rounded border neeto-ui-border-gray-200\"\n src={screenshotPreview}\n />\n <Button\n className=\"absolute -right-2 -top-2 neeto-ui-rounded-full neeto-ui-bg-white neeto-ui-shadow-sm\"\n icon={Close}\n size=\"small\"\n style=\"text\"\n onClick={handleRemoveScreenshot}\n />\n </div>\n ) : (\n <div\n className=\"flex cursor-pointer flex-col items-center justify-center neeto-ui-rounded border-2 border-dashed neeto-ui-border-gray-300 p-6 transition-colors hover:neeto-ui-border-gray-400\"\n role=\"button\"\n tabIndex={0}\n onClick={() => fileInputRef.current?.click()}\n onKeyDown={e => {\n if (e.key === \"Enter\" || e.key === \" \") {\n fileInputRef.current?.click();\n }\n }}\n >\n <i className=\"ri-upload-2-line text-2xl neeto-ui-text-gray-400\" />\n <Typography\n className=\"mt-1 text-blue-600 hover:underline\"\n style=\"body3\"\n weight=\"medium\"\n >\n {t(\"neetoPayments.upi.payment.screenshot.uploadText\")}\n </Typography>\n <Typography className=\"neeto-ui-text-gray-400\" style=\"nano\">\n {t(\"neetoPayments.upi.payment.screenshot.formatHint\", {\n maxSize: MAX_SCREENSHOT_SIZE_MB,\n })}\n </Typography>\n </div>\n )}\n <input\n accept={ACCEPTED_SCREENSHOT_FORMATS}\n className=\"hidden\"\n data-testid=\"manual-upi-screenshot-upload-input-field\"\n ref={fileInputRef}\n type=\"file\"\n onChange={handleScreenshotSelect}\n />\n </div>\n <ActionBlock\n cancelButtonProps={{\n label: t(\"neetoPayments.upi.payment.buttons.back\"),\n onClick: handleCancel,\n disabled: isPending,\n }}\n submitButtonProps={{\n label: t(\"neetoPayments.upi.payment.buttons.submit\"),\n disabled: (!dirty && !screenshotFile) || isPending || isUploading,\n loading: isPending || isUploading,\n }}\n />\n </>\n )}\n </Form>\n );\n};\n\nexport default ManualUpiPayment;\n"],"names":["ACCEPTED_SCREENSHOT_FORMATS","MAX_SCREENSHOT_SIZE_MB","DIRECT_UPLOAD_URL","INITIAL_VALUES","identifier","UPI_TRANSACTION_ID_LENGTH","buildValidationSchema","screenshotFile","yup","object","number","typeError","t","entity","nullable","transform","value","originalValue","test","isPresent","isNotPresent","Number","isInteger","length","toString","toSlots","Array","from","LENGTH","_","index","UpiTransactionIdInput","name","useTranslation","meta","helpers","useField","inputsRef","useRef","slots","setSlots","useState","initialValue","sync","nextSlots","setValue","join","setDigit","digit","map","slot","i","focusBox","current","focus","handleChange","event","sanitized","target","replace","handleKeyDown","key","preventDefault","handlePaste","pasted","clipboardData","getData","slice","Math","min","showError","touched","error","_jsxs","children","_jsx","Typography","className","style","weight","onPaste","autoComplete","inputMode","maxLength","ref","element","type","onBlur","setTouched","onChange","onFocus","select","onKeyDown","ManualUpiPayment","fee","payableId","tip","amount","discountCode","customAmount","handleCancel","payableType","onBeforePayment","noop","onFailedPayment","onSuccessfulPayment","fileInputRef","setScreenshotFile","isUploading","setIsUploading","screenshotPreview","useMemo","URL","createObjectURL","useEffect","revokeObjectURL","vpaIds","pluck","vpas","amountToUpi","isPending","mutate","createPayment","useCreateUpiPayment","onSuccess","onError","validationSchema","handleScreenshotSelect","file","files","size","Toastr","maxSize","handleRemoveScreenshot","uploadScreenshot","Promise","resolve","reject","upload","DirectUpload","create","blob","signed_id","handleSubmit","values","paymentScreenshot","tipAttributes","Form","formikProps","onSubmit","initialValues","dirty","_Fragment","count","vpaId","QRCodeImage","width","height","getQrCodeValue","alt","src","Button","icon","Close","onClick","role","tabIndex","click","e","accept","ActionBlock","cancelButtonProps","label","disabled","submitButtonProps","loading"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAIO,MAAMA,2BAA2B,GAAG,gCAAgC;AAEpE,MAAMC,sBAAsB,GAAG,CAAC;AAEhC,MAAMC,iBAAiB,GAAG,sCAAsC;AAEhE,MAAMC,cAAc,GAAG;AAAEC,EAAAA,UAAU,EAAE;AAAG,CAAC;AAEzC,MAAMC,yBAAyB,GAAG,EAAE;AAEpC,MAAMC,qBAAqB,GAAGC,cAAc,IACjDC,GAAG,CAACC,MAAM,CAAC;AACTL,EAAAA,UAAU,EAAEI,GAAG,CACZE,MAAM,EAAE,CACRC,SAAS,CACRC,CAAC,CAAC,wCAAwC,EAAE;IAC1CC,MAAM,EAAED,CAAC,CAAC,oCAAoC;GAC/C,CACH,CAAC,CACAE,QAAQ,EAAE,CACVC,SAAS,CAAC,CAACC,KAAK,EAAEC,aAAa,KAC9BA,aAAa,KAAK,EAAE,GAAG,IAAI,GAAGD,KAChC,CAAC,CACAE,IAAI,CACH,0BAA0B,EAC1BN,CAAC,CAAC,8DAA8D,CAAC,EACjEI,KAAK,IAAIG,SAAS,CAACH,KAAK,CAAC,IAAIG,SAAS,CAACZ,cAAc,CACvD,CAAC,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AACrByE,UAAAA,QAAQ,EAAErD;SACV;AACFsD,QAAAA,iBAAiB,EAAE;AACjBF,UAAAA,KAAK,EAAEhK,CAAC,CAAC,0CAA0C,CAAC;UACpDiK,QAAQ,EAAG,CAACtB,KAAK,IAAI,CAAChJ,cAAc,IAAKiH,SAAS,IAAIZ,WAAW;UACjEmE,OAAO,EAAEvD,SAAS,IAAIZ;AACxB;AAAE,OACH,CAAC;KACF;AACH,GACG,CAAC;AAEX;;;;"}
|
|
@@ -2,7 +2,7 @@ import { useState } from 'react';
|
|
|
2
2
|
import { noop, findBy } from 'neetocist';
|
|
3
3
|
import { mergeLeft } from 'ramda';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import {
|
|
5
|
+
import { u as useUpdateUpiPayment } from './usePaymentApi-CjtkL3IU.js';
|
|
6
6
|
import { Button, Modal, Typography } from '@bigbinary/neetoui';
|
|
7
7
|
import { Form, Select, Textarea, ActionBlock } from '@bigbinary/neetoui/formik';
|
|
8
8
|
import { t } from 'i18next';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { noop } from 'neetocist';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import {
|
|
4
|
+
import { u as useUpdateUpiPayment } from './usePaymentApi-CjtkL3IU.js';
|
|
5
5
|
import { Button, Modal, Typography } from '@bigbinary/neetoui';
|
|
6
6
|
import { Form, Textarea, ActionBlock } from '@bigbinary/neetoui/formik';
|
|
7
7
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
@@ -4,15 +4,16 @@ var react = require('react');
|
|
|
4
4
|
var activestorage = require('@rails/activestorage');
|
|
5
5
|
var neetocist = require('neetocist');
|
|
6
6
|
var neetoIcons = require('@bigbinary/neeto-icons');
|
|
7
|
-
var neetoui = require('@bigbinary/neetoui');
|
|
8
|
-
var formik = require('@bigbinary/neetoui/formik');
|
|
9
7
|
var QRCodeImage = require('qrcode.react');
|
|
10
8
|
var ramda = require('ramda');
|
|
11
9
|
var reactI18next = require('react-i18next');
|
|
12
10
|
var usePaymentApi = require('./usePaymentApi-CuL13mny.js');
|
|
11
|
+
var neetoui = require('@bigbinary/neetoui');
|
|
12
|
+
var formik$1 = require('@bigbinary/neetoui/formik');
|
|
13
13
|
var constants = require('./index-CpEnC-Gq.js');
|
|
14
14
|
var i18next = require('i18next');
|
|
15
15
|
var yup = require('yup');
|
|
16
|
+
var formik = require('formik');
|
|
16
17
|
var jsxRuntime = require('react/jsx-runtime');
|
|
17
18
|
require('@tanstack/react-query');
|
|
18
19
|
require('neetocommons/react-utils');
|
|
@@ -47,6 +48,7 @@ const DIRECT_UPLOAD_URL = "/rails/active_storage/direct_uploads";
|
|
|
47
48
|
const INITIAL_VALUES = {
|
|
48
49
|
identifier: ""
|
|
49
50
|
};
|
|
51
|
+
const UPI_TRANSACTION_ID_LENGTH = 12;
|
|
50
52
|
const buildValidationSchema = screenshotFile => yup__namespace.object({
|
|
51
53
|
identifier: yup__namespace.number().typeError(i18next.t("neetoPayments.validations.invalidField", {
|
|
52
54
|
entity: i18next.t("neetoPayments.common.transactionId")
|
|
@@ -57,6 +59,79 @@ const buildValidationSchema = screenshotFile => yup__namespace.object({
|
|
|
57
59
|
}), value => neetocist.isNotPresent(value) || value?.toString().length === 12)
|
|
58
60
|
});
|
|
59
61
|
|
|
62
|
+
const toSlots = value => Array.from({
|
|
63
|
+
length: UPI_TRANSACTION_ID_LENGTH
|
|
64
|
+
}, (_, index) => value[index] ?? "");
|
|
65
|
+
const UpiTransactionIdInput = ({
|
|
66
|
+
name = "identifier"
|
|
67
|
+
}) => {
|
|
68
|
+
const {
|
|
69
|
+
t
|
|
70
|
+
} = reactI18next.useTranslation();
|
|
71
|
+
const [, meta, helpers] = formik.useField(name);
|
|
72
|
+
const inputsRef = react.useRef([]);
|
|
73
|
+
const [slots, setSlots] = react.useState(() => toSlots((meta.initialValue ?? "").toString()));
|
|
74
|
+
const sync = nextSlots => {
|
|
75
|
+
setSlots(nextSlots);
|
|
76
|
+
helpers.setValue(nextSlots.join(""));
|
|
77
|
+
};
|
|
78
|
+
const setDigit = (index, digit) => sync(slots.map((slot, i) => i === index ? digit : slot));
|
|
79
|
+
const focusBox = index => inputsRef.current[index]?.focus();
|
|
80
|
+
const handleChange = (index, event) => {
|
|
81
|
+
const sanitized = event.target.value.replace(/\D/g, "");
|
|
82
|
+
setDigit(index, sanitized ? sanitized[sanitized.length - 1] : "");
|
|
83
|
+
if (sanitized && index < UPI_TRANSACTION_ID_LENGTH - 1) focusBox(index + 1);
|
|
84
|
+
};
|
|
85
|
+
const handleKeyDown = (index, event) => {
|
|
86
|
+
if (event.key === "Backspace" && !slots[index] && index > 0) {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
setDigit(index - 1, "");
|
|
89
|
+
focusBox(index - 1);
|
|
90
|
+
} else if (event.key === "ArrowLeft" && index > 0) {
|
|
91
|
+
focusBox(index - 1);
|
|
92
|
+
} else if (event.key === "ArrowRight" && index < UPI_TRANSACTION_ID_LENGTH - 1) {
|
|
93
|
+
focusBox(index + 1);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const handlePaste = event => {
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
const pasted = event.clipboardData.getData("text").replace(/\D/g, "").slice(0, UPI_TRANSACTION_ID_LENGTH);
|
|
99
|
+
if (!pasted) return;
|
|
100
|
+
sync(toSlots(pasted));
|
|
101
|
+
focusBox(Math.min(pasted.length, UPI_TRANSACTION_ID_LENGTH - 1));
|
|
102
|
+
};
|
|
103
|
+
const showError = meta.touched && meta.error;
|
|
104
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
105
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(neetoui.Typography, {
|
|
106
|
+
className: "mb-2",
|
|
107
|
+
style: "body2",
|
|
108
|
+
weight: "medium",
|
|
109
|
+
children: t("neetoPayments.upi.payment.transaction.label")
|
|
110
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
111
|
+
className: "flex flex-wrap gap-2",
|
|
112
|
+
onPaste: handlePaste,
|
|
113
|
+
children: slots.map((slot, index) => /*#__PURE__*/jsxRuntime.jsx("input", {
|
|
114
|
+
autoComplete: "off",
|
|
115
|
+
className: "h-10 w-8 neeto-ui-rounded border neeto-ui-border-gray-300 text-center text-base focus:neeto-ui-border-gray-500 focus:outline-none",
|
|
116
|
+
"data-testid": `upi-transaction-id-box-${index}`,
|
|
117
|
+
inputMode: "numeric",
|
|
118
|
+
maxLength: 1,
|
|
119
|
+
ref: element => inputsRef.current[index] = element,
|
|
120
|
+
type: "text",
|
|
121
|
+
value: slot,
|
|
122
|
+
onBlur: () => helpers.setTouched(true),
|
|
123
|
+
onChange: event => handleChange(index, event),
|
|
124
|
+
onFocus: event => event.target.select(),
|
|
125
|
+
onKeyDown: event => handleKeyDown(index, event)
|
|
126
|
+
}, index))
|
|
127
|
+
}), showError && /*#__PURE__*/jsxRuntime.jsx(neetoui.Typography, {
|
|
128
|
+
className: "neeto-ui-text-error-500 mt-1",
|
|
129
|
+
style: "body3",
|
|
130
|
+
children: meta.error
|
|
131
|
+
})]
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
|
|
60
135
|
const ManualUpiPayment = ({
|
|
61
136
|
fee,
|
|
62
137
|
payableId,
|
|
@@ -135,7 +210,7 @@ const ManualUpiPayment = ({
|
|
|
135
210
|
paymentScreenshot
|
|
136
211
|
});
|
|
137
212
|
};
|
|
138
|
-
return /*#__PURE__*/jsxRuntime.jsx(formik.Form, {
|
|
213
|
+
return /*#__PURE__*/jsxRuntime.jsx(formik$1.Form, {
|
|
139
214
|
className: "space-y-4",
|
|
140
215
|
formikProps: {
|
|
141
216
|
onSubmit: handleSubmit,
|
|
@@ -146,42 +221,41 @@ const ManualUpiPayment = ({
|
|
|
146
221
|
dirty
|
|
147
222
|
}) => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
148
223
|
children: [/*#__PURE__*/jsxRuntime.jsx(neetoui.Typography, {
|
|
149
|
-
|
|
224
|
+
className: "neeto-ui-text-gray-600",
|
|
225
|
+
style: "body2",
|
|
150
226
|
children: t("neetoPayments.upi.payment.vpaText", {
|
|
151
227
|
count: vpaIds.length
|
|
152
228
|
})
|
|
153
229
|
}), neetocist.isPresent(vpaIds) && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
154
|
-
className: "
|
|
230
|
+
className: "flex flex-wrap gap-8",
|
|
155
231
|
children: vpaIds.map(vpaId => /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
156
232
|
className: "flex flex-col items-center justify-center",
|
|
157
233
|
children: [/*#__PURE__*/jsxRuntime.jsx(QRCodeImage, {
|
|
158
234
|
size: 256,
|
|
159
235
|
style: {
|
|
160
|
-
width:
|
|
161
|
-
height:
|
|
236
|
+
width: 120,
|
|
237
|
+
height: 120
|
|
162
238
|
},
|
|
163
239
|
value: constants.getQrCodeValue(vpaId, amountToUpi)
|
|
164
240
|
}), /*#__PURE__*/jsxRuntime.jsx(neetoui.Typography, {
|
|
165
241
|
className: "w-full mt-2 text-center wrap-break-word",
|
|
166
242
|
style: "body2",
|
|
243
|
+
weight: "medium",
|
|
167
244
|
children: vpaId
|
|
168
245
|
})]
|
|
169
246
|
}, vpaId))
|
|
170
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
171
|
-
|
|
172
|
-
name: "identifier",
|
|
173
|
-
placeholder: t("neetoPayments.upi.payment.transaction.placeholder"),
|
|
174
|
-
type: "number"
|
|
247
|
+
}), /*#__PURE__*/jsxRuntime.jsx(UpiTransactionIdInput, {
|
|
248
|
+
name: "identifier"
|
|
175
249
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
176
250
|
className: "flex items-center gap-3",
|
|
177
251
|
children: [/*#__PURE__*/jsxRuntime.jsx("hr", {
|
|
178
|
-
className: "flex-1 border-gray-300"
|
|
252
|
+
className: "flex-1 neeto-ui-border-gray-300"
|
|
179
253
|
}), /*#__PURE__*/jsxRuntime.jsx(neetoui.Typography, {
|
|
180
|
-
className: "text-gray-500 uppercase",
|
|
254
|
+
className: "neeto-ui-text-gray-500 uppercase",
|
|
181
255
|
style: "body2",
|
|
182
256
|
children: t("neetoPayments.common.or")
|
|
183
257
|
}), /*#__PURE__*/jsxRuntime.jsx("hr", {
|
|
184
|
-
className: "flex-1 border-gray-300"
|
|
258
|
+
className: "flex-1 neeto-ui-border-gray-300"
|
|
185
259
|
})]
|
|
186
260
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
187
261
|
children: [/*#__PURE__*/jsxRuntime.jsx(neetoui.Typography, {
|
|
@@ -193,7 +267,7 @@ const ManualUpiPayment = ({
|
|
|
193
267
|
className: "relative inline-block",
|
|
194
268
|
children: [/*#__PURE__*/jsxRuntime.jsx("img", {
|
|
195
269
|
alt: t("neetoPayments.upi.payment.screenshot.alt"),
|
|
196
|
-
className: "max-h-40 rounded border border-gray-200",
|
|
270
|
+
className: "max-h-40 neeto-ui-rounded border neeto-ui-border-gray-200",
|
|
197
271
|
src: screenshotPreview
|
|
198
272
|
}), /*#__PURE__*/jsxRuntime.jsx(neetoui.Button, {
|
|
199
273
|
className: "absolute -right-2 -top-2 neeto-ui-rounded-full neeto-ui-bg-white neeto-ui-shadow-sm",
|
|
@@ -203,7 +277,7 @@ const ManualUpiPayment = ({
|
|
|
203
277
|
onClick: handleRemoveScreenshot
|
|
204
278
|
})]
|
|
205
279
|
}) : /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
206
|
-
className: "flex cursor-pointer flex-col items-center justify-center rounded border-2 border-dashed border-gray-300 p-6 transition-colors hover:border-gray-400",
|
|
280
|
+
className: "flex cursor-pointer flex-col items-center justify-center neeto-ui-rounded border-2 border-dashed neeto-ui-border-gray-300 p-6 transition-colors hover:neeto-ui-border-gray-400",
|
|
207
281
|
role: "button",
|
|
208
282
|
tabIndex: 0,
|
|
209
283
|
onClick: () => fileInputRef.current?.click(),
|
|
@@ -213,13 +287,14 @@ const ManualUpiPayment = ({
|
|
|
213
287
|
}
|
|
214
288
|
},
|
|
215
289
|
children: [/*#__PURE__*/jsxRuntime.jsx("i", {
|
|
216
|
-
className: "ri-upload-2-line text-2xl text-gray-400"
|
|
290
|
+
className: "ri-upload-2-line text-2xl neeto-ui-text-gray-400"
|
|
217
291
|
}), /*#__PURE__*/jsxRuntime.jsx(neetoui.Typography, {
|
|
218
|
-
className: "mt-1 text-
|
|
292
|
+
className: "mt-1 text-blue-600 hover:underline",
|
|
219
293
|
style: "body3",
|
|
294
|
+
weight: "medium",
|
|
220
295
|
children: t("neetoPayments.upi.payment.screenshot.uploadText")
|
|
221
296
|
}), /*#__PURE__*/jsxRuntime.jsx(neetoui.Typography, {
|
|
222
|
-
className: "text-gray-400",
|
|
297
|
+
className: "neeto-ui-text-gray-400",
|
|
223
298
|
style: "nano",
|
|
224
299
|
children: t("neetoPayments.upi.payment.screenshot.formatHint", {
|
|
225
300
|
maxSize: MAX_SCREENSHOT_SIZE_MB
|
|
@@ -233,7 +308,7 @@ const ManualUpiPayment = ({
|
|
|
233
308
|
type: "file",
|
|
234
309
|
onChange: handleScreenshotSelect
|
|
235
310
|
})]
|
|
236
|
-
}), /*#__PURE__*/jsxRuntime.jsx(formik.ActionBlock, {
|
|
311
|
+
}), /*#__PURE__*/jsxRuntime.jsx(formik$1.ActionBlock, {
|
|
237
312
|
cancelButtonProps: {
|
|
238
313
|
label: t("neetoPayments.upi.payment.buttons.back"),
|
|
239
314
|
onClick: handleCancel,
|