@opexa/portal-components 0.0.895 → 0.0.896
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.
|
@@ -7,6 +7,7 @@ import { useForm } from 'react-hook-form';
|
|
|
7
7
|
import invariant from 'tiny-invariant';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import { useShallow } from 'zustand/shallow';
|
|
10
|
+
import { useCreateMemberVerificationMutation } from '../../../client/hooks/useCreateMemberVerificationMutation.js';
|
|
10
11
|
import { useGlobalStore } from '../../../client/hooks/useGlobalStore.js';
|
|
11
12
|
import { useSignOutMutation } from '../../../client/hooks/useSignOutMutation.js';
|
|
12
13
|
import { useUpdateAccountMutation } from '../../../client/hooks/useUpdateAccountMutation.js';
|
|
@@ -21,25 +22,15 @@ import { getQueryClient } from '../../../utils/getQueryClient.js';
|
|
|
21
22
|
import { getSessionQueryKey } from '../../../utils/queryKeys.js';
|
|
22
23
|
import DateOfBirthField from '../../DateOfBirthField.js';
|
|
23
24
|
import { useKYCNonPagcorContext } from './KYCNonPagcorContext.js';
|
|
24
|
-
const
|
|
25
|
+
const fullNameSchema = z
|
|
25
26
|
.string()
|
|
26
|
-
.regex(/^[a-z ]+$/gi, '
|
|
27
|
+
.regex(/^[a-z ]+$/gi, 'Full name must contain only letters')
|
|
27
28
|
.transform((val) => val.trim())
|
|
28
29
|
.refine((val) => val.length >= 2, {
|
|
29
30
|
message: 'First name must be 2 or more characters',
|
|
30
31
|
})
|
|
31
32
|
.refine((val) => val.length <= 50, {
|
|
32
|
-
message: '
|
|
33
|
-
});
|
|
34
|
-
const lastNameBaseSchema = z
|
|
35
|
-
.string()
|
|
36
|
-
.regex(/^[a-z ]+$/gi, 'Last name must contain only letters')
|
|
37
|
-
.transform((val) => val.trim())
|
|
38
|
-
.refine((val) => val.length >= 2, {
|
|
39
|
-
message: 'Last name must be 2 or more characters',
|
|
40
|
-
})
|
|
41
|
-
.refine((val) => val.length <= 50, {
|
|
42
|
-
message: 'Last name must not be more than 50 characters',
|
|
33
|
+
message: 'Full name must not be more than 50 characters',
|
|
43
34
|
});
|
|
44
35
|
const birthdateBaseSchema = z
|
|
45
36
|
.date({
|
|
@@ -56,9 +47,13 @@ const birthdateBaseSchema = z
|
|
|
56
47
|
});
|
|
57
48
|
}
|
|
58
49
|
});
|
|
50
|
+
const emailAddressSchema = z.string().email('Invalid email address');
|
|
59
51
|
const definition = z.object({
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
fullName: fullNameSchema,
|
|
53
|
+
emailAddress: emailAddressSchema,
|
|
54
|
+
nationality: z
|
|
55
|
+
.string()
|
|
56
|
+
.min(2, 'Nationality must be at least 2 characters long'),
|
|
62
57
|
birthday: birthdateBaseSchema,
|
|
63
58
|
});
|
|
64
59
|
export function PersonalInformation() {
|
|
@@ -75,6 +70,18 @@ export function PersonalInformation() {
|
|
|
75
70
|
});
|
|
76
71
|
},
|
|
77
72
|
});
|
|
73
|
+
const createMemberVerificationMutation = useCreateMemberVerificationMutation({
|
|
74
|
+
onError(error) {
|
|
75
|
+
toaster.error({
|
|
76
|
+
description: error.message,
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
onSuccess() {
|
|
80
|
+
toaster.success({
|
|
81
|
+
description: 'Member verification created successfully',
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
});
|
|
78
85
|
const signOutMutation = useSignOutMutation({
|
|
79
86
|
async onSuccess() {
|
|
80
87
|
const keep = new Set([BIOMETRIC_STORAGE_KEY]);
|
|
@@ -94,20 +101,30 @@ export function PersonalInformation() {
|
|
|
94
101
|
const form = useForm({
|
|
95
102
|
resolver: zodResolver(definition),
|
|
96
103
|
defaultValues: {
|
|
97
|
-
|
|
98
|
-
|
|
104
|
+
fullName: '',
|
|
105
|
+
nationality: '',
|
|
106
|
+
emailAddress: '',
|
|
99
107
|
birthday: undefined,
|
|
100
108
|
},
|
|
101
109
|
mode: 'all',
|
|
102
110
|
});
|
|
103
111
|
async function onSubmit(values) {
|
|
104
112
|
await updateAccountMutation.mutateAsync({
|
|
105
|
-
realName:
|
|
113
|
+
realName: values.fullName,
|
|
114
|
+
emailAddress: values.emailAddress,
|
|
106
115
|
birthDay: format(values.birthday, 'yyyy-MM-dd'),
|
|
107
116
|
});
|
|
117
|
+
await createMemberVerificationMutation.mutateAsync({
|
|
118
|
+
nationality: values.nationality,
|
|
119
|
+
address: '',
|
|
120
|
+
natureOfWork: '',
|
|
121
|
+
permanentAddress: '',
|
|
122
|
+
placeOfBirth: '',
|
|
123
|
+
sourceOfIncome: '',
|
|
124
|
+
});
|
|
108
125
|
}
|
|
109
126
|
const birthDay = form.watch('birthday');
|
|
110
|
-
return (_jsxs("div", { children: [_jsx(Dialog.Title, { className: "text-center font-semibold text-lg", children: "Personal Information" }), _jsx(Dialog.Description, { className: "mt-xs text-center text-sm text-text-secondary-700", children: "Provide your basic details and work info." }), _jsxs("form", { className: "mt-7", onSubmit: form.handleSubmit(onSubmit), children: [_jsxs(Field.Root, { className: "mt-2xl", invalid: !!form.formState.errors.
|
|
127
|
+
return (_jsxs("div", { children: [_jsx(Dialog.Title, { className: "text-center font-semibold text-lg", children: "Personal Information" }), _jsx(Dialog.Description, { className: "mt-xs text-center text-sm text-text-secondary-700", children: "Provide your basic details and work info." }), _jsxs("form", { className: "mt-7", onSubmit: form.handleSubmit(onSubmit), children: [_jsxs(Field.Root, { className: "mt-2xl", invalid: !!form.formState.errors.fullName, children: [_jsx(Field.Label, { children: "Full Name" }), _jsx(Field.Input, { placeholder: "Enter your full name", ...form.register('fullName') }), _jsx(Field.ErrorText, { children: form.formState.errors.fullName?.message })] }), _jsxs(Field.Root, { className: "mt-2xl", invalid: !!form.formState.errors.emailAddress, children: [_jsx(Field.Label, { children: "Email Address" }), _jsx(Field.Input, { placeholder: "Enter your email address", ...form.register('emailAddress') }), _jsx(Field.ErrorText, { children: form.formState.errors.emailAddress?.message })] }), _jsxs(Field.Root, { className: "mt-2xl", invalid: !!form.formState.errors.nationality, children: [_jsx(Field.Label, { children: "Nationality" }), _jsx(Field.Input, { placeholder: "Enter your nationality", ...form.register('nationality') }), _jsx(Field.ErrorText, { children: form.formState.errors.nationality?.message })] }), _jsxs(Field.Root, { invalid: !!form.formState.errors.birthday, className: "mt-xl", children: [_jsx(DateOfBirthField, { value: birthDay, onChange: (value) => {
|
|
111
128
|
if (!value)
|
|
112
129
|
return;
|
|
113
130
|
form.setValue('birthday', value, {
|