{"version":3,"file":"FormPlus.CpBCKPSK.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/oOCwDbaxL4ob7CZdABIe/gcMmYRxE6d79sx7cLAYR/FormPlus.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";export default function CheckoutForm(){const[form,setForm]=useState({referralId:\"\",userName:\"\",email:\"\"});const[userName,setUserName]=useState(\"\");const[isLoading,setIsLoading]=useState(false);const[isValid,setIsValid]=useState(false);const[message,setMessage]=useState(null);// Extract userId from URL parameters on component mount\nuseEffect(()=>{const params=new URLSearchParams(window.location.search);const referralId=params.get(\"referralId\");if(referralId){setForm(prevForm=>({...prevForm,referralId:referralId}));}},[]);const handleChange=e=>{setMessage(null);setForm({...form,[e.target.name]:e.target.value});};const handleProceed=async()=>{const{referralId,email}=form;// If API call is successful, proceed with the original redirect\nconst query=new URLSearchParams({referralId,userName,email}).toString();const url=`https://prowellnesscheckout.com/?${query}`;window.location.href=url;setIsValid(false);setUserName(\"\");setMessage(\"\");};const handleValidate=async()=>{const{referralId,email}=form;if(!referralId||!email){alert(\"Please fill in all fields.\");return;}setIsLoading(true);try{const response=await fetch(\"https://financepropartner.com/api/webhook/pro-wellness/verify-details\",{method:\"POST\",headers:{\"Content-Type\":\"application/json\",\"x-webhook-signature\":\"f8e7d6c5b4a3928176543fedcba098765432109876543210fedcba0987654321\"},body:JSON.stringify({referralId,email})});const result=await response.json();if(!response.ok){setMessage(result.message);return;}if(result.isNewUser){setMessage(`You are about to proceed as a new user with email:${email} and userName:${result.userName} and the plan will be applied to ${result.userName}`);}else{setMessage(`You are an existing user and your username is ${result.userName} and the plan will be applied to ${result.userName}`);}setIsValid(true);setUserName(result.userName);}catch(error){alert(\"There was an error processing your request. Please try again.\");}finally{setIsLoading(false);}};return /*#__PURE__*/_jsxs(\"div\",{style:containerStyle,children:[/*#__PURE__*/_jsx(\"h1\",{style:headingStyle,children:\"Tell Us About Yourself\"}),/*#__PURE__*/_jsxs(\"p\",{style:subheadingStyle,children:[\"Enter username and email to join Finance Pro ProWellnessClub Customer as an Individual or Family.\",/*#__PURE__*/_jsx(\"br\",{}),\" Or enter existing account's username and email in order to buy the ProWellnessClub Customer as an Individual or Family Subscription for that account.\"]}),/*#__PURE__*/_jsxs(\"div\",{style:formStyle,children:[/*#__PURE__*/_jsx(\"input\",{name:\"referralId\",placeholder:\"Referral ID\",value:form.referralId,onChange:handleChange,style:inputStyles,disabled:true}),/*#__PURE__*/_jsx(\"input\",{name:\"email\",type:\"email\",placeholder:\"Email\",value:form.email,onChange:handleChange,style:inputStyle,disabled:isLoading})]}),message&&/*#__PURE__*/_jsx(\"div\",{children:/*#__PURE__*/_jsx(\"p\",{style:errorTxtStyle,children:message})}),/*#__PURE__*/_jsx(\"div\",{style:buttonRowStyle,children:!isValid?/*#__PURE__*/_jsx(\"button\",{style:{...buttonStyle,backgroundColor:\"#1a79f6\",opacity:isLoading?.7:1,cursor:isLoading?\"not-allowed\":\"pointer\"},onClick:()=>handleValidate(),children:isLoading?\"Validating...\":\"Validate\"}):/*#__PURE__*/_jsx(\"button\",{style:{...buttonStyle,backgroundColor:\"#208600\",opacity:isLoading?.7:1,cursor:isLoading?\"not-allowed\":\"pointer\"},onClick:()=>handleProceed(),children:isLoading?\"Proceeding...\":\"Proceed\"})})]});}const containerStyle={maxWidth:640,margin:\"60px auto\",padding:\"0 24px\",textAlign:\"center\",fontFamily:\"'Inter', sans-serif\",marginTop:\"100px\"};const headingStyle={fontSize:36,marginBottom:8,color:\"#000000\"};const subheadingStyle={fontSize:15,marginBottom:32,color:\"#000000\"};const formStyle={display:\"grid\",gap:20,marginTop:20};const inputStyle={width:\"100%\",padding:14,fontSize:16,border:\"1px solid #ccc\",borderRadius:8,boxSizing:\"border-box\"};const inputStyles={width:\"100%\",padding:14,fontSize:16,border:\"1px solid #ccc\",borderRadius:8,boxSizing:\"border-box\",backgroundColor:\"white\"};const buttonRowStyle={display:\"flex\",flexDirection:\"column\",gap:20,marginTop:40};const buttonStyle={backgroundColor:\"#208600\",color:\"#fff\",padding:\"16px\",fontSize:16,border:\"none\",borderRadius:10,cursor:\"pointer\"};const errorTxtStyle={display:\"flex\",alignItems:\"center\",justifyContent:\"center\",fontSize:16,marginTop:36,color:\"#208600\",textAlign:\"center\"};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CheckoutForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FormPlus.map"],"mappings":"8IAA+F,SAAwB,GAAc,CAAC,GAAK,CAAC,EAAK,GAASA,EAAS,CAAC,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,CAAC,CAAM,CAAC,EAAS,GAAaA,EAAS,GAAG,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAM,CAAC,EAAQ,GAAYA,EAAS,GAAM,CAAM,CAAC,EAAQ,GAAYA,EAAS,KAAK,CAClX,MAAc,CAA0D,IAAM,EAAlD,IAAI,gBAAgB,EAAO,SAAS,OAAO,CAAyB,IAAI,aAAa,CAAI,GAAY,EAAQ,IAAW,CAAC,GAAG,EAAoB,aAAW,EAAE,EAAI,EAAE,CAAC,CAAC,IAAM,EAAa,GAAG,CAAC,EAAW,KAAK,CAAC,EAAQ,CAAC,GAAG,GAAM,EAAE,OAAO,MAAM,EAAE,OAAO,MAAM,CAAC,EAAS,EAAc,SAAS,CAAC,GAAK,CAAC,aAAW,SAAO,EACrQ,EAAI,oCAAtE,IAAI,gBAAgB,CAAC,aAAW,WAAS,QAAM,CAAC,CAAC,UAAU,GAAuD,EAAO,SAAS,KAAK,EAAI,EAAW,GAAM,CAAC,EAAY,GAAG,CAAC,EAAW,GAAG,EAAS,EAAe,SAAS,CAAC,GAAK,CAAC,aAAW,SAAO,EAAK,GAAG,CAAC,GAAY,CAAC,EAAM,CAAC,MAAM,6BAA6B,CAAC,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