{"version":3,"file":"HubSpotFormHandler.DkIkatGc.mjs","names":["_Fragment"],"sources":["https:/framerusercontent.com/modules/8OrU1iM7GZHHJIzdtN8t/tvRu3chs9PV3544ruTDF/HubSpotFormHandler.js"],"sourcesContent":["import{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import{useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function HubSpotFormHandler({redirectUrl=\"/\",dataPortalId=\"143809414\",dataFormId=\"05507131-bd43-4d08-bbfa-675926e1845a\"}){useEffect(()=>{const form=document.querySelector(\"form\")// adjust selector if needed\n;if(!form)return;const handleSubmit=async e=>{e.preventDefault();const formData=new FormData(form);// Build fields array for HubSpot API\nconst fields=[{name:\"firstname\",value:formData.get(\"firstname\")||\"\"},{name:\"lastname\",value:formData.get(\"lastname\")||\"\"},{name:\"email\",value:formData.get(\"email\")||\"\"},{name:\"phone\",value:formData.get(\"phone\")||\"\"}];// Consent checkbox is special — check if it's checked\nconst consentGiven=formData.get(\"consent\")===\"on\";const comunicationsConsentGiven=formData.get(\"marketing\")===\"on\";if(!consentGiven){return;}const body={fields,legalConsentOptions:{consent:{consentToProcess:true,text:\"I agree to allow stoneworld to store and process my personal data.\"}},context:{pageUri:window.location.href,pageName:document.title}};try{const portalId=dataPortalId;const formGuid=dataFormId;const res=await fetch(`https://api-eu1.hsforms.com/submissions/v3/integration/submit/${portalId}/${formGuid}`,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(body)});if(res.ok){//form.reset()\nwindow.location.href=redirectUrl;}else{const error=await res.json();alert(\"Submission error: \"+(error.errors?.[0]?.message||\"Unknown error\"));}}catch(err){}};form.addEventListener(\"submit\",handleSubmit);return()=>form.removeEventListener(\"submit\",handleSubmit);},[]);return /*#__PURE__*/_jsx(_Fragment,{})// This component just hooks the form, no UI needed\n;}HubSpotFormHandler.defaultProps={text:\"My Title\"};addPropertyControls(HubSpotFormHandler,{redirectUrl:{title:\"Redirect Url:\",type:ControlType.String},dataPortalId:{title:\"Data Portal ID:\",type:ControlType.String,defaultValue:\"143809414\"},dataFormId:{title:\"Data Form ID:\",type:ControlType.String}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HubSpotFormHandler\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HubSpotFormHandler.map"],"mappings":"+LAAkJ,SAAwB,EAAmB,CAAC,cAAY,IAAI,eAAa,YAAY,aAAW,wCAAwC,CAIf,OAJgB,MAAc,CAAC,IAAM,EAAK,SAAS,cAAc,OAAO,CAClV,GAAG,CAAC,EAAK,OAAO,IAAM,EAAa,KAAM,IAAG,CAAC,EAAE,gBAAgB,CAAC,IAAM,EAAS,IAAI,SAAS,EAAK,CAC5F,EAAO,CAAC,CAAC,KAAK,YAAY,MAAM,EAAS,IAAI,YAAY,EAAE,GAAG,CAAC,CAAC,KAAK,WAAW,MAAM,EAAS,IAAI,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,QAAQ,MAAM,EAAS,IAAI,QAAQ,EAAE,GAAG,CAAC,CAAC,KAAK,QAAQ,MAAM,EAAS,IAAI,QAAQ,EAAE,GAAG,CAAC,CAClN,EAAa,EAAS,IAAI,UAAU,GAAG,KAAsE,GAAjC,EAAS,IAAI,YAAY,CAAW,CAAC,EAAc,OAAQ,IAAM,EAAK,CAAC,SAAO,oBAAoB,CAAC,QAAQ,CAAC,iBAAiB,GAAK,KAAK,qEAAqE,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAO,SAAS,KAAK,SAAS,SAAS,MAAM,CAAC,CAAC,GAAG,CAAC,IAAM,EAAS,EAAmB,EAAS,EAAiB,EAAI,MAAM,MAAM,iEAAiE,EAAS,GAAG,IAAW,CAAC,OAAO,OAAO,QAAQ,CAAC,eAAe,mBAAmB,CAAC,KAAK,KAAK,UAAU,EAAK,CAAC,CAAC,CAAC,GAAG,EAA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