Skip to content

Commit f86be19

Browse files
feat: cleanup
1 parent 50aa2eb commit f86be19

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed
Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
{
2-
"name": "Klaviyo",
3-
"description": "Sync your Contentful content with Klaviyo",
4-
"id": "klaviyo",
2+
"name": "HubSpot Email Sync",
3+
"description": "Sync your Contentful content with HubSpot Marketing Emails",
4+
"id": "hubspot-email-sync",
55
"category": "Marketing",
66
"version": "0.1.0",
77
"locations": [
88
{
99
"location": "app-config",
1010
"component": "ConfigScreen"
1111
},
12-
{
13-
"location": "entry-sidebar",
14-
"component": "Sidebar"
15-
},
16-
{
17-
"location": "entry-field",
18-
"component": "Field"
19-
},
20-
{
21-
"location": "dialog",
22-
"component": "FieldSelectDialog"
23-
},
2412
{
2513
"location": "page",
2614
"component": "FieldMappingScreen"
@@ -29,27 +17,28 @@
2917
"parameters": {
3018
"installation": [
3119
{
32-
"id": "hubspotApiKey",
33-
"name": "Hubspot API Key",
34-
"description": "Your Hubspot API key from private app",
20+
"id": "apiKey",
21+
"name": "HubSpot API Key",
22+
"description": "Your HubSpot private app API key (starts with 'pat-')",
3523
"type": "Symbol",
3624
"required": true
3725
}
3826
]
3927
},
4028
"functions": [
4129
{
42-
"id": "hubspotEmailFunction",
43-
"name": "Hubspot Email Function",
44-
"description": "Sync Contentful Entries to HubSpot Emails",
30+
"id": "3rpmmTblbOagoCcT2QVrtb",
31+
"name": "HubSpot Email Function",
32+
"description": "Sync Contentful Entries to HubSpot Marketing Emails",
4533
"path": "functions/hubspotEmail.js",
4634
"entryFile": "functions/hubspotEmail.ts",
4735
"allowNetworks": [
4836
"api.hubapi.com"
4937
],
5038
"accepts": [
5139
"appaction.call"
52-
]
40+
],
41+
"timeout": 30
5342
}
5443
]
5544
}

apps/hubspot/src/locations/Page.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import {
33
Button,
44
Card,
@@ -15,6 +15,7 @@ import {
1515
import { PageAppSDK } from '@contentful/app-sdk';
1616
import { useCMA, useSDK } from '@contentful/react-apps-toolkit';
1717
import { styles } from './Page.styles';
18+
import { C } from 'vitest/dist/chunks/reporters.d.C1ogPriE';
1819

1920
interface HubSpotEmail {
2021
id: string;
@@ -93,6 +94,7 @@ const Page = () => {
9394
contentBlocks: {},
9495
});
9596
const [updating, setUpdating] = useState(false);
97+
const [hubspotAppActionId, setHubspotEmailAction] = useState<string>('');
9698

9799
// Helper function to extract individual text nodes from HTML
98100
const extractTextNodes = (html: string): TextNode[] => {
@@ -166,6 +168,20 @@ const Page = () => {
166168
});
167169
};
168170

171+
useEffect(() => {
172+
const getAppActions = async () => {
173+
const appActions = await cma.appAction.getManyForEnvironment({});
174+
const hubspotEmailAction = appActions.items.find((appAction) => {
175+
if (appAction.name === 'Hubspot Email Action') {
176+
return appAction;
177+
}
178+
});
179+
setHubspotEmailAction(hubspotEmailAction?.sys.id || '');
180+
};
181+
182+
getAppActions();
183+
}, []);
184+
169185
// Test HubSpot connection and fetch emails
170186
const fetchHubSpotEmails = async () => {
171187
try {
@@ -175,7 +191,7 @@ const Page = () => {
175191
const res = await cma.appActionCall.createWithResponse(
176192
{
177193
appDefinitionId: sdk.ids.app || '',
178-
appActionId: '3rpmmTblbOagoCcT2QVrtb',
194+
appActionId: hubspotAppActionId,
179195
},
180196
{
181197
parameters: {
@@ -262,7 +278,7 @@ const Page = () => {
262278
const res = await cma.appActionCall.createWithResponse(
263279
{
264280
appDefinitionId: sdk.ids.app || '',
265-
appActionId: '3rpmmTblbOagoCcT2QVrtb',
281+
appActionId: hubspotAppActionId,
266282
},
267283
{
268284
parameters: {

0 commit comments

Comments
 (0)