Skip to content

Commit eb675ca

Browse files
committed
refactor
1 parent 4721c91 commit eb675ca

1 file changed

Lines changed: 10 additions & 16 deletions

File tree

notification_center/src/App.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,27 @@ function App() {
6464
// Handle confirmation action
6565
if (params.action === 'confirm' && params.lid) {
6666
try {
67-
// Make a POST request to subscribe endpoint with HMAC authentication
68-
const confirmResponse = await fetch('/api/subscribe', {
69-
method: 'POST',
70-
headers: {
71-
'Content-Type': 'application/json'
67+
// Use the existing API client to subscribe to lists
68+
const response = await subscribeToLists({
69+
workspace_id: params.wid,
70+
contact: {
71+
id: '', // Will be populated by the backend
72+
email: params.email,
73+
email_hmac: params.email_hmac
7274
},
73-
body: JSON.stringify({
74-
workspace_id: params.wid,
75-
contact: {
76-
email: params.email,
77-
email_hmac: params.email_hmac
78-
},
79-
list_ids: [params.lid]
80-
})
75+
list_ids: [params.lid]
8176
})
8277

83-
if (confirmResponse.ok) {
78+
if (response.success) {
8479
setConfirmationResult({
8580
success: true,
8681
message: 'Subscription confirmed successfully!',
8782
listId: params.lid
8883
})
8984
} else {
90-
const errorData = await confirmResponse.json()
9185
setConfirmationResult({
9286
success: false,
93-
message: errorData.error || 'Failed to confirm subscription'
87+
message: 'Failed to confirm subscription'
9488
})
9589
}
9690
} catch (err) {

0 commit comments

Comments
 (0)