{"version":3,"file":"WebhookForm.03UGAFdY.mjs","names":["useState","useCallback"],"sources":["https:/framerusercontent.com/modules/dc1ymERPHxBXhBSONLRE/jNc4wdyNlX2tCxcgjZmS/WebhookForm.js"],"sourcesContent":["// Dynamic CMS Webhook Form\n// Creates a form that posts data to a dynamic webhook URL set via property controls.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,startTransition,useCallback}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Webhook Form (CMS)\n *\n * @framerIntrinsicWidth 360\n * @framerIntrinsicHeight 420\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function WebhookForm(props){const{webhookURL,submitLabel,font,buttonFont,borderRadius,style,webinarTitle,webinarDescription,redirectUrl,webinarDateTime,showFirstName,showPhone,webinarBullet1,webinarBullet2,webinarBullet3}=props;const[loading,setLoading]=useState(false);const[success,setSuccess]=useState(false);const[error,setError]=useState(\"\");const[fields,setFields]=useState({name:\"\",email:\"\",phone:\"\"});const[submitted,setSubmitted]=useState(false);function handleChange(e){const{name,value}=e.target;setFields(f=>({...f,[name]:value}));}const handleSubmit=useCallback(async e=>{e.preventDefault();if(!webhookURL.trim()){startTransition(()=>setError(\"No webhook URL set.\"));return;}startTransition(()=>setError(\"\"));startTransition(()=>setLoading(true));setSuccess(false);setSubmitted(false);try{const submissionDate=new Date;const body={Name:fields.name,Email:fields.email,Phone:fields.phone,URL:typeof window!==\"undefined\"?window.location.href:\"\",// Webinar meta from CMS\nWebinarDateTimeRaw:webinarDateTime?String(webinarDateTime):\"\",WebinarTitle:webinarTitle,Description:webinarDescription,// NEW: bullets from CMS\nWebinarBullet1:webinarBullet1||\"\",WebinarBullet2:webinarBullet2||\"\",WebinarBullet3:webinarBullet3||\"\",// Optional: submission timestamps\nSubmissionDate:submissionDate.toISOString().slice(0,10),SubmissionTime:submissionDate.toISOString().slice(11,19)};const formData=new FormData;Object.entries(body).forEach(([key,value])=>{formData.append(key,value);});const res=await fetch(webhookURL,{method:\"POST\",body:formData});if(!res.ok)throw new Error(\"Failed to send: \"+res.status);setSuccess(true);setFields({name:\"\",email:\"\",phone:\"\"});setSubmitted(true);if(redirectUrl&&typeof window!==\"undefined\"){setTimeout(()=>{window.open(redirectUrl,\"_self\");},800);}}catch(err){startTransition(()=>setError(err?.message||\"Unknown error\"));}finally{startTransition(()=>setLoading(false));}},[fields,webhookURL,webinarTitle,webinarDescription,redirectUrl,webinarDateTime,webinarBullet1,webinarBullet2,webinarBullet3]);return /*#__PURE__*/_jsxs(\"form\",{style:{...style,width:\"100%\",height:\"auto\",borderRadius,boxSizing:\"border-box\",display:\"flex\",flexDirection:\"column\",gap:5,...font},onSubmit:handleSubmit,\"aria-label\":\"CMS Webhook Form\",autoComplete:\"off\",children:[/*#__PURE__*/_jsx(\"link\",{href:\"https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&display=swap\",rel:\"stylesheet\"}),showFirstName&&/*#__PURE__*/_jsx(\"input\",{name:\"name\",value:fields.name,onChange:handleChange,required:true,style:{border:`1px solid rgba(0,0,0,0.10)`,padding:\"10px 16px\",borderRadius:10,fontSize:14,outline:\"none\",background:\"transparent\",color:\"#6d6d6d\",lineHeight:\"1.2em\",fontFamily:\"Figtree, sans-serif\",boxSizing:\"border-box\"},autoComplete:\"name\",placeholder:\"First name\"}),showPhone&&/*#__PURE__*/_jsx(\"input\",{name:\"phone\",value:fields.phone,onChange:handleChange,required:true,type:\"tel\",style:{border:`1px solid rgba(0,0,0,0.10)`,padding:\"10px 16px\",borderRadius:10,fontSize:14,outline:\"none\",background:\"transparent\",color:\"#6d6d6d\",lineHeight:\"1.2em\",fontFamily:\"Figtree, sans-serif\",boxSizing:\"border-box\"},autoComplete:\"tel\",placeholder:\"Phone number\"}),/*#__PURE__*/_jsx(\"input\",{name:\"email\",value:fields.email,onChange:handleChange,required:true,type:\"email\",style:{border:`1px solid rgba(0,0,0,0.10)`,padding:\"10px 16px\",borderRadius:10,fontSize:14,outline:\"none\",background:\"transparent\",color:\"#6d6d6d\",lineHeight:\"1.2em\",fontFamily:\"Figtree, sans-serif\",boxSizing:\"border-box\"},autoComplete:\"email\",placeholder:\"Email\"}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",disabled:loading,style:{background:\"linear-gradient(to bottom, #FFDE14, #FFCA00)\",color:\"#000000\",border:\"0.5px solid #E1AC00\",padding:\"15px 0\",borderRadius:12,fontWeight:600,letterSpacing:\"-0.02em\",fontSize:16,cursor:loading?\"default\":\"pointer\",opacity:loading?.6:1,boxShadow:\"inset 0px 2px 0px 0px rgba(255,255,255,0.55), 0 1.5px 3px 0 rgba(32, 35, 39, 0.04),0 0.5px 1px 0 rgba(60,66,87,0.03)\",transition:\"background 0.18s cubic-bezier(.4,0,1,1), border-color 0.18s cubic-bezier(.4,0,1,1)\",...buttonFont},children:submitted?\"Submitted\":loading?\"Sending...\":submitLabel})]});}addPropertyControls(WebhookForm,{webhookURL:{type:ControlType.String,title:\"Webhook URL\",placeholder:\"Paste full webhook URL here…\",defaultValue:\"\",displayTextArea:false},submitLabel:{type:ControlType.String,title:\"Submit Button\",defaultValue:\"Send Message\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"15px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"}},buttonFont:{type:ControlType.Font,title:\"Button Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"14px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"}},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:32},webinarTitle:{type:ControlType.String,title:\"Webinar Title\",defaultValue:\"Upcoming Webinar\"},webinarDescription:{type:ControlType.String,title:\"Description\",defaultValue:\"This is a sample description for the webinar.\",displayTextArea:true},webinarDateTime:{type:ControlType.String,title:\"Webinar Date/Time\",placeholder:\"Bind CMS Date/Time field…\",defaultValue:\"\",description:\"Bind a CMS Date or DateTime field.\"},// NEW: bullet controls (bind these to CMS text fields)\nwebinarBullet1:{type:ControlType.String,title:\"Webinar Bullet 1\",placeholder:\"Bind CMS Bullet 1…\",defaultValue:\"\"},webinarBullet2:{type:ControlType.String,title:\"Webinar Bullet 2\",placeholder:\"Bind CMS Bullet 2…\",defaultValue:\"\"},webinarBullet3:{type:ControlType.String,title:\"Webinar Bullet 3\",placeholder:\"Bind CMS Bullet 3…\",defaultValue:\"\"},redirectUrl:{type:ControlType.Link,title:\"Redirect URL (from CMS)\",placeholder:\"Paste or bind a CMS Link field…\",defaultValue:\"\",description:\"Connect a CMS Link field for dynamic redirect.\"},showFirstName:{type:ControlType.Boolean,title:\"Show First Name\",defaultValue:true},showPhone:{type:ControlType.Boolean,title:\"Show Phone Number\",defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"WebhookForm\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"360\",\"framerIntrinsicHeight\":\"420\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WebhookForm.map"],"mappings":"6MASG,SAAwB,EAAY,EAAM,CAAC,GAAK,CAAC,aAAW,cAAY,OAAK,aAAW,eAAa,QAAM,eAAa,qBAAmB,cAAY,kBAAgB,gBAAc,YAAU,iBAAe,iBAAe,kBAAgB,EAAW,CAAC,EAAQ,GAAYA,EAAS,GAAM,CAAM,CAAC,EAAQ,GAAYA,EAAS,GAAM,CAAM,CAAC,EAAM,GAAUA,EAAS,GAAG,CAAM,CAAC,EAAO,GAAWA,EAAS,CAAC,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAC,SAAS,EAAa,EAAE,CAAC,GAAK,CAAC,OAAK,SAAO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