@opexa/portal-components 0.0.38 → 0.0.41

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 (77) hide show
  1. package/dist/client/hooks/useGlobalStore.d.ts +1 -2
  2. package/dist/client/hooks/useGlobalStore.js +19 -36
  3. package/dist/components/Account/Account.d.ts +1 -7
  4. package/dist/components/Account/Account.js +15 -40
  5. package/dist/components/AccountInfo/AccountInfo.js +20 -3
  6. package/dist/components/AccountSecurity/AccountSecurity.js +14 -6
  7. package/dist/components/AccountVerification/AccountVerification.js +5 -32
  8. package/dist/components/AccountVerification/AccountVerificationContext.d.ts +14 -0
  9. package/dist/components/AccountVerification/AccountVerificationContext.js +27 -0
  10. package/dist/components/AccountVerification/VerificationCapture.d.ts +1 -1
  11. package/dist/components/AccountVerification/VerificationCapture.js +16 -45
  12. package/dist/components/AccountVerification/VerificationComplete.d.ts +1 -0
  13. package/dist/components/AccountVerification/VerificationComplete.js +9 -0
  14. package/dist/components/AccountVerification/VerificationDetails.d.ts +1 -0
  15. package/dist/components/AccountVerification/VerificationDetails.js +38 -0
  16. package/dist/components/DepositWithdrawal/AmountChoices.js +1 -1
  17. package/dist/components/DepositWithdrawal/Deposit/AvailablePromos.js +21 -16
  18. package/dist/components/DepositWithdrawal/Deposit/GCashDeposit/GCashDeposit.js +4 -23
  19. package/dist/components/DepositWithdrawal/Deposit/MayaAppDeposit/MayaAppDeposit.js +4 -23
  20. package/dist/components/DepositWithdrawal/Deposit/MayaDeposit/MayaDeposit.js +4 -23
  21. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositForm.js +5 -24
  22. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositForm.js +4 -23
  23. package/dist/components/DepositWithdrawal/DepositWithdrawal.js +3 -3
  24. package/dist/components/DepositWithdrawal/PaymentMethods.js +2 -2
  25. package/dist/components/DepositWithdrawal/Withdrawal/Withdrawal.js +27 -20
  26. package/dist/components/GameLaunch/GameLaunch.js +33 -57
  27. package/dist/components/KYC/KYC.d.ts +1 -0
  28. package/dist/components/KYC/KYC.js +3 -0
  29. package/dist/components/KYC/index.d.ts +1 -0
  30. package/dist/components/KYC/index.js +1 -0
  31. package/dist/components/Messages/MessageItem.js +12 -7
  32. package/dist/components/Messages/MessagePopup.js +8 -7
  33. package/dist/components/PortalProvider/PortalProvider.d.ts +2 -2
  34. package/dist/components/PortalProvider/PortalProvider.js +8 -5
  35. package/dist/components/PortalProvider/Providers.d.ts +4 -0
  36. package/dist/components/PortalProvider/Providers.js +12 -0
  37. package/dist/components/PortalProvider/Snackbar.d.ts +1 -0
  38. package/dist/components/PortalProvider/Snackbar.js +21 -0
  39. package/dist/components/PortalProvider/WebVitals.d.ts +1 -0
  40. package/dist/components/PortalProvider/WebVitals.js +8 -0
  41. package/dist/components/index.d.ts +1 -0
  42. package/dist/components/index.js +1 -0
  43. package/dist/images/gift.png +0 -0
  44. package/dist/tsconfig.build.tsbuildinfo +1 -1
  45. package/dist/types/index.d.ts +1 -1
  46. package/dist/ui/AlertDialog/AlertDialog.d.ts +154 -154
  47. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +14 -14
  48. package/dist/ui/AlertDialog/alertDialog.recipe.js +4 -4
  49. package/dist/ui/Badge/Badge.d.ts +12 -12
  50. package/dist/ui/Badge/badge.recipe.d.ts +3 -3
  51. package/dist/ui/Button/button.recipe.js +1 -1
  52. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  53. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  54. package/dist/ui/Checkbox/checkbox.recipe.js +2 -2
  55. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  56. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  57. package/dist/ui/Collapsible/Collapsible.d.ts +20 -20
  58. package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
  59. package/dist/ui/Combobox/Combobox.d.ts +196 -196
  60. package/dist/ui/Combobox/combobox.recipe.d.ts +14 -14
  61. package/dist/ui/DatePicker/DatePicker.d.ts +192 -192
  62. package/dist/ui/DatePicker/datePicker.recipe.d.ts +8 -8
  63. package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
  64. package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
  65. package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
  66. package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
  67. package/dist/ui/Popover/Popover.d.ts +55 -55
  68. package/dist/ui/Popover/popover.recipe.d.ts +5 -5
  69. package/dist/ui/Progress/Progress.d.ts +27 -27
  70. package/dist/ui/Progress/progress.recipe.d.ts +3 -3
  71. package/dist/ui/Select/Select.d.ts +45 -45
  72. package/dist/ui/Select/select.recipe.d.ts +3 -3
  73. package/dist/ui/Table/Table.d.ts +21 -21
  74. package/dist/ui/Table/table.recipe.d.ts +3 -3
  75. package/dist/ui/Tabs/Tabs.d.ts +15 -15
  76. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  77. package/package.json +7 -6
@@ -17,7 +17,7 @@ export function AmountChoices(props) {
17
17
  });
18
18
  return (_jsx("div", { className: twMerge('grid grid-cols-4 gap-2', props.className), children: options.map((option) => (_jsx(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
19
19
  setValue(option);
20
- }, disabled: min > option || max < option, "data-selected": dataAttr(value === option), children: formatNumber(option, {
20
+ }, disabled: min > option || max < option, className: "ui-selected:border-button-primary-border ui-selected:bg-button-primary-bg ui-selected:text-button-primary-fg", "data-selected": dataAttr(value === option), children: formatNumber(option, {
21
21
  currency: localeInfo.currency.code,
22
22
  minDecimalPlaces: 0,
23
23
  maxDecimalPlaces: 0,
@@ -1,16 +1,11 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Carousel } from '@ark-ui/react';
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createListCollection } from '@ark-ui/react';
3
3
  import Image from 'next/image';
4
- import Link from 'next/link';
5
- import { twMerge } from 'tailwind-merge';
6
- import { useShallow } from 'zustand/shallow';
7
- import { useAvailablePromosQuery, useControllableState, useGlobalStore, } from '../../../client/hooks/index.js';
8
- import { CheckIcon, ChevronLeftIcon, ChevronRightIcon } from '../../../icons/index.js';
9
- import { Checkbox, IconButton } from '../../../ui/index.js';
4
+ import { useAvailablePromosQuery, useControllableState, } from '../../../client/hooks/index.js';
5
+ import { CheckIcon, ChevronDownIcon } from '../../../icons/index.js';
6
+ import gift from '../../../images/gift.png';
7
+ import { Select } from '../../../ui/index.js';
10
8
  export function AvailablePromos(props) {
11
- const globalStore = useGlobalStore(useShallow((ctx) => ({
12
- depositWithdrawal: ctx.depositWithdrawal,
13
- })));
14
9
  const query = useAvailablePromosQuery();
15
10
  const promos = query.data ?? [];
16
11
  const [value, setValue] = useControllableState({
@@ -18,9 +13,19 @@ export function AvailablePromos(props) {
18
13
  defaultValue: props.defaultValue ?? null,
19
14
  onChange: props.onChange,
20
15
  });
21
- return (_jsxs(Carousel.Root, { slideCount: promos.length, className: props.className, spacing: "16px", slidesPerPage: 2, children: [_jsxs("div", { className: "flex items-center gap-xl", children: [_jsxs("div", { className: "grow", children: [_jsx("h2", { className: "text-lg font-semibold leading-tight", children: "Available Promotions" }), _jsx("p", { className: "text-gray-500 mt-1 text-sm leading-tight", children: "Select a promotion with your deposit. Only one can be active at a time." })] }), _jsxs(Carousel.Control, { children: [_jsx(Carousel.PrevTrigger, { asChild: true, children: _jsx(IconButton, { variant: "outline", colorScheme: "gray", className: "rounded-r-none border-r-0", children: _jsx(ChevronLeftIcon, {}) }) }), _jsx(Carousel.NextTrigger, { asChild: true, children: _jsx(IconButton, { variant: "outline", colorScheme: "gray", className: "rounded-l-none", children: _jsx(ChevronRightIcon, {}) }) })] })] }), _jsx(Carousel.ItemGroup, { className: "mt-3xl", children: promos.map((promo, index) => (_jsx(Carousel.Item, { index: index, children: _jsxs("div", { className: "relative select-none p-0.5", children: [_jsx("div", { className: twMerge('block rounded-lg', promo.id === value && 'ring-gray-500/25 ring-2'), children: promo.banner.url && (_jsx(Image, { src: promo.banner.url, alt: "", width: 288, height: 184, className: "rounded-lg" })) }), _jsxs(Checkbox.Root, { checked: promo.id === value, onCheckedChange: (details) => {
22
- setValue(details.checked ? promo.id : null);
23
- }, className: "absolute right-3 top-3 rounded-md border border-white/50 bg-white/60 p-lg backdrop-blur-sm", children: [_jsx(Checkbox.Control, { className: "bg-white", children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsx(Checkbox.HiddenInput, {})] }), _jsx(Link, { href: `/promos/${promo.id}`, className: "absolute bottom-3 right-3 rounded-md border border-white/50 bg-white/60 px-lg py-md text-sm font-semibold backdrop-blur-sm", onClick: () => {
24
- globalStore.depositWithdrawal.setOpen(false);
25
- }, children: "Promo Details" })] }) }, promo.id))) })] }));
16
+ const collection = createListCollection({
17
+ items: promos,
18
+ itemToValue: (item) => item.id,
19
+ itemToString: (item) => item.name,
20
+ });
21
+ return (_jsxs(Select.Root, { collection: collection, lazyMount: true, positioning: {
22
+ sameWidth: true,
23
+ }, value: value ? [value] : [], onValueChange: (details) => {
24
+ const value = details.value.at(0);
25
+ setValue(value ?? null);
26
+ }, className: props.className, children: [_jsx(Select.Label, { children: "Choose a bonus" }), _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, { placeholder: "Pay without bonus" }), _jsx(Select.Context, { children: (api) => (_jsx(_Fragment, { children: api.value.length ? (_jsx(Select.ClearTrigger, { asChild: true, children: _jsx("span", { onClick: (e) => {
27
+ e.stopPropagation();
28
+ }, children: "Clear" }) })) : (_jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })) })) })] }), _jsx(Select.Positioner, { children: _jsxs(Select.Content, { children: [collection.items.length <= 0 && (_jsxs("div", { className: "p-2", children: [_jsx(Image, { src: gift, alt: "", width: 160, height: 160, className: "mx-auto size-[8.313rem] grayscale" }), _jsx("p", { className: "text-text-tertiary-600 mx-auto mt-1 max-w-[20rem] text-center text-sm", children: "No Bonuses are available at the moment. Please check back later!" })] })), collection.items.length > 0 && (_jsx(Select.ItemGroup, { children: collection.items.map((promo) => (_jsxs(Select.Item, { item: promo, children: [_jsxs(Select.ItemText, { children: [_jsx("span", { className: "block font-medium", children: promo.name }), _jsx("span", { className: "text-text-warning-primary-600 line-clamp-1 block", dangerouslySetInnerHTML: {
29
+ __html: promo.description,
30
+ } })] }), _jsx(Select.ItemIndicator, { asChild: true, children: _jsx(CheckIcon, {}) })] }, promo.id))) }))] }) })] }));
26
31
  }
@@ -1,20 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Portal } from '@ark-ui/react';
3
2
  import { zodResolver } from '@hookform/resolvers/zod';
4
3
  import { useEffect } from 'react';
5
4
  import { Controller, useForm } from 'react-hook-form';
6
5
  import invariant from 'tiny-invariant';
7
6
  import { z } from 'zod';
8
7
  import { useShallow } from 'zustand/shallow';
9
- import { useAvailablePromosQuery, useCreateGCashDepositMutation, useDepositsCountQuery, useDisclosure, useGlobalStore, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
8
+ import { useAvailablePromosQuery, useCreateGCashDepositMutation, useDepositsCountQuery, useGlobalStore, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
10
9
  import { toaster } from '../../../../client/utils/index.js';
11
- import { AlertCircleIcon, ChevronDownIcon, ChevronUpIcon, SpinnerIcon, XIcon, } from '../../../../icons/index.js';
12
- import { AlertDialog, Button, Field, NumberInput } from '../../../../ui/index.js';
10
+ import { ChevronDownIcon, ChevronUpIcon, SpinnerIcon } from '../../../../icons/index.js';
11
+ import { Button, Field, NumberInput } from '../../../../ui/index.js';
13
12
  import { parseDecimal } from '../../../../utils/index.js';
14
13
  import { AmountChoices } from '../../AmountChoices.js';
15
14
  import { AvailablePromos } from '../AvailablePromos.js';
16
15
  export function GCashDeposit() {
17
- const disclosure = useDisclosure();
18
16
  const globalStore = useGlobalStore(useShallow((ctx) => ({
19
17
  depositWithdrawal: ctx.depositWithdrawal,
20
18
  })));
@@ -120,22 +118,5 @@ export function GCashDeposit() {
120
118
  shouldDirty: true,
121
119
  shouldValidate: true,
122
120
  });
123
- }, min: minimumAmount, max: maximumAmount, className: "mt-xl" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { className: "mt-4xl", value: o.field.value, onChange: o.field.onChange })) }), _jsxs("p", { className: "mt-4xl text-xs", children: ["Upon clicking the deposit button, you agree to the", ' ', _jsx("button", { type: "button", className: "underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(Button, { type: "submit", className: "mt-4.5", disabled: createDepositMutation.isPending, onClick: async (e) => {
124
- const ok = await form.trigger('amount');
125
- if (!ok)
126
- return;
127
- if (promos.length <= 0)
128
- return;
129
- if (form.getValues('promo'))
130
- return;
131
- e.preventDefault();
132
- disclosure.setOpen(true);
133
- }, children: createDepositMutation.isPending ? (_jsxs(_Fragment, { children: [_jsx(SpinnerIcon, {}), "Processing..."] })) : ('Deposit') }), _jsx(AlertDialog.Root, { role: "alertdialog", open: disclosure.open, onOpenChange: (details) => {
134
- disclosure.setOpen(details.open);
135
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+10)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+25)]", children: _jsxs(AlertDialog.Content, { children: [_jsxs(AlertDialog.Header, { children: [_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-[#FEE4E2] text-[#D92D20]", children: _jsx(AlertCircleIcon, {}) }), _jsx(AlertDialog.CloseTrigger, { children: _jsx(XIcon, {}) })] }), _jsxs(AlertDialog.Body, { children: [_jsx(AlertDialog.Title, { children: "Submit deposit request without promo?" }), _jsx(AlertDialog.Description, { children: "You haven\u2019t selected a promo. Are you sure you want to proceed without one?" })] }), _jsxs(AlertDialog.Footer, { children: [_jsx(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
136
- disclosure.setOpen(false);
137
- }, children: "Cancel" }), _jsx(Button, { onClick: () => {
138
- handleSubmit();
139
- disclosure.setOpen(false);
140
- }, children: "Proceed" })] })] }) })] }) })] }));
121
+ }, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: o.field.onChange, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: createDepositMutation.isPending ? (_jsxs(_Fragment, { children: [_jsx(SpinnerIcon, {}), "Processing..."] })) : ('Deposit') }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx("button", { type: "button", className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] })] }));
141
122
  }
@@ -1,20 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Portal } from '@ark-ui/react';
3
2
  import { zodResolver } from '@hookform/resolvers/zod';
4
3
  import { useEffect } from 'react';
5
4
  import { Controller, useForm } from 'react-hook-form';
6
5
  import { z } from 'zod';
7
6
  import { useShallow } from 'zustand/shallow';
8
- import { useAvailablePromosQuery, useCreateMayaAppDepositMutation, useDepositsCountQuery, useDisclosure, useGlobalStore, useIsMayaSessionValidQuery, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
7
+ import { useAvailablePromosQuery, useCreateMayaAppDepositMutation, useDepositsCountQuery, useGlobalStore, useIsMayaSessionValidQuery, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
9
8
  import { toaster } from '../../../../client/utils/index.js';
10
- import { AlertCircleIcon, ChevronDownIcon, ChevronUpIcon, SpinnerIcon, XIcon, } from '../../../../icons/index.js';
11
- import { AlertDialog, Button, Field, NumberInput } from '../../../../ui/index.js';
9
+ import { ChevronDownIcon, ChevronUpIcon, SpinnerIcon } from '../../../../icons/index.js';
10
+ import { Button, Field, NumberInput } from '../../../../ui/index.js';
12
11
  import { parseDecimal } from '../../../../utils/index.js';
13
12
  import { AmountChoices } from '../../AmountChoices.js';
14
13
  import { MayaSessionExpired } from '../../MayaSessionExpired.js';
15
14
  import { AvailablePromos } from '../AvailablePromos.js';
16
15
  export function MayaAppDeposit() {
17
- const disclosure = useDisclosure();
18
16
  const globalStore = useGlobalStore(useShallow((ctx) => ({
19
17
  depositWithdrawal: ctx.depositWithdrawal,
20
18
  })));
@@ -126,22 +124,5 @@ export function MayaAppDeposit() {
126
124
  shouldDirty: true,
127
125
  shouldValidate: true,
128
126
  });
129
- }, min: minimumAmount, max: maximumAmount, className: "mt-xl" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { className: "mt-4xl", value: o.field.value, onChange: o.field.onChange })) }), _jsxs("p", { className: "mt-4xl text-xs", children: ["Upon clicking the deposit button, you agree to the", ' ', _jsx("button", { type: "button", className: "underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(Button, { type: "submit", className: "mt-4.5", disabled: createDepositMutation.isPending, onClick: async (e) => {
130
- const ok = await form.trigger('amount');
131
- if (!ok)
132
- return;
133
- if (promos.length <= 0)
134
- return;
135
- if (form.getValues('promo'))
136
- return;
137
- e.preventDefault();
138
- disclosure.setOpen(true);
139
- }, children: createDepositMutation.isPending ? (_jsxs(_Fragment, { children: [_jsx(SpinnerIcon, {}), "Processing..."] })) : ('Deposit') }), _jsx(AlertDialog.Root, { role: "alertdialog", open: disclosure.open, onOpenChange: (details) => {
140
- disclosure.setOpen(details.open);
141
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+10)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+25)]", children: _jsxs(AlertDialog.Content, { children: [_jsxs(AlertDialog.Header, { children: [_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-[#FEE4E2] text-[#D92D20]", children: _jsx(AlertCircleIcon, {}) }), _jsx(AlertDialog.CloseTrigger, { children: _jsx(XIcon, {}) })] }), _jsxs(AlertDialog.Body, { children: [_jsx(AlertDialog.Title, { children: "Submit deposit request without promo?" }), _jsx(AlertDialog.Description, { children: "You haven\u2019t selected a promo. Are you sure you want to proceed without one?" })] }), _jsxs(AlertDialog.Footer, { children: [_jsx(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
142
- disclosure.setOpen(false);
143
- }, children: "Cancel" }), _jsx(Button, { onClick: () => {
144
- handleSubmit();
145
- disclosure.setOpen(false);
146
- }, children: "Proceed" })] })] }) })] }) })] }));
127
+ }, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: o.field.onChange, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: createDepositMutation.isPending ? (_jsxs(_Fragment, { children: [_jsx(SpinnerIcon, {}), "Processing..."] })) : ('Deposit') }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx("button", { type: "button", className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] })] }));
147
128
  }
@@ -1,20 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Portal } from '@ark-ui/react';
3
2
  import { zodResolver } from '@hookform/resolvers/zod';
4
3
  import { useEffect } from 'react';
5
4
  import { Controller, useForm } from 'react-hook-form';
6
5
  import invariant from 'tiny-invariant';
7
6
  import { z } from 'zod';
8
7
  import { useShallow } from 'zustand/shallow';
9
- import { useAvailablePromosQuery, useCreateMayaDepositMutation, useDepositsCountQuery, useDisclosure, useGlobalStore, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
8
+ import { useAvailablePromosQuery, useCreateMayaDepositMutation, useDepositsCountQuery, useGlobalStore, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
10
9
  import { toaster } from '../../../../client/utils/index.js';
11
- import { AlertCircleIcon, ChevronDownIcon, ChevronUpIcon, SpinnerIcon, XIcon, } from '../../../../icons/index.js';
12
- import { AlertDialog, Button, Field, NumberInput } from '../../../../ui/index.js';
10
+ import { ChevronDownIcon, ChevronUpIcon, SpinnerIcon } from '../../../../icons/index.js';
11
+ import { Button, Field, NumberInput } from '../../../../ui/index.js';
13
12
  import { parseDecimal } from '../../../../utils/index.js';
14
13
  import { AmountChoices } from '../../AmountChoices.js';
15
14
  import { AvailablePromos } from '../AvailablePromos.js';
16
15
  export function MayaDeposit() {
17
- const disclosure = useDisclosure();
18
16
  const globalStore = useGlobalStore(useShallow((ctx) => ({
19
17
  depositWithdrawal: ctx.depositWithdrawal,
20
18
  })));
@@ -120,22 +118,5 @@ export function MayaDeposit() {
120
118
  shouldDirty: true,
121
119
  shouldValidate: true,
122
120
  });
123
- }, min: minimumAmount, max: maximumAmount, className: "mt-xl" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { className: "mt-4xl", value: o.field.value, onChange: o.field.onChange })) }), _jsxs("p", { className: "mt-4xl text-xs", children: ["Upon clicking the deposit button, you agree to the", ' ', _jsx("button", { type: "button", className: "underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(Button, { type: "submit", className: "mt-4.5", disabled: createDepositMutation.isPending, onClick: async (e) => {
124
- const ok = await form.trigger('amount');
125
- if (!ok)
126
- return;
127
- if (promos.length <= 0)
128
- return;
129
- if (form.getValues('promo'))
130
- return;
131
- e.preventDefault();
132
- disclosure.setOpen(true);
133
- }, children: createDepositMutation.isPending ? (_jsxs(_Fragment, { children: [_jsx(SpinnerIcon, {}), "Processing..."] })) : ('Deposit') }), _jsx(AlertDialog.Root, { role: "alertdialog", open: disclosure.open, onOpenChange: (details) => {
134
- disclosure.setOpen(details.open);
135
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+10)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+25)]", children: _jsxs(AlertDialog.Content, { children: [_jsxs(AlertDialog.Header, { children: [_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-[#FEE4E2] text-[#D92D20]", children: _jsx(AlertCircleIcon, {}) }), _jsx(AlertDialog.CloseTrigger, { children: _jsx(XIcon, {}) })] }), _jsxs(AlertDialog.Body, { children: [_jsx(AlertDialog.Title, { children: "Submit deposit request without promo?" }), _jsx(AlertDialog.Description, { children: "You haven\u2019t selected a promo. Are you sure you want to proceed without one?" })] }), _jsxs(AlertDialog.Footer, { children: [_jsx(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
136
- disclosure.setOpen(false);
137
- }, children: "Cancel" }), _jsx(Button, { onClick: () => {
138
- handleSubmit();
139
- disclosure.setOpen(false);
140
- }, children: "Proceed" })] })] }) })] }) })] }));
121
+ }, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: o.field.onChange, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: createDepositMutation.isPending ? (_jsxs(_Fragment, { children: [_jsx(SpinnerIcon, {}), "Processing..."] })) : ('Deposit') }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx("button", { type: "button", className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] })] }));
141
122
  }
@@ -1,20 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Portal } from '@ark-ui/react';
3
2
  import { zodResolver } from '@hookform/resolvers/zod';
4
3
  import { noop } from 'lodash-es';
5
4
  import { useEffect } from 'react';
6
5
  import { Controller, useForm } from 'react-hook-form';
7
6
  import { z } from 'zod';
8
- import { useAvailablePromosQuery, useDepositsCountQuery, useDisclosure, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
9
- import { AlertCircleIcon, ChevronDownIcon, ChevronUpIcon, XIcon, } from '../../../../icons/index.js';
10
- import { AlertDialog, Button, Field, NumberInput } from '../../../../ui/index.js';
7
+ import { useAvailablePromosQuery, useDepositsCountQuery, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
8
+ import { ChevronDownIcon, ChevronUpIcon } from '../../../../icons/index.js';
9
+ import { Button, Field, NumberInput } from '../../../../ui/index.js';
11
10
  import { parseDecimal } from '../../../../utils/index.js';
12
11
  import { AmountChoices } from '../../AmountChoices.js';
13
12
  import { AvailablePromos } from '../AvailablePromos.js';
14
13
  import { useOnlineBankDepositContext } from './OnlineBankDepositContext.js';
15
14
  export function OnlineBankDepositForm() {
16
15
  const context = useOnlineBankDepositContext();
17
- const disclosure = useDisclosure();
18
16
  const depositsCountQuery = useDepositsCountQuery();
19
17
  const depositsCount = depositsCountQuery.data ?? 0;
20
18
  const paymentSettingsQuery = usePaymentSettingsQuery();
@@ -97,7 +95,7 @@ export function OnlineBankDepositForm() {
97
95
  },
98
96
  });
99
97
  });
100
- return (_jsxs("form", { onSubmit: handleSubmit, noValidate: true, children: [_jsxs(Field.Root, { children: [_jsx(Field.Label, { children: "Bank" }), _jsx(Field.Input, { value: "BANKNET", onChange: noop, readOnly: true })] }), _jsx(Controller, { control: form.control, name: "amount", render: (o) => (_jsxs(Field.Root, { invalid: !!form.formState.errors.amount, className: "mt-4", children: [_jsxs(NumberInput.Root, { min: 0, step: 1, value: o.field.value, onValueChange: (details) => {
98
+ return (_jsxs("form", { onSubmit: handleSubmit, noValidate: true, children: [_jsxs(Field.Root, { children: [_jsx(Field.Label, { children: "Bank" }), _jsx(Field.Input, { value: "BANKNET", onChange: noop, readOnly: true })] }), _jsx(Controller, { control: form.control, name: "amount", render: (o) => (_jsxs(Field.Root, { invalid: !!form.formState.errors.amount, className: "mt-3xl", children: [_jsxs(NumberInput.Root, { min: 0, step: 1, value: o.field.value, onValueChange: (details) => {
101
99
  o.field.onChange(details.value);
102
100
  }, formatOptions: {
103
101
  maximumFractionDigits: 2,
@@ -108,22 +106,5 @@ export function OnlineBankDepositForm() {
108
106
  shouldDirty: true,
109
107
  shouldValidate: true,
110
108
  });
111
- }, min: minimumAmount, max: maximumAmount, className: "mt-xl" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { className: "mt-3xl", value: o.field.value, onChange: o.field.onChange })) }), _jsxs("p", { className: "mt-4xl text-xs", children: ["Upon clicking the deposit button, you agree to the", ' ', _jsx("button", { type: "button", className: "underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(Button, { type: "submit", className: "mt-4.5", onClick: async (e) => {
112
- const ok = await form.trigger('amount');
113
- if (!ok)
114
- return;
115
- if (promos.length <= 0)
116
- return;
117
- if (form.getValues('promo'))
118
- return;
119
- e.preventDefault();
120
- disclosure.setOpen(true);
121
- }, children: "Deposit" }), _jsx(AlertDialog.Root, { role: "alertdialog", open: disclosure.open, onOpenChange: (details) => {
122
- disclosure.setOpen(details.open);
123
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+10)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+25)]", children: _jsxs(AlertDialog.Content, { children: [_jsxs(AlertDialog.Header, { children: [_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-[#FEE4E2] text-[#D92D20]", children: _jsx(AlertCircleIcon, {}) }), _jsx(AlertDialog.CloseTrigger, { children: _jsx(XIcon, {}) })] }), _jsxs(AlertDialog.Body, { children: [_jsx(AlertDialog.Title, { children: "Submit deposit request without promo?" }), _jsx(AlertDialog.Description, { children: "You haven\u2019t selected a promo. Are you sure you want to proceed without one?" })] }), _jsxs(AlertDialog.Footer, { children: [_jsx(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
124
- disclosure.setOpen(false);
125
- }, children: "Cancel" }), _jsx(Button, { onClick: () => {
126
- handleSubmit();
127
- disclosure.setOpen(false);
128
- }, children: "Proceed" })] })] }) })] }) })] }));
109
+ }, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { className: "mt-3xl", value: o.field.value, onChange: o.field.onChange })) }), _jsx(Button, { type: "submit", className: "mt-3xl", children: "Deposit" }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx("button", { type: "button", className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] })] }));
129
110
  }
@@ -1,19 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Portal } from '@ark-ui/react';
3
2
  import { zodResolver } from '@hookform/resolvers/zod';
4
3
  import { useEffect } from 'react';
5
4
  import { Controller, useForm } from 'react-hook-form';
6
5
  import { z } from 'zod';
7
- import { useAvailablePromosQuery, useDepositsCountQuery, useDisclosure, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
8
- import { AlertCircleIcon, ChevronDownIcon, ChevronUpIcon, XIcon, } from '../../../../icons/index.js';
9
- import { AlertDialog, Button, Field, NumberInput } from '../../../../ui/index.js';
6
+ import { useAvailablePromosQuery, useDepositsCountQuery, usePaymentSettingsQuery, } from '../../../../client/hooks/index.js';
7
+ import { ChevronDownIcon, ChevronUpIcon } from '../../../../icons/index.js';
8
+ import { Button, Field, NumberInput } from '../../../../ui/index.js';
10
9
  import { parseDecimal } from '../../../../utils/index.js';
11
10
  import { AmountChoices } from '../../AmountChoices.js';
12
11
  import { AvailablePromos } from '../AvailablePromos.js';
13
12
  import { useQRPHDepositContext } from './QRPHDepositContext.js';
14
13
  export function QRPHDepositForm() {
15
14
  const context = useQRPHDepositContext();
16
- const disclosure = useDisclosure();
17
15
  const depositsCountQuery = useDepositsCountQuery();
18
16
  const depositsCount = depositsCountQuery.data ?? 0;
19
17
  const paymentSettingsQuery = usePaymentSettingsQuery();
@@ -107,22 +105,5 @@ export function QRPHDepositForm() {
107
105
  shouldDirty: true,
108
106
  shouldValidate: true,
109
107
  });
110
- }, min: minimumAmount, max: maximumAmount, className: "mt-xl" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { className: "mt-4xl", value: o.field.value, onChange: o.field.onChange })) }), _jsxs("p", { className: "mt-4xl text-xs", children: ["Upon clicking the deposit button, you agree to the", ' ', _jsx("button", { type: "button", className: "underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] }), _jsx(Button, { type: "submit", className: "mt-4.5", onClick: async (e) => {
111
- const ok = await form.trigger('amount');
112
- if (!ok)
113
- return;
114
- if (promos.length <= 0)
115
- return;
116
- if (form.getValues('promo'))
117
- return;
118
- e.preventDefault();
119
- disclosure.setOpen(true);
120
- }, children: "Deposit" }), _jsx(AlertDialog.Root, { role: "alertdialog", open: disclosure.open, onOpenChange: (details) => {
121
- disclosure.setOpen(details.open);
122
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+10)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+25)]", children: _jsxs(AlertDialog.Content, { children: [_jsxs(AlertDialog.Header, { children: [_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-[#FEE4E2] text-[#D92D20]", children: _jsx(AlertCircleIcon, {}) }), _jsx(AlertDialog.CloseTrigger, { children: _jsx(XIcon, {}) })] }), _jsxs(AlertDialog.Body, { children: [_jsx(AlertDialog.Title, { children: "Submit deposit request without promo?" }), _jsx(AlertDialog.Description, { children: "You haven\u2019t selected a promo. Are you sure you want to proceed without one?" })] }), _jsxs(AlertDialog.Footer, { children: [_jsx(Button, { variant: "outline", colorScheme: "gray", onClick: () => {
123
- disclosure.setOpen(false);
124
- }, children: "Cancel" }), _jsx(Button, { onClick: () => {
125
- handleSubmit();
126
- disclosure.setOpen(false);
127
- }, children: "Proceed" })] })] }) })] }) })] }));
108
+ }, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: o.field.onChange, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", children: "Deposit" }), _jsxs("p", { className: "text-text-tertiary-600 mt-lg text-xs", children: ["By depositing, you agree to our", ' ', _jsx("button", { type: "button", className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use and Privacy Policy" }), "."] })] }));
128
109
  }
@@ -6,7 +6,7 @@ import { z } from 'zod';
6
6
  import { useShallow } from 'zustand/shallow';
7
7
  import { useGlobalStore, useLocaleInfo, useWalletQuery, } from '../../client/hooks/index.js';
8
8
  import { Wallet02Icon, XIcon } from '../../icons/index.js';
9
- import { Dialog, Tabs } from '../../ui/index.js';
9
+ import { Dialog, IconButton, Tabs } from '../../ui/index.js';
10
10
  import { formatNumber } from '../../utils/index.js';
11
11
  import { Deposit } from './Deposit/Deposit.js';
12
12
  import { Withdrawal } from './Withdrawal/Withdrawal.js';
@@ -20,12 +20,12 @@ export function DepositWithdrawal(props) {
20
20
  });
21
21
  return (_jsxs(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: globalStore.depositWithdrawal.open, onOpenChange: (details) => {
22
22
  globalStore.depositWithdrawal.setOpen(details.open);
23
- }, closeOnEscape: false, closeOnInteractOutside: false, children: [_jsx(Dialog.Trigger, { asChild: true, children: props.children ?? _jsx(DefaulTrigger, {}) }), _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)]", children: _jsxs(Dialog.Content, { className: "lg:min-h-auto mx-auto min-h-full w-full p-2xl lg:w-[640px] lg:rounded-xl lg:p-3xl", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs(Dialog.Header, { className: "flex items-center gap-xl", children: [_jsx("div", { className: "border-border-secondary shadow-xs text-gray-700 flex size-12 items-center justify-center rounded-lg border", children: _jsx(Wallet02Icon, {}) }), _jsx(Dialog.Title, { className: "grow text-lg font-semibold", children: "Wallet" })] }), _jsxs(Dialog.Body, { className: "mt-5", children: [_jsx("p", { className: "text-gray-500 text-center text-sm font-medium leading-tight", children: "Available Balance" }), _jsx("p", { className: "mt-lg text-center text-4xl font-semibold leading-tight tracking-tight", children: formatNumber(walletQuery.data?.balance, {
23
+ }, closeOnEscape: false, closeOnInteractOutside: false, children: [_jsx(Dialog.Trigger, { asChild: true, children: props.children ?? _jsx(DefaulTrigger, {}) }), _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)]", children: _jsxs(Dialog.Content, { className: "lg:min-h-auto mx-auto min-h-full w-full px-4 py-3xl lg:w-[480px] lg:rounded-xl", children: [_jsxs(Dialog.Header, { className: "flex items-center gap-xl", children: [_jsx("div", { className: "border-border-primary shadow-xs text-gray-700 text-text-secondary-700 flex size-10 items-center justify-center rounded-md border", children: _jsx(Wallet02Icon, { className: "size-5" }) }), _jsx(Dialog.Title, { className: "grow text-lg font-semibold", children: "Wallet" }), _jsx(Dialog.Context, { children: (api) => (_jsx(IconButton, { size: "sm", variant: "outline", colorScheme: "gray", onClick: () => api.setOpen(false), children: _jsx(XIcon, {}) })) })] }), _jsxs(Dialog.Body, { className: "mt-3xl", children: [_jsx("p", { className: "text-text-secondary-700 text-center text-sm", children: "Deposit Balance" }), _jsx("p", { className: "text-center text-3xl font-bold leading-tight tracking-tight", children: formatNumber(walletQuery.data?.balance, {
24
24
  currency: localeInfo.currency.code,
25
25
  minDecimalPlaces: 2,
26
26
  }) }), _jsxs(Tabs.Root, { value: globalStore.depositWithdrawal.tab, onValueChange: (details) => {
27
27
  globalStore.depositWithdrawal.setTab(z.enum(['DEPOSIT', 'WITHDRAWAL']).parse(details.value));
28
- }, lazyMount: true, unmountOnExit: true, className: "mt-4xl space-y-4xl", children: [_jsxs(Tabs.List, { className: "w-full", children: [_jsx(Tabs.Trigger, { value: "DEPOSIT", className: "grow", children: "Deposit" }), _jsx(Tabs.Trigger, { value: "WITHDRAWAL", className: "grow", children: "Withdrawal" }), _jsx(Tabs.Indicator, {})] }), _jsx(Tabs.Content, { value: "DEPOSIT", className: "space-y-4xl", children: _jsx(Deposit, {}) }), _jsx(Tabs.Content, { value: "WITHDRAWAL", className: "space-y-4xl", children: _jsx(Withdrawal, {}) })] })] })] }) })] })] }));
28
+ }, lazyMount: true, unmountOnExit: true, className: "mt-3xl space-y-4xl", children: [_jsxs(Tabs.List, { className: "w-full", children: [_jsx(Tabs.Trigger, { value: "DEPOSIT", className: "grow", children: "Deposit" }), _jsx(Tabs.Trigger, { value: "WITHDRAWAL", className: "grow", children: "Withdrawal" }), _jsx(Tabs.Indicator, {})] }), _jsx(Tabs.Content, { value: "DEPOSIT", className: "space-y-3xl", children: _jsx(Deposit, {}) }), _jsx(Tabs.Content, { value: "WITHDRAWAL", className: "space-y-3xl", children: _jsx(Withdrawal, {}) })] })] })] }) })] })] }));
29
29
  }
30
30
  function DefaulTrigger(props) {
31
31
  const localeInfo = useLocaleInfo();
@@ -50,10 +50,10 @@ export function PaymentMethods(props) {
50
50
  defaultValue: props.defaultValue ?? options[0].value,
51
51
  onChange: props.onChange,
52
52
  });
53
- return (_jsxs("div", { className: props.className, children: [_jsx(Field.Label, { asChild: true, children: _jsx("div", { children: "Select your payment method" }) }), _jsx(Checkbox.Group, { value: [value], onValueChange: (newValue) => {
53
+ return (_jsxs("div", { className: props.className, children: [_jsx(Field.Label, { asChild: true, children: _jsx("div", { children: "Available payment methods" }) }), _jsx(Checkbox.Group, { value: [value], onValueChange: (newValue) => {
54
54
  const lastValue = newValue.at(-1);
55
55
  if (!lastValue)
56
56
  return;
57
57
  setValue(PaymentMethodDefinition.parse(lastValue));
58
- }, className: "grid grid-cols-2 gap-x-4 gap-y-3", children: options.map((option) => (_jsxs(Checkbox.Root, { value: option.value, className: "border-border-secondary ui-checked:border-gray-900 ui-checked:outline-solid ui-checked:outline-border-secondary flex cursor-pointer rounded-xl border p-xl ui-checked:outline", children: [_jsx("div", { className: "grow", children: _jsx(Image, { src: option.image, alt: "", width: 200, height: 40, className: "h-5 w-auto lg:h-8", draggable: false }) }), _jsx(Checkbox.Control, { className: "shrink-0", children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsx(Checkbox.HiddenInput, {})] }, option.value))) })] }));
58
+ }, className: "grid grid-cols-2 gap-x-4 gap-y-3", children: options.map((option) => (_jsxs(Checkbox.Root, { value: option.value, className: "border-border-secondary ui-checked:border-border-brand-solid ui-checked:outline-solid ui-checked:outline-border-brand-solid flex cursor-pointer rounded-xl border p-xl ui-checked:outline", children: [_jsx("div", { className: "grow", children: _jsx(Image, { src: option.image, alt: "", width: 200, height: 40, className: "h-5 w-auto lg:h-8", draggable: false }) }), _jsx(Checkbox.Control, { className: "shrink-0", children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsx(Checkbox.HiddenInput, {})] }, option.value))) })] }));
59
59
  }
@@ -1,10 +1,10 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import Link from 'next/link';
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
2
  import { useEffect, useState } from 'react';
4
3
  import { useShallow } from 'zustand/shallow';
5
- import { useAccountQuery, useGlobalStore, useOnMMA, usePaymentSettingsQuery, } from '../../../client/hooks/index.js';
6
- import { AlertCircleIcon, AlertTriangleIcon, ArrowRightIcon, SpinnerIcon, } from '../../../icons/index.js';
7
- import { onMobileDevice } from '../../../utils/index.js';
4
+ import { useAccountQuery, useGlobalStore, useOnMMA, usePaymentSettingsQuery, useWalletQuery, } from '../../../client/hooks/index.js';
5
+ import { AlertCircleIcon, SpinnerIcon } from '../../../icons/index.js';
6
+ import { Button } from '../../../ui/index.js';
7
+ import { onMobileDevice, parseDecimal } from '../../../utils/index.js';
8
8
  import { PaymentMethods } from '../PaymentMethods.js';
9
9
  import { GCashWithdrawal } from './GCashWithdrawal/GCashWithdrawal.js';
10
10
  import { InstapayWithdrawal } from './InstapayWithdrawal/InstapayWithdrawal.js';
@@ -12,6 +12,8 @@ import { MayaAppWithdrawal } from './MayaAppWithdrawal/MayaAppWithdrawal.js';
12
12
  import { MayaWithdrawal } from './MayaWithdrawal/MayaWithdrawal.js';
13
13
  export function Withdrawal() {
14
14
  const [onMMA] = useOnMMA();
15
+ const walletQuery = useWalletQuery();
16
+ const wallet = walletQuery.data;
15
17
  const accountQuery = useAccountQuery();
16
18
  const account = accountQuery.data;
17
19
  const paymentSettingsQuery = usePaymentSettingsQuery();
@@ -51,25 +53,30 @@ export function Withdrawal() {
51
53
  setPaymentMethod(enabledPaymentMethods[0]);
52
54
  }
53
55
  }, [enabledPaymentMethods, paymentMethod]);
54
- if (account) {
55
- if (!account.transactionPassword ||
56
- account.verificationStatus !== 'VERIFIED')
57
- return _jsx(WithdrawalNotAllowed, {});
58
- }
59
- if (paymentSettingsQuery.isLoading) {
56
+ if (accountQuery.isLoading ||
57
+ walletQuery.isLoading ||
58
+ paymentSettingsQuery.isLoading) {
60
59
  return _jsx(SpinnerIcon, { className: "mx-auto size-6" });
61
60
  }
61
+ if (parseDecimal(wallet?.balance, 0) < 1) {
62
+ return _jsx(InsufficientBalance, {});
63
+ }
64
+ if (!account?.transactionPassword ||
65
+ account.verificationStatus !== 'VERIFIED') {
66
+ return _jsx(AccountVerificationRequired, {});
67
+ }
62
68
  if (enabledPaymentMethods.length <= 0) {
63
- return (_jsxs("div", { className: "border-amber-200 text-amber-700 bg-amber-50 flex items-center gap-1.5 rounded-sm border px-3 py-2.5 text-sm", children: [_jsx(AlertCircleIcon, { className: "size-4" }), "No available payment methods"] }));
69
+ return _jsx(NoAvailablePaymentMethods, {});
64
70
  }
65
71
  return (_jsxs(_Fragment, { children: [_jsx(PaymentMethods, { value: paymentMethod, onChange: setPaymentMethod, options: enabledPaymentMethods }), paymentMethod === 'GCASH' && _jsx(GCashWithdrawal, {}), paymentMethod === 'MAYA' && _jsx(MayaWithdrawal, {}), paymentMethod === 'MAYA_APP' && _jsx(MayaAppWithdrawal, {}), paymentMethod === 'INSTAPAY' && _jsx(InstapayWithdrawal, {})] }));
66
72
  }
67
- function WithdrawalNotAllowed() {
68
- const globalStore = useGlobalStore(useShallow((ctx) => ({
69
- depositWithdrawal: ctx.depositWithdrawal,
70
- })));
71
- return (_jsxs("div", { className: "pb-16 pt-4xl lg:pb-12", children: [_jsx("div", { className: "bg-amber-50 text-amber-600 mx-auto flex size-12 items-center justify-center rounded-full lg:size-14", children: _jsx(AlertTriangleIcon, { className: "size-6 lg:size-7" }) }), _jsx("h2", { className: "mt-xl text-center text-lg font-semibold lg:text-2xl", children: "Verification and password not set" }), _jsx("p", { className: "text-gray-500 mx-auto mt-md max-w-[31.25rem] text-center text-sm lg:text-base", children: "To enable withdrawals, first complete the identity verification process and set up your transaction password." }), _jsxs(Link, { href: "/personal-center", className: "text-gray-900 mx-auto mt-2xl flex w-fit items-center gap-md font-semibold", onClick: () => {
72
- globalStore.depositWithdrawal.setOpen(false);
73
- globalStore.depositWithdrawal.setTab('WITHDRAWAL');
74
- }, children: ["Personal Center ", _jsx(ArrowRightIcon, { className: "size-5" })] })] }));
73
+ function AccountVerificationRequired() {
74
+ return (_jsxs("div", { className: "pt-xl", children: [_jsx("div", { className: "bg-bg-warning-secondary mx-auto flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, { className: "text-text-featured-icon-light-warning size-6" }) }), _jsx("h2", { className: "mt-lg text-center text-lg font-semibold", children: "Personal Verification" }), _jsx("p", { className: "text-text-tertiary-600 mx-auto mt-xs max-w-[25rem] text-center text-sm", children: "To withdraw funds, you must first verify your identity. Complete personal verification to ensure your account\u2019s security." }), _jsx(Button, { className: "mt-3xl", children: "Verify Now" })] }));
75
+ }
76
+ function InsufficientBalance() {
77
+ const setTab = useGlobalStore(useShallow((ctx) => ctx.depositWithdrawal.setTab));
78
+ return (_jsxs("div", { className: "pt-xl", children: [_jsx("div", { className: "bg-bg-warning-secondary mx-auto flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, { className: "text-text-featured-icon-light-warning size-6" }) }), _jsx("h2", { className: "mt-lg text-center text-lg font-semibold", children: "Balance is very low" }), _jsx("p", { className: "text-text-tertiary-600 mx-auto mt-xs max-w-[25rem] text-center text-sm", children: "No funds available for withdrawal. Please make a deposit." }), _jsx(Button, { className: "mt-3xl", onClick: () => setTab('DEPOSIT'), children: "Deposit" })] }));
79
+ }
80
+ function NoAvailablePaymentMethods() {
81
+ return (_jsxs("div", { className: "py-xl", children: [_jsx("div", { className: "bg-bg-warning-secondary mx-auto flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, { className: "text-text-featured-icon-light-warning size-6" }) }), _jsx("h2", { className: "mt-lg text-center text-lg font-semibold", children: "Not Available" }), _jsx("p", { className: "text-text-tertiary-600 mx-auto mt-xs max-w-[25rem] text-center text-sm", children: "Withdrawal is not available at this time. Please try again later or contact support for assistance." })] }));
75
82
  }