diff --git a/frontend/src/api/billing.js b/frontend/src/api/billing.js index 31656f2869..b5c57af58f 100644 --- a/frontend/src/api/billing.js +++ b/frontend/src/api/billing.js @@ -39,10 +39,49 @@ const setTrialExpiry = async (teamId, trialEndsAt) => { }) } +const sendTeamTypeContact = async (user, teamType, pageName) => { + const hsPortalId = teamType.properties?.billing?.contactHSPortalId + const hsFormId = teamType.properties?.billing?.contactHSFormId + if (hsPortalId && hsFormId) { + return new Promise((resolve, reject) => { + const url = `https://api.hsforms.com/submissions/v3/integration/submit/${hsPortalId}/${hsFormId}` + const xhr = new XMLHttpRequest() + xhr.open('POST', url) + xhr.setRequestHeader('Content-Type', 'application/json') + const body = JSON.stringify({ + submittedAt: '' + Date.now(), + fields: [{ + objectTypeId: '0-1', + name: 'email', + value: user.email + }], + context: { + pageUri: window.location.href, + pageName + } + }) + xhr.onreadystatechange = () => { + if (xhr.readyState === 4) { + switch (xhr.status) { + case 200: + resolve() + break + default: + reject(xhr.responseText) + break + } + } + } + xhr.send(body) + }) + } +} + export default { toCustomerPortal, getSubscriptionInfo, createSubscription, setupManualBilling, - setTrialExpiry + setTrialExpiry, + sendTeamTypeContact } diff --git a/frontend/src/pages/admin/TeamTypes/dialogs/TeamTypeEditDialog.vue b/frontend/src/pages/admin/TeamTypes/dialogs/TeamTypeEditDialog.vue index 4424620946..a08c1402f5 100644 --- a/frontend/src/pages/admin/TeamTypes/dialogs/TeamTypeEditDialog.vue +++ b/frontend/src/pages/admin/TeamTypes/dialogs/TeamTypeEditDialog.vue @@ -21,6 +21,14 @@