1import{r as c,j as e}from"./ui-B6H_bkrQ.js";import{a4 as S,$ as E,ak as h,B as u,ac as f,m as j,I as g,E as b}from"./index-DmJaNNfq.js";import{u as C,b as L}from"./query-CWVDojdR.js";import{E as T}from"./eye-off-BUGPcbNO.js";import{E as B}from"./eye-CbSuW6s1.js";import"./vendor-BzrpNAyj.js";import"./charts-DxS0nGR8.js";function U(){const[,l]=S(),{toast:p}=E(),[r,y]=c.useState(""),[n,N]=c.useState(""),[o,v]=c.useState(!1);c.useEffect(()=>(document.title="Set Up Your Password | Podcast Room",()=>{document.title="Podcast Room | Professional Podcast Studios"}),[]);const t=new URLSearchParams(window.location.search).get("token"),{data:a,isLoading:P}=C({queryKey:["verify-setup-token",t],queryFn:async()=>t?(await fetch(`/api/customer/verify-setup-token?token=${t}`)).json():{valid:!1,error:"No token provided"},enabled:!!t}),d=L({mutationFn:async s=>{const x=await fetch("/api/customer/set-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!x.ok){const F=await x.json();throw new Error(F.error||"Failed to set password")}return x.json()},onSuccess:()=>{p({title:"Password Set!",description:"Your account is ready. Redirecting..."}),setTimeout(()=>l("/my-account"),1500)},onError:s=>{p({title:"Error",description:s.message,variant:"destructive"})}}),m=r.length>=8,i=r===n&&n.length>0,w=m&&i&&!d.isPending,k=s=>{s.preventDefault(),!(!t||!w)&&d.mutate({token:t,password:r})};return t?P?e.jsx("div",{className:"min-h-screen bg-[#18181B] flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(f,{className:"w-12 h-12 text-[#FFF105] animate-spin mx-auto mb-4"}),e.jsx("p",{className:"text-gray-400",children:"Verifying link..."})]})}):a?.valid?e.jsx("div",{className:"min-h-screen bg-[#18181B] flex items-center justify-center p-4",children:e.jsxs("div",{className:"max-w-md w-full",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold text-[#FFF105] mb-2",children:"PODCAST ROOM"}),e.jsx("p",{className:"text-gray-400",children:"Set up your account"})]}),e.jsxs("div",{className:"bg-gray-800 rounded-xl p-8",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-xl font-semibold text-white mb-1",children:["Welcome, ",a.firstName,"!"]}),e.jsxs("p",{className:"text-gray-400 text-sm",children:["Create a password for your account: ",a.email]})]}),e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"password",className:"text-white",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(g,{id:"password",type:o?"text":"password",value:r,onChange:s=>y(s.target.value),placeholder:"Enter password (min 8 characters)",className:"bg-gray-700 border-gray-600 text-white pr-10","data-testid":"input-password"}),e.jsx("button",{type:"button",onClick:()=>v(!o),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-white",children:o?e.jsx(T,{className:"w-4 h-4"}):e.jsx(B,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[m?e.jsx(b,{className:"w-4 h-4 text-green-500"}):e.jsx("div",{className:"w-4 h-4 rounded-full border border-gray-500"}),e.jsx("span",{className:m?"text-green-500":"text-gray-400",children:"At least 8 characters"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"confirmPassword",className:"text-white",children:"Confirm Password"}),e.jsx(g,{id:"confirmPassword",type:o?"text":"password",value:n,onChange:s=>N(s.target.value),placeholder:"Confirm your password",className:"bg-gray-700 border-gray-600 text-white","data-testid":"input-confirm-password"}),n&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i?e.jsx(b,{className:"w-4 h-4 text-green-500"}):e.jsx(h,{className:"w-4 h-4 text-red-500"}),e.jsx("span",{className:i?"text-green-500":"text-red-500",children:i?"Passwords match":"Passwords do not match"})]})]}),e.jsx(u,{type:"submit",disabled:!w,className:"w-full bg-[#FFF105] text-black hover:bg-[#E6D904] disabled:opacity-50","data-testid":"button-set-password",children:d.isPending?e.jsxs(e.Fragment,{children:[e.jsx(f,{className:"w-4 h-4 mr-2 animate-spin"}),"Setting Password..."]}):"Set Password & Continue"})]})]})]})}):e.jsx("div",{className:"min-h-screen bg-[#18181B] flex items-center justify-center p-4",children:e.jsxs("div",{className:"max-w-md w-full bg-gray-800 rounded-xl p-8 text-center",children:[e.jsx(h,{className:"w-16 h-16 text-amber-500 mx-auto mb-4"}),e.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:a?.expired?"Link Expired":"Invalid Link"}),e.jsx("p",{className:"text-gray-400 mb-6",children:a?.expired?"This password setup link has expired. Please contact us to request a new one.":"This password setup link is invali
1d or has already been used."}),e.jsx(u,{onClick:()=>l("/myaccount"),className:"bg-[#FFF105] text-black hover:bg-[#E6D904] border-0",children:"Go to Login"})]})}):e.jsx("div",{className:"min-h-screen bg-[#18181B] flex items-center justify-center p-4",children:e.jsxs("div",{className:"max-w-md w-full bg-gray-800 rounded-xl p-8 text-center",children:[e.jsx(h,{className:"w-16 h-16 text-red-500 mx-auto mb-4"}),e.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"Invalid Link"}),e.jsx("p",{className:"text-gray-400 mb-6",children:"This password setup link is invalid."}),e.jsx(u,{onClick:()=>l("/myaccount"),className:"bg-[#FFF105] text-black hover:bg-[#E6D904] border-0",children:"Go to Login"})]})})}export{U as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.