@opexa/portal-components 0.0.337 → 0.0.339

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.
@@ -2,6 +2,8 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { ark } from '@ark-ui/react';
4
4
  import { GoogleOAuthProvider, useGoogleLogin } from '@react-oauth/google';
5
+ import { useShallow } from 'zustand/shallow';
6
+ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
5
7
  import { useGoogleClientIdQuery } from '../../client/hooks/useGoogleClientIdQuery.js';
6
8
  import { useSignInMutation } from '../../client/hooks/useSignInMutation.js';
7
9
  import { toaster } from '../../client/utils/toaster.js';
@@ -17,13 +19,17 @@ export const GoogleSignInTrigger = (props) => {
17
19
  return (_jsx(GoogleOAuthProvider, { clientId: googleClientId, children: _jsx(Trigger, { ...props }) }));
18
20
  };
19
21
  const Trigger = ({ children, disabled, asChild, onClick, ...props }) => {
22
+ const signInStore = useGlobalStore(useShallow((ctx) => ctx.signIn));
20
23
  const signIn = useSignInMutation({
21
- onError() {
24
+ onError: () => {
22
25
  toaster.error({
23
26
  title: 'Account Not Found',
24
- description: 'The Google account you used isn’t connected to any existing account in our system. Please connect it to continue.',
27
+ description: 'Account not found. Please try again or contact support.',
25
28
  });
26
29
  },
30
+ onSuccess: () => {
31
+ signInStore.setOpen(false);
32
+ },
27
33
  });
28
34
  const signInGoogle = useGoogleLogin({
29
35
  flow: 'auth-code',
@@ -32,11 +38,19 @@ const Trigger = ({ children, disabled, asChild, onClick, ...props }) => {
32
38
  ux_mode: 'popup',
33
39
  redirect_uri: 'postmessage',
34
40
  onSuccess: async (res) => {
35
- const { token } = await httpRequest.json(`${AUTH_ENDPOINT}/google/auth?state=${res.state}&code=${res.code}&scope=${res.scope}`);
36
- signIn.mutate({
37
- type: 'SOCIALS',
38
- token,
39
- });
41
+ try {
42
+ const { token } = await httpRequest.json(`${AUTH_ENDPOINT}/google/auth?state=${res.state}&code=${res.code}&scope=${res.scope}`);
43
+ signIn.mutate({
44
+ type: 'SOCIALS',
45
+ token,
46
+ });
47
+ }
48
+ catch {
49
+ toaster.error({
50
+ title: 'Account Not Found',
51
+ description: 'The Google account you used isn’t connected to any existing account in our system. Please connect it to continue.',
52
+ });
53
+ }
40
54
  },
41
55
  });
42
56
  return (_jsx(ark.button, { type: "button", onClick: (e) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.337",
3
+ "version": "0.0.339",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",