@bigbinary/neeto-payments-frontend 3.2.2 → 3.2.4

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/cjs/index.js CHANGED
@@ -11,34 +11,37 @@ var SplitTransfersDashboard = require('./SplitTransfersDashboard.js');
11
11
  var StripeConnect = require('./StripeConnect.js');
12
12
  var TaxesDashboard = require('./TaxesDashboard.js');
13
13
  var UpiConnect = require('./UpiConnect.js');
14
- var UpiMarkAsPaidButton = require('./UpiMarkAsPaidButton.js');
15
- var UpiPayment = require('./UpiPayment.js');
14
+ var UpiPayment = require('./index-Cad6GOm0.js');
15
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
16
+ var React = require('react');
17
+ var neetoCist = require('@bigbinary/neeto-cist');
18
+ var Button = require('@bigbinary/neetoui/Button');
19
+ var Modal = require('@bigbinary/neetoui/Modal');
20
+ var Typography = require('@bigbinary/neetoui/Typography');
21
+ var Form = require('@bigbinary/neetoui/formik/Form');
22
+ var Textarea = require('@bigbinary/neetoui/formik/Textarea');
23
+ var Select = require('@bigbinary/neetoui/formik/Select');
24
+ var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
25
+ var reactI18next = require('react-i18next');
26
+ var jsxRuntime = require('react/jsx-runtime');
16
27
  var useRazorpayPayment = require('./useRazorpayPayment.js');
17
28
  var useStripePromise = require('./useStripePromise.js');
18
29
  var constants = require('./index-DFhiGrTx.js');
19
30
  var CopyButtonWrapper = require('./CopyButtonWrapper-Ds1k64E0.js');
20
- require('@babel/runtime/helpers/slicedToArray');
21
- require('react');
22
31
  require('i18next');
23
- require('@bigbinary/neeto-cist');
24
32
  require('@bigbinary/neeto-commons-frontend/react-utils');
25
33
  require('@bigbinary/neeto-filters-frontend/Bar');
26
34
  require('@bigbinary/neeto-molecules/Header');
27
35
  require('@bigbinary/neeto-molecules/SubHeader');
28
36
  require('@bigbinary/neetoui/Tab');
29
- require('@bigbinary/neetoui/Typography');
30
- require('react-i18next');
31
37
  require('./dashboard-Bhh942b_.js');
32
38
  require('@babel/runtime/helpers/defineProperty');
33
39
  require('@tanstack/react-query');
34
40
  require('@tanstack/react-query-devtools');
35
41
  require('@bigbinary/neeto-commons-frontend/constants');
36
- require('react/jsx-runtime');
37
42
  require('axios');
38
43
  require('ramda');
39
44
  require('@bigbinary/neeto-icons/Download');
40
- require('@bigbinary/neetoui/Button');
41
- require('@bigbinary/neetoui/Modal');
42
45
  require('./exportChannel-BsZ3fusx.js');
43
46
  require('@bigbinary/neeto-commons-frontend/utils');
44
47
  require('@babel/runtime/helpers/toConsumableArray');
@@ -64,9 +67,6 @@ require('react-router-dom/cjs/react-router-dom');
64
67
  require('@babel/runtime/helpers/asyncToGenerator');
65
68
  require('@babel/runtime/regenerator');
66
69
  require('./usePaymentApi-Ct4IyY6F.js');
67
- require('@bigbinary/neetoui/formik/Form');
68
- require('@bigbinary/neetoui/formik/Textarea');
69
- require('@bigbinary/neetoui/formik/ActionBlock');
70
70
  require('yup');
71
71
  require('@bigbinary/neeto-molecules/HelpPopover');
72
72
  require('@bigbinary/neetoui/Pane');
@@ -74,7 +74,6 @@ require('@bigbinary/neetoui/Dropdown');
74
74
  require('neetointegrations/Demo');
75
75
  require('neetointegrations/Modal');
76
76
  require('@bigbinary/neetoui/Label');
77
- require('@bigbinary/neetoui/formik/Select');
78
77
  require('dompurify');
79
78
  require('@bigbinary/neetoui/Radio');
80
79
  require('neetointegrations/Finish');
@@ -83,11 +82,126 @@ require('@bigbinary/neeto-molecules/PageLoader');
83
82
  require('@bigbinary/neetoui/formik/Input');
84
83
  require('@bigbinary/neetoui/formik/Radio');
85
84
  require('@bigbinary/neeto-molecules/MoreDropdown');
86
- require('./usePaymentsApi-CRiwy7_v.js');
87
85
  require('qrcode.react');
88
86
  require('@bigbinary/neeto-commons-frontend/initializers');
89
87
  require('@bigbinary/neeto-molecules/CopyToClipboardButton');
90
88
 
89
+ var ConfirmButton = function ConfirmButton(_ref) {
90
+ var vpas = _ref.vpas,
91
+ identifier = _ref.identifier,
92
+ paymentId = _ref.paymentId,
93
+ payableId = _ref.payableId,
94
+ _ref$onSuccess = _ref.onSuccess,
95
+ onSuccess = _ref$onSuccess === void 0 ? neetoCist.noop : _ref$onSuccess;
96
+ var _useState = React.useState(false),
97
+ _useState2 = _slicedToArray(_useState, 2),
98
+ isModalOpen = _useState2[0],
99
+ setIsModalOpen = _useState2[1];
100
+ var _useTranslation = reactI18next.useTranslation(),
101
+ t = _useTranslation.t;
102
+ var _useUpdateUpiPayment = UpiPayment.useUpdateUpiPayment(paymentId, {
103
+ onSuccess: onSuccess
104
+ }),
105
+ updateUpiPayment = _useUpdateUpiPayment.mutate,
106
+ isPending = _useUpdateUpiPayment.isPending;
107
+ var onClose = function onClose() {
108
+ return setIsModalOpen(false);
109
+ };
110
+ var handleSubmit = function handleSubmit(_ref2) {
111
+ var vpaId = _ref2.vpaId,
112
+ notes = _ref2.notes;
113
+ var vpa = neetoCist.findBy({
114
+ id: vpaId
115
+ }, vpas);
116
+ var payload = {
117
+ notes: notes,
118
+ vpaId: vpaId,
119
+ payableId: payableId,
120
+ upiId: vpa.upiId,
121
+ status: "successful"
122
+ };
123
+ updateUpiPayment(payload);
124
+ };
125
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
126
+ children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
127
+ label: t("neetoPayments.upi.payment.buttons.confirmPayment"),
128
+ loading: isPending,
129
+ size: "small",
130
+ style: "secondary",
131
+ onClick: function onClick() {
132
+ return setIsModalOpen(true);
133
+ }
134
+ }), /*#__PURE__*/jsxRuntime.jsxs(Modal, {
135
+ onClose: onClose,
136
+ isOpen: isModalOpen,
137
+ size: "large",
138
+ children: [/*#__PURE__*/jsxRuntime.jsx(Modal.Header, {
139
+ children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
140
+ style: "h2",
141
+ children: t("neetoPayments.upi.confirmModal.title")
142
+ })
143
+ }), /*#__PURE__*/jsxRuntime.jsx(Form, {
144
+ formikProps: {
145
+ enableReinitialize: true,
146
+ onSubmit: handleSubmit,
147
+ initialValues: UpiPayment.CONFIRM_FORM_INITIAL_VALUE,
148
+ validationSchema: UpiPayment.CONFIRM_FORM_VALIDATION_SCHEMA
149
+ },
150
+ children: function children(_ref3) {
151
+ var setFieldValue = _ref3.setFieldValue;
152
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
153
+ children: [/*#__PURE__*/jsxRuntime.jsx(Modal.Body, {
154
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
155
+ className: "flex flex-col space-y-4",
156
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
157
+ lineHeight: "normal",
158
+ style: "body2",
159
+ children: t("neetoPayments.upi.confirmModal.upiTransactionId", {
160
+ identifier: identifier
161
+ })
162
+ }), /*#__PURE__*/jsxRuntime.jsx(Select, {
163
+ label: t("neetoPayments.upi.confirmModal.accountIdLabel"),
164
+ name: "vpaId",
165
+ options: vpas === null || vpas === void 0 ? void 0 : vpas.map(function (_ref4) {
166
+ var address = _ref4.address,
167
+ id = _ref4.id;
168
+ return {
169
+ label: address,
170
+ value: id
171
+ };
172
+ }),
173
+ onChange: function onChange(_ref5) {
174
+ var value = _ref5.value;
175
+ return setFieldValue("vpaId", value);
176
+ }
177
+ }), /*#__PURE__*/jsxRuntime.jsx(Textarea, {
178
+ "data-cy": "confirm-booking-modal-input-textfield",
179
+ label: t("neetoPayments.upi.confirmModal.notes"),
180
+ name: "notes",
181
+ placeholder: t("neetoPayments.upi.confirmModal.notesPlaceholder")
182
+ })]
183
+ })
184
+ }), /*#__PURE__*/jsxRuntime.jsx(Modal.Footer, {
185
+ className: "space-x-2",
186
+ children: /*#__PURE__*/jsxRuntime.jsx(ActionBlock, {
187
+ isSubmitting: isPending,
188
+ position: "right",
189
+ cancelButtonProps: {
190
+ onClick: onClose,
191
+ style: "tertiary"
192
+ },
193
+ submitButtonProps: {
194
+ label: t("neetoPayments.common.confirm")
195
+ }
196
+ })
197
+ })]
198
+ });
199
+ }
200
+ })]
201
+ })]
202
+ });
203
+ };
204
+
91
205
  var css = ".ant-table-cell-row-hover .identifier-copy-button{visibility:visible!important}";
92
206
  CopyButtonWrapper.n(css,{});
93
207
 
@@ -102,10 +216,10 @@ exports.SplitTransfersDashboard = SplitTransfersDashboard;
102
216
  exports.StripeConnect = StripeConnect;
103
217
  exports.TaxesDashboard = TaxesDashboard;
104
218
  exports.UpiConnect = UpiConnect;
105
- exports.UpiMarkAsPaidButton = UpiMarkAsPaidButton;
106
- exports.UpiPayment = UpiPayment;
219
+ exports.UpiPayment = UpiPayment.UpiPayment;
107
220
  exports.useRazorpayPayment = useRazorpayPayment;
108
221
  exports.useStripePromise = useStripePromise;
109
222
  exports.CURRENCY_OPTIONS = constants.CURRENCY_OPTIONS;
110
223
  exports.buildStripeTransactionLink = constants.buildStripeTransactionLink;
224
+ exports.ConfirmButton = ConfirmButton;
111
225
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../app/javascript/src/components/UpiPayment/ConfirmButton.jsx"],"sourcesContent":["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 {\n CONFIRM_FORM_INITIAL_VALUE,\n CONFIRM_FORM_VALIDATION_SCHEMA,\n} from \"./constants\";\n\nconst ConfirmButton = ({\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 style=\"secondary\"\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: CONFIRM_FORM_INITIAL_VALUE,\n validationSchema: CONFIRM_FORM_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 ConfirmButton;\n"],"names":["ConfirmButton","_ref","vpas","identifier","paymentId","payableId","_ref$onSuccess","onSuccess","noop","_useState","useState","_useState2","_slicedToArray","isModalOpen","setIsModalOpen","_useTranslation","useTranslation","t","_useUpdateUpiPayment","useUpdateUpiPayment","updateUpiPayment","mutate","isPending","onClose","handleSubmit","_ref2","vpaId","notes","vpa","findBy","id","payload","upiId","status","_jsxs","_Fragment","children","_jsx","Button","label","loading","size","style","onClick","Modal","isOpen","Header","Typography","Form","formikProps","enableReinitialize","onSubmit","initialValues","CONFIRM_FORM_INITIAL_VALUE","validationSchema","CONFIRM_FORM_VALIDATION_SCHEMA","_ref3","setFieldValue","Body","className","lineHeight","Select","name","options","map","_ref4","address","value","onChange","_ref5","Textarea","placeholder","Footer","ActionBlock","isSubmitting","position","cancelButtonProps","submitButtonProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAMA,aAAa,GAAG,SAAhBA,aAAaA,CAAAC,IAAA,EAMb;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,cAAI,GAAAF,cAAA;AAEhB,EAAA,IAAAG,SAAA,GAAsCC,cAAQ,CAAC,KAAK,CAAC;IAAAC,UAAA,GAAAC,cAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAA9CI,IAAAA,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WACf,CAAC;AAAA;AACJ,OACG,CAAC;AAAA,KACF,CAAC;AAAA,GACR,CAAC;AAEP;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,154 @@
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 { useMutation } from '@tanstack/react-query';
11
+ import axios from 'axios';
12
+ import { B as BASE_URL } from './index-Cl511Juk.js';
13
+ import { t } from 'i18next';
14
+ import * as yup from 'yup';
15
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
16
+
17
+ var create = function create(payload) {
18
+ return axios.post("".concat(BASE_URL, "/api/v1/public/upi/payments"), {
19
+ payment: payload
20
+ });
21
+ };
22
+ var update = function update(id, payload) {
23
+ return axios.put("".concat(BASE_URL, "/api/v1/upi/payments/").concat(id), {
24
+ payment: payload
25
+ });
26
+ };
27
+ var paymentsApi = {
28
+ create: create,
29
+ update: update
30
+ };
31
+
32
+ function ownKeys$1(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; }
33
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
34
+ var useCreateUpiPayment = function useCreateUpiPayment(options) {
35
+ return useMutation(_objectSpread$1({
36
+ mutationFn: paymentsApi.create
37
+ }, options));
38
+ };
39
+ var useUpdateUpiPayment = function useUpdateUpiPayment(id) {
40
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
41
+ return useMutation(_objectSpread$1({
42
+ mutationFn: function mutationFn(payload) {
43
+ return paymentsApi.update(id, payload);
44
+ }
45
+ }, options));
46
+ };
47
+
48
+ var VALIDATION_SCHEMA = yup.object({
49
+ 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"))
50
+ });
51
+ var CONFIRM_FORM_INITIAL_VALUE = {
52
+ vpaId: "",
53
+ notes: ""
54
+ };
55
+ var CONFIRM_FORM_VALIDATION_SCHEMA = yup.object({
56
+ vpaId: yup.string().required(t("neetoPayments.upi.confirmModal.vpasIdRequired"))
57
+ });
58
+
59
+ var vpaIdToQrCodeValue = function vpaIdToQrCodeValue(vpaId) {
60
+ return "upi://pay?pa=".concat(vpaId);
61
+ };
62
+
63
+ 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; }
64
+ 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; }
65
+ var UpiPayment = function UpiPayment(_ref) {
66
+ var fee = _ref.fee,
67
+ payableId = _ref.payableId,
68
+ discountCode = _ref.discountCode,
69
+ handleCancel = _ref.handleCancel,
70
+ _ref$onBeforePayment = _ref.onBeforePayment,
71
+ onBeforePayment = _ref$onBeforePayment === void 0 ? noop : _ref$onBeforePayment,
72
+ _ref$onFailedPayment = _ref.onFailedPayment,
73
+ onFailedPayment = _ref$onFailedPayment === void 0 ? noop : _ref$onFailedPayment,
74
+ _ref$onSuccessfulPaym = _ref.onSuccessfulPayment,
75
+ onSuccessfulPayment = _ref$onSuccessfulPaym === void 0 ? noop : _ref$onSuccessfulPaym;
76
+ var _useTranslation = useTranslation(),
77
+ t = _useTranslation.t;
78
+ var vpaIds = pluck("address", fee === null || fee === void 0 ? void 0 : fee.vpas);
79
+ var _useCreateUpiPayment = useCreateUpiPayment({
80
+ onSuccess: onSuccessfulPayment,
81
+ onError: onFailedPayment
82
+ }),
83
+ isPending = _useCreateUpiPayment.isPending,
84
+ createPayment = _useCreateUpiPayment.mutate;
85
+ var handleSubmit = function handleSubmit(values) {
86
+ onBeforePayment();
87
+ var payload = _objectSpread(_objectSpread({}, values), {}, {
88
+ payableId: payableId,
89
+ discountCode: discountCode
90
+ });
91
+ createPayment(payload);
92
+ };
93
+ return /*#__PURE__*/jsx("div", {
94
+ children: /*#__PURE__*/jsx(Form, {
95
+ className: "space-y-4",
96
+ formikProps: {
97
+ onSubmit: handleSubmit,
98
+ initialValues: {
99
+ identifier: ""
100
+ },
101
+ validationSchema: VALIDATION_SCHEMA
102
+ },
103
+ children: function children(_ref2) {
104
+ var dirty = _ref2.dirty;
105
+ return /*#__PURE__*/jsxs(Fragment, {
106
+ children: [/*#__PURE__*/jsx(Typography, {
107
+ style: "body1",
108
+ children: t("neetoPayments.upi.payment.vpaText", {
109
+ count: vpaIds.length
110
+ })
111
+ }), isPresent(vpaIds) && /*#__PURE__*/jsx("div", {
112
+ className: "grid grid-cols-1 gap-8 gap-y-4 sm:grid-cols-2",
113
+ children: vpaIds.map(function (vpaId) {
114
+ return /*#__PURE__*/jsxs("div", {
115
+ className: "flex flex-col items-center justify-center",
116
+ children: [/*#__PURE__*/jsx(QRCodeImage, {
117
+ size: 256,
118
+ style: {
119
+ width: 80,
120
+ height: 80
121
+ },
122
+ value: vpaIdToQrCodeValue(vpaId)
123
+ }), /*#__PURE__*/jsx(Typography, {
124
+ className: "mt-2 w-full break-words text-center",
125
+ style: "body2",
126
+ children: vpaId
127
+ })]
128
+ }, vpaId);
129
+ })
130
+ }), /*#__PURE__*/jsx(Input, {
131
+ required: true,
132
+ label: t("neetoPayments.upi.payment.transaction.label"),
133
+ name: "identifier",
134
+ placeholder: t("neetoPayments.upi.payment.transaction.placeholder")
135
+ }), /*#__PURE__*/jsx(ActionBlock, {
136
+ cancelButtonProps: {
137
+ label: t("neetoPayments.upi.payment.buttons.back"),
138
+ onClick: handleCancel,
139
+ disabled: isPending
140
+ },
141
+ submitButtonProps: {
142
+ label: t("neetoPayments.upi.payment.buttons.submit"),
143
+ disabled: !dirty || isPending,
144
+ loading: isPending
145
+ }
146
+ })]
147
+ });
148
+ }
149
+ })
150
+ });
151
+ };
152
+
153
+ export { CONFIRM_FORM_INITIAL_VALUE as C, UpiPayment as U, CONFIRM_FORM_VALIDATION_SCHEMA as a, useUpdateUpiPayment as u };
154
+ //# sourceMappingURL=index-BWLyK2S8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BWLyK2S8.js","sources":["../app/javascript/src/apis/upi/payments.js","../app/javascript/src/hooks/reactQuery/upi/usePaymentsApi.js","../app/javascript/src/components/UpiPayment/constants.js","../app/javascript/src/components/UpiPayment/utils.js","../app/javascript/src/components/UpiPayment/index.jsx"],"sourcesContent":["import axios from \"axios\";\n\nimport { BASE_URL } from \"src/constants\";\n\nconst create = payload =>\n axios.post(`${BASE_URL}/api/v1/public/upi/payments`, {\n payment: payload,\n });\n\nconst update = (id, payload) =>\n axios.put(`${BASE_URL}/api/v1/upi/payments/${id}`, {\n payment: payload,\n });\n\nconst paymentsApi = { create, update };\n\nexport default paymentsApi;\n","import { useMutation } from \"@tanstack/react-query\";\n\nimport paymentsApi from \"apis/upi/payments\";\n\nexport const useCreateUpiPayment = options =>\n useMutation({ mutationFn: paymentsApi.create, ...options });\n\nexport const useUpdateUpiPayment = (id, options = {}) =>\n useMutation({\n mutationFn: payload => paymentsApi.update(id, payload),\n ...options,\n });\n","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\nexport const CONFIRM_FORM_INITIAL_VALUE = { vpaId: \"\", notes: \"\" };\n\nexport const CONFIRM_FORM_VALIDATION_SCHEMA = yup.object({\n vpaId: yup\n .string()\n .required(t(\"neetoPayments.upi.confirmModal.vpasIdRequired\")),\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":["create","payload","axios","post","concat","BASE_URL","payment","update","id","put","paymentsApi","useCreateUpiPayment","options","useMutation","_objectSpread","mutationFn","useUpdateUpiPayment","arguments","length","undefined","VALIDATION_SCHEMA","yup","object","identifier","string","required","t","min","max","CONFIRM_FORM_INITIAL_VALUE","vpaId","notes","CONFIRM_FORM_VALIDATION_SCHEMA","vpaIdToQrCodeValue","UpiPayment","_ref","fee","payableId","discountCode","handleCancel","_ref$onBeforePayment","onBeforePayment","noop","_ref$onFailedPayment","onFailedPayment","_ref$onSuccessfulPaym","onSuccessfulPayment","_useTranslation","useTranslation","vpaIds","pluck","vpas","_useCreateUpiPayment","onSuccess","onError","isPending","createPayment","mutate","handleSubmit","values","_jsx","children","Form","className","formikProps","onSubmit","initialValues","validationSchema","_ref2","dirty","_jsxs","_Fragment","Typography","style","count","isPresent","map","QRCodeImage","size","width","height","value","Input","label","name","placeholder","ActionBlock","cancelButtonProps","onClick","disabled","submitButtonProps","loading"],"mappings":";;;;;;;;;;;;;;;;AAIA,IAAMA,MAAM,GAAG,SAATA,MAAMA,CAAGC,OAAO,EAAA;AAAA,EAAA,OACpBC,KAAK,CAACC,IAAI,IAAAC,MAAA,CAAIC,QAAQ,EAA+B,6BAAA,CAAA,EAAA;AACnDC,IAAAA,OAAO,EAAEL;AACX,GAAC,CAAC;AAAA,CAAA;AAEJ,IAAMM,MAAM,GAAG,SAATA,MAAMA,CAAIC,EAAE,EAAEP,OAAO,EAAA;EAAA,OACzBC,KAAK,CAACO,GAAG,CAAAL,EAAAA,CAAAA,MAAA,CAAIC,QAAQ,EAAAD,uBAAAA,CAAAA,CAAAA,MAAA,CAAwBI,EAAE,CAAI,EAAA;AACjDF,IAAAA,OAAO,EAAEL;AACX,GAAC,CAAC;AAAA,CAAA;AAEJ,IAAMS,WAAW,GAAG;AAAEV,EAAAA,MAAM,EAANA,MAAM;AAAEO,EAAAA,MAAM,EAANA;AAAO,CAAC;;;;ACV/B,IAAMI,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAGC,OAAO,EAAA;EAAA,OACxCC,WAAW,CAAAC,eAAA,CAAA;IAAGC,UAAU,EAAEL,WAAW,CAACV;GAAWY,EAAAA,OAAO,CAAE,CAAC;AAAA,CAAA;IAEhDI,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIR,EAAE,EAAA;AAAA,EAAA,IAAEI,OAAO,GAAAK,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE;EAAA,OAClDJ,WAAW,CAAAC,eAAA,CAAA;AACTC,IAAAA,U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W,EAAE3D,CAAC,CACZ,mDACF;AAAE,WACH,CAAC,eACFkC,GAAA,CAAC0B,WAAW,EAAA;AACVC,YAAAA,iBAAiB,EAAE;AACjBJ,cAAAA,KAAK,EAAEzD,CAAC,CAAC,wCAAwC,CAAC;AAClD8D,cAAAA,OAAO,EAAEjD,YAAY;AACrBkD,cAAAA,QAAQ,EAAElC;aACV;AACFmC,YAAAA,iBAAiB,EAAE;AACjBP,cAAAA,KAAK,EAAEzD,CAAC,CAAC,0CAA0C,CAAC;AACpD+D,cAAAA,QAAQ,EAAE,CAACpB,KAAK,IAAId,SAAS;AAC7BoC,cAAAA,OAAO,EAAEpC;AACX;AAAE,WACH,CAAC;AAAA,SACF,CAAC;AAAA;KAED;AAAC,GACJ,CAAC;AAEV;;;;"}
package/dist/index.js CHANGED
@@ -9,34 +9,38 @@ export { default as SplitTransfersDashboard } from './SplitTransfersDashboard.js
9
9
  export { default as StripeConnect } from './StripeConnect.js';
10
10
  export { default as TaxesDashboard } from './TaxesDashboard.js';
11
11
  export { default as UpiConnect } from './UpiConnect.js';
12
- export { default as UpiMarkAsPaidButton } from './UpiMarkAsPaidButton.js';
13
- export { default as UpiPayment } from './UpiPayment.js';
12
+ import { u as useUpdateUpiPayment, C as CONFIRM_FORM_INITIAL_VALUE, a as CONFIRM_FORM_VALIDATION_SCHEMA } from './index-BWLyK2S8.js';
13
+ export { U as UpiPayment } from './index-BWLyK2S8.js';
14
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
15
+ import { useState } from 'react';
16
+ import { findBy, noop } from '@bigbinary/neeto-cist';
17
+ import Button from '@bigbinary/neetoui/Button';
18
+ import Modal from '@bigbinary/neetoui/Modal';
19
+ import Typography from '@bigbinary/neetoui/Typography';
20
+ import Form from '@bigbinary/neetoui/formik/Form';
21
+ import Textarea from '@bigbinary/neetoui/formik/Textarea';
22
+ import Select from '@bigbinary/neetoui/formik/Select';
23
+ import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
24
+ import { useTranslation } from 'react-i18next';
25
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
14
26
  export { default as useRazorpayPayment } from './useRazorpayPayment.js';
15
27
  export { default as useStripePromise } from './useStripePromise.js';
16
28
  export { C as CURRENCY_OPTIONS, b as buildStripeTransactionLink } from './index-Cl511Juk.js';
17
29
  import { n } from './CopyButtonWrapper-SoJkwX-d.js';
18
- import '@babel/runtime/helpers/slicedToArray';
19
- import 'react';
20
30
  import 'i18next';
21
- import '@bigbinary/neeto-cist';
22
31
  import '@bigbinary/neeto-commons-frontend/react-utils';
23
32
  import '@bigbinary/neeto-filters-frontend/Bar';
24
33
  import '@bigbinary/neeto-molecules/Header';
25
34
  import '@bigbinary/neeto-molecules/SubHeader';
26
35
  import '@bigbinary/neetoui/Tab';
27
- import '@bigbinary/neetoui/Typography';
28
- import 'react-i18next';
29
36
  import './dashboard-BWze-7eb.js';
30
37
  import '@babel/runtime/helpers/defineProperty';
31
38
  import '@tanstack/react-query';
32
39
  import '@tanstack/react-query-devtools';
33
40
  import '@bigbinary/neeto-commons-frontend/constants';
34
- import 'react/jsx-runtime';
35
41
  import 'axios';
36
42
  import 'ramda';
37
43
  import '@bigbinary/neeto-icons/Download';
38
- import '@bigbinary/neetoui/Button';
39
- import '@bigbinary/neetoui/Modal';
40
44
  import './exportChannel-CViICC6x.js';
41
45
  import '@bigbinary/neeto-commons-frontend/utils';
42
46
  import '@babel/runtime/helpers/toConsumableArray';
@@ -62,9 +66,6 @@ import 'react-router-dom/cjs/react-router-dom';
62
66
  import '@babel/runtime/helpers/asyncToGenerator';
63
67
  import '@babel/runtime/regenerator';
64
68
  import './usePaymentApi-DiWHWkBI.js';
65
- import '@bigbinary/neetoui/formik/Form';
66
- import '@bigbinary/neetoui/formik/Textarea';
67
- import '@bigbinary/neetoui/formik/ActionBlock';
68
69
  import 'yup';
69
70
  import '@bigbinary/neeto-molecules/HelpPopover';
70
71
  import '@bigbinary/neetoui/Pane';
@@ -72,7 +73,6 @@ import '@bigbinary/neetoui/Dropdown';
72
73
  import 'neetointegrations/Demo';
73
74
  import 'neetointegrations/Modal';
74
75
  import '@bigbinary/neetoui/Label';
75
- import '@bigbinary/neetoui/formik/Select';
76
76
  import 'dompurify';
77
77
  import '@bigbinary/neetoui/Radio';
78
78
  import 'neetointegrations/Finish';
@@ -81,11 +81,128 @@ import '@bigbinary/neeto-molecules/PageLoader';
81
81
  import '@bigbinary/neetoui/formik/Input';
82
82
  import '@bigbinary/neetoui/formik/Radio';
83
83
  import '@bigbinary/neeto-molecules/MoreDropdown';
84
- import './usePaymentsApi-1Lsm4d5C.js';
85
84
  import 'qrcode.react';
86
85
  import '@bigbinary/neeto-commons-frontend/initializers';
87
86
  import '@bigbinary/neeto-molecules/CopyToClipboardButton';
88
87
 
88
+ var ConfirmButton = function ConfirmButton(_ref) {
89
+ var vpas = _ref.vpas,
90
+ identifier = _ref.identifier,
91
+ paymentId = _ref.paymentId,
92
+ payableId = _ref.payableId,
93
+ _ref$onSuccess = _ref.onSuccess,
94
+ onSuccess = _ref$onSuccess === void 0 ? noop : _ref$onSuccess;
95
+ var _useState = useState(false),
96
+ _useState2 = _slicedToArray(_useState, 2),
97
+ isModalOpen = _useState2[0],
98
+ setIsModalOpen = _useState2[1];
99
+ var _useTranslation = useTranslation(),
100
+ t = _useTranslation.t;
101
+ var _useUpdateUpiPayment = useUpdateUpiPayment(paymentId, {
102
+ onSuccess: onSuccess
103
+ }),
104
+ updateUpiPayment = _useUpdateUpiPayment.mutate,
105
+ isPending = _useUpdateUpiPayment.isPending;
106
+ var onClose = function onClose() {
107
+ return setIsModalOpen(false);
108
+ };
109
+ var handleSubmit = function handleSubmit(_ref2) {
110
+ var vpaId = _ref2.vpaId,
111
+ notes = _ref2.notes;
112
+ var vpa = findBy({
113
+ id: vpaId
114
+ }, vpas);
115
+ var payload = {
116
+ notes: notes,
117
+ vpaId: vpaId,
118
+ payableId: payableId,
119
+ upiId: vpa.upiId,
120
+ status: "successful"
121
+ };
122
+ updateUpiPayment(payload);
123
+ };
124
+ return /*#__PURE__*/jsxs(Fragment, {
125
+ children: [/*#__PURE__*/jsx(Button, {
126
+ label: t("neetoPayments.upi.payment.buttons.confirmPayment"),
127
+ loading: isPending,
128
+ size: "small",
129
+ style: "secondary",
130
+ onClick: function onClick() {
131
+ return setIsModalOpen(true);
132
+ }
133
+ }), /*#__PURE__*/jsxs(Modal, {
134
+ onClose: onClose,
135
+ isOpen: isModalOpen,
136
+ size: "large",
137
+ children: [/*#__PURE__*/jsx(Modal.Header, {
138
+ children: /*#__PURE__*/jsx(Typography, {
139
+ style: "h2",
140
+ children: t("neetoPayments.upi.confirmModal.title")
141
+ })
142
+ }), /*#__PURE__*/jsx(Form, {
143
+ formikProps: {
144
+ enableReinitialize: true,
145
+ onSubmit: handleSubmit,
146
+ initialValues: CONFIRM_FORM_INITIAL_VALUE,
147
+ validationSchema: CONFIRM_FORM_VALIDATION_SCHEMA
148
+ },
149
+ children: function children(_ref3) {
150
+ var setFieldValue = _ref3.setFieldValue;
151
+ return /*#__PURE__*/jsxs(Fragment, {
152
+ children: [/*#__PURE__*/jsx(Modal.Body, {
153
+ children: /*#__PURE__*/jsxs("div", {
154
+ className: "flex flex-col space-y-4",
155
+ children: [/*#__PURE__*/jsx(Typography, {
156
+ lineHeight: "normal",
157
+ style: "body2",
158
+ children: t("neetoPayments.upi.confirmModal.upiTransactionId", {
159
+ identifier: identifier
160
+ })
161
+ }), /*#__PURE__*/jsx(Select, {
162
+ label: t("neetoPayments.upi.confirmModal.accountIdLabel"),
163
+ name: "vpaId",
164
+ options: vpas === null || vpas === void 0 ? void 0 : vpas.map(function (_ref4) {
165
+ var address = _ref4.address,
166
+ id = _ref4.id;
167
+ return {
168
+ label: address,
169
+ value: id
170
+ };
171
+ }),
172
+ onChange: function onChange(_ref5) {
173
+ var value = _ref5.value;
174
+ return setFieldValue("vpaId", value);
175
+ }
176
+ }), /*#__PURE__*/jsx(Textarea, {
177
+ "data-cy": "confirm-booking-modal-input-textfield",
178
+ label: t("neetoPayments.upi.confirmModal.notes"),
179
+ name: "notes",
180
+ placeholder: t("neetoPayments.upi.confirmModal.notesPlaceholder")
181
+ })]
182
+ })
183
+ }), /*#__PURE__*/jsx(Modal.Footer, {
184
+ className: "space-x-2",
185
+ children: /*#__PURE__*/jsx(ActionBlock, {
186
+ isSubmitting: isPending,
187
+ position: "right",
188
+ cancelButtonProps: {
189
+ onClick: onClose,
190
+ style: "tertiary"
191
+ },
192
+ submitButtonProps: {
193
+ label: t("neetoPayments.common.confirm")
194
+ }
195
+ })
196
+ })]
197
+ });
198
+ }
199
+ })]
200
+ })]
201
+ });
202
+ };
203
+
89
204
  var css = ".ant-table-cell-row-hover .identifier-copy-button{visibility:visible!important}";
90
205
  n(css,{});
206
+
207
+ export { ConfirmButton };
91
208
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../app/javascript/src/components/UpiPayment/ConfirmButton.jsx"],"sourcesContent":["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 {\n CONFIRM_FORM_INITIAL_VALUE,\n CONFIRM_FORM_VALIDATION_SCHEMA,\n} from \"./constants\";\n\nconst ConfirmButton = ({\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 style=\"secondary\"\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: CONFIRM_FORM_INITIAL_VALUE,\n validationSchema: CONFIRM_FORM_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 ConfirmButton;\n"],"names":["ConfirmButton","_ref","vpas","identifier","paymentId","payableId","_ref$onSuccess","onSuccess","noop","_useState","useState","_useState2","_slicedToArray","isModalOpen","setIsModalOpen","_useTranslation","useTranslation","t","_useUpdateUpiPayment","useUpdateUpiPayment","updateUpiPayment","mutate","isPending","onClose","handleSubmit","_ref2","vpaId","notes","vpa","findBy","id","payload","upiId","status","_jsxs","_Fragment","children","_jsx","Button","label","loading","size","style","onClick","Modal","isOpen","Header","Typography","Form","formikProps","enableReinitialize","onSubmit","initialValues","CONFIRM_FORM_INITIAL_VALUE","validationSchema","CONFIRM_FORM_VALIDATION_SCHEMA","_ref3","setFieldValue","Body","className","lineHeight","Select","name","options","map","_ref4","address","value","onChange","_ref5","Textarea","placeholder","Footer","ActionBlock","isSubmitting","position","cancelButtonProps","submitButtonProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAMA,aAAa,GAAG,SAAhBA,aAAaA,CAAAC,IAAA,EAMb;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,G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