@bigbinary/neeto-payments-frontend 3.2.5 → 3.3.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/ConfirmUpiPaymentButton.js +148 -0
- package/dist/ConfirmUpiPaymentButton.js.map +1 -0
- package/dist/UpiPayment.js +113 -13
- package/dist/UpiPayment.js.map +1 -1
- package/dist/cjs/ConfirmUpiPaymentButton.js +169 -0
- package/dist/cjs/ConfirmUpiPaymentButton.js.map +1 -0
- package/dist/cjs/UpiPayment.js +129 -14
- package/dist/cjs/UpiPayment.js.map +1 -1
- package/dist/cjs/index.js +17 -131
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/usePaymentsApi-CRsEWHjO.js +41 -0
- package/dist/cjs/usePaymentsApi-CRsEWHjO.js.map +1 -0
- package/dist/index.js +15 -132
- package/dist/index.js.map +1 -1
- package/dist/usePaymentsApi-BwHtaZK6.js +38 -0
- package/dist/usePaymentsApi-BwHtaZK6.js.map +1 -0
- package/package.json +1 -1
- package/dist/cjs/index-Cad6GOm0.js +0 -178
- package/dist/cjs/index-Cad6GOm0.js.map +0 -1
- package/dist/index-BWLyK2S8.js +0 -154
- package/dist/index-BWLyK2S8.js.map +0 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { findBy, noop } from '@bigbinary/neeto-cist';
|
|
4
|
+
import Button from '@bigbinary/neetoui/Button';
|
|
5
|
+
import Modal from '@bigbinary/neetoui/Modal';
|
|
6
|
+
import Typography from '@bigbinary/neetoui/Typography';
|
|
7
|
+
import Form from '@bigbinary/neetoui/formik/Form';
|
|
8
|
+
import Textarea from '@bigbinary/neetoui/formik/Textarea';
|
|
9
|
+
import Select from '@bigbinary/neetoui/formik/Select';
|
|
10
|
+
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
11
|
+
import { useTranslation } from 'react-i18next';
|
|
12
|
+
import { u as useUpdateUpiPayment } from './usePaymentsApi-BwHtaZK6.js';
|
|
13
|
+
import { t } from 'i18next';
|
|
14
|
+
import * as yup from 'yup';
|
|
15
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
16
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
17
|
+
import '@tanstack/react-query';
|
|
18
|
+
import 'axios';
|
|
19
|
+
import './index-Cl511Juk.js';
|
|
20
|
+
import '@bigbinary/neeto-commons-frontend/constants';
|
|
21
|
+
import '@bigbinary/neeto-commons-frontend/utils';
|
|
22
|
+
import 'ramda';
|
|
23
|
+
|
|
24
|
+
var INITIAL_VALUE = {
|
|
25
|
+
vpaId: "",
|
|
26
|
+
notes: ""
|
|
27
|
+
};
|
|
28
|
+
var VALIDATION_SCHEMA = yup.object({
|
|
29
|
+
vpaId: yup.string().required(t("neetoPayments.upi.confirmModal.vpasIdRequired"))
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
var ConfirmUpiPaymentButton = function ConfirmUpiPaymentButton(_ref) {
|
|
33
|
+
var vpas = _ref.vpas,
|
|
34
|
+
identifier = _ref.identifier,
|
|
35
|
+
paymentId = _ref.paymentId,
|
|
36
|
+
payableId = _ref.payableId,
|
|
37
|
+
_ref$onSuccess = _ref.onSuccess,
|
|
38
|
+
onSuccess = _ref$onSuccess === void 0 ? noop : _ref$onSuccess;
|
|
39
|
+
var _useState = useState(false),
|
|
40
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
41
|
+
isModalOpen = _useState2[0],
|
|
42
|
+
setIsModalOpen = _useState2[1];
|
|
43
|
+
var _useTranslation = useTranslation(),
|
|
44
|
+
t = _useTranslation.t;
|
|
45
|
+
var _useUpdateUpiPayment = useUpdateUpiPayment(paymentId, {
|
|
46
|
+
onSuccess: onSuccess
|
|
47
|
+
}),
|
|
48
|
+
updateUpiPayment = _useUpdateUpiPayment.mutate,
|
|
49
|
+
isPending = _useUpdateUpiPayment.isPending;
|
|
50
|
+
var onClose = function onClose() {
|
|
51
|
+
return setIsModalOpen(false);
|
|
52
|
+
};
|
|
53
|
+
var handleSubmit = function handleSubmit(_ref2) {
|
|
54
|
+
var vpaId = _ref2.vpaId,
|
|
55
|
+
notes = _ref2.notes;
|
|
56
|
+
var vpa = findBy({
|
|
57
|
+
id: vpaId
|
|
58
|
+
}, vpas);
|
|
59
|
+
var payload = {
|
|
60
|
+
notes: notes,
|
|
61
|
+
vpaId: vpaId,
|
|
62
|
+
payableId: payableId,
|
|
63
|
+
upiId: vpa.upiId,
|
|
64
|
+
status: "successful"
|
|
65
|
+
};
|
|
66
|
+
updateUpiPayment(payload);
|
|
67
|
+
};
|
|
68
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
69
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
70
|
+
label: t("neetoPayments.upi.payment.buttons.confirmPayment"),
|
|
71
|
+
loading: isPending,
|
|
72
|
+
size: "small",
|
|
73
|
+
onClick: function onClick() {
|
|
74
|
+
return setIsModalOpen(true);
|
|
75
|
+
}
|
|
76
|
+
}), /*#__PURE__*/jsxs(Modal, {
|
|
77
|
+
onClose: onClose,
|
|
78
|
+
isOpen: isModalOpen,
|
|
79
|
+
size: "large",
|
|
80
|
+
children: [/*#__PURE__*/jsx(Modal.Header, {
|
|
81
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
82
|
+
style: "h2",
|
|
83
|
+
children: t("neetoPayments.upi.confirmModal.title")
|
|
84
|
+
})
|
|
85
|
+
}), /*#__PURE__*/jsx(Form, {
|
|
86
|
+
formikProps: {
|
|
87
|
+
enableReinitialize: true,
|
|
88
|
+
onSubmit: handleSubmit,
|
|
89
|
+
initialValues: INITIAL_VALUE,
|
|
90
|
+
validationSchema: VALIDATION_SCHEMA
|
|
91
|
+
},
|
|
92
|
+
children: function children(_ref3) {
|
|
93
|
+
var setFieldValue = _ref3.setFieldValue;
|
|
94
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
95
|
+
children: [/*#__PURE__*/jsx(Modal.Body, {
|
|
96
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
97
|
+
className: "flex flex-col space-y-4",
|
|
98
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
99
|
+
lineHeight: "normal",
|
|
100
|
+
style: "body2",
|
|
101
|
+
children: t("neetoPayments.upi.confirmModal.upiTransactionId", {
|
|
102
|
+
identifier: identifier
|
|
103
|
+
})
|
|
104
|
+
}), /*#__PURE__*/jsx(Select, {
|
|
105
|
+
label: t("neetoPayments.upi.confirmModal.accountIdLabel"),
|
|
106
|
+
name: "vpaId",
|
|
107
|
+
options: vpas === null || vpas === void 0 ? void 0 : vpas.map(function (_ref4) {
|
|
108
|
+
var address = _ref4.address,
|
|
109
|
+
id = _ref4.id;
|
|
110
|
+
return {
|
|
111
|
+
label: address,
|
|
112
|
+
value: id
|
|
113
|
+
};
|
|
114
|
+
}),
|
|
115
|
+
onChange: function onChange(_ref5) {
|
|
116
|
+
var value = _ref5.value;
|
|
117
|
+
return setFieldValue("vpaId", value);
|
|
118
|
+
}
|
|
119
|
+
}), /*#__PURE__*/jsx(Textarea, {
|
|
120
|
+
"data-cy": "confirm-booking-modal-input-textfield",
|
|
121
|
+
label: t("neetoPayments.upi.confirmModal.notes"),
|
|
122
|
+
name: "notes",
|
|
123
|
+
placeholder: t("neetoPayments.upi.confirmModal.notesPlaceholder")
|
|
124
|
+
})]
|
|
125
|
+
})
|
|
126
|
+
}), /*#__PURE__*/jsx(Modal.Footer, {
|
|
127
|
+
className: "space-x-2",
|
|
128
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
129
|
+
isSubmitting: isPending,
|
|
130
|
+
position: "right",
|
|
131
|
+
cancelButtonProps: {
|
|
132
|
+
onClick: onClose,
|
|
133
|
+
style: "tertiary"
|
|
134
|
+
},
|
|
135
|
+
submitButtonProps: {
|
|
136
|
+
label: t("neetoPayments.common.confirm")
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
})]
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
})]
|
|
143
|
+
})]
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export { ConfirmUpiPaymentButton as default };
|
|
148
|
+
//# sourceMappingURL=ConfirmUpiPaymentButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfirmUpiPaymentButton.js","sources":["../app/javascript/src/components/ConfirmUpiPaymentButton/constants.js","../app/javascript/src/components/ConfirmUpiPaymentButton/index.jsx"],"sourcesContent":["import { t } from \"i18next\";\nimport * as yup from \"yup\";\n\nexport const INITIAL_VALUE = { vpaId: \"\", notes: \"\" };\n\nexport const VALIDATION_SCHEMA = yup.object({\n vpaId: yup\n .string()\n .required(t(\"neetoPayments.upi.confirmModal.vpasIdRequired\")),\n});\n","import { useState } from \"react\";\n\nimport { findBy, noop } from \"neetocist\";\nimport { Button, Modal, Typography } from \"neetoui\";\nimport { Form, Textarea, Select, ActionBlock } from \"neetoui/formik\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { useUpdateUpiPayment } from \"hooks/reactQuery/upi/usePaymentsApi\";\n\nimport { INITIAL_VALUE, VALIDATION_SCHEMA } from \"./constants\";\n\nconst ConfirmUpiPaymentButton = ({\n vpas,\n identifier,\n paymentId,\n payableId,\n onSuccess = noop,\n}) => {\n const [isModalOpen, setIsModalOpen] = useState(false);\n\n const { t } = useTranslation();\n\n const { mutate: updateUpiPayment, isPending } = useUpdateUpiPayment(\n paymentId,\n { onSuccess }\n );\n const onClose = () => setIsModalOpen(false);\n\n const handleSubmit = ({ vpaId, notes }) => {\n const vpa = findBy({ id: vpaId }, vpas);\n const payload = {\n notes,\n vpaId,\n payableId,\n upiId: vpa.upiId,\n status: \"successful\",\n };\n updateUpiPayment(payload);\n };\n\n return (\n <>\n <Button\n label={t(\"neetoPayments.upi.payment.buttons.confirmPayment\")}\n loading={isPending}\n size=\"small\"\n onClick={() => setIsModalOpen(true)}\n />\n <Modal {...{ onClose }} isOpen={isModalOpen} size=\"large\">\n <Modal.Header>\n <Typography style=\"h2\">\n {t(\"neetoPayments.upi.confirmModal.title\")}\n </Typography>\n </Modal.Header>\n <Form\n formikProps={{\n enableReinitialize: true,\n onSubmit: handleSubmit,\n initialValues: INITIAL_VALUE,\n validationSchema: VALIDATION_SCHEMA,\n }}\n >\n {({ setFieldValue }) => (\n <>\n <Modal.Body>\n <div className=\"flex flex-col space-y-4\">\n <Typography lineHeight=\"normal\" style=\"body2\">\n {t(\"neetoPayments.upi.confirmModal.upiTransactionId\", {\n identifier,\n })}\n </Typography>\n <Select\n label={t(\"neetoPayments.upi.confirmModal.accountIdLabel\")}\n name=\"vpaId\"\n options={vpas?.map(({ address, id }) => ({\n label: address,\n value: id,\n }))}\n onChange={({ value }) => setFieldValue(\"vpaId\", value)}\n />\n <Textarea\n data-cy=\"confirm-booking-modal-input-textfield\"\n label={t(\"neetoPayments.upi.confirmModal.notes\")}\n name=\"notes\"\n placeholder={t(\n \"neetoPayments.upi.confirmModal.notesPlaceholder\"\n )}\n />\n </div>\n </Modal.Body>\n <Modal.Footer className=\"space-x-2\">\n <ActionBlock\n isSubmitting={isPending}\n position=\"right\"\n cancelButtonProps={{\n onClick: onClose,\n style: \"tertiary\",\n }}\n submitButtonProps={{\n label: t(\"neetoPayments.common.confirm\"),\n }}\n />\n </Modal.Footer>\n </>\n )}\n </Form>\n </Modal>\n </>\n );\n};\n\nexport default ConfirmUpiPaymentButton;\n"],"names":["INITIAL_VALUE","vpaId","notes","VALIDATION_SCHEMA","yup","object","string","required","t","ConfirmUpiPaymentButton","_ref","vpas","identifier","paymentId","payableId","_ref$onSuccess","onSuccess","noop","_useState","useState","_useState2","_slicedToArray","isModalOpen","setIsModalOpen","_useTranslation","useTranslation","_useUpdateUpiPayment","useUpdateUpiPayment","updateUpiPayment","mutate","isPending","onClose","handleSubmit","_ref2","vpa","findBy","id","payload","upiId","status","_jsxs","_Fragment","children","_jsx","Button","label","loading","size","onClick","Modal","isOpen","Header","Typography","style","Form","formikProps","enableReinitialize","onSubmit","initialValues","validationSchema","_ref3","setFieldValue","Body","className","lineHeight","Select","name","options","map","_ref4","address","value","onChange","_ref5","Textarea","placeholder","Footer","ActionBlock","isSubmitting","position","cancelButtonProps","submitButtonProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAMA,aAAa,GAAG;AAAEC,EAAAA,KAAK,EAAE,EAAE;AAAEC,EAAAA,KAAK,EAAE;AAAG,CAAC;AAE9C,IAAMC,iBAAiB,GAAGC,GAAG,CAACC,MAAM,CAAC;AAC1CJ,EAAAA,KAAK,EAAEG,GAAG,CACPE,MAAM,EAAE,CACRC,QAAQ,CAACC,CAAC,CAAC,+CAA+C,CAAC;AAChE,CAAC,CAAC;;ACEF,IAAMC,uBAAuB,GAAG,SAA1BA,uBAAuBA,CAAAC,IAAA,EAMvB;AAAA,EAAA,IALJC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,UAAU,GAAAF,IAAA,CAAVE,UAAU;IACVC,SAAS,GAAAH,IAAA,CAATG,SAAS;IACTC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IAAAC,cAAA,GAAAL,IAAA,CACTM,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAGE,KAAAA,CAAAA,GAAAA,IAAI,GAAAF,cAAA;AAEhB,EAAA,IAAAG,SAAA,GAAsCC,QAAQ,CAAC,KAAK,CAAC;IAAAC,UAAA,GAAAC,cAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAA9CI,IAAAA,WAAW,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,cAAc,GAAAH,UAAA,CAAA,CAAA,CAAA;AAElC,EAAA,IAAAI,eAAA,GAAcC,cAAc,EAAE;IAAtBjB,CAAC,GAAAgB,eAAA,CAADhB,CAAC;AAET,EAAA,IAAAkB,oBAAA,GAAgDC,mBAAmB,CACjEd,SAAS,EACT;AAAEG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C,EAAE;oBAAA,OAAQ;AACvCS,sBAAAA,KAAK,EAAEyB,OAAO;AACdC,sBAAAA,KAAK,EAAEnC;qBACR;AAAA,mBAAC,CAAE;AACJoC,kBAAAA,QAAQ,EAAE,SAAVA,QAAQA,CAAAC,KAAA,EAAA;AAAA,oBAAA,IAAKF,KAAK,GAAAE,KAAA,CAALF,KAAK;AAAA,oBAAA,OAAOV,aAAa,CAAC,OAAO,EAAEU,KAAK,CAAC;AAAA;AAAC,iBACxD,CAAC,eACF5B,GAAA,CAAC+B,QAAQ,EAAA;AACP,kBAAA,SAAA,EAAQ,uCAAuC;AAC/C7B,kBAAAA,KAAK,EAAErC,CAAC,CAAC,sCAAsC,CAAE;AACjD0D,kBAAAA,IAAI,EAAC,OAAO;kBACZS,WAAW,EAAEnE,CAAC,CACZ,iDACF;AAAE,iBACH,CAAC;eACC;AAAC,aACI,CAAC,eACbmC,GAAA,CAACM,KAAK,CAAC2B,MAAM,EAAA;AAACb,cAAAA,SAAS,EAAC,WAAW;cAAArB,QAAA,eACjCC,GAAA,CAACkC,WAAW,EAAA;AACVC,gBAAAA,YAAY,EAAEhD,SAAU;AACxBiD,gBAAAA,QAAQ,EAAC,OAAO;AAChBC,gBAAAA,iBAAiB,EAAE;AACjBhC,kBAAAA,OAAO,EAAEjB,OAAO;AAChBsB,kBAAAA,KAAK,EAAE;iBACP;AACF4B,gBAAAA,iBAAiB,EAAE;kBACjBpC,KAAK,EAAErC,CAAC,CAAC,8BAA8B;AACzC;eACD;AAAC,aACU,CAAC;AAAA,WACf,CAAC;AAAA;AACJ,OACG,CAAC;AAAA,KACF,CAAC;AAAA,GACR,CAAC;AAEP;;;;"}
|
package/dist/UpiPayment.js
CHANGED
|
@@ -1,19 +1,119 @@
|
|
|
1
|
-
import '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import '@bigbinary/neeto-cist';
|
|
3
|
-
import '@bigbinary/neetoui/Typography';
|
|
4
|
-
import '@bigbinary/neetoui/formik/ActionBlock';
|
|
5
|
-
import '@bigbinary/neetoui/formik/Form';
|
|
6
|
-
import '@bigbinary/neetoui/formik/Input';
|
|
7
|
-
import 'qrcode.react';
|
|
8
|
-
import 'ramda';
|
|
9
|
-
import 'react-i18next';
|
|
10
|
-
|
|
11
|
-
import '
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import { isPresent, noop } from '@bigbinary/neeto-cist';
|
|
3
|
+
import Typography from '@bigbinary/neetoui/Typography';
|
|
4
|
+
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
5
|
+
import Form from '@bigbinary/neetoui/formik/Form';
|
|
6
|
+
import Input from '@bigbinary/neetoui/formik/Input';
|
|
7
|
+
import QRCodeImage from 'qrcode.react';
|
|
8
|
+
import { pluck } from 'ramda';
|
|
9
|
+
import { useTranslation } from 'react-i18next';
|
|
10
|
+
import { a as useCreateUpiPayment } from './usePaymentsApi-BwHtaZK6.js';
|
|
11
|
+
import { t } from 'i18next';
|
|
12
|
+
import * as yup from 'yup';
|
|
13
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
12
14
|
import '@tanstack/react-query';
|
|
13
15
|
import 'axios';
|
|
14
16
|
import './index-Cl511Juk.js';
|
|
15
|
-
import 'i18next';
|
|
16
17
|
import '@bigbinary/neeto-commons-frontend/constants';
|
|
17
18
|
import '@bigbinary/neeto-commons-frontend/utils';
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
var VALIDATION_SCHEMA = yup.object({
|
|
21
|
+
identifier: yup.string().required(t("neetoPayments.upi.payment.transaction.required")).min(6, t("neetoPayments.upi.payment.transaction.sixCharacters")).max(6, t("neetoPayments.upi.payment.transaction.sixCharacters"))
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
var vpaIdToQrCodeValue = function vpaIdToQrCodeValue(vpaId) {
|
|
25
|
+
return "upi://pay?pa=".concat(vpaId);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
29
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
|
+
var UpiPayment = function UpiPayment(_ref) {
|
|
31
|
+
var fee = _ref.fee,
|
|
32
|
+
payableId = _ref.payableId,
|
|
33
|
+
discountCode = _ref.discountCode,
|
|
34
|
+
handleCancel = _ref.handleCancel,
|
|
35
|
+
_ref$onBeforePayment = _ref.onBeforePayment,
|
|
36
|
+
onBeforePayment = _ref$onBeforePayment === void 0 ? noop : _ref$onBeforePayment,
|
|
37
|
+
_ref$onFailedPayment = _ref.onFailedPayment,
|
|
38
|
+
onFailedPayment = _ref$onFailedPayment === void 0 ? noop : _ref$onFailedPayment,
|
|
39
|
+
_ref$onSuccessfulPaym = _ref.onSuccessfulPayment,
|
|
40
|
+
onSuccessfulPayment = _ref$onSuccessfulPaym === void 0 ? noop : _ref$onSuccessfulPaym;
|
|
41
|
+
var _useTranslation = useTranslation(),
|
|
42
|
+
t = _useTranslation.t;
|
|
43
|
+
var vpaIds = pluck("address", fee === null || fee === void 0 ? void 0 : fee.vpas);
|
|
44
|
+
var _useCreateUpiPayment = useCreateUpiPayment({
|
|
45
|
+
onSuccess: onSuccessfulPayment,
|
|
46
|
+
onError: onFailedPayment
|
|
47
|
+
}),
|
|
48
|
+
isPending = _useCreateUpiPayment.isPending,
|
|
49
|
+
createPayment = _useCreateUpiPayment.mutate;
|
|
50
|
+
var handleSubmit = function handleSubmit(values) {
|
|
51
|
+
onBeforePayment();
|
|
52
|
+
var payload = _objectSpread(_objectSpread({}, values), {}, {
|
|
53
|
+
payableId: payableId,
|
|
54
|
+
discountCode: discountCode
|
|
55
|
+
});
|
|
56
|
+
createPayment(payload);
|
|
57
|
+
};
|
|
58
|
+
return /*#__PURE__*/jsx("div", {
|
|
59
|
+
children: /*#__PURE__*/jsx(Form, {
|
|
60
|
+
className: "space-y-4",
|
|
61
|
+
formikProps: {
|
|
62
|
+
onSubmit: handleSubmit,
|
|
63
|
+
initialValues: {
|
|
64
|
+
identifier: ""
|
|
65
|
+
},
|
|
66
|
+
validationSchema: VALIDATION_SCHEMA
|
|
67
|
+
},
|
|
68
|
+
children: function children(_ref2) {
|
|
69
|
+
var dirty = _ref2.dirty;
|
|
70
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
71
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
72
|
+
style: "body1",
|
|
73
|
+
children: t("neetoPayments.upi.payment.vpaText", {
|
|
74
|
+
count: vpaIds.length
|
|
75
|
+
})
|
|
76
|
+
}), isPresent(vpaIds) && /*#__PURE__*/jsx("div", {
|
|
77
|
+
className: "grid grid-cols-1 gap-8 gap-y-4 sm:grid-cols-2",
|
|
78
|
+
children: vpaIds.map(function (vpaId) {
|
|
79
|
+
return /*#__PURE__*/jsxs("div", {
|
|
80
|
+
className: "flex flex-col items-center justify-center",
|
|
81
|
+
children: [/*#__PURE__*/jsx(QRCodeImage, {
|
|
82
|
+
size: 256,
|
|
83
|
+
style: {
|
|
84
|
+
width: 80,
|
|
85
|
+
height: 80
|
|
86
|
+
},
|
|
87
|
+
value: vpaIdToQrCodeValue(vpaId)
|
|
88
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
89
|
+
className: "mt-2 w-full break-words text-center",
|
|
90
|
+
style: "body2",
|
|
91
|
+
children: vpaId
|
|
92
|
+
})]
|
|
93
|
+
}, vpaId);
|
|
94
|
+
})
|
|
95
|
+
}), /*#__PURE__*/jsx(Input, {
|
|
96
|
+
required: true,
|
|
97
|
+
label: t("neetoPayments.upi.payment.transaction.label"),
|
|
98
|
+
name: "identifier",
|
|
99
|
+
placeholder: t("neetoPayments.upi.payment.transaction.placeholder")
|
|
100
|
+
}), /*#__PURE__*/jsx(ActionBlock, {
|
|
101
|
+
cancelButtonProps: {
|
|
102
|
+
label: t("neetoPayments.upi.payment.buttons.back"),
|
|
103
|
+
onClick: handleCancel,
|
|
104
|
+
disabled: isPending
|
|
105
|
+
},
|
|
106
|
+
submitButtonProps: {
|
|
107
|
+
label: t("neetoPayments.upi.payment.buttons.submit"),
|
|
108
|
+
disabled: !dirty || isPending,
|
|
109
|
+
loading: isPending
|
|
110
|
+
}
|
|
111
|
+
})]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export { UpiPayment as default };
|
|
19
119
|
//# sourceMappingURL=UpiPayment.js.map
|
package/dist/UpiPayment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpiPayment.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UpiPayment.js","sources":["../app/javascript/src/components/UpiPayment/constants.js","../app/javascript/src/components/UpiPayment/utils.js","../app/javascript/src/components/UpiPayment/index.jsx"],"sourcesContent":["import { t } from \"i18next\";\nimport * as yup from \"yup\";\n\nexport const VALIDATION_SCHEMA = yup.object({\n identifier: yup\n .string()\n .required(t(\"neetoPayments.upi.payment.transaction.required\"))\n .min(6, t(\"neetoPayments.upi.payment.transaction.sixCharacters\"))\n .max(6, t(\"neetoPayments.upi.payment.transaction.sixCharacters\")),\n});\n","export const vpaIdToQrCodeValue = vpaId => `upi://pay?pa=${vpaId}`;\n","import { noop, isPresent } from \"neetocist\";\nimport { 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/upi/usePaymentsApi\";\n\nimport { VALIDATION_SCHEMA } from \"./constants\";\nimport { vpaIdToQrCodeValue } from \"./utils\";\n\nconst UpiPayment = ({\n fee,\n payableId,\n discountCode,\n handleCancel,\n onBeforePayment = noop,\n onFailedPayment = noop,\n onSuccessfulPayment = noop,\n}) => {\n const { t } = useTranslation();\n\n const vpaIds = pluck(\"address\", fee?.vpas);\n\n const { isPending, mutate: createPayment } = useCreateUpiPayment({\n onSuccess: onSuccessfulPayment,\n onError: onFailedPayment,\n });\n\n const handleSubmit = values => {\n onBeforePayment();\n const payload = { ...values, payableId, discountCode };\n createPayment(payload);\n };\n\n return (\n <div>\n <Form\n className=\"space-y-4\"\n formikProps={{\n onSubmit: handleSubmit,\n initialValues: { identifier: \"\" },\n validationSchema: VALIDATION_SCHEMA,\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={vpaIdToQrCodeValue(vpaId)}\n />\n <Typography\n className=\"mt-2 w-full break-words text-center\"\n style=\"body2\"\n >\n {vpaId}\n </Typography>\n </div>\n ))}\n </div>\n )}\n <Input\n required\n label={t(\"neetoPayments.upi.payment.transaction.label\")}\n name=\"identifier\"\n placeholder={t(\n \"neetoPayments.upi.payment.transaction.placeholder\"\n )}\n />\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 || isPending,\n loading: isPending,\n }}\n />\n </>\n )}\n </Form>\n </div>\n );\n};\n\nexport default UpiPayment;\n"],"names":["VALIDATION_SCHEMA","yup","object","identifier","string","required","t","min","max","vpaIdToQrCodeValue","vpaId","concat","UpiPayment","_ref","fee","payableId","discountCode","handleCancel","_ref$onBeforePayment","onBeforePayment","noop","_ref$onFailedPayment","onFailedPayment","_ref$onSuccessfulPaym","onSuccessfulPayment","_useTranslation","useTranslation","vpaIds","pluck","vpas","_useCreateUpiPayment","useCreateUpiPayment","onSuccess","onError","isPending","createPayment","mutate","handleSubmit","values","payload","_objectSpread","_jsx","children","Form","className","formikProps","onSubmit","initialValues","validationSchema","_ref2","dirty","_jsxs","_Fragment","Typography","style","count","length","isPresent","map","QRCodeImage","size","width","height","value","Input","label","name","placeholder","ActionBlock","cancelButtonProps","onClick","disabled","submitButtonProps","loading"],"mappings":";;;;;;;;;;;;;;;;;;;AAGO,IAAMA,iBAAiB,GAAGC,GAAG,CAACC,MAAM,CAAC;AAC1CC,EAAAA,UAAU,EAAEF,GAAG,CACZG,MAAM,EAAE,CACRC,QAAQ,CAACC,CAAC,CAAC,gDAAgD,CAAC,CAAC,CAC7DC,GAAG,CAAC,CAAC,EAAED,CAAC,CAAC,qDAAqD,CAAC,CAAC,CAChEE,GAAG,CAAC,CAAC,EAAEF,CAAC,CAAC,qDAAqD,CAAC;AACpE,CAAC,CAAC;;ACTK,IAAMG,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAGC,KAAK,EAAA;EAAA,OAAAC,eAAAA,CAAAA,MAAA,CAAoBD,KAAK,CAAA;AAAA,CAAE;;;;ACYlE,IAAME,UAAU,GAAG,SAAbA,UAAUA,CAAAC,IAAA,EAQV;AAAA,EAAA,IAPJC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IACHC,SAAS,GAAAF,IAAA,CAATE,SAAS;IACTC,YAAY,GAAAH,IAAA,CAAZG,YAAY;IACZC,YAAY,GAAAJ,IAAA,CAAZ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AAA,CAACuB,KAAK,EAAA;YACJ3D,QAAQ,EAAA,IAAA;AACR4D,YAAAA,KAAK,EAAE3D,CAAC,CAAC,6CAA6C,CAAE;AACxD4D,YAAAA,IAAI,EAAC,YAAY;YACjBC,WAAW,EAAE7D,CAAC,CACZ,mDACF;AAAE,WACH,CAAC,eACFmC,GAAA,CAAC2B,WAAW,EAAA;AACVC,YAAAA,iBAAiB,EAAE;AACjBJ,cAAAA,KAAK,EAAE3D,CAAC,CAAC,wCAAwC,CAAC;AAClDgE,cAAAA,OAAO,EAAErD,YAAY;AACrBsD,cAAAA,QAAQ,EAAErC;aACV;AACFsC,YAAAA,iBAAiB,EAAE;AACjBP,cAAAA,KAAK,EAAE3D,CAAC,CAAC,0CAA0C,CAAC;AACpDiE,cAAAA,QAAQ,EAAE,CAACrB,KAAK,IAAIhB,SAAS;AAC7BuC,cAAAA,OAAO,EAAEvC;AACX;AAAE,WACH,CAAC;AAAA,SACF,CAAC;AAAA;KAED;AAAC,GACJ,CAAC;AAEV;;;;"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var neetoCist = require('@bigbinary/neeto-cist');
|
|
6
|
+
var Button = require('@bigbinary/neetoui/Button');
|
|
7
|
+
var Modal = require('@bigbinary/neetoui/Modal');
|
|
8
|
+
var Typography = require('@bigbinary/neetoui/Typography');
|
|
9
|
+
var Form = require('@bigbinary/neetoui/formik/Form');
|
|
10
|
+
var Textarea = require('@bigbinary/neetoui/formik/Textarea');
|
|
11
|
+
var Select = require('@bigbinary/neetoui/formik/Select');
|
|
12
|
+
var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
|
|
13
|
+
var reactI18next = require('react-i18next');
|
|
14
|
+
var usePaymentsApi = require('./usePaymentsApi-CRsEWHjO.js');
|
|
15
|
+
var i18next = require('i18next');
|
|
16
|
+
var yup = require('yup');
|
|
17
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
18
|
+
require('@babel/runtime/helpers/defineProperty');
|
|
19
|
+
require('@tanstack/react-query');
|
|
20
|
+
require('axios');
|
|
21
|
+
require('./index-DFhiGrTx.js');
|
|
22
|
+
require('@bigbinary/neeto-commons-frontend/constants');
|
|
23
|
+
require('@bigbinary/neeto-commons-frontend/utils');
|
|
24
|
+
require('ramda');
|
|
25
|
+
|
|
26
|
+
function _interopNamespaceDefault(e) {
|
|
27
|
+
var n = Object.create(null);
|
|
28
|
+
if (e) {
|
|
29
|
+
Object.keys(e).forEach(function (k) {
|
|
30
|
+
if (k !== 'default') {
|
|
31
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
32
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () { return e[k]; }
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
n.default = e;
|
|
40
|
+
return Object.freeze(n);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
|
|
44
|
+
|
|
45
|
+
var INITIAL_VALUE = {
|
|
46
|
+
vpaId: "",
|
|
47
|
+
notes: ""
|
|
48
|
+
};
|
|
49
|
+
var VALIDATION_SCHEMA = yup__namespace.object({
|
|
50
|
+
vpaId: yup__namespace.string().required(i18next.t("neetoPayments.upi.confirmModal.vpasIdRequired"))
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
var ConfirmUpiPaymentButton = function ConfirmUpiPaymentButton(_ref) {
|
|
54
|
+
var vpas = _ref.vpas,
|
|
55
|
+
identifier = _ref.identifier,
|
|
56
|
+
paymentId = _ref.paymentId,
|
|
57
|
+
payableId = _ref.payableId,
|
|
58
|
+
_ref$onSuccess = _ref.onSuccess,
|
|
59
|
+
onSuccess = _ref$onSuccess === void 0 ? neetoCist.noop : _ref$onSuccess;
|
|
60
|
+
var _useState = React.useState(false),
|
|
61
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
62
|
+
isModalOpen = _useState2[0],
|
|
63
|
+
setIsModalOpen = _useState2[1];
|
|
64
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
65
|
+
t = _useTranslation.t;
|
|
66
|
+
var _useUpdateUpiPayment = usePaymentsApi.useUpdateUpiPayment(paymentId, {
|
|
67
|
+
onSuccess: onSuccess
|
|
68
|
+
}),
|
|
69
|
+
updateUpiPayment = _useUpdateUpiPayment.mutate,
|
|
70
|
+
isPending = _useUpdateUpiPayment.isPending;
|
|
71
|
+
var onClose = function onClose() {
|
|
72
|
+
return setIsModalOpen(false);
|
|
73
|
+
};
|
|
74
|
+
var handleSubmit = function handleSubmit(_ref2) {
|
|
75
|
+
var vpaId = _ref2.vpaId,
|
|
76
|
+
notes = _ref2.notes;
|
|
77
|
+
var vpa = neetoCist.findBy({
|
|
78
|
+
id: vpaId
|
|
79
|
+
}, vpas);
|
|
80
|
+
var payload = {
|
|
81
|
+
notes: notes,
|
|
82
|
+
vpaId: vpaId,
|
|
83
|
+
payableId: payableId,
|
|
84
|
+
upiId: vpa.upiId,
|
|
85
|
+
status: "successful"
|
|
86
|
+
};
|
|
87
|
+
updateUpiPayment(payload);
|
|
88
|
+
};
|
|
89
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
90
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
91
|
+
label: t("neetoPayments.upi.payment.buttons.confirmPayment"),
|
|
92
|
+
loading: isPending,
|
|
93
|
+
size: "small",
|
|
94
|
+
onClick: function onClick() {
|
|
95
|
+
return setIsModalOpen(true);
|
|
96
|
+
}
|
|
97
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(Modal, {
|
|
98
|
+
onClose: onClose,
|
|
99
|
+
isOpen: isModalOpen,
|
|
100
|
+
size: "large",
|
|
101
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Modal.Header, {
|
|
102
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
103
|
+
style: "h2",
|
|
104
|
+
children: t("neetoPayments.upi.confirmModal.title")
|
|
105
|
+
})
|
|
106
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Form, {
|
|
107
|
+
formikProps: {
|
|
108
|
+
enableReinitialize: true,
|
|
109
|
+
onSubmit: handleSubmit,
|
|
110
|
+
initialValues: INITIAL_VALUE,
|
|
111
|
+
validationSchema: VALIDATION_SCHEMA
|
|
112
|
+
},
|
|
113
|
+
children: function children(_ref3) {
|
|
114
|
+
var setFieldValue = _ref3.setFieldValue;
|
|
115
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
116
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Modal.Body, {
|
|
117
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
118
|
+
className: "flex flex-col space-y-4",
|
|
119
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
120
|
+
lineHeight: "normal",
|
|
121
|
+
style: "body2",
|
|
122
|
+
children: t("neetoPayments.upi.confirmModal.upiTransactionId", {
|
|
123
|
+
identifier: identifier
|
|
124
|
+
})
|
|
125
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Select, {
|
|
126
|
+
label: t("neetoPayments.upi.confirmModal.accountIdLabel"),
|
|
127
|
+
name: "vpaId",
|
|
128
|
+
options: vpas === null || vpas === void 0 ? void 0 : vpas.map(function (_ref4) {
|
|
129
|
+
var address = _ref4.address,
|
|
130
|
+
id = _ref4.id;
|
|
131
|
+
return {
|
|
132
|
+
label: address,
|
|
133
|
+
value: id
|
|
134
|
+
};
|
|
135
|
+
}),
|
|
136
|
+
onChange: function onChange(_ref5) {
|
|
137
|
+
var value = _ref5.value;
|
|
138
|
+
return setFieldValue("vpaId", value);
|
|
139
|
+
}
|
|
140
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Textarea, {
|
|
141
|
+
"data-cy": "confirm-booking-modal-input-textfield",
|
|
142
|
+
label: t("neetoPayments.upi.confirmModal.notes"),
|
|
143
|
+
name: "notes",
|
|
144
|
+
placeholder: t("neetoPayments.upi.confirmModal.notesPlaceholder")
|
|
145
|
+
})]
|
|
146
|
+
})
|
|
147
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Modal.Footer, {
|
|
148
|
+
className: "space-x-2",
|
|
149
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock, {
|
|
150
|
+
isSubmitting: isPending,
|
|
151
|
+
position: "right",
|
|
152
|
+
cancelButtonProps: {
|
|
153
|
+
onClick: onClose,
|
|
154
|
+
style: "tertiary"
|
|
155
|
+
},
|
|
156
|
+
submitButtonProps: {
|
|
157
|
+
label: t("neetoPayments.common.confirm")
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
})]
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
})]
|
|
164
|
+
})]
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
module.exports = ConfirmUpiPaymentButton;
|
|
169
|
+
//# sourceMappingURL=ConfirmUpiPaymentButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfirmUpiPaymentButton.js","sources":["../../app/javascript/src/components/ConfirmUpiPaymentButton/constants.js","../../app/javascript/src/components/ConfirmUpiPaymentButton/index.jsx"],"sourcesContent":["import { t } from \"i18next\";\nimport * as yup from \"yup\";\n\nexport const INITIAL_VALUE = { vpaId: \"\", notes: \"\" };\n\nexport const VALIDATION_SCHEMA = yup.object({\n vpaId: yup\n .string()\n .required(t(\"neetoPayments.upi.confirmModal.vpasIdRequired\")),\n});\n","import { useState } from \"react\";\n\nimport { findBy, noop } from \"neetocist\";\nimport { Button, Modal, Typography } from \"neetoui\";\nimport { Form, Textarea, Select, ActionBlock } from \"neetoui/formik\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { useUpdateUpiPayment } from \"hooks/reactQuery/upi/usePaymentsApi\";\n\nimport { INITIAL_VALUE, VALIDATION_SCHEMA } from \"./constants\";\n\nconst ConfirmUpiPaymentButton = ({\n vpas,\n identifier,\n paymentId,\n payableId,\n onSuccess = noop,\n}) => {\n const [isModalOpen, setIsModalOpen] = useState(false);\n\n const { t } = useTranslation();\n\n const { mutate: updateUpiPayment, isPending } = useUpdateUpiPayment(\n paymentId,\n { onSuccess }\n );\n const onClose = () => setIsModalOpen(false);\n\n const handleSubmit = ({ vpaId, notes }) => {\n const vpa = findBy({ id: vpaId }, vpas);\n const payload = {\n notes,\n vpaId,\n payableId,\n upiId: vpa.upiId,\n status: \"successful\",\n };\n updateUpiPayment(payload);\n };\n\n return (\n <>\n <Button\n label={t(\"neetoPayments.upi.payment.buttons.confirmPayment\")}\n loading={isPending}\n size=\"small\"\n onClick={() => setIsModalOpen(true)}\n />\n <Modal {...{ onClose }} isOpen={isModalOpen} size=\"large\">\n <Modal.Header>\n <Typography style=\"h2\">\n {t(\"neetoPayments.upi.confirmModal.title\")}\n </Typography>\n </Modal.Header>\n <Form\n formikProps={{\n enableReinitialize: true,\n onSubmit: handleSubmit,\n initialValues: INITIAL_VALUE,\n validationSchema: VALIDATION_SCHEMA,\n }}\n >\n {({ setFieldValue }) => (\n <>\n <Modal.Body>\n <div className=\"flex flex-col space-y-4\">\n <Typography lineHeight=\"normal\" style=\"body2\">\n {t(\"neetoPayments.upi.confirmModal.upiTransactionId\", {\n identifier,\n })}\n </Typography>\n <Select\n label={t(\"neetoPayments.upi.confirmModal.accountIdLabel\")}\n name=\"vpaId\"\n options={vpas?.map(({ address, id }) => ({\n label: address,\n value: id,\n }))}\n onChange={({ value }) => setFieldValue(\"vpaId\", value)}\n />\n <Textarea\n data-cy=\"confirm-booking-modal-input-textfield\"\n label={t(\"neetoPayments.upi.confirmModal.notes\")}\n name=\"notes\"\n placeholder={t(\n \"neetoPayments.upi.confirmModal.notesPlaceholder\"\n )}\n />\n </div>\n </Modal.Body>\n <Modal.Footer className=\"space-x-2\">\n <ActionBlock\n isSubmitting={isPending}\n position=\"right\"\n cancelButtonProps={{\n onClick: onClose,\n style: \"tertiary\",\n }}\n submitButtonProps={{\n label: t(\"neetoPayments.common.confirm\"),\n }}\n />\n </Modal.Footer>\n </>\n )}\n </Form>\n </Modal>\n </>\n );\n};\n\nexport default ConfirmUpiPaymentButton;\n"],"names":["INITIAL_VALUE","vpaId","notes","VALIDATION_SCHEMA","yup","object","string","required","t","ConfirmUpiPaymentButton","_ref","vpas","identifier","paymentId","payableId","_ref$onSuccess","onSuccess","noop","_useState","useState","_useState2","_slicedToArray","isModalOpen","setIsModalOpen","_useTranslation","useTranslation","_useUpdateUpiPayment","useUpdateUpiPayment","updateUpiPayment","mutate","isPending","onClose","handleSubmit","_ref2","vpa","findBy","id","payload","upiId","status","_jsxs","_Fragment","children","_jsx","Button","label","loading","size","onClick","Modal","isOpen","Header","Typography","style","Form","formikProps","enableReinitialize","onSubmit","initialValues","validationSchema","_ref3","setFieldValue","Body","className","lineHeight","Select","name","options","map","_ref4","address","value","onChange","_ref5","Textarea","placeholder","Footer","ActionBlock","isSubmitting","position","cancelButtonProps","submitButtonProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAMA,aAAa,GAAG;AAAEC,EAAAA,KAAK,EAAE,EAAE;AAAEC,EAAAA,KAAK,EAAE;AAAG,CAAC;AAE9C,IAAMC,iBAAiB,GAAGC,cAAG,CAACC,MAAM,CAAC;AAC1CJ,EAAAA,KAAK,EAAEG,cAAG,CACPE,MAAM,EAAE,CACRC,QAAQ,CAACC,SAAC,CAAC,+CAA+C,CAAC;AAChE,CAAC,CAAC;;ACEF,IAAMC,uBAAuB,GAAG,SAA1BA,uBAAuBA,CAAAC,IAAA,EAMvB;AAAA,EAAA,IALJC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,UAAU,GAAAF,IAAA,CAAVE,UAAU;I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