Skip to content

Commit 792fc21

Browse files
Fix redirect to new window
Update `shopify-auth` Edge Function to open redirect in a new browser window.
1 parent 708b05a commit 792fc21

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/hooks/useShopifySupabase.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,22 @@ export const useShopifySupabase = (campaignId: string) => {
9595
throw new Error('URL d\'autorisation non reçue');
9696
}
9797

98-
// Rediriger vers Shopify
99-
window.location.href = data.authUrl;
98+
// Rediriger vers Shopify dans une nouvelle fenêtre
99+
const popup = window.open(data.authUrl, 'shopify-auth', 'width=600,height=700,scrollbars=yes,resizable=yes');
100+
101+
if (!popup) {
102+
throw new Error('Le popup a été bloqué. Veuillez autoriser les popups pour ce site.');
103+
}
104+
105+
// Surveiller la fermeture du popup
106+
const checkClosed = setInterval(() => {
107+
if (popup.closed) {
108+
clearInterval(checkClosed);
109+
setIsLoading(false);
110+
// Rafraîchir les intégrations au cas où l'autorisation aurait réussi
111+
fetchIntegrations();
112+
}
113+
}, 1000);
100114

101115
} catch (error) {
102116
console.error('Erreur initiation OAuth:', error);

0 commit comments

Comments
 (0)