@opexa/portal-components 0.0.902 → 0.0.904
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ark } from '@ark-ui/react/factory';
|
|
3
4
|
import FacebookLogin from '@greatsumini/react-facebook-login';
|
|
4
5
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
5
6
|
import { GoogleOAuthProvider, useGoogleLogin } from '@react-oauth/google';
|
|
@@ -15,12 +16,15 @@ import { useFacebookClientQuery } from '../../client/hooks/useFacebookClientQuer
|
|
|
15
16
|
import { useGoogleClientIdQuery } from '../../client/hooks/useGoogleClientIdQuery.js';
|
|
16
17
|
import { useLocaleInfo } from '../../client/hooks/useLocaleInfo.js';
|
|
17
18
|
import { useMobileNumberParser } from '../../client/hooks/useMobileNumberParser.js';
|
|
19
|
+
import { useProfileCompletionQuery } from '../../client/hooks/useProfileCompletionQuery.js';
|
|
18
20
|
import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
|
|
19
21
|
import { useUnlinkFacebookMutation } from '../../client/hooks/useUnlinkFacebookMutation.js';
|
|
20
22
|
import { useUnlinkGoogleMutation } from '../../client/hooks/useUnlinkGoogleMutation.js';
|
|
21
23
|
import { useUpdateAccountMutation } from '../../client/hooks/useUpdateAccountMutation.js';
|
|
22
24
|
import { toaster } from '../../client/utils/toaster.js';
|
|
23
25
|
import { AUTH_ENDPOINT, PLATFORM_CODE } from '../../constants/index.js';
|
|
26
|
+
import { AlertCircleIcon } from '../../icons/AlertCircleIcon.js';
|
|
27
|
+
import { CheckVerified02Icon } from '../../icons/CheckVerified02Icon.js';
|
|
24
28
|
import { FacebookIcon } from '../../icons/FacebookIcon.js';
|
|
25
29
|
import { GoogleIcon } from '../../icons/GoogleIcon.js';
|
|
26
30
|
import { LinkBroken02Icon } from '../../icons/LinkBroken02Icon.js';
|
|
@@ -32,7 +36,7 @@ import { Field } from '../../ui/Field/index.js';
|
|
|
32
36
|
import { IconButton } from '../../ui/IconButton/index.js';
|
|
33
37
|
import { Portal } from '../../ui/Portal/index.js';
|
|
34
38
|
import { getQueryClient } from '../../utils/getQueryClient.js';
|
|
35
|
-
import { getAccountQueryKey } from '../../utils/queryKeys.js';
|
|
39
|
+
import { getAccountQueryKey, getProfileCompletionQueryKey, } from '../../utils/queryKeys.js';
|
|
36
40
|
const accountSchema = z.object({
|
|
37
41
|
name: z
|
|
38
42
|
.string()
|
|
@@ -137,7 +141,9 @@ function PersonalInfo(props) {
|
|
|
137
141
|
}
|
|
138
142
|
}, [account, form]);
|
|
139
143
|
const branchName = props.branchCodes?.find((branch) => branch.code === account?.branchCode);
|
|
140
|
-
const displayBranchName =
|
|
144
|
+
const displayBranchName = branchName
|
|
145
|
+
? `${branchName?.code} - ${branchName?.name}`
|
|
146
|
+
: null;
|
|
141
147
|
return (_jsxs("div", { children: [_jsx("h2", { className: "font-semibold text-sm text-text-secondary-700", children: "Personal Data" }), _jsxs("form", { className: "mt-5 rounded-xl border border-border-secondary bg-bg-primary-alt shadow-xs", onSubmit: form.handleSubmit((data) => {
|
|
142
148
|
updateAccountMutation.mutate({
|
|
143
149
|
realName: data.realName && account?.realName !== data.realName
|
|
@@ -152,6 +158,8 @@ function PersonalInfo(props) {
|
|
|
152
158
|
function ContactInfo() {
|
|
153
159
|
const localeInfo = useLocaleInfo();
|
|
154
160
|
const accountQuery = useAccountQuery();
|
|
161
|
+
const profileCompletionQuery = useProfileCompletionQuery();
|
|
162
|
+
const profileCompletion = profileCompletionQuery.data;
|
|
155
163
|
const account = accountQuery.data;
|
|
156
164
|
const { parse, format, equals } = useMobileNumberParser();
|
|
157
165
|
const updateAccountMutation = useUpdateAccountMutation({
|
|
@@ -159,6 +167,9 @@ function ContactInfo() {
|
|
|
159
167
|
toaster.success({
|
|
160
168
|
description: 'Changes saved!',
|
|
161
169
|
});
|
|
170
|
+
getQueryClient().invalidateQueries({
|
|
171
|
+
queryKey: getProfileCompletionQueryKey(),
|
|
172
|
+
});
|
|
162
173
|
},
|
|
163
174
|
onError(error) {
|
|
164
175
|
toaster.error({
|
|
@@ -192,7 +203,9 @@ function ContactInfo() {
|
|
|
192
203
|
});
|
|
193
204
|
}
|
|
194
205
|
}, [account, form, parse]);
|
|
195
|
-
return (_jsxs("div", { children: [_jsx("h2", { className: "font-semibold text-sm text-text-secondary-700", children: "Contact Info" }),
|
|
206
|
+
return (_jsxs("div", { children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("h2", { className: "grow font-semibold text-sm text-text-secondary-700", children: "Contact Info" }), _jsx(ark.svg, { asChild: true, className: twMerge('size-6', profileCompletion?.personalInformation
|
|
207
|
+
? 'text-text-success-primary'
|
|
208
|
+
: 'text-text-warning-primary'), children: profileCompletion?.personalInformation ? (_jsx(CheckVerified02Icon, {})) : (_jsx(AlertCircleIcon, {})) })] }), _jsxs("form", { className: "mt-5 rounded-xl border border-border-secondary bg-bg-primary-alt shadow-xs", onSubmit: form.handleSubmit((data) => {
|
|
196
209
|
updateAccountMutation.mutate({
|
|
197
210
|
emailAddress: data.emailAddress && account?.emailAddress !== data.emailAddress
|
|
198
211
|
? data.emailAddress
|
|
@@ -21,6 +21,8 @@ import { Field } from '../../ui/Field/index.js';
|
|
|
21
21
|
import { PasswordInput } from '../../ui/PasswordInput/index.js';
|
|
22
22
|
import { Portal } from '../../ui/Portal/index.js';
|
|
23
23
|
import { Select } from '../../ui/Select/index.js';
|
|
24
|
+
import { getQueryClient } from '../../utils/getQueryClient.js';
|
|
25
|
+
import { getProfileCompletionQueryKey } from '../../utils/queryKeys.js';
|
|
24
26
|
export function AccountSecurity(props) {
|
|
25
27
|
return (_jsxs("div", { className: twMerge('space-y-3xl', props.className), children: [_jsx(LoginPassword, {}), _jsx(TransactionPassword, {})] }));
|
|
26
28
|
}
|
|
@@ -33,6 +35,9 @@ function LoginPassword() {
|
|
|
33
35
|
toaster.success({
|
|
34
36
|
description: 'Changes saved!',
|
|
35
37
|
});
|
|
38
|
+
getQueryClient().invalidateQueries({
|
|
39
|
+
queryKey: getProfileCompletionQueryKey(),
|
|
40
|
+
});
|
|
36
41
|
},
|
|
37
42
|
onError(error) {
|
|
38
43
|
toaster.error({
|
|
@@ -42,7 +47,10 @@ function LoginPassword() {
|
|
|
42
47
|
});
|
|
43
48
|
const schema = z
|
|
44
49
|
.object({
|
|
45
|
-
password: z
|
|
50
|
+
password: z
|
|
51
|
+
.string()
|
|
52
|
+
.min(8, 'Password must be at least 8 characters')
|
|
53
|
+
.max(150, 'Password must be at most 150 characters'),
|
|
46
54
|
confirmPassword: z.string().min(1, 'Please confirm your password'),
|
|
47
55
|
secretQuestion: z.enum(SECRET_QUESTIONS).nullable().optional(),
|
|
48
56
|
secretAnswer: z
|
|
@@ -115,6 +123,9 @@ function TransactionPassword() {
|
|
|
115
123
|
toaster.success({
|
|
116
124
|
description: 'Changes saved!',
|
|
117
125
|
});
|
|
126
|
+
getQueryClient().invalidateQueries({
|
|
127
|
+
queryKey: getProfileCompletionQueryKey(),
|
|
128
|
+
});
|
|
118
129
|
},
|
|
119
130
|
onError(error) {
|
|
120
131
|
toaster.error({
|
|
@@ -124,7 +135,10 @@ function TransactionPassword() {
|
|
|
124
135
|
});
|
|
125
136
|
const schema = z
|
|
126
137
|
.object({
|
|
127
|
-
password: z
|
|
138
|
+
password: z
|
|
139
|
+
.string()
|
|
140
|
+
.min(8, 'Password must be at least 8 characters')
|
|
141
|
+
.max(150, 'Password must be at most 150 characters'),
|
|
128
142
|
confirmPassword: z.string().min(1, 'Please confirm your password'),
|
|
129
143
|
})
|
|
130
144
|
.superRefine((data, ctx) => {
|