Skip to content

Commit

Permalink
[nan-638] cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
khaliqgant committed Mar 26, 2024
1 parent 2989d74 commit 1eff44a
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/webapp/src/pages/Connection/Create.tsx
Expand Up @@ -308,15 +308,17 @@ export default function IntegrationCreate() {
apiAuthString = `
credentials: {
apiKey: '${apiKey}'
}`;
}
`;
}

if (integration?.authMode === AuthModes.Basic) {
apiAuthString = `
credentials: {
username: '${apiAuthUsername}',
password: '${apiAuthPassword}'
}`;
}
`;
}

let appStoreAuthString = '';
Expand All @@ -327,7 +329,8 @@ export default function IntegrationCreate() {
privateKeyId: '${privateKeyId}',
issuerId: '${issuerId}',
privateKey: '${privateKey}'
}`;
}
`;
}

let oauthCredentialsString = '';
Expand All @@ -337,7 +340,8 @@ export default function IntegrationCreate() {
credentials: {
oauth_client_id: '${optionalOAuthClientId}',
oauth_client_secret: '${optionalOAuthClientSecret}'
}`;
}
`;
}

const connectionConfigStr =
Expand All @@ -353,17 +357,18 @@ export default function IntegrationCreate() {
[connectionConfigParamsStr, authorizationParamsStr, hmacKeyStr, userScopesStr, apiAuthString, appStoreAuthString, oauthCredentialsString]
.filter(Boolean)
.join(', ') +
' }';
'}';

return `import Nango from '@nangohq/frontend';
const nango = new Nango(${argsStr});
nango.${integration?.authMode === AuthModes.None ? 'create' : 'auth'}('${integration?.uniqueKey}', '${connectionId}'${connectionConfigStr}).then((result: { providerConfigKey: string; connectionId: string }) => {
nango.${integration?.authMode === AuthModes.None ? 'create' : 'auth'}('${integration?.uniqueKey}', '${connectionId}'${connectionConfigStr})
.then((result: { providerConfigKey: string; connectionId: string }) => {
// do something
}).catch((err: { message: string; type: string }) => {
}).catch((err: { message: string; type: string }) => {
// handle error
});`;
});`;
};

return (
Expand Down

0 comments on commit 1eff44a

Please sign in to comment.