Skip to content

Commit 5d5999b

Browse files
authored
fix useTriggerProviderReconnect (#15620)
1 parent 6a8dcf8 commit 5d5999b

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

packages/twenty-front/src/modules/settings/accounts/hooks/__tests__/useTriggerProviderReconnect.test.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ describe('useTriggerProviderReconnect', () => {
115115

116116
expect(mockTriggerApisOAuth).toHaveBeenCalledWith(
117117
ConnectedAccountProvider.GOOGLE,
118-
undefined,
118+
{
119+
redirectLocation: '/settings/accounts',
120+
},
119121
);
120122
expect(mockNavigate).not.toHaveBeenCalled();
121123
});
@@ -133,7 +135,9 @@ describe('useTriggerProviderReconnect', () => {
133135

134136
expect(mockTriggerApisOAuth).toHaveBeenCalledWith(
135137
ConnectedAccountProvider.MICROSOFT,
136-
undefined,
138+
{
139+
redirectLocation: '/settings/accounts',
140+
},
137141
);
138142
expect(mockNavigate).not.toHaveBeenCalled();
139143
});
@@ -160,7 +164,10 @@ describe('useTriggerProviderReconnect', () => {
160164

161165
expect(mockTriggerApisOAuth).toHaveBeenCalledWith(
162166
ConnectedAccountProvider.GOOGLE,
163-
options,
167+
{
168+
...options,
169+
redirectLocation: '/settings/accounts',
170+
},
164171
);
165172
expect(mockNavigate).not.toHaveBeenCalled();
166173
});
@@ -186,7 +193,10 @@ describe('useTriggerProviderReconnect', () => {
186193

187194
expect(mockTriggerApisOAuth).toHaveBeenCalledWith(
188195
ConnectedAccountProvider.MICROSOFT,
189-
options,
196+
{
197+
...options,
198+
redirectLocation: '/settings/accounts',
199+
},
190200
);
191201
expect(mockNavigate).not.toHaveBeenCalled();
192202
});
@@ -205,7 +215,9 @@ describe('useTriggerProviderReconnect', () => {
205215

206216
expect(mockTriggerApisOAuth).toHaveBeenCalledWith(
207217
ConnectedAccountProvider.GOOGLE,
208-
undefined,
218+
{
219+
redirectLocation: '/settings/accounts',
220+
},
209221
);
210222
expect(mockNavigate).not.toHaveBeenCalled();
211223
});
@@ -230,7 +242,9 @@ describe('useTriggerProviderReconnect', () => {
230242

231243
expect(mockTriggerApisOAuth).toHaveBeenCalledWith(
232244
ConnectedAccountProvider.GOOGLE,
233-
undefined,
245+
{
246+
redirectLocation: '/settings/accounts',
247+
},
234248
);
235249
});
236250
});

packages/twenty-front/src/modules/settings/accounts/hooks/useTriggerProviderReconnect.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useCallback } from 'react';
22
import { ConnectedAccountProvider, SettingsPath } from 'twenty-shared/types';
3+
import { getSettingsPath } from 'twenty-shared/utils';
34

45
import { useTriggerApisOAuth } from '@/settings/accounts/hooks/useTriggerApiOAuth';
56
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
@@ -26,7 +27,10 @@ export const useTriggerProviderReconnect = () => {
2627
return;
2728
}
2829

29-
await triggerApisOAuth(provider, options);
30+
await triggerApisOAuth(provider, {
31+
...options,
32+
redirectLocation: getSettingsPath(SettingsPath.Accounts),
33+
});
3034
},
3135
[triggerApisOAuth, navigate],
3236
);

0 commit comments

Comments
 (0)