@opexa/portal-components 0.0.364 → 0.0.365

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.
@@ -15,15 +15,12 @@ import { useDisclosure } from '../../../../client/hooks/useDisclosure.js';
15
15
  import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
16
16
  import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSettingsQuery.js';
17
17
  import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
18
- import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
19
- import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
20
18
  import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
21
19
  import { XIcon } from '../../../../icons/XIcon.js';
22
20
  import { ObjectType } from '../../../../services/ObjectType.js';
23
21
  import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
24
22
  import { Button } from '../../../../ui/Button/index.js';
25
23
  import { Field } from '../../../../ui/Field/index.js';
26
- import { NumberInput } from '../../../../ui/NumberInput/index.js';
27
24
  import { Portal } from '../../../../ui/Portal/index.js';
28
25
  import { parseDecimal } from '../../../../utils/parseDecimal.js';
29
26
  import { AmountChoices } from '../../AmountChoices.js';
@@ -89,6 +86,13 @@ export function PisoPayDeposit() {
89
86
  .object({
90
87
  amount: z.string().superRefine((val, ctx) => {
91
88
  const n = parseDecimal(val, 0);
89
+ if (val.includes('.')) {
90
+ ctx.addIssue({
91
+ code: z.ZodIssueCode.custom,
92
+ message: 'Amount must be a whole number',
93
+ });
94
+ return;
95
+ }
92
96
  if (n < minimumAmount) {
93
97
  ctx.addIssue({
94
98
  type: 'number',
@@ -160,12 +164,7 @@ export function PisoPayDeposit() {
160
164
  promo: data.promo,
161
165
  }),
162
166
  });
163
- }), noValidate: true, children: [_jsx(Controller, { control: form.control, name: "amount", render: (o) => (_jsxs(Field.Root, { invalid: !!form.formState.errors.amount, children: [_jsxs(NumberInput.Root, { min: 0, step: 1, value: o.field.value, onValueChange: (details) => {
164
- o.field.onChange(details.value);
165
- }, formatOptions: {
166
- maximumFractionDigits: 2,
167
- minimumFractionDigits: 0,
168
- }, allowMouseWheel: true, children: [_jsx(NumberInput.Label, { children: "Enter amount you want to deposit" }), _jsxs(NumberInput.Control, { children: [_jsx(NumberInput.Input, {}), _jsx(NumberInput.IncrementTrigger, { children: _jsx(ChevronUpIcon, {}) }), _jsx(NumberInput.DecrementTrigger, { children: _jsx(ChevronDownIcon, {}) })] })] }), _jsx(Field.ErrorText, { children: form.formState.errors.amount?.message })] })) }), _jsx(AmountChoices, { value: parseDecimal(form.watch('amount'), 0), onChange: (value) => {
167
+ }), noValidate: true, children: [_jsxs(Field.Root, { invalid: !!form.formState.errors.amount, className: "mt-3xl", children: [_jsx(Field.Label, { children: "Enter amount you want to withdraw" }), _jsx(Field.Input, { type: "number", ...form.register('amount') }), _jsx(Field.ErrorText, { children: form.formState.errors.amount?.message })] }), _jsx(AmountChoices, { value: parseDecimal(form.watch('amount').trim().replace(/,/g, ''), 0), onChange: (value) => {
169
168
  form.setValue('amount', value.toString(), {
170
169
  shouldTouch: true,
171
170
  shouldDirty: true,
@@ -9,11 +9,8 @@ import { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePr
9
9
  import { useDepositsCountQuery } from '../../../../client/hooks/useDepositsCountQuery.js';
10
10
  import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
11
11
  import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSettingsQuery.js';
12
- import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
13
- import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
14
12
  import { Button } from '../../../../ui/Button/index.js';
15
13
  import { Field } from '../../../../ui/Field/index.js';
16
- import { NumberInput } from '../../../../ui/NumberInput/index.js';
17
14
  import { parseDecimal } from '../../../../utils/parseDecimal.js';
18
15
  import { AmountChoices } from '../../AmountChoices.js';
19
16
  import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
@@ -40,6 +37,13 @@ export function QRPHDepositForm() {
40
37
  .object({
41
38
  amount: z.string().superRefine((val, ctx) => {
42
39
  const n = parseDecimal(val, 0);
40
+ if (val.includes('.')) {
41
+ ctx.addIssue({
42
+ code: z.ZodIssueCode.custom,
43
+ message: 'Amount must be a whole number',
44
+ });
45
+ return;
46
+ }
43
47
  if (n < minimumAmount) {
44
48
  ctx.addIssue({
45
49
  type: 'number',
@@ -99,12 +103,7 @@ export function QRPHDepositForm() {
99
103
  }, [form, minimumAmount]);
100
104
  if (context.view !== 'form')
101
105
  return null;
102
- return (_jsxs("form", { onSubmit: form.handleSubmit(context.generateQRCode), noValidate: true, children: [_jsx(Controller, { control: form.control, name: "amount", render: (o) => (_jsxs(Field.Root, { invalid: !!form.formState.errors.amount, children: [_jsxs(NumberInput.Root, { min: 0, step: 1, value: o.field.value, onValueChange: (details) => {
103
- o.field.onChange(details.value);
104
- }, formatOptions: {
105
- maximumFractionDigits: 2,
106
- minimumFractionDigits: 0,
107
- }, allowMouseWheel: true, children: [_jsx(NumberInput.Label, { children: "Enter amount you want to deposit" }), _jsxs(NumberInput.Control, { children: [_jsx(NumberInput.Input, {}), _jsx(NumberInput.IncrementTrigger, { children: _jsx(ChevronUpIcon, {}) }), _jsx(NumberInput.DecrementTrigger, { children: _jsx(ChevronDownIcon, {}) })] })] }), _jsx(Field.ErrorText, { children: form.formState.errors.amount?.message })] })) }), _jsx(AmountChoices, { value: parseDecimal(form.watch('amount'), 0), onChange: (value) => {
106
+ return (_jsxs("form", { onSubmit: form.handleSubmit(context.generateQRCode), noValidate: true, children: [_jsxs(Field.Root, { invalid: !!form.formState.errors.amount, className: "mt-3xl", children: [_jsx(Field.Label, { children: "Enter amount you want to withdraw" }), _jsx(Field.Input, { type: "number", ...form.register('amount') }), _jsx(Field.ErrorText, { children: form.formState.errors.amount?.message })] }), _jsx(AmountChoices, { value: parseDecimal(form.watch('amount'), 0), onChange: (value) => {
108
107
  form.setValue('amount', value.toString(), {
109
108
  shouldTouch: true,
110
109
  shouldDirty: true,
@@ -14,7 +14,6 @@ import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSett
14
14
  import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
15
15
  import { CheckIcon } from '../../../../icons/CheckIcon.js';
16
16
  import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
17
- import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
18
17
  import { EyeIcon } from '../../../../icons/EyeIcon.js';
19
18
  import { EyeOffIcon } from '../../../../icons/EyeOffIcon.js';
20
19
  import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
@@ -22,7 +21,6 @@ import { XIcon } from '../../../../icons/XIcon.js';
22
21
  import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
23
22
  import { Button } from '../../../../ui/Button/index.js';
24
23
  import { Field } from '../../../../ui/Field/index.js';
25
- import { NumberInput } from '../../../../ui/NumberInput/index.js';
26
24
  import { PasswordInput } from '../../../../ui/PasswordInput/index.js';
27
25
  import { Portal } from '../../../../ui/Portal/index.js';
28
26
  import { Select } from '../../../../ui/Select/index.js';
@@ -61,6 +59,13 @@ export function InstapayWithdrawal() {
61
59
  const definition = z.object({
62
60
  amount: z.string().superRefine((val, ctx) => {
63
61
  const n = parseDecimal(val, 0);
62
+ if (val.includes('.')) {
63
+ ctx.addIssue({
64
+ code: z.ZodIssueCode.custom,
65
+ message: 'Amount must be a whole number',
66
+ });
67
+ return;
68
+ }
64
69
  if (n < minimumAmount) {
65
70
  ctx.addIssue({
66
71
  type: 'number',
@@ -143,12 +148,7 @@ export function InstapayWithdrawal() {
143
148
  sameWidth: true,
144
149
  }, value: o.field.value ? [o.field.value] : [], onValueChange: (details) => {
145
150
  o.field.onChange(details.value.at(0) ?? '');
146
- }, children: [_jsx(Select.Label, { children: "Bank" }), _jsx(Select.Control, { children: _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, {}), _jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })] }) }), _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: _jsx(Select.ItemGroup, { children: bankCollection.items.map((item) => (_jsxs(Select.Item, { item: item, children: [_jsx(Select.ItemText, { children: item.name }), _jsx(Select.ItemIndicator, { asChild: true, children: _jsx(CheckIcon, {}) })] }, item.id))) }) }) })] }), _jsx(Field.ErrorText, { children: form.formState.errors.bankCode?.message })] })) }), _jsxs(Field.Root, { invalid: !!form.formState.errors.accountNumber, className: "mt-3xl", children: [_jsx(Field.Label, { children: "Bank account number" }), _jsx(Field.Input, { ...form.register('accountNumber') }), _jsx(Field.ErrorText, { children: form.formState.errors.accountNumber?.message })] }), _jsxs(Field.Root, { invalid: !!form.formState.errors.accountName, className: "mt-3xl", children: [_jsx(Field.Label, { children: "Account name" }), _jsx(Field.Input, { ...form.register('accountName') }), _jsx(Field.ErrorText, { children: form.formState.errors.accountName?.message })] }), _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) => {
147
- o.field.onChange(details.value);
148
- }, formatOptions: {
149
- maximumFractionDigits: 2,
150
- minimumFractionDigits: 0,
151
- }, allowMouseWheel: true, children: [_jsx(NumberInput.Label, { children: "Enter amount you want to withdraw" }), _jsxs(NumberInput.Control, { children: [_jsx(NumberInput.Input, {}), _jsx(NumberInput.IncrementTrigger, { children: _jsx(ChevronUpIcon, {}) }), _jsx(NumberInput.DecrementTrigger, { children: _jsx(ChevronDownIcon, {}) })] })] }), _jsx(Field.ErrorText, { children: form.formState.errors.amount?.message })] })) }), _jsx(AmountChoices, { value: parseDecimal(form.watch('amount'), 0), onChange: (value) => {
151
+ }, children: [_jsx(Select.Label, { children: "Bank" }), _jsx(Select.Control, { children: _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, {}), _jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })] }) }), _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: _jsx(Select.ItemGroup, { children: bankCollection.items.map((item) => (_jsxs(Select.Item, { item: item, children: [_jsx(Select.ItemText, { children: item.name }), _jsx(Select.ItemIndicator, { asChild: true, children: _jsx(CheckIcon, {}) })] }, item.id))) }) }) })] }), _jsx(Field.ErrorText, { children: form.formState.errors.bankCode?.message })] })) }), _jsxs(Field.Root, { invalid: !!form.formState.errors.accountNumber, className: "mt-3xl", children: [_jsx(Field.Label, { children: "Bank account number" }), _jsx(Field.Input, { ...form.register('accountNumber') }), _jsx(Field.ErrorText, { children: form.formState.errors.accountNumber?.message })] }), _jsxs(Field.Root, { invalid: !!form.formState.errors.accountName, className: "mt-3xl", children: [_jsx(Field.Label, { children: "Account name" }), _jsx(Field.Input, { ...form.register('accountName') }), _jsx(Field.ErrorText, { children: form.formState.errors.accountName?.message })] }), _jsxs(Field.Root, { invalid: !!form.formState.errors.amount, className: "mt-3xl", children: [_jsx(Field.Label, { children: "Enter amount you want to withdraw" }), _jsx(Field.Input, { type: "number", ...form.register('amount') }), _jsx(Field.ErrorText, { children: form.formState.errors.amount?.message })] }), _jsx(AmountChoices, { value: parseDecimal(form.watch('amount').trim().replace(/,/g, ''), 0), onChange: (value) => {
152
152
  form.setValue('amount', value.toString(), {
153
153
  shouldTouch: true,
154
154
  shouldDirty: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.364",
3
+ "version": "0.0.365",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",