diff --git a/src/hooks/useConnections.ts b/src/hooks/useConnections.ts index f53db1f..74dfd1e 100644 --- a/src/hooks/useConnections.ts +++ b/src/hooks/useConnections.ts @@ -791,6 +791,9 @@ export function useConnections() { knowledgePreferences?: import('../api/connectionApi').KnowledgePreferences | null, ): Promise => { if (isConnecting) return; + if (type === 'infomaniak') { + throw new Error('Infomaniak uses PAT flow – use createInfomaniakConnection + submitInfomaniakToken instead.'); + } setIsConnecting(true); try { const newConnection = await createConnection({ diff --git a/src/pages/basedata/ConnectionsPage.tsx b/src/pages/basedata/ConnectionsPage.tsx index f721b38..4815410 100644 --- a/src/pages/basedata/ConnectionsPage.tsx +++ b/src/pages/basedata/ConnectionsPage.tsx @@ -46,6 +46,8 @@ export const ConnectionsPage: React.FC = () => { connectWithPopup, refreshMicrosoftToken, refreshGoogleToken, + createInfomaniakConnection, + submitInfomaniakToken, isConnecting, } = useConnections(); @@ -234,6 +236,17 @@ export const ConnectionsPage: React.FC = () => { } }; + const handleInfomaniakConnect = async (token: string, knowledgeEnabled: boolean) => { + try { + const newConn = await createInfomaniakConnection(); + await submitInfomaniakToken(newConn.id, token); + refetch(); + if (knowledgeEnabled) showSyncBanner('Infomaniak'); + } catch (error) { + console.error('Error creating Infomaniak connection:', error); + } + }; + const handleMsftAdminConsent = () => { const url = `${getApiBaseUrl()}/api/msft/adminconsent`; window.open(url, 'msft-admin-consent', 'width=560,height=720,scrollbars=yes,resizable=yes'); @@ -469,6 +482,7 @@ export const ConnectionsPage: React.FC = () => { open={wizardOpen} onClose={() => setWizardOpen(false)} onConnect={handleWizardConnect} + onInfomaniakConnect={handleInfomaniakConnect} onMsftAdminConsent={handleMsftAdminConsent} isConnecting={isConnecting} />