@opexa/portal-components 0.0.391 → 0.0.392

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,7 +7,7 @@ import { prefetchSessionQuery } from '../../server/utils/prefetchSessionQuery.js
7
7
  import { prefetchWalletQuery } from '../../server/utils/prefetchWalletQuery.js';
8
8
  import { getQueryClient } from '../../utils/getQueryClient.js';
9
9
  import { FeatureFlag } from './FeatureFlag.js';
10
- import { LinkGoogleAccountObserver } from './LinkGoogleAccountObserver.js';
10
+ import { SocialAccountLinkObserver } from './SocialAccountLinkObserver.js';
11
11
  import { Providers } from './Providers.js';
12
12
  import { SessionWatcher } from './SessionWatcher.js';
13
13
  import { SetupBtag } from './SetupBtag.js';
@@ -22,5 +22,5 @@ export async function PortalProvider({ recaptchaSiteKey, children, }) {
22
22
  prefetchAccountQuery(),
23
23
  prefetchWalletQuery(),
24
24
  ]);
25
- return (_jsxs(Fragment, { children: [_jsx(Providers, { recaptchaSiteKey: recaptchaSiteKey, children: _jsxs(HydrationBoundary, { state: dehydrate(queryClient), children: [children, _jsx(SessionWatcher, {}), _jsx(Suspense, { children: _jsx(SetupDomain, {}) }), _jsx(Suspense, { children: _jsx(SetupCellxpertCxd, {}) }), _jsx(Suspense, { children: _jsx(SetupBtag, {}) })] }) }), _jsx(Snackbar, {}), _jsx(Suspense, { children: _jsx(LinkGoogleAccountObserver, {}) }), _jsx(Suspense, { children: _jsx(FeatureFlag, {}) })] }));
25
+ return (_jsxs(Fragment, { children: [_jsx(Providers, { recaptchaSiteKey: recaptchaSiteKey, children: _jsxs(HydrationBoundary, { state: dehydrate(queryClient), children: [children, _jsx(SessionWatcher, {}), _jsx(Suspense, { children: _jsx(SetupDomain, {}) }), _jsx(Suspense, { children: _jsx(SetupCellxpertCxd, {}) }), _jsx(Suspense, { children: _jsx(SetupBtag, {}) })] }) }), _jsx(Snackbar, {}), _jsx(Suspense, { children: _jsx(SocialAccountLinkObserver, {}) }), _jsx(Suspense, { children: _jsx(FeatureFlag, {}) })] }));
26
26
  }
@@ -0,0 +1 @@
1
+ export declare function SocialAccountLinkObserver(): null;
@@ -0,0 +1,39 @@
1
+ 'use client';
2
+ import { useSearchParams } from 'next/navigation';
3
+ import { useTimeout } from 'usehooks-ts';
4
+ import { toaster } from '../../client/utils/toaster.js';
5
+ import { getQueryClient } from '../../utils/getQueryClient.js';
6
+ import { getSessionQueryKey } from '../../utils/queryKeys.js';
7
+ export function SocialAccountLinkObserver() {
8
+ const searchParams = useSearchParams();
9
+ const code = searchParams.get('message') ?? searchParams.get('status');
10
+ const providerParam = searchParams.get('provider');
11
+ const provider = providerParam === 'facebook' ? 'Facebook' : 'Google';
12
+ const queryClient = getQueryClient();
13
+ useTimeout(() => {
14
+ if (!code)
15
+ return;
16
+ if (code === 'duplicate') {
17
+ if (provider === 'Facebook') {
18
+ return toaster.error({
19
+ title: 'Facebook Account Already Linked',
20
+ description: 'This Facebook account is already linked to another player. Please use a different account or check your player settings.',
21
+ });
22
+ }
23
+ return toaster.error({
24
+ title: 'Duplicate Account',
25
+ description: 'An account with this email already exists. Please try signing in instead.',
26
+ });
27
+ }
28
+ if (code === 'linked') {
29
+ queryClient.invalidateQueries({
30
+ queryKey: getSessionQueryKey(),
31
+ });
32
+ return toaster.success({
33
+ title: `${provider} Account Linked Successfully`,
34
+ description: `Your ${provider} account has been successfully connected.`,
35
+ });
36
+ }
37
+ }, code ? 100 : null);
38
+ return null;
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.391",
3
+ "version": "0.0.392",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",