@opexa/portal-components 0.0.778 → 0.0.780

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 (64) hide show
  1. package/dist/components/KYC/KYCDefault/KYCDefault.js +4 -1
  2. package/dist/components/TransactionRecords/TableFilters.js +1 -0
  3. package/dist/constants/EnvVar.d.ts +1 -1
  4. package/dist/types/index.d.ts +1 -1
  5. package/dist/ui/AlertDialog/AlertDialog.d.ts +187 -187
  6. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +17 -17
  7. package/dist/ui/Badge/Badge.d.ts +12 -12
  8. package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
  9. package/dist/ui/Badge/badge.recipe.d.ts +3 -3
  10. package/dist/ui/Carousel/Carousel.d.ts +72 -72
  11. package/dist/ui/Carousel/carousel.recipe.d.ts +8 -8
  12. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  13. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  14. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  15. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  16. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  17. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  18. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  19. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  20. package/dist/ui/Dialog/Dialog.d.ts +33 -33
  21. package/dist/ui/Dialog/dialog.recipe.d.ts +3 -3
  22. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  23. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  24. package/dist/ui/Menu/Menu.d.ts +252 -252
  25. package/dist/ui/Menu/menu.recipe.d.ts +14 -14
  26. package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
  27. package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
  28. package/dist/ui/Popover/Popover.d.ts +121 -121
  29. package/dist/ui/Popover/popover.recipe.d.ts +11 -11
  30. package/dist/ui/Select/Select.d.ts +45 -45
  31. package/dist/ui/Select/select.recipe.d.ts +3 -3
  32. package/dist/ui/Table/Table.d.ts +21 -21
  33. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  34. package/dist/ui/Table/table.recipe.d.ts +3 -3
  35. package/dist/ui/Tabs/Tabs.d.ts +15 -15
  36. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  37. package/dist/ui/Tooltip/Tooltip.d.ts +30 -30
  38. package/dist/ui/Tooltip/tooltip.recipe.d.ts +5 -5
  39. package/package.json +1 -1
  40. package/dist/components/AccountInfo/GoogleDisconnect.d.ts +0 -7
  41. package/dist/components/AccountInfo/GoogleDisconnect.js +0 -11
  42. package/dist/components/DepositWithdrawal/Deposit/GCashWebpayDeposit /GCashWebpayDeposit .d.ts +0 -1
  43. package/dist/components/DepositWithdrawal/Deposit/GCashWebpayDeposit /GCashWebpayDeposit .js +0 -191
  44. package/dist/components/DigitainLauncher/Loading.d.ts +0 -1
  45. package/dist/components/DigitainLauncher/Loading.js +0 -5
  46. package/dist/components/KYC/BasicInformation.d.ts +0 -1
  47. package/dist/components/KYC/BasicInformation.js +0 -101
  48. package/dist/components/KYC/IdentityVerification.d.ts +0 -1
  49. package/dist/components/KYC/IdentityVerification.js +0 -120
  50. package/dist/components/KYC/Indicator.d.ts +0 -1
  51. package/dist/components/KYC/Indicator.js +0 -8
  52. package/dist/components/KYC/KYC.lazy.d.ts +0 -6
  53. package/dist/components/KYC/KYC.lazy.js +0 -45
  54. package/dist/components/KYC/KYCContext.d.ts +0 -6
  55. package/dist/components/KYC/KYCContext.js +0 -2
  56. package/dist/components/KYC/PersonalInformation.d.ts +0 -1
  57. package/dist/components/KYC/PersonalInformation.js +0 -122
  58. package/dist/components/KYC/useKYC.d.ts +0 -25
  59. package/dist/components/KYC/useKYC.js +0 -38
  60. package/dist/components/PortalProvider/CXDTokenObserver.d.ts +0 -1
  61. package/dist/components/PortalProvider/CXDTokenObserver.js +0 -30
  62. package/dist/icons/LinkBrokenIcon.d.ts +0 -2
  63. package/dist/icons/LinkBrokenIcon.js +0 -4
  64. package/dist/images/responsible-gaming-yellow.png +0 -0
@@ -3,9 +3,9 @@ export declare const tooltipRecipe: import("tailwind-variants").TVReturnType<{
3
3
  [key: string]: import("tailwind-variants").ClassValue | {
4
4
  content?: import("tailwind-variants").ClassValue;
5
5
  trigger?: import("tailwind-variants").ClassValue;
6
- positioner?: import("tailwind-variants").ClassValue;
7
6
  arrow?: import("tailwind-variants").ClassValue;
8
7
  arrowTip?: import("tailwind-variants").ClassValue;
8
+ positioner?: import("tailwind-variants").ClassValue;
9
9
  };
10
10
  };
11
11
  } | {
@@ -13,19 +13,19 @@ export declare const tooltipRecipe: import("tailwind-variants").TVReturnType<{
13
13
  [x: string]: import("tailwind-variants").ClassValue | {
14
14
  content?: import("tailwind-variants").ClassValue;
15
15
  trigger?: import("tailwind-variants").ClassValue;
16
- positioner?: import("tailwind-variants").ClassValue;
17
16
  arrow?: import("tailwind-variants").ClassValue;
18
17
  arrowTip?: import("tailwind-variants").ClassValue;
18
+ positioner?: import("tailwind-variants").ClassValue;
19
19
  };
20
20
  };
21
- } | {}, Record<"content" | "trigger" | "positioner" | "arrow" | "arrowTip", string | string[]>, undefined, {
21
+ } | {}, Record<"content" | "trigger" | "arrow" | "arrowTip" | "positioner", string | string[]>, undefined, {
22
22
  [key: string]: {
23
23
  [key: string]: import("tailwind-variants").ClassValue | {
24
24
  content?: import("tailwind-variants").ClassValue;
25
25
  trigger?: import("tailwind-variants").ClassValue;
26
- positioner?: import("tailwind-variants").ClassValue;
27
26
  arrow?: import("tailwind-variants").ClassValue;
28
27
  arrowTip?: import("tailwind-variants").ClassValue;
28
+ positioner?: import("tailwind-variants").ClassValue;
29
29
  };
30
30
  };
31
- } | {}, Record<"content" | "trigger" | "positioner" | "arrow" | "arrowTip", string | string[]>, import("tailwind-variants").TVReturnType<unknown, Record<"content" | "trigger" | "positioner" | "arrow" | "arrowTip", string | string[]>, undefined, unknown, unknown, undefined>>;
31
+ } | {}, Record<"content" | "trigger" | "arrow" | "arrowTip" | "positioner", string | string[]>, import("tailwind-variants").TVReturnType<unknown, Record<"content" | "trigger" | "arrow" | "arrowTip" | "positioner", string | string[]>, undefined, unknown, unknown, undefined>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.778",
3
+ "version": "0.0.780",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",
@@ -1,7 +0,0 @@
1
- import { type UseDisclosureReturn } from '../../client/hooks/useDisclosure';
2
- interface GoogleDisconnectProps {
3
- onConfirmAction?: (ctx: UseDisclosureReturn) => React.ReactNode;
4
- children?: (ctx: UseDisclosureReturn) => React.ReactNode;
5
- }
6
- export declare function GoogleDisconnect(props: GoogleDisconnectProps): import("react/jsx-runtime").JSX.Element;
7
- export {};
@@ -1,11 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useDisclosure, } from '../../client/hooks/useDisclosure.js';
4
- import { LinkBrokenIcon } from '../../icons/LinkBrokenIcon.js';
5
- import { XIcon } from '../../icons/XIcon.js';
6
- import { Dialog } from '../../ui/Dialog/index.js';
7
- import { Portal } from '../../ui/Portal/index.js';
8
- export function GoogleDisconnect(props) {
9
- const disclosure = useDisclosure();
10
- return (_jsxs(_Fragment, { children: [props.children?.(disclosure), _jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: disclosure.open, onOpenChange: (details) => disclosure.setOpen(details.open), closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "mx-auto min-h-auto max-w-[25rem] overflow-y-auto rounded-xl p-6", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "flex flex-col ", children: [_jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary text-text-brand", children: _jsx(LinkBrokenIcon, {}) }), _jsx("h2", { className: "mb-1 text-center font-semibold text-lg xl:mt-xl", children: "Disconnect Google Account" }), _jsx("p", { className: "text-center text-sm text-text-tertiary-600 leading-2xl", children: "Are you sure you want to disconnect your Google account? This may affect your ability to log in or sync data." })] }), _jsx("div", { className: "pt-6", children: props.onConfirmAction?.(disclosure) })] }) })] }) })] }));
11
- }
@@ -1 +0,0 @@
1
- export declare function GCashWebpayDeposit(): import("react/jsx-runtime").JSX.Element;
@@ -1,191 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { zodResolver } from '@hookform/resolvers/zod';
3
- import Link from 'next/link';
4
- import { useEffect, useState } from 'react';
5
- import { Controller, useForm } from 'react-hook-form';
6
- import invariant from 'tiny-invariant';
7
- import { z } from 'zod';
8
- import { useShallow } from 'zustand/shallow';
9
- import { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePromosQuery.js';
10
- import { useCreateGCashWebpayDepositMutation } from '../../../../client/hooks/useCreateGCashWebpayDepositMutation.js';
11
- import { useDepositQuery } from '../../../../client/hooks/useDepositQuery.js';
12
- import { useDepositsCountQuery } from '../../../../client/hooks/useDepositsCountQuery.js';
13
- import { useDisclosure } from '../../../../client/hooks/useDisclosure.js';
14
- import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
15
- import { useMemberVerificationQuery } from '../../../../client/hooks/useMemberVerificationQuery.js';
16
- import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSettingsQuery.js';
17
- import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
18
- import { ChevronDownIcon } from '../../../../icons/ChevronDownIcon.js';
19
- import { ChevronUpIcon } from '../../../../icons/ChevronUpIcon.js';
20
- import { SpinnerIcon } from '../../../../icons/SpinnerIcon.js';
21
- import { XIcon } from '../../../../icons/XIcon.js';
22
- import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
23
- import { Button } from '../../../../ui/Button/index.js';
24
- import { Field } from '../../../../ui/Field/index.js';
25
- import { NumberInput } from '../../../../ui/NumberInput/index.js';
26
- import { Portal } from '../../../../ui/Portal/index.js';
27
- import { parseDecimal } from '../../../../utils/parseDecimal.js';
28
- import { AmountChoices } from '../../AmountChoices.js';
29
- import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
30
- import { AvailablePromos } from '../AvailablePromos.js';
31
- export function GCashWebpayDeposit() {
32
- const depositWithdrawalProps = useDepositWithdrawalPropsContext();
33
- const disclosure = useDisclosure();
34
- const globalStore = useGlobalStore(useShallow((ctx) => ({
35
- depositWithdrawal: ctx.depositWithdrawal,
36
- kycVerificationStatus: ctx.kycVerificationStatus,
37
- })));
38
- const verificationQuery = useMemberVerificationQuery();
39
- const verificationStatus = verificationQuery.data?.status ?? 'UNVERIFIED';
40
- const [status, setStatus] = useState('waiting');
41
- const createDepositMutation = useCreateGCashWebpayDepositMutation({
42
- onMutate() {
43
- disclosure.setOpen(true);
44
- setStatus('processing');
45
- },
46
- onSuccess(data) {
47
- invariant(data.checkoutUrl);
48
- window.open(data.checkoutUrl, '_blank', 'noopener,noreferrer');
49
- form.reset();
50
- disclosure.setOpen(false);
51
- },
52
- onError() {
53
- disclosure.setOpen(true);
54
- setStatus('failed');
55
- },
56
- });
57
- const depositQuery = useDepositQuery(createDepositMutation.data?.id, {
58
- enabled: createDepositMutation.data != null,
59
- refetchInterval(ctx) {
60
- if (ctx.state.data?.status === 'CANCELLED' ||
61
- ctx.state.data?.status === 'CONFIRMED') {
62
- return false;
63
- }
64
- else {
65
- return 2500;
66
- }
67
- },
68
- });
69
- useEffect(() => {
70
- if (depositQuery.data?.status === 'CANCELLED') {
71
- disclosure.setOpen(true);
72
- setStatus('failed');
73
- }
74
- else if (depositQuery.data?.status === 'CONFIRMED') {
75
- disclosure.setOpen(true);
76
- setStatus('success');
77
- }
78
- }, [depositQuery.data?.status, disclosure]);
79
- const depositsCountQuery = useDepositsCountQuery();
80
- const depositsCount = depositsCountQuery.data ?? 0;
81
- const paymentSettingsQuery = usePaymentSettingsQuery();
82
- const paymentSettings = paymentSettingsQuery.data;
83
- const gatewaySettings = paymentSettings?.gcashWebpayDepositGatewaySettings;
84
- const maximumAmount = parseDecimal(gatewaySettings?.maximumAmount, 0);
85
- const minimumAmount = depositsCount <= 0
86
- ? parseDecimal(paymentSettingsQuery.data?.minimumFirstDepositAmount, 0)
87
- : parseDecimal(gatewaySettings?.minimumAmount, 0);
88
- const promosQuery = useAvailablePromosQuery();
89
- const promos = promosQuery.data ?? [];
90
- const definition = z
91
- .object({
92
- amount: z.string().superRefine((val, ctx) => {
93
- const n = parseDecimal(val, 0);
94
- if (n < minimumAmount) {
95
- ctx.addIssue({
96
- type: 'number',
97
- code: z.ZodIssueCode.too_small,
98
- inclusive: true,
99
- minimum: minimumAmount,
100
- message: `Minimum amount is ${minimumAmount.toLocaleString()}`,
101
- });
102
- }
103
- if (n > maximumAmount) {
104
- ctx.addIssue({
105
- type: 'number',
106
- code: z.ZodIssueCode.too_big,
107
- inclusive: true,
108
- maximum: maximumAmount,
109
- message: `Maximum amount is ${maximumAmount.toLocaleString()}`,
110
- });
111
- }
112
- }),
113
- promo: z.string().optional().nullable(),
114
- })
115
- .superRefine((value, ctx) => {
116
- const promo = promos.find((o) => o.id === value.promo);
117
- const promoMinAmount = parseDecimal(promo?.minimumDepositAmount, 0);
118
- const promoMaxAmount = parseDecimal(promo?.maximumDepositAmount, 0);
119
- const amount = parseDecimal(value.amount, 0);
120
- if (promo && amount < promoMinAmount) {
121
- ctx.addIssue({
122
- path: ['amount'],
123
- code: z.ZodIssueCode.custom,
124
- message: `Minimum amount for this promo is ${promoMinAmount.toLocaleString()}`,
125
- });
126
- }
127
- if (promo && amount > promoMaxAmount) {
128
- ctx.addIssue({
129
- path: ['amount'],
130
- code: z.ZodIssueCode.custom,
131
- message: `Maximum amount for this promo is ${promoMaxAmount}`,
132
- });
133
- }
134
- });
135
- const form = useForm({
136
- mode: 'all',
137
- resolver: zodResolver(definition),
138
- defaultValues: {
139
- amount: '0',
140
- promo: globalStore.depositWithdrawal.promo ?? null,
141
- },
142
- });
143
- useEffect(() => {
144
- if (minimumAmount) {
145
- form.reset({
146
- amount: minimumAmount.toString(),
147
- promo: form.getValues('promo') ?? null,
148
- });
149
- }
150
- }, [form, minimumAmount]);
151
- return (_jsxs("form", { onSubmit: form.handleSubmit(async (data) => {
152
- //handle new kyc process
153
- if (verificationStatus === 'PENDING' ||
154
- verificationStatus === 'UNVERIFIED' ||
155
- verificationStatus === 'REJECTED' ||
156
- verificationStatus === 'CREATED') {
157
- globalStore.kycVerificationStatus.setOpen(true);
158
- return;
159
- }
160
- else {
161
- createDepositMutation.reset();
162
- createDepositMutation.mutate({
163
- amount: data.amount.toString(),
164
- promo: data.promo ?? undefined,
165
- successRedirectionUrl: window.location.origin,
166
- cancelRedirectionUrl: window.location.origin,
167
- });
168
- }
169
- }), 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) => {
170
- o.field.onChange(details.value);
171
- }, formatOptions: {
172
- maximumFractionDigits: 2,
173
- minimumFractionDigits: 0,
174
- }, 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) => {
175
- form.setValue('amount', value.toString(), {
176
- shouldTouch: true,
177
- shouldDirty: true,
178
- shouldValidate: true,
179
- });
180
- }, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: (value) => {
181
- o.field.onChange(value);
182
- globalStore.depositWithdrawal.setPromo(null);
183
- }, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", disabled: createDepositMutation.isPending, children: "Deposit" }), _jsxs("p", { className: "mt-lg text-text-tertiary-600 text-xs", children: ["By depositing, you agree to our", ' ', _jsx(Link, { href: depositWithdrawalProps.termsOfUseUrl ?? '/terms-of-use', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use" }), ' ', "and", ' ', _jsx(Link, { href: depositWithdrawalProps.privacyPolicyUrl ?? '/privacy-policy', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Privacy Policy" }), "."] }), _jsx(AlertDialog.Root, { open: disclosure.open, onOpenChange: (details) => {
184
- disclosure.setOpen(details.open);
185
- }, lazyMount: true, unmountOnExit: true, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs(AlertDialog.Header, { children: [status === 'processing' && (_jsx(SpinnerIcon, { className: "size-12 text-text-brand-primary-600" })), status === 'success' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-success-secondary text-text-featured-icon-light-success", children: _jsx(AlertCircleIcon, {}) })), status === 'failed' && (_jsx("div", { className: "flex size-12 items-center justify-center rounded-full bg-bg-error-secondary text-text-featured-icon-light-error", children: _jsx(AlertCircleIcon, {}) }))] }), _jsxs(AlertDialog.Body, { children: [_jsxs(AlertDialog.Title, { children: [status === 'processing' && 'Processing Deposit', status === 'success' && 'Deposit Successful', status === 'failed' && 'Deposit Failed'] }), _jsxs(AlertDialog.Description, { children: [status === 'processing' &&
186
- "We're verifying your account and amount. Please hold a moment.", status === 'success' &&
187
- 'Your deposit has been successfully processed.', status === 'failed' &&
188
- 'Something went wrong while processing your deposit. Please try again or contact support.'] })] }), (status === 'failed' || status === 'success') && (_jsx(AlertDialog.Footer, { children: _jsx(AlertDialog.Context, { children: (api) => (_jsx(Button, { onClick: () => {
189
- api.setOpen(false);
190
- }, children: status === 'failed' ? 'Try Again' : 'Ok' })) }) }))] }) })] }) })] }));
191
- }
@@ -1 +0,0 @@
1
- export declare function Loading(): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- export function Loading() {
4
- return (_jsx("div", { className: "flex h-[calc(100vh-400px)] w-full items-center justify-center px-4", children: _jsxs("div", { className: "flex flex-col items-center space-y-4", children: [_jsx("div", { className: "h-10 w-10 animate-spin rounded-full border-4 border-blue-500 border-t-transparent" }), _jsx("p", { className: "font-medium text-gray-700 text-lg", children: "Loading Sports Book\u2026" })] }) }));
5
- }
@@ -1 +0,0 @@
1
- export declare function BasicInformation(): import("react/jsx-runtime").JSX.Element;
@@ -1,101 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { zodResolver } from '@hookform/resolvers/zod';
3
- import { differenceInYears, format, isSameDay, isValid, parse } from 'date-fns';
4
- import { isNil, omitBy, size } from 'lodash-es';
5
- import { useEffect } from 'react';
6
- import { useForm } from 'react-hook-form';
7
- import invariant from 'tiny-invariant';
8
- import { z } from 'zod';
9
- import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
10
- import { useUpdateAccountMutation } from '../../client/hooks/useUpdateAccountMutation.js';
11
- import { toaster } from '../../client/utils/toaster.js';
12
- import { Button } from '../../ui/Button/index.js';
13
- import { Dialog } from '../../ui/Dialog/index.js';
14
- import { Field } from '../../ui/Field/index.js';
15
- import { useKYCContext } from './KYCContext.js';
16
- const definition = z.object({
17
- realName: z
18
- .string()
19
- .min(3, 'Name must be 3 or more characters')
20
- .max(50, 'Name must not be more than 50 characters')
21
- .regex(/^[a-z0-9 ]+$/gi, 'Name must not contain special characters')
22
- .trim(),
23
- birthDay: z
24
- .string()
25
- .min(1, 'Date of birth is required')
26
- .superRefine((value, ctx) => {
27
- const dob = parse(value, 'yyyy-MM-dd', new Date());
28
- if (!isValid(dob)) {
29
- return ctx.addIssue({
30
- code: z.ZodIssueCode.invalid_date,
31
- });
32
- }
33
- const now = new Date();
34
- const age = differenceInYears(now, dob);
35
- if (age < 21) {
36
- return ctx.addIssue({
37
- code: z.ZodIssueCode.custom,
38
- message: 'You must be at least 21 years old',
39
- });
40
- }
41
- }),
42
- branchCode: z.string().min(4).max(10).optional().or(z.literal('')),
43
- });
44
- export function BasicInformation() {
45
- const kyc = useKYCContext();
46
- const form = useForm({
47
- resolver: zodResolver(definition),
48
- mode: 'all',
49
- defaultValues: {
50
- birthDay: '',
51
- branchCode: '',
52
- realName: '',
53
- },
54
- });
55
- const accountQuery = useAccountQuery();
56
- const account = accountQuery.data;
57
- const stepCompleted = account != null && account.realName != null && account.birthDay != null;
58
- useEffect(() => {
59
- if (stepCompleted)
60
- kyc.setStep(2);
61
- }, [stepCompleted, kyc]);
62
- useEffect(() => {
63
- if (account) {
64
- form.reset({
65
- realName: account.realName ?? '',
66
- birthDay: account.birthDay
67
- ? format(account.birthDay, 'yyyy-MM-dd')
68
- : '',
69
- });
70
- }
71
- }, [account, form]);
72
- const updateAccountMutation = useUpdateAccountMutation({
73
- onError(error) {
74
- toaster.error({
75
- title: 'Error',
76
- description: error.message,
77
- });
78
- },
79
- onSuccess() {
80
- kyc.setStep(2);
81
- toaster.success({
82
- title: 'Success',
83
- description: 'Basic information has been set successfully.',
84
- });
85
- },
86
- });
87
- return (_jsxs("div", { children: [_jsx(Dialog.Title, { className: "text-center font-semibold text-lg", children: "Basic Information" }), _jsx(Dialog.Description, { className: "mt-xs text-center text-sm text-text-secondary-700", children: "Enter your basic details for identification and communication." }), _jsxs("form", { className: "mt-3", onSubmit: form.handleSubmit((data) => {
88
- invariant(account);
89
- const input = omitBy({
90
- realName: account.realName === data.realName ? undefined : data.realName,
91
- birthDay: account.birthDay && isSameDay(data.birthDay, account.birthDay)
92
- ? undefined
93
- : format(data.birthDay, 'yyyy-MM-dd'),
94
- }, isNil);
95
- if (size(input) === 0)
96
- return kyc.setStep(2);
97
- updateAccountMutation.mutate(input);
98
- }), children: [_jsxs(Field.Root, { invalid: !!form.formState.errors.realName, readOnly: !!accountQuery.data?.realName, children: [_jsx(Field.Label, { children: "Real Name" }), _jsx(Field.Input, { placeholder: "Enter your real name", ...form.register('realName') }), _jsx(Field.ErrorText, { children: form.formState.errors.realName?.message })] }), _jsxs(Field.Root, { className: "mt-3", invalid: !!form.formState.errors.branchCode, readOnly: !!accountQuery.data?.birthDay, children: [_jsx(Field.Label, { children: "Date of Birth" }), _jsx(Field.Input, { type: "date", ...form.register('birthDay') }), _jsx(Field.ErrorText, { children: form.formState.errors.birthDay?.message })] }), _jsx(Button, { type: "submit", className: "mt-8", disabled: accountQuery.isLoading ||
99
- updateAccountMutation.isPending ||
100
- stepCompleted, children: "Continue" })] })] }));
101
- }
@@ -1 +0,0 @@
1
- export declare function IdentityVerification(): import("react/jsx-runtime").JSX.Element;
@@ -1,120 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { zodResolver } from '@hookform/resolvers/zod';
4
- import { useEffect } from 'react';
5
- import { Controller, useForm } from 'react-hook-form';
6
- import { z } from 'zod';
7
- import { useShallow } from 'zustand/shallow';
8
- import { useCreateMemberVerificationMutation } from '../../client/hooks/useCreateMemberVerificationMutation.js';
9
- import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
10
- import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
11
- import { useUpdateMemberVerificationMutation } from '../../client/hooks/useUpdateMemberVerificationMutation.js';
12
- import { toaster } from '../../client/utils/toaster.js';
13
- import { Button } from '../../ui/Button/index.js';
14
- import { Dialog } from '../../ui/Dialog/index.js';
15
- import { Field } from '../../ui/Field/index.js';
16
- import { getQueryClient } from '../../utils/getQueryClient.js';
17
- import { getMemberVerificationQueryKey } from '../../utils/queryKeys.js';
18
- import { IdFrontImageField } from '../shared/IdFrontImageField/index.js';
19
- import { SelfieImageField } from '../shared/SelfieImageField/index.js';
20
- import { useKYCContext } from './KYCContext.js';
21
- const formSchema = z.object({
22
- selfieImage: z.string().min(1, 'Selfie image is required.'),
23
- idFrontImage: z.string().min(1, 'Front image of ID is required.'),
24
- });
25
- export function IdentityVerification() {
26
- const kyc = useKYCContext();
27
- const { mutate: createMemberVerification, isPending: createPending } = useCreateMemberVerificationMutation({
28
- onSuccess: () => {
29
- toaster.success({
30
- title: 'ID Front Image & Selfie Image uploaded successfully',
31
- });
32
- },
33
- onError: (error) => {
34
- toaster.error({
35
- title: 'Failed to upload ID Front Image & Selfie Image',
36
- description: error.message,
37
- });
38
- },
39
- });
40
- const { mutate: updateMemberVerification, isPending: updatePending } = useUpdateMemberVerificationMutation({
41
- onSuccess: () => {
42
- const queryClient = getQueryClient();
43
- toaster.success({
44
- title: 'ID Front Image & Selfie Image updated successfully',
45
- });
46
- queryClient.setQueryData(getMemberVerificationQueryKey(), (prev) => {
47
- if (!prev)
48
- return prev;
49
- return {
50
- ...prev,
51
- status: 'CREATED',
52
- };
53
- });
54
- },
55
- onError: (error) => {
56
- toaster.error({
57
- title: 'Failed to upload ID Front Image & Selfie Image',
58
- description: error.message,
59
- });
60
- },
61
- });
62
- const memberVerification = useMemberVerificationQuery();
63
- const memberId = memberVerification.data?.id;
64
- const globalStore = useGlobalStore(useShallow((ctx) => ({
65
- kyc: ctx.kyc,
66
- })));
67
- const form = useForm({
68
- resolver: zodResolver(formSchema),
69
- defaultValues: {
70
- idFrontImage: '',
71
- selfieImage: '',
72
- },
73
- });
74
- function onSubmit(values) {
75
- if (!memberId) {
76
- createMemberVerification({
77
- selfieImage: values.selfieImage,
78
- idFrontImage: values.idFrontImage,
79
- address: '',
80
- nationality: '',
81
- natureOfWork: '',
82
- permanentAddress: '',
83
- placeOfBirth: '',
84
- sourceOfIncome: '',
85
- });
86
- kyc.setStep(3);
87
- }
88
- else {
89
- updateMemberVerification({
90
- id: memberId,
91
- data: {
92
- selfieImage: values.selfieImage,
93
- idFrontImage: values.idFrontImage,
94
- },
95
- });
96
- kyc.setStep(3);
97
- }
98
- }
99
- useEffect(() => {
100
- if (kyc.selfieImageId)
101
- form.setValue('selfieImage', kyc.selfieImageId);
102
- if (kyc.idFrontImageId)
103
- form.setValue('idFrontImage', kyc.idFrontImageId);
104
- }, [form, kyc.idFrontImageId, kyc.selfieImageId]);
105
- return (_jsxs("div", { children: [_jsx(Dialog.Title, { className: "text-center font-semibold text-lg", children: "Verify your identity" }), _jsx(Dialog.Description, { className: "mt-xs text-center text-sm text-text-secondary-700", children: "Verify your details to confirm your identity and secure your access." }), _jsxs("div", { className: "mt-7 rounded-xl border border-border-primary bg-bg-primary p-lg text-text-placeholder text-xs leading-tight", children: [_jsx("h3", { className: "font-semibold", children: "Instructions" }), _jsxs("ol", { className: "mt-2 list-inside list-decimal", children: [_jsx("li", { children: "Upload a full photo of your ID." }), _jsx("li", { children: "Please ensure that all details in the uploaded image are legible." }), _jsx("li", { children: "Please ensure that the ID uploaded is within the validity period." })] })] }), _jsxs("form", { className: "mt-xl", onSubmit: form.handleSubmit(onSubmit), children: [_jsx(Controller, { control: form.control, name: "idFrontImage", render: (o) => (_jsxs(Field.Root, { invalid: o.fieldState.invalid, children: [_jsx(Field.Label, { children: "Front of your ID" }), _jsx(IdFrontImageField, { value: o.field.value, onChange: o.field.onChange, onError: (error) => {
106
- form.setValue('idFrontImage', '');
107
- form.setError('idFrontImage', {
108
- type: 'validate',
109
- message: error.message,
110
- });
111
- } }), _jsx(Field.ErrorText, { children: o.fieldState.error?.message })] })) }), _jsx(Controller, { control: form.control, name: "selfieImage", render: (o) => (_jsxs(Field.Root, { invalid: o.fieldState.invalid, className: "mt-3", children: [_jsx(Field.Label, { children: "Selfie holding your ID" }), _jsx(SelfieImageField, { value: o.field.value, onChange: o.field.onChange, onError: (error) => {
112
- form.setValue('selfieImage', '');
113
- form.setError('selfieImage', {
114
- type: 'validate',
115
- message: error.message,
116
- });
117
- } }), _jsx(Field.ErrorText, { children: o.fieldState.error?.message })] })) }), _jsx(Button, { type: "submit", className: "mt-6", disabled: createPending || updatePending, children: "Continue" }), _jsx(Button, { variant: "outline", colorScheme: "gray", className: "mt-lg", type: "button", onClick: () => {
118
- globalStore.kyc.setOpen(false);
119
- }, children: "Skip for now" })] })] }));
120
- }
@@ -1 +0,0 @@
1
- export declare function Indicator(): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { noop } from 'lodash-es';
3
- import { Progress } from '../../ui/Progress/index.js';
4
- import { useKYCContext } from './KYCContext.js';
5
- export function Indicator() {
6
- const kyc = useKYCContext();
7
- return (_jsxs("div", { className: "flex items-center justify-center gap-1.5 py-3", children: [_jsx(Progress.Root, { className: "w-10 shrink-0", value: kyc.step > 1 ? 100 : 0, onValueChange: noop, children: _jsx(Progress.Track, { className: "bg-bg-primary-hover", children: _jsx(Progress.Range, {}) }) }), _jsx(Progress.Root, { className: "w-10 shrink-0", value: kyc.step > 2 ? 100 : 0, onValueChange: noop, children: _jsx(Progress.Track, { className: "bg-bg-primary-hover", children: _jsx(Progress.Range, {}) }) }), _jsx(Progress.Root, { className: "w-10 shrink-0", value: kyc.step === 3 ? 100 : 0, onValueChange: noop, children: _jsx(Progress.Track, { className: "bg-bg-primary-hover", children: _jsx(Progress.Range, {}) }) })] }));
8
- }
@@ -1,6 +0,0 @@
1
- import type { ImageProps } from 'next/image';
2
- import { type KYCReminderProps } from './KYCReminder.lazy';
3
- export interface KYCProps extends KYCReminderProps {
4
- logo: ImageProps['src'];
5
- }
6
- export declare function KYC(props: KYCProps): import("react/jsx-runtime").JSX.Element;
@@ -1,45 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import Image from 'next/image';
3
- import { useEffect } from 'react';
4
- import { useShallow } from 'zustand/shallow';
5
- import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
6
- import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
7
- import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
8
- import { XIcon } from '../../icons/XIcon.js';
9
- import { Dialog } from '../../ui/Dialog/index.js';
10
- import { Portal } from '../../ui/Portal/index.js';
11
- import { BasicInformation } from './BasicInformation.js';
12
- import { IdentityVerification } from './IdentityVerification.js';
13
- import { Indicator } from './Indicator.js';
14
- import { KYCContext } from './KYCContext.js';
15
- import { KYCReminder } from './KYCReminder.lazy.js';
16
- import { PersonalInformation } from './PersonalInformation.js';
17
- import { useKYC } from './useKYC.js';
18
- export function KYC(props) {
19
- const globalStore = useGlobalStore(useShallow((ctx) => ({ kyc: ctx.kyc })));
20
- const kyc = useKYC();
21
- const { data: account } = useAccountQuery();
22
- const { data: verification } = useMemberVerificationQuery();
23
- const isBasicInfoCompleted = account?.realName !== null && account?.birthDay !== null;
24
- const isUploadCompleted = Boolean(verification?.idFrontImage) && Boolean(verification?.selfieImage);
25
- const isVerified = Boolean(verification?.status === 'VERIFIED') ||
26
- Boolean(verification?.status === 'PENDING') ||
27
- Boolean(verification?.status === 'APPROVED');
28
- const isRejected = Boolean(verification?.status === 'REJECTED');
29
- const hasMissingData = !isBasicInfoCompleted || !isUploadCompleted || !isVerified;
30
- const steps = !isBasicInfoCompleted
31
- ? 1
32
- : !isUploadCompleted
33
- ? 2
34
- : isRejected
35
- ? 2
36
- : 3;
37
- useEffect(() => {
38
- if (steps) {
39
- kyc.setStep(steps);
40
- }
41
- }, [steps, kyc]);
42
- return (_jsxs(_Fragment, { children: [_jsx(KYCContext, { value: kyc, children: _jsx(Dialog.Root, { open: globalStore.kyc.open && hasMissingData, onOpenChange: (details) => {
43
- globalStore.kyc.setOpen(details.open);
44
- }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: kyc.reset, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsx(Dialog.Content, { className: "mx-auto min-h-full w-full overflow-y-auto bg-bg-primary-alt lg:min-h-auto lg:w-fit", children: _jsxs("div", { className: "flex h-dvh w-full flex-col overflow-y-auto p-3xl sm:h-fit sm:overflow-auto lg:w-[400px]", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsx(Image, { src: props.logo, alt: "", width: 200, height: 100, className: "mx-auto mb-5 block h-7.5 w-auto", draggable: false }), _jsx(Indicator, {}), kyc.step === 1 && _jsx(BasicInformation, {}), kyc.step === 2 && _jsx(IdentityVerification, {}), kyc.step === 3 && _jsx(PersonalInformation, {})] }) }) })] }) }) }), _jsx(KYCReminder, { ...props })] }));
45
- }
@@ -1,6 +0,0 @@
1
- import type { UseKYCReturn } from './useKYC';
2
- export declare const KYCContext: (props: {
3
- value: UseKYCReturn;
4
- } & {
5
- children?: import("react").ReactNode | undefined;
6
- }) => React.ReactNode, useKYCContext: () => UseKYCReturn;
@@ -1,2 +0,0 @@
1
- import { createContext } from '../../client/utils/createContext.js';
2
- export const [KYCContext, useKYCContext] = createContext();
@@ -1 +0,0 @@
1
- export declare function PersonalInformation(): import("react/jsx-runtime").JSX.Element;