@opexa/portal-components 0.0.15 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/client/hooks/index.d.ts +4 -0
  2. package/dist/client/hooks/useCreateGCashWithdrawalMutation.d.ts +4 -0
  3. package/dist/client/hooks/useCreateGCashWithdrawalMutation.js +1 -0
  4. package/dist/client/hooks/useCreateGCashWithdrawalMutation.mjs +38 -0
  5. package/dist/client/hooks/useCreateInstapayWithdrawalMutation.d.ts +4 -0
  6. package/dist/client/hooks/useCreateInstapayWithdrawalMutation.js +1 -0
  7. package/dist/client/hooks/useCreateInstapayWithdrawalMutation.mjs +38 -0
  8. package/dist/client/hooks/useCreateMayaAppWithdrawalMutation.d.ts +4 -0
  9. package/dist/client/hooks/useCreateMayaAppWithdrawalMutation.js +1 -0
  10. package/dist/client/hooks/useCreateMayaAppWithdrawalMutation.mjs +38 -0
  11. package/dist/client/hooks/useCreateMayaWithdrawalMutation.d.ts +4 -0
  12. package/dist/client/hooks/useCreateMayaWithdrawalMutation.js +1 -0
  13. package/dist/client/hooks/useCreateMayaWithdrawalMutation.mjs +38 -0
  14. package/dist/client/hooks/useDepositQuery.js +1 -1
  15. package/dist/client/hooks/useDepositQuery.mjs +12 -13
  16. package/dist/client/hooks/usePromoQuery.js +1 -1
  17. package/dist/client/hooks/usePromoQuery.mjs +13 -13
  18. package/dist/client-hooks.js +1 -1
  19. package/dist/client-hooks.mjs +84 -76
  20. package/dist/components/DepositWithdrawal/Deposit/AvailablePromos.js +1 -0
  21. package/dist/components/DepositWithdrawal/{AvailablePromos.mjs → Deposit/AvailablePromos.mjs} +31 -31
  22. package/dist/components/DepositWithdrawal/Deposit/GCashDeposit/GCashDeposit.js +1 -1
  23. package/dist/components/DepositWithdrawal/Deposit/GCashDeposit/GCashDeposit.mjs +1 -1
  24. package/dist/components/DepositWithdrawal/Deposit/MayaAppDeposit/MayaAppDeposit.js +1 -1
  25. package/dist/components/DepositWithdrawal/Deposit/MayaAppDeposit/MayaAppDeposit.mjs +4 -4
  26. package/dist/components/DepositWithdrawal/Deposit/MayaDeposit/MayaDeposit.js +1 -1
  27. package/dist/components/DepositWithdrawal/Deposit/MayaDeposit/MayaDeposit.mjs +1 -1
  28. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositForm.js +1 -1
  29. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositForm.mjs +75 -98
  30. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositForm.js +1 -1
  31. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositForm.mjs +1 -1
  32. package/dist/components/DepositWithdrawal/MayaSessionExpired.d.ts +1 -0
  33. package/dist/components/DepositWithdrawal/MayaSessionExpired.js +1 -0
  34. package/dist/components/DepositWithdrawal/{Deposit/MayaAppDeposit/SessionExpired.mjs → MayaSessionExpired.mjs} +3 -3
  35. package/dist/components/DepositWithdrawal/PaymentMethods.js +1 -1
  36. package/dist/components/DepositWithdrawal/PaymentMethods.mjs +23 -17
  37. package/dist/components/DepositWithdrawal/Withdrawal/GCashWithdrawal/GCashWithdrawal.d.ts +1 -0
  38. package/dist/components/DepositWithdrawal/Withdrawal/GCashWithdrawal/GCashWithdrawal.js +1 -0
  39. package/dist/components/DepositWithdrawal/Withdrawal/GCashWithdrawal/GCashWithdrawal.mjs +205 -0
  40. package/dist/components/DepositWithdrawal/Withdrawal/InstapayWithdrawal/InstapayWithdrawal.d.ts +1 -0
  41. package/dist/components/DepositWithdrawal/Withdrawal/InstapayWithdrawal/InstapayWithdrawal.js +1 -0
  42. package/dist/components/DepositWithdrawal/Withdrawal/InstapayWithdrawal/InstapayWithdrawal.mjs +264 -0
  43. package/dist/components/DepositWithdrawal/Withdrawal/MayaAppWithdrawal/MayaAppWithdrawal.d.ts +1 -0
  44. package/dist/components/DepositWithdrawal/Withdrawal/MayaAppWithdrawal/MayaAppWithdrawal.js +1 -0
  45. package/dist/components/DepositWithdrawal/Withdrawal/MayaAppWithdrawal/MayaAppWithdrawal.mjs +186 -0
  46. package/dist/components/DepositWithdrawal/Withdrawal/MayaWithdrawal/MayaWithdrawal.d.ts +1 -0
  47. package/dist/components/DepositWithdrawal/Withdrawal/MayaWithdrawal/MayaWithdrawal.js +1 -0
  48. package/dist/components/DepositWithdrawal/Withdrawal/MayaWithdrawal/MayaWithdrawal.mjs +205 -0
  49. package/dist/components/DepositWithdrawal/Withdrawal/Withdrawal.d.ts +1 -1
  50. package/dist/components/DepositWithdrawal/Withdrawal/Withdrawal.js +1 -1
  51. package/dist/components/DepositWithdrawal/Withdrawal/Withdrawal.mjs +81 -3
  52. package/dist/components/DepositWithdrawal/utils.d.ts +1 -1
  53. package/dist/components/DepositWithdrawal/utils.js +1 -1
  54. package/dist/components/DepositWithdrawal/utils.mjs +2 -1
  55. package/dist/components/Marquee/Marquee.js +1 -1
  56. package/dist/components/Marquee/Marquee.mjs +11 -13
  57. package/dist/images/instapay.png.js +1 -0
  58. package/dist/images/instapay.png.mjs +4 -0
  59. package/dist/theme.css +28 -2
  60. package/dist/ui/Field/field.recipe.js +1 -1
  61. package/dist/ui/Field/field.recipe.mjs +3 -3
  62. package/dist/ui/PasswordInput/PasswordInput.d.ts +1 -0
  63. package/dist/ui/PasswordInput/index.d.ts +1 -0
  64. package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +52 -0
  65. package/dist/utils/queryKeys.d.ts +4 -0
  66. package/dist/utils/queryKeys.js +1 -1
  67. package/dist/utils/queryKeys.mjs +50 -38
  68. package/dist/utils.js +1 -1
  69. package/dist/utils.mjs +48 -44
  70. package/package.json +3 -4
  71. package/dist/components/DepositWithdrawal/AvailablePromos.js +0 -1
  72. package/dist/components/DepositWithdrawal/Deposit/MayaAppDeposit/SessionExpired.d.ts +0 -1
  73. package/dist/components/DepositWithdrawal/Deposit/MayaAppDeposit/SessionExpired.js +0 -1
  74. package/dist/components/DepositWithdrawal/Withdrawal/GCashWithdrawal.d.ts +0 -1
  75. package/dist/components/DepositWithdrawal/Withdrawal/InstapayWithdrawal.d.ts +0 -1
  76. package/dist/components/DepositWithdrawal/Withdrawal/MayaAppWithdrawal.d.ts +0 -1
  77. package/dist/components/DepositWithdrawal/Withdrawal/MayaWithdrawal.d.ts +0 -1
  78. /package/dist/components/DepositWithdrawal/{AvailablePromos.d.ts → Deposit/AvailablePromos.d.ts} +0 -0
@@ -0,0 +1,264 @@
1
+ import { jsxs as r, jsx as e, Fragment as L } from "react/jsx-runtime";
2
+ import { createListCollection as T } from "@ark-ui/react";
3
+ import { zodResolver as V } from "@hookform/resolvers/zod";
4
+ import { useEffect as w, useMemo as W } from "react";
5
+ import { useForm as $, Controller as y } from "react-hook-form";
6
+ import { z as s } from "zod";
7
+ import { useShallow as D } from "zustand/shallow";
8
+ import "@opexa/portal-sdk-core";
9
+ import "@tanstack/react-query";
10
+ import "tiny-invariant";
11
+ import "../../../../constants/index.mjs";
12
+ import "../../../../utils/capitalize.mjs";
13
+ import { parseDecimal as c } from "../../../../utils/parseDecimal.mjs";
14
+ import "../../../../utils/getLocaleInfo.mjs";
15
+ import "../../../../utils/getQueryClient.mjs";
16
+ import "../../../../utils/isMobile.mjs";
17
+ import "lodash-es";
18
+ import "@opexa/portal-sdk-core/object-id";
19
+ import { useCreateInstapayWithdrawalMutation as R } from "../../../../client/hooks/useCreateInstapayWithdrawalMutation.mjs";
20
+ import { useGlobalStore as B } from "../../../../client/hooks/useGlobalStore.mjs";
21
+ import "../../../../client/hooks/useInfiniteQueryHelper.mjs";
22
+ import { useInstapayBankListQuery as M } from "../../../../client/hooks/useInstapayBankListQuery.mjs";
23
+ import "usehooks-ts";
24
+ import { usePaymentSettingsQuery as Q } from "../../../../client/hooks/usePaymentSettingsQuery.mjs";
25
+ import { toaster as I } from "../../../../client/utils/toaster.mjs";
26
+ import { CheckIcon as A } from "../../../../icons/CheckIcon.mjs";
27
+ import { ChevronDownIcon as S } from "../../../../icons/ChevronDownIcon.mjs";
28
+ import { ChevronUpIcon as E } from "../../../../icons/ChevronUpIcon.mjs";
29
+ import { SpinnerIcon as F } from "../../../../icons/SpinnerIcon.mjs";
30
+ import "../../../../ui/AlertDialog/AlertDialog.mjs";
31
+ import "../../../../ui/Avatar/Avatar.mjs";
32
+ import "../../../../ui/Badge/Badge.mjs";
33
+ import { Button as j } from "../../../../ui/Button/Button.mjs";
34
+ import "../../../../ui/Checkbox/Checkbox.mjs";
35
+ import "../../../../ui/Clipboard/Clipboard.mjs";
36
+ import "../../../../ui/DatePicker/DatePicker.mjs";
37
+ import "../../../../ui/Dialog/Dialog.mjs";
38
+ import "../../../../ui/Drawer/Drawer.mjs";
39
+ import { Root as d, ErrorText as p, Label as v, Input as x } from "../../../../ui/Field/Field.mjs";
40
+ import "../../../../ui/IconButton/iconButton.recipe.mjs";
41
+ import { Root as G, Label as U, Control as q, Input as z, IncrementTrigger as O, DecrementTrigger as Z } from "../../../../ui/NumberInput/NumberInput.mjs";
42
+ import "../../../../ui/PinInput/PinInput.mjs";
43
+ import "../../../../ui/Popover/Popover.mjs";
44
+ import "tailwind-merge";
45
+ import "../../../../ui/SegmentGroup/SegmentGroup.mjs";
46
+ import { Root as _, Label as H, Control as J, Trigger as K, ValueText as X, Indicator as Y, Positioner as ee, Content as oe, ItemGroup as te, Item as re, ItemText as ne, ItemIndicator as ie } from "../../../../ui/Select/Select.mjs";
47
+ import "../../../../ui/Table/Table.mjs";
48
+ import "../../../../ui/Tabs/Tabs.mjs";
49
+ import { AmountChoices as ae } from "../../AmountChoices.mjs";
50
+ function no() {
51
+ var g, C;
52
+ const k = B(
53
+ D((o) => ({
54
+ depositWithdrawal: o.depositWithdrawal
55
+ }))
56
+ ), h = R({
57
+ onSuccess() {
58
+ t.reset(), k.depositWithdrawal.setOpen(!1), I.success({
59
+ description: "Withdrawal request submitted successfully."
60
+ });
61
+ },
62
+ onError(o) {
63
+ I.error({
64
+ description: o.message
65
+ });
66
+ }
67
+ }), a = M().data, f = Q().data, l = f == null ? void 0 : f.instapayWithdrawalGatewaySettings, m = c(l == null ? void 0 : l.minimumAmount, 0), u = c(l == null ? void 0 : l.maximumAmount, 0), N = s.object({
68
+ amount: s.string().superRefine((o, i) => {
69
+ const n = c(o, 0);
70
+ n < m && i.addIssue({
71
+ type: "number",
72
+ code: s.ZodIssueCode.too_small,
73
+ inclusive: !0,
74
+ minimum: m,
75
+ message: `Minimum amount is ${m.toLocaleString()}`
76
+ }), n > u && i.addIssue({
77
+ type: "number",
78
+ code: s.ZodIssueCode.too_big,
79
+ inclusive: !0,
80
+ maximum: u,
81
+ message: `Maximum amount is ${u.toLocaleString()}`
82
+ });
83
+ }),
84
+ password: s.string().min(8, "Password must be 8 or more characters").max(64, "Password must be not be more than 64 characters"),
85
+ accountNumber: s.string().min(1).trim(),
86
+ bankCode: s.string().min(1, "Bank is required").trim()
87
+ }), t = $({
88
+ mode: "all",
89
+ resolver: V(N),
90
+ defaultValues: {
91
+ amount: "0",
92
+ password: "",
93
+ accountNumber: "",
94
+ bankCode: ""
95
+ }
96
+ });
97
+ w(() => {
98
+ m && t.reset({
99
+ amount: m.toString(),
100
+ bankCode: t.getValues("bankCode"),
101
+ password: "",
102
+ accountNumber: ""
103
+ });
104
+ }, [t, m]), w(() => {
105
+ a != null && a.length && t.reset({
106
+ amount: t.getValues("amount"),
107
+ bankCode: a[0].code,
108
+ password: "",
109
+ accountNumber: ""
110
+ });
111
+ }, [t, a]);
112
+ const P = t.handleSubmit(async (o) => {
113
+ h.mutate({
114
+ amount: o.amount,
115
+ transactionPassword: o.password,
116
+ accountNumber: o.accountNumber,
117
+ bankCode: o.bankCode
118
+ });
119
+ }), b = W(
120
+ () => T({
121
+ items: a ?? [],
122
+ itemToValue: (o) => o.code,
123
+ itemToString: (o) => o.name
124
+ }),
125
+ [a]
126
+ );
127
+ return console.log(b.items), /* @__PURE__ */ r("form", { onSubmit: P, noValidate: !0, autoComplete: "off", children: [
128
+ /* @__PURE__ */ e(
129
+ y,
130
+ {
131
+ control: t.control,
132
+ name: "bankCode",
133
+ render: (o) => {
134
+ var i;
135
+ return /* @__PURE__ */ r(d, { invalid: !!t.formState.errors.bankCode, children: [
136
+ /* @__PURE__ */ r(
137
+ _,
138
+ {
139
+ collection: b,
140
+ positioning: {
141
+ sameWidth: !0
142
+ },
143
+ value: o.field.value ? [o.field.value] : [],
144
+ onValueChange: (n) => {
145
+ o.field.onChange(n.value.at(0) ?? "");
146
+ },
147
+ children: [
148
+ /* @__PURE__ */ e(H, { children: "Bank" }),
149
+ /* @__PURE__ */ e(J, { children: /* @__PURE__ */ r(K, { children: [
150
+ /* @__PURE__ */ e(X, {}),
151
+ /* @__PURE__ */ e(Y, { asChild: !0, children: /* @__PURE__ */ e(S, {}) })
152
+ ] }) }),
153
+ /* @__PURE__ */ e(ee, { children: /* @__PURE__ */ e(oe, { children: /* @__PURE__ */ e(te, { children: b.items.map((n) => /* @__PURE__ */ r(re, { item: n, children: [
154
+ /* @__PURE__ */ e(ne, { children: n.name }),
155
+ /* @__PURE__ */ e(ie, { asChild: !0, children: /* @__PURE__ */ e(A, {}) })
156
+ ] }, n.id)) }) }) })
157
+ ]
158
+ }
159
+ ),
160
+ /* @__PURE__ */ e(p, { children: (i = t.formState.errors.bankCode) == null ? void 0 : i.message })
161
+ ] });
162
+ }
163
+ }
164
+ ),
165
+ /* @__PURE__ */ r(
166
+ d,
167
+ {
168
+ invalid: !!t.formState.errors.accountNumber,
169
+ className: "mt-3xl",
170
+ children: [
171
+ /* @__PURE__ */ e(v, { children: "Bank account number" }),
172
+ /* @__PURE__ */ e(x, { ...t.register("accountNumber") }),
173
+ /* @__PURE__ */ e(p, { children: (g = t.formState.errors.accountNumber) == null ? void 0 : g.message })
174
+ ]
175
+ }
176
+ ),
177
+ /* @__PURE__ */ e(
178
+ y,
179
+ {
180
+ control: t.control,
181
+ name: "amount",
182
+ render: (o) => {
183
+ var i;
184
+ return /* @__PURE__ */ r(
185
+ d,
186
+ {
187
+ invalid: !!t.formState.errors.amount,
188
+ className: "mt-3xl",
189
+ children: [
190
+ /* @__PURE__ */ r(
191
+ G,
192
+ {
193
+ min: 0,
194
+ step: 1,
195
+ value: o.field.value,
196
+ onValueChange: (n) => {
197
+ o.field.onChange(n.value);
198
+ },
199
+ formatOptions: {
200
+ maximumFractionDigits: 2,
201
+ minimumFractionDigits: 0
202
+ },
203
+ allowMouseWheel: !0,
204
+ children: [
205
+ /* @__PURE__ */ e(U, { children: "Enter amount you want to withdraw" }),
206
+ /* @__PURE__ */ r(q, { children: [
207
+ /* @__PURE__ */ e(z, {}),
208
+ /* @__PURE__ */ e(O, { children: /* @__PURE__ */ e(E, {}) }),
209
+ /* @__PURE__ */ e(Z, { children: /* @__PURE__ */ e(S, {}) })
210
+ ] })
211
+ ]
212
+ }
213
+ ),
214
+ /* @__PURE__ */ e(p, { children: (i = t.formState.errors.amount) == null ? void 0 : i.message })
215
+ ]
216
+ }
217
+ );
218
+ }
219
+ }
220
+ ),
221
+ /* @__PURE__ */ e(
222
+ ae,
223
+ {
224
+ value: c(t.watch("amount"), 0),
225
+ onChange: (o) => {
226
+ t.setValue("amount", o.toString(), {
227
+ shouldTouch: !0,
228
+ shouldDirty: !0,
229
+ shouldValidate: !0
230
+ });
231
+ },
232
+ min: m,
233
+ max: u,
234
+ className: "mt-xl"
235
+ }
236
+ ),
237
+ /* @__PURE__ */ r(d, { className: "mt-3xl", invalid: !!t.formState.errors.password, children: [
238
+ /* @__PURE__ */ e(v, { children: "Password" }),
239
+ /* @__PURE__ */ e(x, { type: "password", ...t.register("password") }),
240
+ /* @__PURE__ */ e(p, { children: (C = t.formState.errors.password) == null ? void 0 : C.message })
241
+ ] }),
242
+ /* @__PURE__ */ r("p", { className: "mt-4xl text-xs", children: [
243
+ "Upon clicking the deposit button, you agree to the",
244
+ " ",
245
+ /* @__PURE__ */ e("button", { type: "button", className: "underline underline-offset-2", children: "Terms of Use and Privacy Policy" }),
246
+ "."
247
+ ] }),
248
+ /* @__PURE__ */ e(
249
+ j,
250
+ {
251
+ type: "submit",
252
+ className: "mt-4.5",
253
+ disabled: h.isPending,
254
+ children: h.isPending ? /* @__PURE__ */ r(L, { children: [
255
+ /* @__PURE__ */ e(F, {}),
256
+ "Processing..."
257
+ ] }) : "Deposit"
258
+ }
259
+ )
260
+ ] });
261
+ }
262
+ export {
263
+ no as InstapayWithdrawal
264
+ };
@@ -0,0 +1 @@
1
+ export declare function MayaAppWithdrawal(): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("@hookform/resolvers/zod"),f=require("react"),q=require("react-hook-form"),u=require("zod"),b=require("zustand/shallow");require("@opexa/portal-sdk-core");require("@tanstack/react-query");require("tiny-invariant");require("../../../../constants/index.js");require("../../../../utils/capitalize.js");const l=require("../../../../utils/parseDecimal.js");require("../../../../utils/getLocaleInfo.js");require("../../../../utils/getQueryClient.js");require("../../../../utils/isMobile.js");require("lodash-es");require("@opexa/portal-sdk-core/object-id");const M=require("../../../../client/hooks/useCreateMayaAppWithdrawalMutation.js"),v=require("../../../../client/hooks/useGlobalStore.js");require("../../../../client/hooks/useInfiniteQueryHelper.js");const I=require("../../../../client/hooks/useIsMayaSessionValidQuery.js");require("usehooks-ts");const C=require("../../../../client/hooks/usePaymentSettingsQuery.js"),x=require("../../../../client/utils/toaster.js"),P=require("../../../../icons/ChevronDownIcon.js"),W=require("../../../../icons/ChevronUpIcon.js"),A=require("../../../../icons/SpinnerIcon.js");require("../../../../ui/AlertDialog/AlertDialog.js");require("../../../../ui/Avatar/Avatar.js");require("../../../../ui/Badge/Badge.js");const D=require("../../../../ui/Button/Button.js");require("../../../../ui/Checkbox/Checkbox.js");require("../../../../ui/Clipboard/Clipboard.js");require("../../../../ui/DatePicker/DatePicker.js");require("../../../../ui/Dialog/Dialog.js");require("../../../../ui/Drawer/Drawer.js");const i=require("../../../../ui/Field/Field.js");require("@ark-ui/react");require("../../../../ui/IconButton/iconButton.recipe.js");const n=require("../../../../ui/NumberInput/NumberInput.js");require("../../../../ui/PinInput/PinInput.js");require("../../../../ui/Popover/Popover.js");require("tailwind-merge");require("../../../../ui/SegmentGroup/SegmentGroup.js");require("../../../../ui/Select/Select.js");require("../../../../ui/Table/Table.js");require("../../../../ui/Tabs/Tabs.js");const V=require("../../AmountChoices.js"),z=require("../../MayaSessionExpired.js");function Q(){var h;const y=v.useGlobalStore(b.useShallow(r=>({depositWithdrawal:r.depositWithdrawal}))),d=M.useCreateMayaAppWithdrawalMutation({onSuccess(){s.reset(),y.depositWithdrawal.setOpen(!1),x.toaster.success({description:"Withdrawal request submitted successfully."})},onError(r){x.toaster.error({description:r.message})}}),g=I.useIsMayaSessionValidQuery().data??!0,p=C.usePaymentSettingsQuery().data,o=p==null?void 0:p.mayaAppWithdrawalGatewaySettings,c=l.parseDecimal(o==null?void 0:o.maximumAmount,0),t=l.parseDecimal(o==null?void 0:o.minimumAmount,0),w=u.z.object({amount:u.z.string().superRefine((r,a)=>{const m=l.parseDecimal(r,0);m<t&&a.addIssue({type:"number",code:u.z.ZodIssueCode.too_small,inclusive:!0,minimum:t,message:`Minimum amount is ${t.toLocaleString()}`}),m>c&&a.addIssue({type:"number",code:u.z.ZodIssueCode.too_big,inclusive:!0,maximum:c,message:`Maximum amount is ${c.toLocaleString()}`})}),password:u.z.string().min(8,"Password must be 8 or more characters").max(64,"Password must be not be more than 64 characters")}),s=q.useForm({mode:"all",resolver:j.zodResolver(w),defaultValues:{amount:"0",password:""}});f.useEffect(()=>{t&&s.reset({amount:t.toString(),password:""})},[s,t]);const S=s.handleSubmit(async r=>{d.mutate({amount:r.amount,transactionPassword:r.password})});return g?e.jsxs("form",{onSubmit:S,noValidate:!0,children:[e.jsx(q.Controller,{control:s.control,name:"amount",render:r=>{var a;return e.jsxs(i.Root,{invalid:!!s.formState.errors.amount,children:[e.jsxs(n.Root,{min:0,step:1,value:r.field.value,onValueChange:m=>{r.field.onChange(m.value)},formatOptions:{maximumFractionDigits:2,minimumFractionDigits:0},allowMouseWheel:!0,children:[e.jsx(n.Label,{children:"Enter amount you want to deposit"}),e.jsxs(n.Control,{children:[e.jsx(n.Input,{}),e.jsx(n.IncrementTrigger,{children:e.jsx(W.ChevronUpIcon,{})}),e.jsx(n.DecrementTrigger,{children:e.jsx(P.ChevronDownIcon,{})})]})]}),e.jsx(i.ErrorText,{children:(a=s.formState.errors.amount)==null?void 0:a.message})]})}}),e.jsx(V.AmountChoices,{value:l.parseDecimal(s.watch("amount"),0),onChange:r=>{s.setValue("amount",r.toString(),{shouldTouch:!0,shouldDirty:!0,shouldValidate:!0})},min:t,max:c,className:"mt-xl"}),e.jsxs(i.Root,{className:"mt-3xl",invalid:!!s.formState.errors.password,children:[e.jsx(i.Label,{children:"Transaction Password"}),e.jsx(i.Input,{type:"password",...s.register("password")}),e.jsx(i.ErrorText,{children:(h=s.formState.errors.password)==null?void 0:h.message})]}),e.jsxs("p",{className:"mt-4xl text-xs",children:["Upon clicking the deposit button, you agree to the"," ",e.jsx("button",{type:"button",className:"underline underline-offset-2",children:"Terms of Use and Privacy Policy"}),"."]}),e.jsx(D.Button,{type:"submit",className:"mt-4.5",disabled:d.isPending,children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(A.SpinnerIcon,{}),"Processing..."]}):"Withdraw"})]}):e.jsx(z.MayaSessionExpired,{})}exports.MayaAppWithdrawal=Q;
@@ -0,0 +1,186 @@
1
+ import { jsx as o, jsxs as i, Fragment as x } from "react/jsx-runtime";
2
+ import { zodResolver as v } from "@hookform/resolvers/zod";
3
+ import { useEffect as I } from "react";
4
+ import { useForm as M, Controller as C } from "react-hook-form";
5
+ import { z as a } from "zod";
6
+ import { useShallow as P } from "zustand/shallow";
7
+ import "@opexa/portal-sdk-core";
8
+ import "@tanstack/react-query";
9
+ import "tiny-invariant";
10
+ import "../../../../constants/index.mjs";
11
+ import "../../../../utils/capitalize.mjs";
12
+ import { parseDecimal as l } from "../../../../utils/parseDecimal.mjs";
13
+ import "../../../../utils/getLocaleInfo.mjs";
14
+ import "../../../../utils/getQueryClient.mjs";
15
+ import "../../../../utils/isMobile.mjs";
16
+ import "lodash-es";
17
+ import "@opexa/portal-sdk-core/object-id";
18
+ import { useCreateMayaAppWithdrawalMutation as W } from "../../../../client/hooks/useCreateMayaAppWithdrawalMutation.mjs";
19
+ import { useGlobalStore as V } from "../../../../client/hooks/useGlobalStore.mjs";
20
+ import "../../../../client/hooks/useInfiniteQueryHelper.mjs";
21
+ import { useIsMayaSessionValidQuery as A } from "../../../../client/hooks/useIsMayaSessionValidQuery.mjs";
22
+ import "usehooks-ts";
23
+ import { usePaymentSettingsQuery as D } from "../../../../client/hooks/usePaymentSettingsQuery.mjs";
24
+ import { toaster as f } from "../../../../client/utils/toaster.mjs";
25
+ import { ChevronDownIcon as Q } from "../../../../icons/ChevronDownIcon.mjs";
26
+ import { ChevronUpIcon as T } from "../../../../icons/ChevronUpIcon.mjs";
27
+ import { SpinnerIcon as E } from "../../../../icons/SpinnerIcon.mjs";
28
+ import "../../../../ui/AlertDialog/AlertDialog.mjs";
29
+ import "../../../../ui/Avatar/Avatar.mjs";
30
+ import "../../../../ui/Badge/Badge.mjs";
31
+ import { Button as L } from "../../../../ui/Button/Button.mjs";
32
+ import "../../../../ui/Checkbox/Checkbox.mjs";
33
+ import "../../../../ui/Clipboard/Clipboard.mjs";
34
+ import "../../../../ui/DatePicker/DatePicker.mjs";
35
+ import "../../../../ui/Dialog/Dialog.mjs";
36
+ import "../../../../ui/Drawer/Drawer.mjs";
37
+ import { Root as h, ErrorText as g, Label as N, Input as R } from "../../../../ui/Field/Field.mjs";
38
+ import "@ark-ui/react";
39
+ import "../../../../ui/IconButton/iconButton.recipe.mjs";
40
+ import { Root as $, Label as F, Control as j, Input as U, IncrementTrigger as z, DecrementTrigger as G } from "../../../../ui/NumberInput/NumberInput.mjs";
41
+ import "../../../../ui/PinInput/PinInput.mjs";
42
+ import "../../../../ui/Popover/Popover.mjs";
43
+ import "tailwind-merge";
44
+ import "../../../../ui/SegmentGroup/SegmentGroup.mjs";
45
+ import "../../../../ui/Select/Select.mjs";
46
+ import "../../../../ui/Table/Table.mjs";
47
+ import "../../../../ui/Tabs/Tabs.mjs";
48
+ import { AmountChoices as O } from "../../AmountChoices.mjs";
49
+ import { MayaSessionExpired as Z } from "../../MayaSessionExpired.mjs";
50
+ function Oo() {
51
+ var c;
52
+ const y = V(
53
+ P((t) => ({
54
+ depositWithdrawal: t.depositWithdrawal
55
+ }))
56
+ ), p = W({
57
+ onSuccess() {
58
+ r.reset(), y.depositWithdrawal.setOpen(!1), f.success({
59
+ description: "Withdrawal request submitted successfully."
60
+ });
61
+ },
62
+ onError(t) {
63
+ f.error({
64
+ description: t.message
65
+ });
66
+ }
67
+ }), w = A().data ?? !0, d = D().data, m = d == null ? void 0 : d.mayaAppWithdrawalGatewaySettings, n = l(m == null ? void 0 : m.maximumAmount, 0), e = l(m == null ? void 0 : m.minimumAmount, 0), b = a.object({
68
+ amount: a.string().superRefine((t, s) => {
69
+ const u = l(t, 0);
70
+ u < e && s.addIssue({
71
+ type: "number",
72
+ code: a.ZodIssueCode.too_small,
73
+ inclusive: !0,
74
+ minimum: e,
75
+ message: `Minimum amount is ${e.toLocaleString()}`
76
+ }), u > n && s.addIssue({
77
+ type: "number",
78
+ code: a.ZodIssueCode.too_big,
79
+ inclusive: !0,
80
+ maximum: n,
81
+ message: `Maximum amount is ${n.toLocaleString()}`
82
+ });
83
+ }),
84
+ password: a.string().min(8, "Password must be 8 or more characters").max(64, "Password must be not be more than 64 characters")
85
+ }), r = M({
86
+ mode: "all",
87
+ resolver: v(b),
88
+ defaultValues: {
89
+ amount: "0",
90
+ password: ""
91
+ }
92
+ });
93
+ I(() => {
94
+ e && r.reset({
95
+ amount: e.toString(),
96
+ password: ""
97
+ });
98
+ }, [r, e]);
99
+ const S = r.handleSubmit(async (t) => {
100
+ p.mutate({
101
+ amount: t.amount,
102
+ transactionPassword: t.password
103
+ });
104
+ });
105
+ return w ? /* @__PURE__ */ i("form", { onSubmit: S, noValidate: !0, children: [
106
+ /* @__PURE__ */ o(
107
+ C,
108
+ {
109
+ control: r.control,
110
+ name: "amount",
111
+ render: (t) => {
112
+ var s;
113
+ return /* @__PURE__ */ i(h, { invalid: !!r.formState.errors.amount, children: [
114
+ /* @__PURE__ */ i(
115
+ $,
116
+ {
117
+ min: 0,
118
+ step: 1,
119
+ value: t.field.value,
120
+ onValueChange: (u) => {
121
+ t.field.onChange(u.value);
122
+ },
123
+ formatOptions: {
124
+ maximumFractionDigits: 2,
125
+ minimumFractionDigits: 0
126
+ },
127
+ allowMouseWheel: !0,
128
+ children: [
129
+ /* @__PURE__ */ o(F, { children: "Enter amount you want to deposit" }),
130
+ /* @__PURE__ */ i(j, { children: [
131
+ /* @__PURE__ */ o(U, {}),
132
+ /* @__PURE__ */ o(z, { children: /* @__PURE__ */ o(T, {}) }),
133
+ /* @__PURE__ */ o(G, { children: /* @__PURE__ */ o(Q, {}) })
134
+ ] })
135
+ ]
136
+ }
137
+ ),
138
+ /* @__PURE__ */ o(g, { children: (s = r.formState.errors.amount) == null ? void 0 : s.message })
139
+ ] });
140
+ }
141
+ }
142
+ ),
143
+ /* @__PURE__ */ o(
144
+ O,
145
+ {
146
+ value: l(r.watch("amount"), 0),
147
+ onChange: (t) => {
148
+ r.setValue("amount", t.toString(), {
149
+ shouldTouch: !0,
150
+ shouldDirty: !0,
151
+ shouldValidate: !0
152
+ });
153
+ },
154
+ min: e,
155
+ max: n,
156
+ className: "mt-xl"
157
+ }
158
+ ),
159
+ /* @__PURE__ */ i(h, { className: "mt-3xl", invalid: !!r.formState.errors.password, children: [
160
+ /* @__PURE__ */ o(N, { children: "Transaction Password" }),
161
+ /* @__PURE__ */ o(R, { type: "password", ...r.register("password") }),
162
+ /* @__PURE__ */ o(g, { children: (c = r.formState.errors.password) == null ? void 0 : c.message })
163
+ ] }),
164
+ /* @__PURE__ */ i("p", { className: "mt-4xl text-xs", children: [
165
+ "Upon clicking the deposit button, you agree to the",
166
+ " ",
167
+ /* @__PURE__ */ o("button", { type: "button", className: "underline underline-offset-2", children: "Terms of Use and Privacy Policy" }),
168
+ "."
169
+ ] }),
170
+ /* @__PURE__ */ o(
171
+ L,
172
+ {
173
+ type: "submit",
174
+ className: "mt-4.5",
175
+ disabled: p.isPending,
176
+ children: p.isPending ? /* @__PURE__ */ i(x, { children: [
177
+ /* @__PURE__ */ o(E, {}),
178
+ "Processing..."
179
+ ] }) : "Withdraw"
180
+ }
181
+ )
182
+ ] }) : /* @__PURE__ */ o(Z, {});
183
+ }
184
+ export {
185
+ Oo as MayaAppWithdrawal
186
+ };
@@ -0,0 +1 @@
1
+ export declare function MayaWithdrawal(): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("@hookform/resolvers/zod"),S=require("react"),x=require("react-hook-form"),n=require("zod"),v=require("zustand/shallow");require("@opexa/portal-sdk-core");require("@tanstack/react-query");require("tiny-invariant");require("../../../../constants/index.js");require("../../../../utils/capitalize.js");const c=require("../../../../utils/parseDecimal.js");require("../../../../utils/getLocaleInfo.js");require("../../../../utils/getQueryClient.js");require("../../../../utils/isMobile.js");require("lodash-es");require("@opexa/portal-sdk-core/object-id");const I=require("../../../../client/hooks/useCreateMayaWithdrawalMutation.js"),C=require("../../../../client/hooks/useGlobalStore.js");require("../../../../client/hooks/useInfiniteQueryHelper.js");const M=require("../../../../client/hooks/useLocaleInfo.js"),P=require("../../../../client/hooks/useMobileNumberParser.js");require("usehooks-ts");const D=require("../../../../client/hooks/usePaymentSettingsQuery.js"),f=require("../../../../client/utils/toaster.js"),W=require("../../../../icons/ChevronDownIcon.js"),z=require("../../../../icons/ChevronUpIcon.js"),R=require("../../../../icons/SpinnerIcon.js");require("../../../../ui/AlertDialog/AlertDialog.js");require("../../../../ui/Avatar/Avatar.js");require("../../../../ui/Badge/Badge.js");const T=require("../../../../ui/Button/Button.js");require("../../../../ui/Checkbox/Checkbox.js");require("../../../../ui/Clipboard/Clipboard.js");require("../../../../ui/DatePicker/DatePicker.js");require("../../../../ui/Dialog/Dialog.js");require("../../../../ui/Drawer/Drawer.js");const t=require("../../../../ui/Field/Field.js");require("@ark-ui/react");require("../../../../ui/IconButton/iconButton.recipe.js");const a=require("../../../../ui/NumberInput/NumberInput.js");require("../../../../ui/PinInput/PinInput.js");require("../../../../ui/Popover/Popover.js");require("tailwind-merge");require("../../../../ui/SegmentGroup/SegmentGroup.js");require("../../../../ui/Select/Select.js");require("../../../../ui/Table/Table.js");require("../../../../ui/Tabs/Tabs.js");const L=require("../../AmountChoices.js");function A(){var q,p;const g=C.useGlobalStore(v.useShallow(s=>({depositWithdrawal:s.depositWithdrawal}))),h=M.useLocaleInfo(),j=P.useMobileNumberParser(),d=I.useCreateMayaWithdrawalMutation({onSuccess(){r.reset(),g.depositWithdrawal.setOpen(!1),f.toaster.success({description:"Withdrawal request submitted successfully."})},onError(s){f.toaster.error({description:s.message})}}),b=D.usePaymentSettingsQuery().data,i=b==null?void 0:b.mayaWithdrawalGatewaySettings,o=c.parseDecimal(i==null?void 0:i.minimumAmount,0),m=c.parseDecimal(i==null?void 0:i.maximumAmount,0),w=n.z.object({amount:n.z.string().superRefine((s,u)=>{const l=c.parseDecimal(s,0);l<o&&u.addIssue({type:"number",code:n.z.ZodIssueCode.too_small,inclusive:!0,minimum:o,message:`Minimum amount is ${o.toLocaleString()}`}),l>m&&u.addIssue({type:"number",code:n.z.ZodIssueCode.too_big,inclusive:!0,maximum:m,message:`Maximum amount is ${m.toLocaleString()}`})}),password:n.z.string().min(8,"Password must be 8 or more characters").max(64,"Password must be not be more than 64 characters"),mobileNumber:n.z.string().regex(h.mobileNumber.pattern,"Invalid mobile number")}),r=x.useForm({mode:"all",resolver:N.zodResolver(w),defaultValues:{amount:"0",password:"",mobileNumber:""}});S.useEffect(()=>{o&&r.reset({amount:o.toString(),password:"",mobileNumber:""})},[r,o]);const y=r.handleSubmit(async s=>{d.mutate({amount:s.amount,recipientMobileNumber:j.format(s.mobileNumber),transactionPassword:s.password})});return e.jsxs("form",{onSubmit:y,noValidate:!0,autoComplete:"off",children:[e.jsxs(t.Root,{invalid:!!r.formState.errors.mobileNumber,children:[e.jsx(t.Label,{children:"Mobile Number"}),e.jsxs("div",{className:"relative",children:[e.jsx(h.country.flag,{className:"pointer-events-none absolute left-3.5 top-1/2 size-5 -translate-y-1/2"}),e.jsx(t.Input,{className:"pl-10.5",...r.register("mobileNumber")})]}),e.jsx(t.ErrorText,{children:(q=r.formState.errors.mobileNumber)==null?void 0:q.message})]}),e.jsx(x.Controller,{control:r.control,name:"amount",render:s=>{var u;return e.jsxs(t.Root,{invalid:!!r.formState.errors.amount,className:"mt-3xl",children:[e.jsxs(a.Root,{min:0,step:1,value:s.field.value,onValueChange:l=>{s.field.onChange(l.value)},formatOptions:{maximumFractionDigits:2,minimumFractionDigits:0},allowMouseWheel:!0,children:[e.jsx(a.Label,{children:"Enter amount you want to withdraw"}),e.jsxs(a.Control,{children:[e.jsx(a.Input,{}),e.jsx(a.IncrementTrigger,{children:e.jsx(z.ChevronUpIcon,{})}),e.jsx(a.DecrementTrigger,{children:e.jsx(W.ChevronDownIcon,{})})]})]}),e.jsx(t.ErrorText,{children:(u=r.formState.errors.amount)==null?void 0:u.message})]})}}),e.jsx(L.AmountChoices,{value:c.parseDecimal(r.watch("amount"),0),onChange:s=>{r.setValue("amount",s.toString(),{shouldTouch:!0,shouldDirty:!0,shouldValidate:!0})},min:o,max:m,className:"mt-xl"}),e.jsxs(t.Root,{className:"mt-3xl",invalid:!!r.formState.errors.password,children:[e.jsx(t.Label,{children:"Password"}),e.jsx(t.Input,{type:"password",...r.register("password")}),e.jsx(t.ErrorText,{children:(p=r.formState.errors.password)==null?void 0:p.message})]}),e.jsxs("p",{className:"mt-4xl text-xs",children:["Upon clicking the deposit button, you agree to the"," ",e.jsx("button",{type:"button",className:"underline underline-offset-2",children:"Terms of Use and Privacy Policy"}),"."]}),e.jsx(T.Button,{type:"submit",className:"mt-4.5",disabled:d.isPending,children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(R.SpinnerIcon,{}),"Processing..."]}):"Deposit"})]})}exports.MayaWithdrawal=A;