{"version":3,"file":"Form.C8S4fccM.mjs","names":[],"sources":["https:/framerusercontent.com/modules/wYZwo4GtwGYiTl1E6oOV/WTjwsNKAkH81AlbsXrGH/Form.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState}from\"react\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function DynamicForm({style,webhookURL,fields,borderColor,fillColor,textColor,cornerRadius,redirectURL}){const[formData,setFormData]=useState({});const[submitStatus,setSubmitStatus]=useState(null);const handleSubmit=async e=>{e.preventDefault();const emailField=fields.find(field=>field.type===\"email\");if(emailField){const email=formData[emailField.label];if(email){const domain=email.split(\"@\")[1];const forbiddenDomains=[\"gmail.com\",\"hotmail.com\",\"yahoo.com\",\"outlook.com\",\"icloud.com\",\"msn.com\"];if(forbiddenDomains.includes(domain)){setSubmitStatus(\"Please enter your work email.\");return;}}}const urlParams=new URLSearchParams(window.location.search);const utmParams={};urlParams.forEach((value,key)=>{if(key.startsWith(\"utm_\")){utmParams[key]=value;}});try{const dataToSend={...formData,...utmParams,userAgent:navigator.userAgent,pageURL:window.location.href};await fetch(webhookURL,{method:\"POST\",mode:\"no-cors\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(dataToSend)});window.location.href=redirectURL// Redirecting the user\n;}catch(error){setSubmitStatus(\"Something went wrong. Please try again.\");}};const handleChange=(e,fieldName)=>{setFormData({...formData,[fieldName]:e.target.value});};return /*#__PURE__*/_jsxs(\"div\",{children:[/*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSubmit,style:{width:\"100%\"},children:[fields.map((field,index)=>{let inputElement;switch(field.type){case\"email\":case\"text\":inputElement=/*#__PURE__*/_jsx(\"input\",{type:field.type,required:field.required,placeholder:field.placeholder,name:field.label,onChange:e=>handleChange(e,field.label),style:{borderStyle:\"solid\",borderWidth:\"1px\",borderColor,backgroundColor:fillColor,color:textColor,borderRadius:cornerRadius+\"px\",width:\"100%\",padding:\"10px\",marginBottom:\"16px\"}});break;case\"phone\":inputElement=/*#__PURE__*/_jsx(\"input\",{type:\"tel\",pattern:\"^[+0-9]+$\",required:field.required,placeholder:field.placeholder,name:field.label,onChange:e=>handleChange(e,field.label),style:{borderStyle:\"solid\",borderWidth:\"1px\",borderColor,backgroundColor:fillColor,color:textColor,borderRadius:cornerRadius+\"px\",width:\"100%\",padding:\"10px\",marginBottom:\"16px\"}});break;case\"dropdown\":inputElement=/*#__PURE__*/_jsx(\"select\",{required:field.required,name:field.label,onChange:e=>handleChange(e,field.label),style:{borderWidth:\"1px\",borderColor,backgroundColor:fillColor,color:textColor,borderRadius:cornerRadius+\"px\",width:\"100%\",padding:\"10px\",marginBottom:\"16px\"},children:field.options.map(option=>/*#__PURE__*/_jsx(\"option\",{value:option,children:option}))});break;case\"textArea\":inputElement=/*#__PURE__*/_jsx(\"textarea\",{required:field.required,placeholder:field.placeholder,name:field.label,maxLength:150,onChange:e=>handleChange(e,field.label),style:{borderWidth:\"1px\",borderColor,backgroundColor:fillColor,color:textColor,borderRadius:cornerRadius+\"px\",width:\"100%\",padding:\"10px\",marginBottom:\"16px\",resize:\"vertical\"}});break;default:return null;}return /*#__PURE__*/_jsxs(\"div\",{style:style,children:[/*#__PURE__*/_jsx(\"label\",{style:{fontWeight:\"600\",marginBottom:\"8px\",display:\"block\",color:textColor},children:field.label}),field.description&&/*#__PURE__*/_jsx(\"div\",{style:{marginBottom:\"5px\",color:textColor},children:field.description}),inputElement]},index);}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",style:{fontWeight:\"600\",border:\"none\",background:\"#0D0F42\",color:\"#fff\",borderRadius:cornerRadius+\"px\",padding:\"10px\",width:\"100%\",cursor:\"pointer\"},children:\"Submit\"})]}),submitStatus&&/*#__PURE__*/_jsx(\"p\",{style:{color:\"red\"},children:submitStatus})]});}DynamicForm.displayName=\"Form\";addPropertyControls(DynamicForm,{webhookURL:{type:ControlType.String,title:\"Webhook URL\"},redirectURL:{type:ControlType.String,title:\"Redirect URL\"},fields:{type:ControlType.Array,title:\"Fields\",propertyControl:{type:ControlType.Object,controls:{label:{type:ControlType.String,title:\"Label\"},type:{type:ControlType.Enum,options:[\"email\",\"dropdown\",\"phone\",\"textArea\",\"text\"],optionTitles:[\"Email\",\"Dropdown\",\"Phone Number\",\"Message (Text Area)\",\"Plain Text\"],title:\"Type\"},description:{type:ControlType.String,title:\"Description\",displayTextArea:true,optional:true},options:{type:ControlType.Array,title:\"Options\",control:{type:ControlType.String},optional:true},required:{type:ControlType.Boolean,title:\"Required\"},placeholder:{type:ControlType.String,title:\"Placeholder\",optional:true}}}},borderColor:{type:ControlType.Color,title:\"Border Color\"},fillColor:{type:ControlType.Color,title:\"Fill Color\"},textColor:{type:ControlType.Color,title:\"Text Color\"},cornerRadius:{type:ControlType.Number,title:\"Corner Radius\",min:0,max:100,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DynamicForm\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Form.map"],"mappings":"gUAGG,SAAwB,EAAY,CAAC,QAAM,aAAW,SAAO,cAAY,YAAU,YAAU,eAAa,cAAY,CAAC,CAAC,GAAK,CAAC,EAAS,EAAY,CAAC,EAAS,CAAE,EAAC,CAAM,CAAC,EAAa,EAAgB,CAAC,EAAS,KAAK,CAAO,EAAa,MAAM,GAAG,CAAC,EAAE,gBAAgB,CAAC,IAAM,EAAW,EAAO,KAAK,GAAO,EAAM,OAAO,QAAQ,CAAC,GAAG,EAAW,CAAC,IAAM,EAAM,EAAS,EAAW,OAAO,GAAG,EAAM,CAAC,IAAM,EAAO,EAAM,MAAM,IAAI,CAAC,GAAS,EAAiB,CAAC,YAAY,cAAc,YAAY,cAAc,aAA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