{"version":3,"file":"Form.CS_6WsYP.mjs","names":["useState"],"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,eAAa,CAAC,GAAK,CAAC,EAAS,GAAaA,EAAS,EAAE,CAAC,CAAM,CAAC,EAAa,GAAiBA,EAAS,KAAK,CAAO,EAAa,KAAM,IAAG,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,GAAuG,GAA7E,CAAC,YAAY,cAAc,YAAY,cAAc,aAAa,UAAU,C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