Skip to content

Commit b46c6af

Browse files
authored
Merge pull request #2 from team-plain/move-to-threads
Migrate to threads
2 parents 268c7d1 + 54a9ed1 commit b46c6af

File tree

3 files changed

+16
-170
lines changed

3 files changed

+16
-170
lines changed

package-lock.json

Lines changed: 7 additions & 160 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@radix-ui/react-popover": "1.0.6",
14-
"@team-plain/typescript-sdk": "2.4.0",
14+
"@team-plain/typescript-sdk": "2.18.0",
1515
"clsx": "1.2.1",
1616
"next": "13.3.2",
1717
"prettier": "2.8.8",

pages/api/contact-form.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
4949

5050
console.log(`Customer upserted ${upsertCustomerRes.data.customer.id}`);
5151

52-
const upsertTimelineEntryRes = await client.upsertCustomTimelineEntry({
53-
customerId: upsertCustomerRes.data.customer.id,
52+
const createThreadRes = await client.createThread({
53+
customerIdentifier: {
54+
customerId: upsertCustomerRes.data.customer.id,
55+
},
5456
title: 'Contact form',
5557
components: [
5658
{
@@ -59,17 +61,14 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
5961
},
6062
},
6163
],
62-
changeCustomerStatusToActive: true,
6364
});
6465

65-
if (upsertTimelineEntryRes.error) {
66-
console.error(
67-
inspect(upsertTimelineEntryRes.error, { showHidden: false, depth: null, colors: true })
68-
);
69-
return res.status(500).json({ error: upsertTimelineEntryRes.error.message });
66+
if (createThreadRes.error) {
67+
console.error(inspect(createThreadRes.error, { showHidden: false, depth: null, colors: true }));
68+
return res.status(500).json({ error: createThreadRes.error.message });
7069
}
7170

72-
console.log(`Custom timeline entry upserted ${upsertTimelineEntryRes.data.timelineEntry.id}.`);
71+
console.log(`Thread created ${createThreadRes.data.id}.`);
7372

7473
res.status(200).json({ error: null });
7574
}

0 commit comments

Comments
 (0)