@opexa/portal-components 0.0.346 → 0.0.348
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.
- package/dist/client/hooks/useUnlinkGoogleMutation.d.ts +1 -2
- package/dist/client/hooks/useUnlinkGoogleMutation.js +2 -2
- package/dist/components/AccountInfo/AccountInfo.js +28 -16
- package/dist/icons/LinkBroken02Icon.d.ts +2 -0
- package/dist/icons/LinkBroken02Icon.js +4 -0
- package/dist/services/account.js +2 -2
- package/package.json +1 -1
|
@@ -10,10 +10,10 @@ export const useUnlinkGoogleMutation = (config) => {
|
|
|
10
10
|
return useMutation({
|
|
11
11
|
...config,
|
|
12
12
|
mutationKey: getUnlinkGoogleMutationKey(),
|
|
13
|
-
mutationFn: async (
|
|
13
|
+
mutationFn: async (id) => {
|
|
14
14
|
const session = await getSession();
|
|
15
15
|
invariant(session.status === 'authenticated');
|
|
16
|
-
await unlinkGoogle(
|
|
16
|
+
await unlinkGoogle(id, {
|
|
17
17
|
headers: {
|
|
18
18
|
Authorization: `Bearer ${session.token}`,
|
|
19
19
|
},
|
|
@@ -20,11 +20,14 @@ import { toaster } from '../../client/utils/toaster.js';
|
|
|
20
20
|
import { AUTH_ENDPOINT, PLATFORM_CODE } from '../../constants/index.js';
|
|
21
21
|
import { FacebookIcon } from '../../icons/FacebookIcon.js';
|
|
22
22
|
import { GoogleIcon } from '../../icons/GoogleIcon.js';
|
|
23
|
+
import { LinkBroken02Icon } from '../../icons/LinkBroken02Icon.js';
|
|
24
|
+
import { XIcon } from '../../icons/XIcon.js';
|
|
23
25
|
import avatar from '../../images/placeholder-avatar.png';
|
|
24
26
|
import { Button } from '../../ui/Button/index.js';
|
|
27
|
+
import { Dialog } from '../../ui/Dialog/index.js';
|
|
25
28
|
import { Field } from '../../ui/Field/index.js';
|
|
26
29
|
import { IconButton } from '../../ui/IconButton/index.js';
|
|
27
|
-
import {
|
|
30
|
+
import { Portal } from '../../ui/Portal/index.js';
|
|
28
31
|
export function AccountInfo(props) {
|
|
29
32
|
return (_jsxs("div", { className: twMerge('space-y-3xl', props.className), children: [_jsx(ProfileInfo, {}), _jsx(ContactInfo, {}), _jsx(PersonalInfo, {}), _jsx(SSO, { google: props.googleSso, facebook: props.facebookSso })] }));
|
|
30
33
|
}
|
|
@@ -163,8 +166,6 @@ const LinkGoogleAccount = () => {
|
|
|
163
166
|
const account = accountQuery.data;
|
|
164
167
|
const sessionQuery = useSessionQuery();
|
|
165
168
|
const session = sessionQuery.data;
|
|
166
|
-
const unlinkGoogleAccountMutation = useUnlinkGoogleMutation();
|
|
167
|
-
const disclosure = useDisclosure();
|
|
168
169
|
const loginGoogle = useGoogleLogin({
|
|
169
170
|
flow: 'auth-code',
|
|
170
171
|
state: encodeURIComponent(`${window.location.origin},${PLATFORM_CODE},${session?.token}`),
|
|
@@ -174,17 +175,28 @@ const LinkGoogleAccount = () => {
|
|
|
174
175
|
});
|
|
175
176
|
if (!account)
|
|
176
177
|
return null;
|
|
177
|
-
return (_jsxs("div", { className: "flex items-center gap-sm", children: [_jsxs("div", { className: "flex grow items-center gap-sm", children: [_jsx(IconButton, { variant: "outline", colorScheme: "gray", children: _jsx(GoogleIcon, { className: "size-6" }) }),
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
},
|
|
181
|
-
onError: () => {
|
|
182
|
-
toaster.error({
|
|
183
|
-
title: 'Error',
|
|
184
|
-
description: 'An error occurred while disconnecting your Google account. Please try again later.',
|
|
185
|
-
});
|
|
186
|
-
},
|
|
187
|
-
}), children: "Disconnect" })] })), children: (ctx) => {
|
|
188
|
-
return (_jsx("button", { type: "button", onClick: () => ctx.setOpen(true), className: "font-semibold text-button-tertiary-error-fg text-sm", children: "Disconnect" }));
|
|
189
|
-
} })) : (_jsx(Button, { onClick: () => loginGoogle(), fullWidth: false, children: "Connect" }))] }));
|
|
178
|
+
return (_jsxs("div", { className: "flex items-center gap-sm", children: [_jsxs("div", { className: "flex grow items-center gap-sm", children: [_jsx(IconButton, { variant: "outline", colorScheme: "gray", children: _jsx(GoogleIcon, { className: "size-6" }) }), _jsxs("div", { children: [_jsx("p", { className: "font-medium text-sm leading-tight", children: "Google" }), _jsx("p", { className: twMerge('mt-xs text-xs leading-tight', account.googleId
|
|
179
|
+
? 'text-text-success-primary-600'
|
|
180
|
+
: 'text-text-secondary-700'), children: account.googleId ? 'Connected' : 'Not Connected' })] })] }), account.googleId ? (_jsx(UnlinkGoogleAccount, {})) : (_jsx(Button, { onClick: () => loginGoogle(), fullWidth: false, children: "Connect" }))] }));
|
|
190
181
|
};
|
|
182
|
+
function UnlinkGoogleAccount() {
|
|
183
|
+
const accountQuery = useAccountQuery();
|
|
184
|
+
const account = accountQuery.data;
|
|
185
|
+
const disclosure = useDisclosure();
|
|
186
|
+
const unlinkGoogleMutation = useUnlinkGoogleMutation({
|
|
187
|
+
onSuccess() {
|
|
188
|
+
disclosure.setOpen(false);
|
|
189
|
+
},
|
|
190
|
+
onError() {
|
|
191
|
+
toaster.error({
|
|
192
|
+
title: 'Error',
|
|
193
|
+
description: 'An error occurred while disconnecting your Google account. Please try again later.',
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
if (!account)
|
|
198
|
+
return null;
|
|
199
|
+
return (_jsxs(Dialog.Root, { open: disclosure.open, onOpenChange: (details) => disclosure.setOpen(details.open), lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: [_jsx(Dialog.Trigger, { className: "font-semibold text-button-tertiary-error-fg text-sm", children: "Disconnect" }), _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(LinkBroken02Icon, {}) }), _jsx(Dialog.Title, { className: "mb-1 text-center font-semibold text-lg xl:mt-xl", children: "Disconnect Google Account" }), _jsx(Dialog.Description, { 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(Dialog.Context, { children: (api) => (_jsxs("div", { className: "flex justify-between gap-2 pt-6", children: [_jsx(Button, { variant: "outline", disabled: unlinkGoogleMutation.isPending, onClick: () => api.setOpen(false), children: "Cancel" }), _jsx(Button, { variant: "solid", disabled: unlinkGoogleMutation.isPending, onClick: () => {
|
|
200
|
+
unlinkGoogleMutation.mutate(account.id);
|
|
201
|
+
}, children: "Disconnect" })] })) })] }) })] })] }));
|
|
202
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export function LinkBroken02Icon(props) {
|
|
3
|
+
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", ...props, children: _jsx("path", { d: "m8.5 15.5 7-7M9 4V2m6 18v2M4 9H2m18 6h2M4.914 4.914 3.5 3.5m15.586 15.586L20.5 20.5M12 17.657l-2.121 2.121a4 4 0 1 1-5.657-5.657L6.343 12m11.314 0 2.121-2.121a4 4 0 0 0-5.657-5.657L12 6.343" }) }));
|
|
4
|
+
}
|
package/dist/services/account.js
CHANGED
|
@@ -257,9 +257,9 @@ export const getGoogleClientId = cache(async (options) => {
|
|
|
257
257
|
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, GOOGLE_CLIENT_ID, undefined, options);
|
|
258
258
|
return res.googleClientId ?? null;
|
|
259
259
|
});
|
|
260
|
-
export const unlinkGoogle =
|
|
260
|
+
export const unlinkGoogle = async (id, options) => {
|
|
261
261
|
await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, UNLINK_GOOGLE, { input: { id } }, options);
|
|
262
|
-
}
|
|
262
|
+
};
|
|
263
263
|
export const generateSumsubVerificationToken = async (options) => {
|
|
264
264
|
const res = await graphqlRequest(ACCOUNT_GRAPHQL_ENDPOINT, GENERATE_SUMSUB_VERIFICATION_TOKEN, undefined, options);
|
|
265
265
|
return res.generateSumsubVerificationToken;
|