{"version":3,"file":"CourseForm.C7CS5Ine.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/onTtZqfgFqZcP9cA9nEg/EWIHgaiyM5yNvnw7vYMb/CourseForm.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState}from\"react\";export default function CourseForm(){// State for all three input fields, submission status, and errors\nconst[name,setName]=useState(\"\");const[email,setEmail]=useState(\"\");const[phone,setPhone]=useState(\"\");const[isSubmitting,setIsSubmitting]=useState(false);const[error,setError]=useState(\"\");// Same clean helper functions from the first form\n// ===============================================\n// Formats the phone number as the user types\nconst formatPhone=value=>{const numbers=value.replace(/\\D/g,\"\").substring(0,11);if(!numbers)return\"\";let formatted=\"+7\";const phoneBody=numbers.startsWith(\"7\")||numbers.startsWith(\"8\")?numbers.substring(1):numbers;if(phoneBody.length>0)formatted+=` (${phoneBody.substring(0,3)}`;if(phoneBody.length>3)formatted+=`) ${phoneBody.substring(3,6)}`;if(phoneBody.length>6)formatted+=`-${phoneBody.substring(6,8)}`;if(phoneBody.length>8)formatted+=`-${phoneBody.substring(8,10)}`;return formatted;};// Checks if the phone number has the required length\nconst isPhoneValid=()=>{const numbers=phone.replace(/\\D/g,\"\");return numbers.length===11||numbers.length===10&&!numbers.startsWith(\"7\");};// Gathers basic attribution data without complex tracking\nconst getAttributionData=()=>{const stored=window.getStoredAttribution?.()||{};const params=new URLSearchParams(window.location.search);return{// UTM params\nutm_source:params.get(\"utm_source\")||stored.utm_source||\"\",utm_medium:params.get(\"utm_medium\")||stored.utm_medium||\"\",utm_campaign:params.get(\"utm_campaign\")||stored.utm_campaign||\"\",utm_term:params.get(\"utm_term\")||stored.utm_term||\"\",utm_content:params.get(\"utm_content\")||stored.utm_content||\"\",// Click IDs\nfbclid:params.get(\"fbclid\")||stored.fbclid||\"\",gclid:params.get(\"gclid\")||stored.gclid||\"\",yclid:params.get(\"yclid\")||stored.yclid||\"\",// Basic session data\nlanding_page:stored.landing_page||window.location.href,referrer:document.referrer||\"\",browser_id:stored.browser_id||\"\",session_id:stored.session_id||\"\",device_type:/Mobile|Android|iPhone/i.test(navigator.userAgent)?\"mobile\":\"desktop\"};};// Submission handler with logic from the first form\n// ==================================================\nconst handleSubmit=async e=>{e.preventDefault();// --- Validation for all fields ---\nif(!name.trim()){setError(\"Пожалуйста, введите имя\");return;}if(!email.trim()||!/\\S+@\\S+\\.\\S+/.test(email)){setError(\"Введите корректный email\");return;}if(!isPhoneValid()){setError(\"Введите номер в формате +7 (XXX) XXX-XX-XX\");return;}if(isSubmitting)return;// --- Prepare for Submission ---\nsetIsSubmitting(true);setError(\"\");// Clean phone number for the backend\nconst phoneClean=phone.replace(/\\D/g,\"\");const formattedPhone=phoneClean.startsWith(\"8\")?\"+7\"+phoneClean.substring(1):\"+\"+phoneClean;// Get attribution data\nconst attribution=getAttributionData();// Prepare the final data payload, now including the email\nconst data={name,phone:formattedPhone,email,date:new Date().toISOString(),timestamp:Date.now(),form_page_url:window.location.href,...attribution};// --- API Call ---\ntry{const response=await fetch(\"https://test.nfactorial.school/api/websiteForm\",{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(data)});if(!response.ok){throw new Error(`HTTP error! status: ${response.status}`);}// On success, redirect\nwindow.location.href=\"https://www.nfactorial.school/thanks\";}catch(err){setError(\"Ошибка отправки. Попробуйте еще раз.\");setIsSubmitting(false);console.error(\"Form submission error:\",err);}};// Determine if the button should be disabled\nconst isButtonDisabled=isSubmitting||!name.trim()||!email.trim()||!isPhoneValid();return /*#__PURE__*/_jsxs(\"div\",{style:styles.container,children:[/*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSubmit,style:styles.form,children:[/*#__PURE__*/_jsxs(\"div\",{style:styles.row,children:[/*#__PURE__*/_jsx(\"input\",{type:\"text\",placeholder:\"Имя\",value:name,onChange:e=>setName(e.target.value),required:true,style:styles.input}),/*#__PURE__*/_jsx(\"input\",{type:\"email\",placeholder:\"Email\",value:email,onChange:e=>setEmail(e.target.value),required:true,style:styles.input})]}),/*#__PURE__*/_jsx(\"input\",{type:\"tel\",placeholder:\"+7 (___) ___-__-__\",value:phone,onChange:e=>setPhone(formatPhone(e.target.value)),required:true,style:{...styles.input,borderColor:phone&&!isPhoneValid()?\"red\":\"#EAE7E3\"}}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",disabled:isButtonDisabled,style:{...styles.button,opacity:isButtonDisabled?.6:1,cursor:isButtonDisabled?\"not-allowed\":\"pointer\"},children:isSubmitting?\"Отправка...\":\"Получить консультацию\"})]}),error&&/*#__PURE__*/_jsx(\"p\",{style:styles.error,children:error})]});}// Styles from the second form, consolidated into one object\nconst styles={container:{backgroundColor:\"rgba(246, 246, 246, 0.2)\",padding:\"8px\",borderRadius:\"20px\"},form:{display:\"flex\",flexDirection:\"column\",gap:\"10px\"},row:{display:\"flex\",gap:\"12px\"},input:{padding:\"16px\",border:\"1px solid #EAE7E3\",borderRadius:\"28px\",fontSize:\"18px\",color:\"black\",width:\"100%\",boxSizing:\"border-box\",outline:\"none\"},button:{padding:\"16px\",border:\"none\",borderRadius:\"28px\",backgroundColor:\"#E01424\",color:\"white\",fontSize:\"18px\",fontWeight:\"500\",cursor:\"pointer\",transition:\"all 0.3s ease\"},error:{color:\"red\",fontWeight:\"600\",textAlign:\"center\",marginTop:\"8px\"}};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CourseForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CourseForm.map"],"mappings":"8IAAqF,SAAwB,GAAY,CACzH,GAAK,CAAC,EAAK,GAASA,EAAS,GAAG,CAAM,CAAC,EAAM,GAAUA,EAAS,GAAG,CAAM,CAAC,EAAM,GAAUA,EAAS,GAAG,CAAM,CAAC,EAAa,GAAiBA,EAAS,GAAM,CAAM,CAAC,EAAM,GAAUA,EAAS,GAAG,CAGvL,EAAY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