@amp-labs/react 1.0.2 → 1.1.0

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.
Files changed (30) hide show
  1. package/README.md +1 -1
  2. package/build/generated-sources/api/src/apis/DefaultApi.d.ts +30 -4
  3. package/build/generated-sources/api/src/apis/DefaultApi.js +29 -2
  4. package/build/generated-sources/api/src/models/CreateInstallationRequest.d.ts +2 -2
  5. package/build/generated-sources/api/src/models/CreateInstallationRequest.js +2 -2
  6. package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.d.ts +3 -3
  7. package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.js +3 -4
  8. package/build/generated-sources/api/src/models/OauthConnectRequest.d.ts +1 -1
  9. package/build/generated-sources/api/src/models/OauthConnectRequest.js +1 -2
  10. package/build/generated-sources/api/src/models/Operation.d.ts +6 -12
  11. package/build/generated-sources/api/src/models/Operation.js +3 -6
  12. package/build/src/components/Configure/ObjectManagementNav/index.js +5 -4
  13. package/build/src/components/Configure/ProtectedConnectionLayout.js +6 -5
  14. package/build/src/components/Configure/UninstallContent.js +8 -1
  15. package/build/src/components/Oauth/Hubspot/HubspotLandingContent.d.ts +7 -0
  16. package/build/src/components/Oauth/Hubspot/HubspotLandingContent.js +10 -0
  17. package/build/src/components/Oauth/Hubspot/HubspotOauthFlow.d.ts +15 -0
  18. package/build/src/components/Oauth/Hubspot/HubspotOauthFlow.js +50 -0
  19. package/build/src/components/Oauth/OAuthErrorAlert.d.ts +5 -0
  20. package/build/src/components/Oauth/OAuthErrorAlert.js +12 -0
  21. package/build/src/components/{Salesforce → Oauth/Salesforce}/SalesforceOauthFlow.d.ts +2 -2
  22. package/build/src/components/Oauth/Salesforce/SalesforceOauthFlow.js +57 -0
  23. package/build/src/components/Oauth/Salesforce/SubdomainEntry.d.ts +8 -0
  24. package/build/src/components/Oauth/Salesforce/SubdomainEntry.js +12 -0
  25. package/build/src/components/Oauth/fetchOAuthCallbackURL.d.ts +1 -0
  26. package/build/src/components/Oauth/fetchOAuthCallbackURL.js +29 -0
  27. package/build/src/constants.d.ts +1 -0
  28. package/build/src/constants.js +2 -1
  29. package/package.json +2 -2
  30. package/build/src/components/Salesforce/SalesforceOauthFlow.js +0 -89
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Ampersand React Library
1
+ # Ampersand React library
2
2
 
3
3
  ## Overview
4
4
  Ampersand is a config-first platform for SaaS builders who are creating user-facing integrations.
@@ -74,6 +74,10 @@ export interface GetHydratedRevisionRequest {
74
74
  revisionId: string;
75
75
  connectionId: string;
76
76
  }
77
+ export interface GetOperationRequest {
78
+ projectId: string;
79
+ operationId: string;
80
+ }
77
81
  export interface GetProjectRequest {
78
82
  projectId: string;
79
83
  }
@@ -346,7 +350,7 @@ export interface DefaultApiInterface {
346
350
  generateUploadUrl(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SignedUrl>;
347
351
  /**
348
352
  *
349
- * @summary get a connection
353
+ * @summary Get a connection
350
354
  * @param {string} projectId
351
355
  * @param {string} connectionId
352
356
  * @param {*} [options] Override http request option.
@@ -355,7 +359,7 @@ export interface DefaultApiInterface {
355
359
  */
356
360
  getConnectionRaw(requestParameters: GetConnectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Connection>>;
357
361
  /**
358
- * get a connection
362
+ * Get a connection
359
363
  */
360
364
  getConnection(requestParameters: GetConnectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Connection>;
361
365
  /**
@@ -374,6 +378,20 @@ export interface DefaultApiInterface {
374
378
  * Hydrate a revision with information from the consumer\'s SaaS instance.
375
379
  */
376
380
  getHydratedRevision(requestParameters: GetHydratedRevisionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<HydratedRevision>;
381
+ /**
382
+ *
383
+ * @summary Get an operation
384
+ * @param {string} projectId
385
+ * @param {string} operationId
386
+ * @param {*} [options] Override http request option.
387
+ * @throws {RequiredError}
388
+ * @memberof DefaultApiInterface
389
+ */
390
+ getOperationRaw(requestParameters: GetOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Operation>>;
391
+ /**
392
+ * Get an operation
393
+ */
394
+ getOperation(requestParameters: GetOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Operation>;
377
395
  /**
378
396
  *
379
397
  * @summary Get a project
@@ -742,11 +760,11 @@ export declare class DefaultApi extends runtime.BaseAPI implements DefaultApiInt
742
760
  */
743
761
  generateUploadUrl(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SignedUrl>;
744
762
  /**
745
- * get a connection
763
+ * Get a connection
746
764
  */
747
765
  getConnectionRaw(requestParameters: GetConnectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Connection>>;
748
766
  /**
749
- * get a connection
767
+ * Get a connection
750
768
  */
751
769
  getConnection(requestParameters: GetConnectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Connection>;
752
770
  /**
@@ -757,6 +775,14 @@ export declare class DefaultApi extends runtime.BaseAPI implements DefaultApiInt
757
775
  * Hydrate a revision with information from the consumer\'s SaaS instance.
758
776
  */
759
777
  getHydratedRevision(requestParameters: GetHydratedRevisionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<HydratedRevision>;
778
+ /**
779
+ * Get an operation
780
+ */
781
+ getOperationRaw(requestParameters: GetOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Operation>>;
782
+ /**
783
+ * Get an operation
784
+ */
785
+ getOperation(requestParameters: GetOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Operation>;
760
786
  /**
761
787
  * Get a project
762
788
  */
@@ -424,7 +424,7 @@ class DefaultApi extends runtime.BaseAPI {
424
424
  return await response.value();
425
425
  }
426
426
  /**
427
- * get a connection
427
+ * Get a connection
428
428
  */
429
429
  async getConnectionRaw(requestParameters, initOverrides) {
430
430
  if (requestParameters.projectId === null || requestParameters.projectId === undefined) {
@@ -444,7 +444,7 @@ class DefaultApi extends runtime.BaseAPI {
444
444
  return new runtime.JSONApiResponse(response, (jsonValue) => (0, models_1.ConnectionFromJSON)(jsonValue));
445
445
  }
446
446
  /**
447
- * get a connection
447
+ * Get a connection
448
448
  */
449
449
  async getConnection(requestParameters, initOverrides) {
450
450
  const response = await this.getConnectionRaw(requestParameters, initOverrides);
@@ -486,6 +486,33 @@ class DefaultApi extends runtime.BaseAPI {
486
486
  const response = await this.getHydratedRevisionRaw(requestParameters, initOverrides);
487
487
  return await response.value();
488
488
  }
489
+ /**
490
+ * Get an operation
491
+ */
492
+ async getOperationRaw(requestParameters, initOverrides) {
493
+ if (requestParameters.projectId === null || requestParameters.projectId === undefined) {
494
+ throw new runtime.RequiredError('projectId', 'Required parameter requestParameters.projectId was null or undefined when calling getOperation.');
495
+ }
496
+ if (requestParameters.operationId === null || requestParameters.operationId === undefined) {
497
+ throw new runtime.RequiredError('operationId', 'Required parameter requestParameters.operationId was null or undefined when calling getOperation.');
498
+ }
499
+ const queryParameters = {};
500
+ const headerParameters = {};
501
+ const response = await this.request({
502
+ path: `/projects/{projectId}/operations/{operationId}`.replace(`{${"projectId"}}`, encodeURIComponent(String(requestParameters.projectId))).replace(`{${"operationId"}}`, encodeURIComponent(String(requestParameters.operationId))),
503
+ method: 'GET',
504
+ headers: headerParameters,
505
+ query: queryParameters,
506
+ }, initOverrides);
507
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, models_1.OperationFromJSON)(jsonValue));
508
+ }
509
+ /**
510
+ * Get an operation
511
+ */
512
+ async getOperation(requestParameters, initOverrides) {
513
+ const response = await this.getOperationRaw(requestParameters, initOverrides);
514
+ return await response.value();
515
+ }
489
516
  /**
490
517
  * Get a project
491
518
  */
@@ -23,11 +23,11 @@ export interface CreateInstallationRequest {
23
23
  */
24
24
  groupRef: string;
25
25
  /**
26
- * The ID of the SaaS connection tied to this installation.
26
+ * The ID of the SaaS connection tied to this installation. If omitted the default connection for this group will be used.
27
27
  * @type {string}
28
28
  * @memberof CreateInstallationRequest
29
29
  */
30
- connectionId: string;
30
+ connectionId?: string;
31
31
  /**
32
32
  *
33
33
  * @type {CreateInstallationRequestConfig}
@@ -14,6 +14,7 @@
14
14
  */
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.CreateInstallationRequestToJSON = exports.CreateInstallationRequestFromJSONTyped = exports.CreateInstallationRequestFromJSON = exports.instanceOfCreateInstallationRequest = void 0;
17
+ const runtime_1 = require("../runtime");
17
18
  const CreateInstallationRequestConfig_1 = require("./CreateInstallationRequestConfig");
18
19
  /**
19
20
  * Check if a given object implements the CreateInstallationRequest interface.
@@ -21,7 +22,6 @@ const CreateInstallationRequestConfig_1 = require("./CreateInstallationRequestCo
21
22
  function instanceOfCreateInstallationRequest(value) {
22
23
  let isInstance = true;
23
24
  isInstance = isInstance && "groupRef" in value;
24
- isInstance = isInstance && "connectionId" in value;
25
25
  isInstance = isInstance && "config" in value;
26
26
  return isInstance;
27
27
  }
@@ -36,7 +36,7 @@ function CreateInstallationRequestFromJSONTyped(json, ignoreDiscriminator) {
36
36
  }
37
37
  return {
38
38
  'groupRef': json['groupRef'],
39
- 'connectionId': json['connectionId'],
39
+ 'connectionId': !(0, runtime_1.exists)(json, 'connectionId') ? undefined : json['connectionId'],
40
40
  'config': (0, CreateInstallationRequestConfig_1.CreateInstallationRequestConfigFromJSON)(json['config']),
41
41
  };
42
42
  }
@@ -17,17 +17,17 @@ import type { ConfigContent } from './ConfigContent';
17
17
  */
18
18
  export interface CreateInstallationRequestConfig {
19
19
  /**
20
- * The ID of the revision that this config is based on.
20
+ * The ID of the revision that this config is based on. If omitted, the latest revision is assumed.
21
21
  * @type {string}
22
22
  * @memberof CreateInstallationRequestConfig
23
23
  */
24
- revisionId: string;
24
+ revisionId?: string;
25
25
  /**
26
26
  * The person who created the config, in the format of "consumer:{consumer-id}" or "builder:{builder-id}".
27
27
  * @type {string}
28
28
  * @memberof CreateInstallationRequestConfig
29
29
  */
30
- createdBy: string;
30
+ createdBy?: string;
31
31
  /**
32
32
  *
33
33
  * @type {ConfigContent}
@@ -14,14 +14,13 @@
14
14
  */
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.CreateInstallationRequestConfigToJSON = exports.CreateInstallationRequestConfigFromJSONTyped = exports.CreateInstallationRequestConfigFromJSON = exports.instanceOfCreateInstallationRequestConfig = void 0;
17
+ const runtime_1 = require("../runtime");
17
18
  const ConfigContent_1 = require("./ConfigContent");
18
19
  /**
19
20
  * Check if a given object implements the CreateInstallationRequestConfig interface.
20
21
  */
21
22
  function instanceOfCreateInstallationRequestConfig(value) {
22
23
  let isInstance = true;
23
- isInstance = isInstance && "revisionId" in value;
24
- isInstance = isInstance && "createdBy" in value;
25
24
  isInstance = isInstance && "content" in value;
26
25
  return isInstance;
27
26
  }
@@ -35,8 +34,8 @@ function CreateInstallationRequestConfigFromJSONTyped(json, ignoreDiscriminator)
35
34
  return json;
36
35
  }
37
36
  return {
38
- 'revisionId': json['revisionId'],
39
- 'createdBy': json['createdBy'],
37
+ 'revisionId': !(0, runtime_1.exists)(json, 'revisionId') ? undefined : json['revisionId'],
38
+ 'createdBy': !(0, runtime_1.exists)(json, 'createdBy') ? undefined : json['createdBy'],
40
39
  'content': (0, ConfigContent_1.ConfigContentFromJSON)(json['content']),
41
40
  };
42
41
  }
@@ -20,7 +20,7 @@ export interface OauthConnectRequest {
20
20
  * @type {string}
21
21
  * @memberof OauthConnectRequest
22
22
  */
23
- providerWorkspaceRef: string;
23
+ providerWorkspaceRef?: string;
24
24
  /**
25
25
  * The project ID.
26
26
  * @type {string}
@@ -20,7 +20,6 @@ const runtime_1 = require("../runtime");
20
20
  */
21
21
  function instanceOfOauthConnectRequest(value) {
22
22
  let isInstance = true;
23
- isInstance = isInstance && "providerWorkspaceRef" in value;
24
23
  isInstance = isInstance && "projectId" in value;
25
24
  isInstance = isInstance && "groupRef" in value;
26
25
  isInstance = isInstance && "consumerRef" in value;
@@ -38,7 +37,7 @@ function OauthConnectRequestFromJSONTyped(json, ignoreDiscriminator) {
38
37
  return json;
39
38
  }
40
39
  return {
41
- 'providerWorkspaceRef': json['providerWorkspaceRef'],
40
+ 'providerWorkspaceRef': !(0, runtime_1.exists)(json, 'providerWorkspaceRef') ? undefined : json['providerWorkspaceRef'],
42
41
  'projectId': json['projectId'],
43
42
  'groupRef': json['groupRef'],
44
43
  'groupName': !(0, runtime_1.exists)(json, 'groupName') ? undefined : json['groupName'],
@@ -35,29 +35,23 @@ export interface Operation {
35
35
  */
36
36
  objectName: string;
37
37
  /**
38
- * The Ampersand installation ID.
39
- * @type {string}
40
- * @memberof Operation
41
- */
42
- installationId: string;
43
- /**
44
- * The status of the operation.
38
+ * The operation ID.
45
39
  * @type {string}
46
40
  * @memberof Operation
47
41
  */
48
- status?: string;
42
+ id: string;
49
43
  /**
50
- * The workflow reference.
44
+ * The Ampersand installation ID.
51
45
  * @type {string}
52
46
  * @memberof Operation
53
47
  */
54
- workflowRef: string;
48
+ installationId: string;
55
49
  /**
56
- * The run reference.
50
+ * The status of the operation.
57
51
  * @type {string}
58
52
  * @memberof Operation
59
53
  */
60
- runRef: string;
54
+ status?: string;
61
55
  /**
62
56
  * The error history of the operation.
63
57
  * @type {Array<OperationError>}
@@ -24,9 +24,8 @@ function instanceOfOperation(value) {
24
24
  isInstance = isInstance && "projectId" in value;
25
25
  isInstance = isInstance && "actionType" in value;
26
26
  isInstance = isInstance && "objectName" in value;
27
+ isInstance = isInstance && "id" in value;
27
28
  isInstance = isInstance && "installationId" in value;
28
- isInstance = isInstance && "workflowRef" in value;
29
- isInstance = isInstance && "runRef" in value;
30
29
  return isInstance;
31
30
  }
32
31
  exports.instanceOfOperation = instanceOfOperation;
@@ -42,10 +41,9 @@ function OperationFromJSONTyped(json, ignoreDiscriminator) {
42
41
  'projectId': json['projectId'],
43
42
  'actionType': json['actionType'],
44
43
  'objectName': json['objectName'],
44
+ 'id': json['id'],
45
45
  'installationId': json['installationId'],
46
46
  'status': !(0, runtime_1.exists)(json, 'status') ? undefined : json['status'],
47
- 'workflowRef': json['workflowRef'],
48
- 'runRef': json['runRef'],
49
47
  'errorHistory': !(0, runtime_1.exists)(json, 'errorHistory') ? undefined : (json['errorHistory'].map(OperationError_1.OperationErrorFromJSON)),
50
48
  'createTime': !(0, runtime_1.exists)(json, 'createTime') ? undefined : (new Date(json['createTime'])),
51
49
  };
@@ -62,10 +60,9 @@ function OperationToJSON(value) {
62
60
  'projectId': value.projectId,
63
61
  'actionType': value.actionType,
64
62
  'objectName': value.objectName,
63
+ 'id': value.id,
65
64
  'installationId': value.installationId,
66
65
  'status': value.status,
67
- 'workflowRef': value.workflowRef,
68
- 'runRef': value.runRef,
69
66
  'errorHistory': value.errorHistory === undefined ? undefined : (value.errorHistory.map(OperationError_1.OperationErrorToJSON)),
70
67
  'createTime': value.createTime === undefined ? undefined : (value.createTime.toISOString()),
71
68
  };
@@ -6,9 +6,10 @@ const react_1 = require("react");
6
6
  const react_2 = require("@chakra-ui/react");
7
7
  const InstallIntegrationContext_1 = require("../../../context/InstallIntegrationContext");
8
8
  const ProjectContext_1 = require("../../../context/ProjectContext");
9
+ const utils_1 = require("../../../utils");
9
10
  const ConfigurationStateProvider_1 = require("../state/ConfigurationStateProvider");
10
11
  const HydratedRevisionContext_1 = require("../state/HydratedRevisionContext");
11
- const utils_1 = require("../utils");
12
+ const utils_2 = require("../utils");
12
13
  const NavObjectItem_1 = require("./NavObjectItem");
13
14
  const UninstallInstallation_1 = require("./UninstallInstallation");
14
15
  // Create a context for the selected navObject's name
@@ -33,17 +34,17 @@ function getSelectedObject(navObjects, tabIndex) {
33
34
  }
34
35
  // note: when the object key exists in the config; the user has already completed the object before
35
36
  function ObjectManagementNav({ children, }) {
36
- const { installation } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
37
+ const { installation, provider } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
37
38
  const { hydratedRevision } = (0, HydratedRevisionContext_1.useHydratedRevision)();
38
39
  const { objectConfigurationsState } = (0, ConfigurationStateProvider_1.useConfigureState)();
39
40
  const config = installation === null || installation === void 0 ? void 0 : installation.config;
40
- const navObjects = hydratedRevision && (0, utils_1.generateNavObjects)(config, hydratedRevision);
41
+ const navObjects = hydratedRevision && (0, utils_2.generateNavObjects)(config, hydratedRevision);
41
42
  const [tabIndex, setTabIndex] = (0, react_1.useState)(0);
42
43
  const handleTabsChange = (index) => { setTabIndex(index); };
43
44
  const selectedObject = getSelectedObject(navObjects || [], tabIndex);
44
45
  const { project } = (0, ProjectContext_1.useProject)();
45
46
  const appName = (project === null || project === void 0 ? void 0 : project.appName) || '';
46
- return ((0, jsx_runtime_1.jsx)(SelectedObjectNameContext.Provider, { value: selectedObject === null || selectedObject === void 0 ? void 0 : selectedObject.name, children: (0, jsx_runtime_1.jsxs)(react_2.Box, { p: 8, maxWidth: "55rem", border: "1px solid #EFEFEF", borderRadius: 6, boxShadow: "md", margin: "auto", bgColor: "whitesmoke", display: "flex", gap: "6", minHeight: "100%", children: [(0, jsx_runtime_1.jsxs)(react_2.Box, { width: "20rem", children: [(0, jsx_runtime_1.jsx)(react_2.Text, { children: "Salesforce integration" }), (0, jsx_runtime_1.jsx)(react_2.Text, { marginBottom: "20px", fontSize: "1.125rem", fontWeight: "500", children: appName }), navObjects && ((0, jsx_runtime_1.jsxs)(react_2.Tabs, { index: tabIndex, onChange: handleTabsChange, orientation: "horizontal", children: [navObjects.map((object) => {
47
+ return ((0, jsx_runtime_1.jsx)(SelectedObjectNameContext.Provider, { value: selectedObject === null || selectedObject === void 0 ? void 0 : selectedObject.name, children: (0, jsx_runtime_1.jsxs)(react_2.Box, { p: 8, maxWidth: "55rem", border: "1px solid #EFEFEF", borderRadius: 6, boxShadow: "md", margin: "auto", bgColor: "whitesmoke", display: "flex", gap: "6", minHeight: "100%", children: [(0, jsx_runtime_1.jsxs)(react_2.Box, { width: "20rem", children: [(0, jsx_runtime_1.jsxs)(react_2.Text, { children: [(0, utils_1.capitalize)(provider), " integration"] }), (0, jsx_runtime_1.jsx)(react_2.Text, { marginBottom: "20px", fontSize: "1.125rem", fontWeight: "500", children: appName }), navObjects && ((0, jsx_runtime_1.jsxs)(react_2.Tabs, { index: tabIndex, onChange: handleTabsChange, orientation: "horizontal", children: [navObjects.map((object) => {
47
48
  var _a, _b;
48
49
  return ((0, jsx_runtime_1.jsx)(NavObjectItem_1.NavObjectItem, { objectName: object.name, completed: object.completed, pending: ((_a = objectConfigurationsState[object.name]) === null || _a === void 0 ? void 0 : _a.isOptionalFieldsModified)
49
50
  || ((_b = objectConfigurationsState[object.name]) === null || _b === void 0 ? void 0 : _b.isRequiredMapFieldsModified) }, object.name));
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.ProtectedConnectionLayout = void 0;
7
4
  const jsx_runtime_1 = require("react/jsx-runtime");
@@ -9,7 +6,8 @@ const react_1 = require("react");
9
6
  const constants_1 = require("../../constants");
10
7
  const ConnectionsContext_1 = require("../../context/ConnectionsContext");
11
8
  const InstallIntegrationContext_1 = require("../../context/InstallIntegrationContext");
12
- const SalesforceOauthFlow_1 = __importDefault(require("../Salesforce/SalesforceOauthFlow"));
9
+ const HubspotOauthFlow_1 = require("../Oauth/Hubspot/HubspotOauthFlow");
10
+ const SalesforceOauthFlow_1 = require("../Oauth/Salesforce/SalesforceOauthFlow");
13
11
  function ProtectedConnectionLayout({ provider, consumerRef, consumerName, groupRef, groupName, children, }) {
14
12
  const { selectedConnection, setSelectedConnection, connections } = (0, ConnectionsContext_1.useConnections)();
15
13
  (0, react_1.useEffect)(() => {
@@ -26,7 +24,10 @@ function ProtectedConnectionLayout({ provider, consumerRef, consumerName, groupR
26
24
  if (selectedConnection)
27
25
  return children;
28
26
  if (provider === constants_1.PROVIDER_SALESFORCE || providerFromProps === constants_1.PROVIDER_SALESFORCE) {
29
- return ((0, jsx_runtime_1.jsx)(SalesforceOauthFlow_1.default, { consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName }));
27
+ return ((0, jsx_runtime_1.jsx)(SalesforceOauthFlow_1.SalesforceOauthFlow, { consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName }));
28
+ }
29
+ if (provider === constants_1.PROVIDER_HUBSPOT || providerFromProps === constants_1.PROVIDER_HUBSPOT) {
30
+ return ((0, jsx_runtime_1.jsx)(HubspotOauthFlow_1.HubspotOauthFlow, { consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName }));
30
31
  }
31
32
  return ((0, jsx_runtime_1.jsx)("div", { children: "Unsupported provider" }));
32
33
  }
@@ -4,10 +4,12 @@ exports.UninstallContent = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const react_2 = require("@chakra-ui/react");
7
+ const ApiKeyProvider_1 = require("../../context/ApiKeyProvider");
7
8
  const InstallIntegrationContext_1 = require("../../context/InstallIntegrationContext");
8
9
  const ProjectContext_1 = require("../../context/ProjectContext");
9
10
  const api_1 = require("../../services/api");
10
11
  function UninstallContent() {
12
+ const apiKey = (0, ApiKeyProvider_1.useApiKey)();
11
13
  const { projectId, appName } = (0, ProjectContext_1.useProject)();
12
14
  const { integrationId, installation, resetInstallations } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
13
15
  const [loading, setLoading] = (0, react_1.useState)(false);
@@ -17,7 +19,12 @@ function UninstallContent() {
17
19
  setLoading(true);
18
20
  console.warn('uninstalling installation', { projectId, integrationId, installationId: installation.id });
19
21
  try {
20
- await (0, api_1.api)().deleteInstallation({ projectId, integrationId, installationId: installation.id });
22
+ await (0, api_1.api)().deleteInstallation({ projectId, integrationId, installationId: installation.id }, {
23
+ headers: {
24
+ 'X-Api-Key': apiKey,
25
+ 'Content-Type': 'application/json',
26
+ },
27
+ });
21
28
  resetInstallations();
22
29
  console.warn('successfully uninstalled installation: ', installation.id);
23
30
  }
@@ -0,0 +1,7 @@
1
+ type HubspotLandingContentProps = {
2
+ handleSubmit: () => void;
3
+ error: string | null;
4
+ isButtonDisabled?: boolean;
5
+ };
6
+ export declare function HubspotLandingContent({ handleSubmit, error, isButtonDisabled, }: HubspotLandingContentProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HubspotLandingContent = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@chakra-ui/react");
6
+ const OAuthErrorAlert_1 = require("../OAuthErrorAlert");
7
+ function HubspotLandingContent({ handleSubmit, error, isButtonDisabled, }) {
8
+ return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsx)(react_1.Box, { p: 8, maxWidth: "600px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", textAlign: ['left'], margin: "auto", marginTop: "40px", bgColor: "white", children: (0, jsx_runtime_1.jsxs)(react_1.FormControl, { children: [(0, jsx_runtime_1.jsx)(react_1.FormLabel, { marginTop: "16", marginBottom: "0", children: (0, jsx_runtime_1.jsx)(react_1.Heading, { as: "h4", size: "md", children: "Set up HubSpot integration" }) }), (0, jsx_runtime_1.jsx)(OAuthErrorAlert_1.OAuthErrorAlert, { error: error }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(react_1.Button, { isDisabled: isButtonDisabled, width: "100%", type: "submit", onClick: handleSubmit, children: "Next" })] }) }) }));
9
+ }
10
+ exports.HubspotLandingContent = HubspotLandingContent;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Hubspot landing component, which then will launch to create an OAuth connection to Hubspot.
3
+ */
4
+ interface HubspotOauthFlowProps {
5
+ consumerRef: string;
6
+ consumerName?: string;
7
+ groupRef: string;
8
+ groupName?: string;
9
+ }
10
+ /**
11
+ * HubspotOauthFlow first prompts user with a next button,
12
+ * then launches a popup with the OAuth flow.
13
+ */
14
+ export declare function HubspotOauthFlow({ consumerRef, consumerName, groupRef, groupName, }: HubspotOauthFlowProps): import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.HubspotOauthFlow = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ /**
9
+ * Hubspot landing component, which then will launch to create an OAuth connection to Hubspot.
10
+ */
11
+ const react_1 = require("react");
12
+ const constants_1 = require("../../../constants");
13
+ const ApiKeyProvider_1 = require("../../../context/ApiKeyProvider");
14
+ const ProjectContext_1 = require("../../../context/ProjectContext");
15
+ const OAuthPopup_1 = __importDefault(require("../../Connect/OAuthPopup"));
16
+ const fetchOAuthCallbackURL_1 = require("../fetchOAuthCallbackURL");
17
+ const HubspotLandingContent_1 = require("./HubspotLandingContent");
18
+ /**
19
+ * HubspotOauthFlow first prompts user with a next button,
20
+ * then launches a popup with the OAuth flow.
21
+ */
22
+ function HubspotOauthFlow({ consumerRef, consumerName, groupRef, groupName, }) {
23
+ const { projectId } = (0, ProjectContext_1.useProject)();
24
+ const apiKey = (0, ApiKeyProvider_1.useApiKey)();
25
+ const [oAuthCallbackURL, setOAuthCallbackURL] = (0, react_1.useState)(null);
26
+ const [error, setError] = (0, react_1.useState)(null);
27
+ // 1. fetch provider apps
28
+ // 2. find matching app to provider
29
+ // 3. fetch OAuth callback URL from connection so that oath popup can be launched
30
+ const handleSubmit = async () => {
31
+ var _a;
32
+ setError(null);
33
+ if (consumerName && groupName && apiKey) {
34
+ try {
35
+ const url = await (0, fetchOAuthCallbackURL_1.fetchOAuthCallbackURL)(projectId, consumerRef, groupRef, consumerName, groupName, apiKey, constants_1.PROVIDER_HUBSPOT);
36
+ setOAuthCallbackURL(url);
37
+ }
38
+ catch (err) {
39
+ console.error(err);
40
+ setError((_a = err.message) !== null && _a !== void 0 ? _a : 'Unexpected error');
41
+ }
42
+ }
43
+ };
44
+ const onClose = (0, react_1.useCallback)((err) => {
45
+ setError(err);
46
+ setOAuthCallbackURL(null);
47
+ }, []);
48
+ return ((0, jsx_runtime_1.jsx)(OAuthPopup_1.default, { title: "Connect to Hubspot", url: oAuthCallbackURL, onClose: onClose, children: (0, jsx_runtime_1.jsx)(HubspotLandingContent_1.HubspotLandingContent, { handleSubmit: handleSubmit, error: error }) }));
49
+ }
50
+ exports.HubspotOauthFlow = HubspotOauthFlow;
@@ -0,0 +1,5 @@
1
+ interface OAuthErrorAlertProps {
2
+ error: string | null;
3
+ }
4
+ export declare function OAuthErrorAlert({ error }: OAuthErrorAlertProps): import("react/jsx-runtime").JSX.Element | null;
5
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OAuthErrorAlert = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@chakra-ui/react");
6
+ function OAuthErrorAlert({ error }) {
7
+ if (error) {
8
+ return ((0, jsx_runtime_1.jsxs)(react_1.Alert, { status: "error", marginTop: "2em", children: [(0, jsx_runtime_1.jsx)(react_1.AlertIcon, {}), (0, jsx_runtime_1.jsx)(react_1.AlertDescription, { children: error })] }));
9
+ }
10
+ return null;
11
+ }
12
+ exports.OAuthErrorAlert = OAuthErrorAlert;
@@ -12,5 +12,5 @@ interface SalesforceOauthFlowProps {
12
12
  * SalesforceOauthFlow first prompts user for their workspace ("subdomain" in Salesforce lingo),
13
13
  * then launches a popup with the OAuth flow.
14
14
  */
15
- declare function SalesforceOauthFlow({ consumerRef, consumerName, groupRef, groupName, }: SalesforceOauthFlowProps): import("react/jsx-runtime").JSX.Element;
16
- export default SalesforceOauthFlow;
15
+ export declare function SalesforceOauthFlow({ consumerRef, consumerName, groupRef, groupName, }: SalesforceOauthFlowProps): import("react/jsx-runtime").JSX.Element;
16
+ export {};
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SalesforceOauthFlow = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ /**
9
+ * Prompts customer to input their Salesforce subdomain, then creates an OAuth connection to
10
+ * that Salesforce instance.
11
+ */
12
+ const react_1 = require("react");
13
+ const constants_1 = require("../../../constants");
14
+ const ApiKeyProvider_1 = require("../../../context/ApiKeyProvider");
15
+ const ProjectContext_1 = require("../../../context/ProjectContext");
16
+ const OAuthPopup_1 = __importDefault(require("../../Connect/OAuthPopup"));
17
+ const fetchOAuthCallbackURL_1 = require("../fetchOAuthCallbackURL");
18
+ const SubdomainEntry_1 = require("./SubdomainEntry");
19
+ /**
20
+ * SalesforceOauthFlow first prompts user for their workspace ("subdomain" in Salesforce lingo),
21
+ * then launches a popup with the OAuth flow.
22
+ */
23
+ function SalesforceOauthFlow({ consumerRef, consumerName, groupRef, groupName, }) {
24
+ const { projectId } = (0, ProjectContext_1.useProject)();
25
+ const apiKey = (0, ApiKeyProvider_1.useApiKey)();
26
+ const [workspace, setWorkspace] = (0, react_1.useState)('');
27
+ const [oAuthCallbackURL, setOAuthCallbackURL] = (0, react_1.useState)(null);
28
+ const [error, setError] = (0, react_1.useState)(null);
29
+ const isButtonDisabled = workspace.length === 0;
30
+ const provider = constants_1.PROVIDER_SALESFORCE;
31
+ // 1. fetch provider apps
32
+ // 2. find matching app to provider
33
+ // 3. fetch OAuth callback URL from connection so that oath popup can be launched
34
+ const handleSubmit = async () => {
35
+ var _a;
36
+ setError(null);
37
+ if (workspace && consumerName && groupName && apiKey) {
38
+ try {
39
+ const url = await (0, fetchOAuthCallbackURL_1.fetchOAuthCallbackURL)(projectId, consumerRef, groupRef, consumerName, groupName, apiKey, provider, workspace);
40
+ setOAuthCallbackURL(url);
41
+ }
42
+ catch (err) {
43
+ console.error(err);
44
+ setError((_a = err.message) !== null && _a !== void 0 ? _a : 'Unexpected error');
45
+ }
46
+ }
47
+ else {
48
+ setError('missing required fields');
49
+ }
50
+ };
51
+ const onClose = (0, react_1.useCallback)((err) => {
52
+ setError(err);
53
+ setOAuthCallbackURL(null);
54
+ }, []);
55
+ return ((0, jsx_runtime_1.jsx)(OAuthPopup_1.default, { title: "Connect to Salesforce", url: oAuthCallbackURL, onClose: onClose, children: (0, jsx_runtime_1.jsx)(SubdomainEntry_1.SubdomainEntry, { handleSubmit: handleSubmit, setWorkspace: setWorkspace, error: error, isButtonDisabled: isButtonDisabled }) }));
56
+ }
57
+ exports.SalesforceOauthFlow = SalesforceOauthFlow;
@@ -0,0 +1,8 @@
1
+ type SubdomainEntryProps = {
2
+ handleSubmit: () => void;
3
+ setWorkspace: (workspace: string) => void;
4
+ error: string | null;
5
+ isButtonDisabled?: boolean;
6
+ };
7
+ export declare function SubdomainEntry({ handleSubmit, setWorkspace, error, isButtonDisabled, }: SubdomainEntryProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SubdomainEntry = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const icons_1 = require("@chakra-ui/icons");
6
+ const react_1 = require("@chakra-ui/react");
7
+ const OAuthErrorAlert_1 = require("../OAuthErrorAlert");
8
+ const SALESFORCE_HELP_URL = 'https://help.salesforce.com/articleView?id=domain_name_not_found.htm&type=5';
9
+ function SubdomainEntry({ handleSubmit, setWorkspace, error, isButtonDisabled, }) {
10
+ return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsx)(react_1.Box, { p: 8, maxWidth: "600px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", textAlign: ['left'], margin: "auto", marginTop: "40px", bgColor: "white", children: (0, jsx_runtime_1.jsxs)(react_1.FormControl, { children: [(0, jsx_runtime_1.jsx)(react_1.FormLabel, { marginTop: "16", marginBottom: "0", children: (0, jsx_runtime_1.jsx)(react_1.Heading, { as: "h4", size: "md", children: "Enter your Salesforce subdomain" }) }), (0, jsx_runtime_1.jsxs)(react_1.Link, { href: SALESFORCE_HELP_URL, color: "blackAlpha.600", isExternal: true, children: ["What is my Salesforce subdomain?", (0, jsx_runtime_1.jsx)(icons_1.ExternalLinkIcon, { mx: "2px" })] }), (0, jsx_runtime_1.jsx)(OAuthErrorAlert_1.OAuthErrorAlert, { error: error }), (0, jsx_runtime_1.jsxs)(react_1.Flex, { marginTop: "1em", children: [(0, jsx_runtime_1.jsx)(react_1.Input, { placeholder: "MyDomain", onChange: (event) => setWorkspace(event.currentTarget.value) }), (0, jsx_runtime_1.jsx)(react_1.Text, { lineHeight: "2.2em", marginLeft: "0.4em", children: ".my.salesforce.com" })] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(react_1.Button, { isDisabled: isButtonDisabled, width: "100%", type: "submit", onClick: handleSubmit, children: "Next" })] }) }) }));
11
+ }
12
+ exports.SubdomainEntry = SubdomainEntry;
@@ -0,0 +1 @@
1
+ export declare const fetchOAuthCallbackURL: (projectId: string, consumerRef: string, groupRef: string, consumerName: string, groupName: string, apiKey: string, provider?: string, workspace?: string) => Promise<string>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchOAuthCallbackURL = void 0;
4
+ const constants_1 = require("../../constants");
5
+ const api_1 = require("../../services/api");
6
+ const utils_1 = require("../../utils");
7
+ const fetchOAuthCallbackURL = async (projectId, consumerRef, groupRef, consumerName, groupName, apiKey, provider = constants_1.PROVIDER_SALESFORCE, workspace) => {
8
+ const providerApps = await (0, api_1.api)().listProviderApps({ projectId }, {
9
+ headers: { 'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '' },
10
+ });
11
+ const app = providerApps.find((a) => a.provider === provider);
12
+ if (!app) {
13
+ throw new Error(`You must first set up a ${(0, utils_1.capitalize)(provider)} Connected App using the Ampersand Console.`);
14
+ }
15
+ const url = await (0, api_1.api)().oauthConnect({
16
+ connectOAuthParams: {
17
+ providerWorkspaceRef: workspace,
18
+ projectId,
19
+ groupRef,
20
+ groupName,
21
+ consumerRef,
22
+ consumerName,
23
+ providerAppId: app.id,
24
+ provider,
25
+ },
26
+ });
27
+ return url;
28
+ };
29
+ exports.fetchOAuthCallbackURL = fetchOAuthCallbackURL;
@@ -1 +1,2 @@
1
1
  export declare const PROVIDER_SALESFORCE = "salesforce";
2
+ export declare const PROVIDER_HUBSPOT = "hubspot";
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROVIDER_SALESFORCE = void 0;
3
+ exports.PROVIDER_HUBSPOT = exports.PROVIDER_SALESFORCE = void 0;
4
4
  exports.PROVIDER_SALESFORCE = 'salesforce';
5
+ exports.PROVIDER_HUBSPOT = 'hubspot';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@amp-labs/react",
3
- "version": "1.0.2",
4
- "description": "Ampersand React library",
3
+ "version": "1.1.0",
4
+ "description": "Ampersand React library.",
5
5
  "author": {
6
6
  "name": "Ampersand Labs",
7
7
  "url": "http://withampersand.com"
@@ -1,89 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const jsx_runtime_1 = require("react/jsx-runtime");
7
- /**
8
- * Prompts customer to input their Salesforce subdomain, then creates an OAuth connection to
9
- * that Salesforce instance.
10
- */
11
- const react_1 = require("react");
12
- const icons_1 = require("@chakra-ui/icons");
13
- const react_2 = require("@chakra-ui/react");
14
- const constants_1 = require("../../constants");
15
- const ApiKeyProvider_1 = require("../../context/ApiKeyProvider");
16
- const ProjectContext_1 = require("../../context/ProjectContext");
17
- const api_1 = require("../../services/api");
18
- const OAuthPopup_1 = __importDefault(require("../Connect/OAuthPopup"));
19
- function OAuthErrorAlert({ error }) {
20
- if (error) {
21
- return ((0, jsx_runtime_1.jsxs)(react_2.Alert, { status: "error", marginTop: "2em", children: [(0, jsx_runtime_1.jsx)(react_2.AlertIcon, {}), (0, jsx_runtime_1.jsx)(react_2.AlertDescription, { children: error })] }));
22
- }
23
- return null;
24
- }
25
- const SALESFORCE_HELP_URL = 'https://help.salesforce.com/articleView?id=domain_name_not_found.htm&type=5';
26
- function SubdomainEntry({ handleSubmit, setWorkspace, error, isButtonDisabled, }) {
27
- return ((0, jsx_runtime_1.jsx)(react_2.Container, { children: (0, jsx_runtime_1.jsx)(react_2.Box, { p: 8, maxWidth: "600px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", textAlign: ['left'], margin: "auto", marginTop: "40px", bgColor: "white", children: (0, jsx_runtime_1.jsxs)(react_2.FormControl, { children: [(0, jsx_runtime_1.jsx)(react_2.FormLabel, { marginTop: "16", marginBottom: "0", children: (0, jsx_runtime_1.jsx)(react_2.Heading, { as: "h4", size: "md", children: "Enter your Salesforce subdomain" }) }), (0, jsx_runtime_1.jsxs)(react_2.Link, { href: SALESFORCE_HELP_URL, color: "blackAlpha.600", isExternal: true, children: ["What is my Salesforce subdomain?", (0, jsx_runtime_1.jsx)(icons_1.ExternalLinkIcon, { mx: "2px" })] }), (0, jsx_runtime_1.jsx)(OAuthErrorAlert, { error: error }), (0, jsx_runtime_1.jsxs)(react_2.Flex, { marginTop: "1em", children: [(0, jsx_runtime_1.jsx)(react_2.Input, { placeholder: "MyDomain", onChange: (event) => setWorkspace(event.currentTarget.value) }), (0, jsx_runtime_1.jsx)(react_2.Text, { lineHeight: "2.2em", marginLeft: "0.4em", children: ".my.salesforce.com" })] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(react_2.Button, { isDisabled: isButtonDisabled, width: "100%", type: "submit", onClick: handleSubmit, children: "Next" })] }) }) }));
28
- }
29
- const fetchOAuthCallbackURL = async (projectId, workspace, consumerRef, groupRef, consumerName, groupName, apiKey, provider = constants_1.PROVIDER_SALESFORCE) => {
30
- const providerApps = await (0, api_1.api)().listProviderApps({ projectId }, {
31
- headers: { 'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '' },
32
- });
33
- const app = providerApps.find((a) => a.provider === provider);
34
- if (!app) {
35
- throw new Error(`You must first set up a ${provider} Connected App using the Ampersand Console.`);
36
- }
37
- const url = await (0, api_1.api)().oauthConnect({
38
- connectOAuthParams: {
39
- providerWorkspaceRef: workspace,
40
- projectId,
41
- groupRef,
42
- groupName,
43
- consumerRef,
44
- consumerName,
45
- providerAppId: app.id,
46
- provider,
47
- },
48
- });
49
- return url;
50
- };
51
- /**
52
- * SalesforceOauthFlow first prompts user for their workspace ("subdomain" in Salesforce lingo),
53
- * then launches a popup with the OAuth flow.
54
- */
55
- function SalesforceOauthFlow({ consumerRef, consumerName, groupRef, groupName, }) {
56
- const { projectId } = (0, ProjectContext_1.useProject)();
57
- const apiKey = (0, ApiKeyProvider_1.useApiKey)();
58
- const [workspace, setWorkspace] = (0, react_1.useState)('');
59
- const [oAuthCallbackURL, setOAuthCallbackURL] = (0, react_1.useState)(null);
60
- const [error, setError] = (0, react_1.useState)(null);
61
- const isButtonDisabled = workspace.length === 0;
62
- const provider = constants_1.PROVIDER_SALESFORCE;
63
- // 1. fetch provider apps
64
- // 2. find matching app to provider
65
- // 3. fetch OAuth callback URL from connection so that oath popup can be launched
66
- const handleSubmit = async () => {
67
- var _a;
68
- setError(null);
69
- if (workspace && consumerName && groupName && apiKey) {
70
- try {
71
- const url = await fetchOAuthCallbackURL(projectId, workspace, consumerRef, groupRef, consumerName, groupName, apiKey, provider);
72
- setOAuthCallbackURL(url);
73
- }
74
- catch (err) {
75
- console.error(err);
76
- setError((_a = err.message) !== null && _a !== void 0 ? _a : 'Unexpected error');
77
- }
78
- }
79
- else {
80
- setError('missing required fields');
81
- }
82
- };
83
- const onClose = (0, react_1.useCallback)((err) => {
84
- setError(err);
85
- setOAuthCallbackURL(null);
86
- }, []);
87
- return ((0, jsx_runtime_1.jsx)(OAuthPopup_1.default, { title: "Connect to Salesforce", url: oAuthCallbackURL, onClose: onClose, children: (0, jsx_runtime_1.jsx)(SubdomainEntry, { handleSubmit: handleSubmit, setWorkspace: setWorkspace, error: error, isButtonDisabled: isButtonDisabled }) }));
88
- }
89
- exports.default = SalesforceOauthFlow;