@quiltt/react 4.2.0 → 4.2.2
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/CHANGELOG.md +18 -0
- package/dist/{QuilttAuthProvider-client-DLARZukU.js → QuilttAuthProvider-client-C25Tg4_a.js} +2 -1
- package/dist/index.d.ts +11 -3
- package/dist/index.js +5 -4
- package/dist/{useQuilttConnector-client-BK7ybRZe.js → useQuilttConnector-client-BwpjuFHf.js} +14 -22
- package/dist/useQuilttInstitutions-client-CdmGK6Wv.js +89 -0
- package/dist/{useQuilttSession-client-Ddb55W0n.js → useQuilttSession-client-DhsbThvI.js} +1 -1
- package/package.json +4 -4
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useQuilttConnector.ts +11 -22
- package/src/hooks/useQuilttInstitutions.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @quiltt/react
|
|
2
2
|
|
|
3
|
+
## 4.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#352](https://github.com/quiltt/quiltt-js/pull/352) [`45b3b32`](https://github.com/quiltt/quiltt-js/commit/45b3b3270b69b95c9553e149e15870be4f43af3b) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Fix useQuilttInstitutions export
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`45b3b32`](https://github.com/quiltt/quiltt-js/commit/45b3b3270b69b95c9553e149e15870be4f43af3b)]:
|
|
10
|
+
- @quiltt/core@4.2.2
|
|
11
|
+
|
|
12
|
+
## 4.2.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#350](https://github.com/quiltt/quiltt-js/pull/350) [`0233592`](https://github.com/quiltt/quiltt-js/commit/02335928bb872a6588c2ca81a1bd9a081053bd29) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Bugfix: early return in effect prevents reconnect from being called
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`0233592`](https://github.com/quiltt/quiltt-js/commit/02335928bb872a6588c2ca81a1bd9a081053bd29)]:
|
|
19
|
+
- @quiltt/core@4.2.1
|
|
20
|
+
|
|
3
21
|
## 4.2.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/{QuilttAuthProvider-client-DLARZukU.js → QuilttAuthProvider-client-C25Tg4_a.js}
RENAMED
|
@@ -4,9 +4,10 @@ import { JsonWebTokenParse, QuilttClient, InMemoryCache } from '@quiltt/core';
|
|
|
4
4
|
import '@apollo/client/react/hooks/useApolloClient.js';
|
|
5
5
|
import './QuilttSettings-client-BK-0SQME.js';
|
|
6
6
|
import './useSession-client-CCAvnROP.js';
|
|
7
|
+
import 'use-debounce';
|
|
7
8
|
import { jsx } from 'react/jsx-runtime';
|
|
8
9
|
import { ApolloProvider } from '@apollo/client/react/context/ApolloProvider.js';
|
|
9
|
-
import { u as useQuilttSession } from './useQuilttSession-client-
|
|
10
|
+
import { u as useQuilttSession } from './useQuilttSession-client-DhsbThvI.js';
|
|
10
11
|
|
|
11
12
|
const useIdentifySession = (auth, setSession)=>{
|
|
12
13
|
const identifySession = useCallback(async (payload, callbacks)=>{
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Maybe, QuilttJWT, UsernamePayload, UnprocessableData, AuthAPI, PasscodePayload, ConnectorSDKConnectorOptions, ConnectorSDKCallbacks } from '@quiltt/core';
|
|
1
|
+
import { Maybe, QuilttJWT, UsernamePayload, UnprocessableData, AuthAPI, PasscodePayload, ConnectorSDKConnectorOptions, InstitutionsData, ConnectorSDKCallbacks } from '@quiltt/core';
|
|
2
2
|
export * from '@quiltt/core';
|
|
3
3
|
import { RefObject, useEffect, Dispatch, SetStateAction, FC, PropsWithChildren, JSX, ComponentType, ElementType, MouseEvent } from 'react';
|
|
4
4
|
import { useApolloClient } from '@apollo/client/react/hooks/useApolloClient.js';
|
|
@@ -66,6 +66,14 @@ declare const useQuilttConnector: (connectorId?: string, options?: ConnectorSDKC
|
|
|
66
66
|
open: () => void;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
+
type UseQuilttInstitutions = (connectorId: string, onErrorCallback?: (msg: string) => void) => {
|
|
70
|
+
searchTerm: string;
|
|
71
|
+
searchResults: InstitutionsData;
|
|
72
|
+
isSearching: boolean;
|
|
73
|
+
setSearchTerm: (term: string) => void;
|
|
74
|
+
};
|
|
75
|
+
declare const useQuilttInstitutions: UseQuilttInstitutions;
|
|
76
|
+
|
|
69
77
|
type UseQuilttSession = (environmentId?: string) => {
|
|
70
78
|
session: Maybe<QuilttJWT> | undefined;
|
|
71
79
|
importSession: ImportSession;
|
|
@@ -176,5 +184,5 @@ type QuilttContainerProps<T extends ElementType> = PropsWithChildren<{
|
|
|
176
184
|
*/
|
|
177
185
|
declare const QuilttContainer: <T extends ElementType = "div">({ as, connectorId, connectionId, forceRemountOnConnectionChange, onEvent, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, children, ...props }: QuilttContainerProps<T> & PropsOf<T>) => react_jsx_runtime.JSX.Element;
|
|
178
186
|
|
|
179
|
-
export { QuilttAuthProvider, QuilttButton, QuilttContainer, QuilttProvider, QuilttSettingsProvider, useAuthenticateSession, useEventListener, useIdentifySession, useImportSession, useIsomorphicLayoutEffect, useQuilttClient, useQuilttConnector, useQuilttSession, useQuilttSettings, useRevokeSession, useSession, useStorage };
|
|
180
|
-
export type { AuthenticateSession, IdentifySession, ImportSession, RevokeSession, SetSession, UseQuilttSession };
|
|
187
|
+
export { QuilttAuthProvider, QuilttButton, QuilttContainer, QuilttProvider, QuilttSettingsProvider, useAuthenticateSession, useEventListener, useIdentifySession, useImportSession, useIsomorphicLayoutEffect, useQuilttClient, useQuilttConnector, useQuilttInstitutions, useQuilttSession, useQuilttSettings, useRevokeSession, useSession, useStorage };
|
|
188
|
+
export type { AuthenticateSession, IdentifySession, ImportSession, RevokeSession, SetSession, UseQuilttInstitutions, UseQuilttSession };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export * from '@quiltt/core';
|
|
2
2
|
export { u as useEventListener } from './useEventListener-client-DVM5xwKY.js';
|
|
3
3
|
export { u as useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect-client-DeTHOKz1.js';
|
|
4
|
-
import { Q as QuilttAuthProvider, i as isDeepEqual } from './QuilttAuthProvider-client-
|
|
5
|
-
export { b as useAuthenticateSession, a as useIdentifySession, u as useImportSession, c as useRevokeSession } from './QuilttAuthProvider-client-
|
|
4
|
+
import { Q as QuilttAuthProvider, i as isDeepEqual } from './QuilttAuthProvider-client-C25Tg4_a.js';
|
|
5
|
+
export { b as useAuthenticateSession, a as useIdentifySession, u as useImportSession, c as useRevokeSession } from './QuilttAuthProvider-client-C25Tg4_a.js';
|
|
6
6
|
export { u as useQuilttClient } from './useQuilttClient-client-CAAUait1.js';
|
|
7
|
-
import { u as useQuilttConnector } from './useQuilttConnector-client-
|
|
8
|
-
export { u as
|
|
7
|
+
import { u as useQuilttConnector } from './useQuilttConnector-client-BwpjuFHf.js';
|
|
8
|
+
export { u as useQuilttInstitutions } from './useQuilttInstitutions-client-CdmGK6Wv.js';
|
|
9
|
+
export { u as useQuilttSession } from './useQuilttSession-client-DhsbThvI.js';
|
|
9
10
|
export { u as useQuilttSettings } from './useQuilttSettings-client-BOCBjFXe.js';
|
|
10
11
|
export { u as useSession } from './useSession-client-CCAvnROP.js';
|
|
11
12
|
export { u as useStorage } from './useStorage-client-DHcq3Kuh.js';
|
package/dist/{useQuilttConnector-client-BK7ybRZe.js → useQuilttConnector-client-BwpjuFHf.js}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
3
|
import { cdnBase } from '@quiltt/core';
|
|
4
|
-
import { u as useQuilttSession } from './useQuilttSession-client-
|
|
4
|
+
import { u as useQuilttSession } from './useQuilttSession-client-DhsbThvI.js';
|
|
5
5
|
import { u as useScript } from './useScript-client-JCgaTW9n.js';
|
|
6
6
|
|
|
7
|
-
var version = "4.2.
|
|
7
|
+
var version = "4.2.2";
|
|
8
8
|
|
|
9
9
|
const useQuilttConnector = (connectorId, options)=>{
|
|
10
10
|
const status = useScript(`${cdnBase}/v1/connector.js?agent=react-${version}`, {
|
|
@@ -20,50 +20,42 @@ const useQuilttConnector = (connectorId, options)=>{
|
|
|
20
20
|
const prevConnectorIdRef = useRef(connectorId);
|
|
21
21
|
const connectorCreatedRef = useRef(false);
|
|
22
22
|
// Set Session
|
|
23
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: trigger effects when script status changes too
|
|
23
24
|
useEffect(()=>{
|
|
24
25
|
if (typeof Quiltt === 'undefined') return;
|
|
25
|
-
console.debug('[Quiltt] script status: ', status);
|
|
26
26
|
Quiltt.authenticate(session?.token);
|
|
27
27
|
}, [
|
|
28
28
|
status,
|
|
29
29
|
session?.token
|
|
30
30
|
]);
|
|
31
31
|
// Set Connector
|
|
32
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: trigger effects when script status changes too
|
|
32
33
|
useEffect(()=>{
|
|
33
34
|
if (typeof Quiltt === 'undefined' || !connectorId) return;
|
|
34
|
-
console.debug('[Quiltt] script status: ', status);
|
|
35
35
|
const currentConnectionId = options?.connectionId;
|
|
36
36
|
const currentInstitution = options?.institution;
|
|
37
|
-
// Check
|
|
37
|
+
// Check for changes
|
|
38
38
|
const connectionIdChanged = prevConnectionIdRef.current !== currentConnectionId;
|
|
39
39
|
const connectorIdChanged = prevConnectorIdRef.current !== connectorId;
|
|
40
|
-
|
|
41
|
-
//
|
|
42
|
-
if (
|
|
43
|
-
// The SDK will automatically update the existing handler with new connectionId
|
|
44
|
-
// via the DocumentObserver -> Engine.onChange -> Handler.updateOptions flow
|
|
45
|
-
console.debug('[Quiltt] connectionId changed, SDK will handle update automatically');
|
|
46
|
-
// Update our refs
|
|
47
|
-
prevConnectionIdRef.current = currentConnectionId;
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
// Only create new connector if we haven't created one yet or if connectorId changed
|
|
51
|
-
if (!connectorCreatedRef.current || connectorIdChanged) {
|
|
52
|
-
// Create new connector (initial mount or connectorId changed)
|
|
40
|
+
const hasChanges = connectionIdChanged || connectorIdChanged || !connectorCreatedRef.current;
|
|
41
|
+
// Update if there are changes, regardless of what the changes are
|
|
42
|
+
if (hasChanges) {
|
|
53
43
|
if (currentConnectionId) {
|
|
44
|
+
// Always use reconnect when connectionId is available
|
|
54
45
|
setConnector(Quiltt.reconnect(connectorId, {
|
|
55
46
|
connectionId: currentConnectionId
|
|
56
47
|
}));
|
|
57
48
|
} else {
|
|
49
|
+
// Use connect for new connections without connectionId
|
|
58
50
|
setConnector(Quiltt.connect(connectorId, {
|
|
59
51
|
institution: currentInstitution
|
|
60
52
|
}));
|
|
61
53
|
}
|
|
54
|
+
// Update refs
|
|
62
55
|
connectorCreatedRef.current = true;
|
|
56
|
+
prevConnectionIdRef.current = currentConnectionId;
|
|
57
|
+
prevConnectorIdRef.current = connectorId;
|
|
63
58
|
}
|
|
64
|
-
// Update refs
|
|
65
|
-
prevConnectionIdRef.current = currentConnectionId;
|
|
66
|
-
prevConnectorIdRef.current = connectorId;
|
|
67
59
|
}, [
|
|
68
60
|
connectorId,
|
|
69
61
|
options?.connectionId,
|
|
@@ -158,4 +150,4 @@ const useQuilttConnector = (connectorId, options)=>{
|
|
|
158
150
|
};
|
|
159
151
|
};
|
|
160
152
|
|
|
161
|
-
export { useQuilttConnector as u };
|
|
153
|
+
export { useQuilttConnector as u, version as v };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useMemo, useState, useCallback, useEffect } from 'react';
|
|
3
|
+
import { useDebounce } from 'use-debounce';
|
|
4
|
+
import { InstitutionsAPI } from '@quiltt/core';
|
|
5
|
+
import { v as version } from './useQuilttConnector-client-BwpjuFHf.js';
|
|
6
|
+
import { u as useSession } from './useSession-client-CCAvnROP.js';
|
|
7
|
+
|
|
8
|
+
const useQuilttInstitutions = (connectorId, onErrorCallback)=>{
|
|
9
|
+
const agent = useMemo(()=>{
|
|
10
|
+
// Try deprecated navigator.product first (still used in some RN versions)
|
|
11
|
+
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
12
|
+
return `react-native-${version}`;
|
|
13
|
+
}
|
|
14
|
+
// Detect React Native by its unique environment characteristics
|
|
15
|
+
const isReactNative = !!// Has window (unlike Node.js)
|
|
16
|
+
(typeof window !== 'undefined' && // No document in window (unlike browsers)
|
|
17
|
+
typeof window.document === 'undefined' && // Has navigator (unlike Node.js)
|
|
18
|
+
typeof navigator !== 'undefined');
|
|
19
|
+
return isReactNative ? `react-native-${version}` : `react-${version}`;
|
|
20
|
+
}, []);
|
|
21
|
+
const institutionsAPI = useMemo(()=>new InstitutionsAPI(connectorId, agent), [
|
|
22
|
+
connectorId,
|
|
23
|
+
agent
|
|
24
|
+
]);
|
|
25
|
+
const [session] = useSession();
|
|
26
|
+
const [searchTermInput, setSearchTermInput] = useState('');
|
|
27
|
+
const [searchTerm] = useDebounce(searchTermInput, 350);
|
|
28
|
+
const [searchResults, setSearchResults] = useState([]);
|
|
29
|
+
const [isSearching, setIsSearching] = useState(false);
|
|
30
|
+
/**
|
|
31
|
+
* Start Search
|
|
32
|
+
* This function is used to initiate a search for institutions based on the provided term with
|
|
33
|
+
* a minimum length of 2 characters. Debouncing is applied to avoid excessive API calls.
|
|
34
|
+
*/ const startSearch = useCallback((term)=>{
|
|
35
|
+
if (term.trim().length < 2) {
|
|
36
|
+
setSearchResults([]);
|
|
37
|
+
setIsSearching(false);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
setIsSearching(true);
|
|
41
|
+
setSearchTermInput(term);
|
|
42
|
+
}, []);
|
|
43
|
+
const handleError = useCallback((message)=>{
|
|
44
|
+
const errorMessage = message || 'Unknown error occurred while searching institutions';
|
|
45
|
+
console.error('Quiltt Institutions Search Error:', errorMessage);
|
|
46
|
+
if (onErrorCallback) onErrorCallback(errorMessage);
|
|
47
|
+
}, [
|
|
48
|
+
onErrorCallback
|
|
49
|
+
]);
|
|
50
|
+
/**
|
|
51
|
+
* Run Search
|
|
52
|
+
* This effect will run when the searchTerm changes and is at least 2 characters long.
|
|
53
|
+
*/ useEffect(()=>{
|
|
54
|
+
if (!session?.token || !connectorId || !searchTerm || searchTerm.trim().length < 2) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const abortController = new AbortController();
|
|
58
|
+
institutionsAPI.search(session?.token, connectorId, searchTerm, abortController.signal).then((response)=>{
|
|
59
|
+
if (!abortController.signal.aborted) {
|
|
60
|
+
if (response.status === 200) {
|
|
61
|
+
setSearchResults(response.data);
|
|
62
|
+
} else {
|
|
63
|
+
handleError(response.data.message || 'Failed to fetch institutions');
|
|
64
|
+
}
|
|
65
|
+
setIsSearching(false);
|
|
66
|
+
}
|
|
67
|
+
}).catch((error)=>{
|
|
68
|
+
if (!abortController.signal.aborted) {
|
|
69
|
+
handleError(error.message);
|
|
70
|
+
setIsSearching(false);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return ()=>abortController.abort();
|
|
74
|
+
}, [
|
|
75
|
+
session?.token,
|
|
76
|
+
connectorId,
|
|
77
|
+
searchTerm,
|
|
78
|
+
institutionsAPI,
|
|
79
|
+
handleError
|
|
80
|
+
]);
|
|
81
|
+
return {
|
|
82
|
+
searchTerm,
|
|
83
|
+
searchResults,
|
|
84
|
+
isSearching,
|
|
85
|
+
setSearchTerm: startSearch
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { useQuilttInstitutions as u };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { AuthAPI } from '@quiltt/core';
|
|
4
|
-
import { u as useImportSession, a as useIdentifySession, b as useAuthenticateSession, c as useRevokeSession } from './QuilttAuthProvider-client-
|
|
4
|
+
import { u as useImportSession, a as useIdentifySession, b as useAuthenticateSession, c as useRevokeSession } from './QuilttAuthProvider-client-C25Tg4_a.js';
|
|
5
5
|
import { u as useQuilttSettings } from './useQuilttSettings-client-BOCBjFXe.js';
|
|
6
6
|
import { u as useSession } from './useSession-client-CCAvnROP.js';
|
|
7
7
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quiltt/react",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "React Components and Hooks for Quiltt Connector",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"quiltt",
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@apollo/client": "^3.12.4",
|
|
38
38
|
"use-debounce": "^10.0.4",
|
|
39
|
-
"@quiltt/core": "4.2.
|
|
39
|
+
"@quiltt/core": "4.2.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@biomejs/biome": "1.9.4",
|
|
43
|
-
"@types/node": "22.
|
|
43
|
+
"@types/node": "22.15.31",
|
|
44
44
|
"@types/react": "18.3.20",
|
|
45
45
|
"@types/react-dom": "18.3.5",
|
|
46
46
|
"bunchee": "6.3.4",
|
|
47
47
|
"react": "18.3.1",
|
|
48
48
|
"react-dom": "18.3.1",
|
|
49
49
|
"rimraf": "6.0.1",
|
|
50
|
-
"typescript": "5.8.
|
|
50
|
+
"typescript": "5.8.3"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
package/src/hooks/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './helpers'
|
|
|
2
2
|
export * from './session'
|
|
3
3
|
export * from './useQuilttClient'
|
|
4
4
|
export * from './useQuilttConnector'
|
|
5
|
+
export * from './useQuilttInstitutions'
|
|
5
6
|
export * from './useQuilttSession'
|
|
6
7
|
export * from './useQuilttSettings'
|
|
7
8
|
export * from './useSession'
|
|
@@ -36,52 +36,41 @@ export const useQuilttConnector = (
|
|
|
36
36
|
const connectorCreatedRef = useRef<boolean>(false)
|
|
37
37
|
|
|
38
38
|
// Set Session
|
|
39
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: trigger effects when script status changes too
|
|
39
40
|
useEffect(() => {
|
|
40
41
|
if (typeof Quiltt === 'undefined') return
|
|
41
|
-
console.debug('[Quiltt] script status: ', status)
|
|
42
42
|
|
|
43
43
|
Quiltt.authenticate(session?.token)
|
|
44
44
|
}, [status, session?.token])
|
|
45
45
|
|
|
46
46
|
// Set Connector
|
|
47
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: trigger effects when script status changes too
|
|
47
48
|
useEffect(() => {
|
|
48
49
|
if (typeof Quiltt === 'undefined' || !connectorId) return
|
|
49
|
-
console.debug('[Quiltt] script status: ', status)
|
|
50
50
|
|
|
51
51
|
const currentConnectionId = options?.connectionId
|
|
52
52
|
const currentInstitution = options?.institution
|
|
53
53
|
|
|
54
|
-
// Check
|
|
54
|
+
// Check for changes
|
|
55
55
|
const connectionIdChanged = prevConnectionIdRef.current !== currentConnectionId
|
|
56
56
|
const connectorIdChanged = prevConnectorIdRef.current !== connectorId
|
|
57
|
+
const hasChanges = connectionIdChanged || connectorIdChanged || !connectorCreatedRef.current
|
|
57
58
|
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
if (connectionIdChanged && !connectorIdChanged && connectorCreatedRef.current) {
|
|
61
|
-
// The SDK will automatically update the existing handler with new connectionId
|
|
62
|
-
// via the DocumentObserver -> Engine.onChange -> Handler.updateOptions flow
|
|
63
|
-
console.debug('[Quiltt] connectionId changed, SDK will handle update automatically')
|
|
64
|
-
|
|
65
|
-
// Update our refs
|
|
66
|
-
prevConnectionIdRef.current = currentConnectionId
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Only create new connector if we haven't created one yet or if connectorId changed
|
|
71
|
-
if (!connectorCreatedRef.current || connectorIdChanged) {
|
|
72
|
-
// Create new connector (initial mount or connectorId changed)
|
|
59
|
+
// Update if there are changes, regardless of what the changes are
|
|
60
|
+
if (hasChanges) {
|
|
73
61
|
if (currentConnectionId) {
|
|
62
|
+
// Always use reconnect when connectionId is available
|
|
74
63
|
setConnector(Quiltt.reconnect(connectorId, { connectionId: currentConnectionId }))
|
|
75
64
|
} else {
|
|
65
|
+
// Use connect for new connections without connectionId
|
|
76
66
|
setConnector(Quiltt.connect(connectorId, { institution: currentInstitution }))
|
|
77
67
|
}
|
|
78
68
|
|
|
69
|
+
// Update refs
|
|
79
70
|
connectorCreatedRef.current = true
|
|
71
|
+
prevConnectionIdRef.current = currentConnectionId
|
|
72
|
+
prevConnectorIdRef.current = connectorId
|
|
80
73
|
}
|
|
81
|
-
|
|
82
|
-
// Update refs
|
|
83
|
-
prevConnectionIdRef.current = currentConnectionId
|
|
84
|
-
prevConnectorIdRef.current = connectorId
|
|
85
74
|
}, [connectorId, options?.connectionId, options?.institution, status])
|
|
86
75
|
|
|
87
76
|
// onEvent
|
|
@@ -7,7 +7,7 @@ import { useDebounce } from 'use-debounce'
|
|
|
7
7
|
import { InstitutionsAPI } from '@quiltt/core'
|
|
8
8
|
import type { ErrorData, InstitutionsData } from '@quiltt/core'
|
|
9
9
|
|
|
10
|
-
import { version } from '
|
|
10
|
+
import { version } from '../version'
|
|
11
11
|
import useSession from './useSession'
|
|
12
12
|
|
|
13
13
|
export type UseQuilttInstitutions = (
|