1import{m as A,a as E,o as I,r as n,j as e,b,L as g,B as y,p as T,R as N,s as v}from"./index-Mli6dXd9.js";import{f as F}from"./fantaisy-icon.png.asset-DlPdZ6Gz.js";import{O as L}from"./OTPInput-BHZ1WycJ.js";import{M as w}from"./MinimalHeader-Bnr-E-of.js";import{C as O}from"./circle-check-mMdPzTyP.js";import{P as Y}from"./phone-CgKNmv4z.js";import{C as _}from"./circle-alert-BY5gsvWA.js";const q=()=>{const C=A(),{toast:u}=E(),[x]=I(),[S,o]=n.useState(Array(6).fill("")),[f,l]=n.useState(!1),[h,p]=n.useState(!1),[t,j]=n.useState(0),[d,i]=n.useState(""),[V,P]=n.useState("pending"),a=x.get("phone")||"",m=x.get("userId")||"";n.useEffect(()=>{if(t>0){const s=setTimeout(()=>j(t-1),1e3);return()=>clearTimeout(s)}},[t]);const k=async s=>{if(s.length===6){l(!0),i("");try{const{data:r,error:c}=await v.functions.invoke("verify-phone-otp",{body:{phone_number:a,code:s,user_id:m}});if(c||!(r!=null&&r.success)){i((r==null?void 0:r.error)||(c==null?void 0:c.message)||"Invalid code. Please try again."),o(Array(6).fill("")),l(!1);return}P("success"),u({title:"Phone verified!",description:"Your phone number has been verified successfully."}),setTimeout(()=>
1{C("/onboarding/personalize",{replace:!0})},2e3)}catch(r){console.error("[VerifyPhone] Verification error:",r),i("Something went wrong. Please try again."),o(Array(6).fill(""))}finally{l(!1)}}},R=async()=>{if(!(t>0||!a||!m)){p(!0),i("");try{const{data:s,error:r}=await v.functions.invoke("send-phone-otp",{body:{phone_number:a,user_id:m}});if(r||!(s!=null&&s.success)){i((s==null?void 0:s.error)||"Failed to resend code.");return}u({title:"New code sent!",description:"Check your phone for the new verification code."}),j(60),o(Array(6).fill(""))}catch(s){console.error("[VerifyPhone] Resend error:",s),i("Failed to resend verification code.")}finally{p(!1)}}};return V==="success"?e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[e.jsx(b,{title:"Phone Verified",description:"Your phone number has been verified."}),e.jsx(w,{}),e.jsx("main",{className:"flex-1 flex items-center justify-center pt-20 px-4 py-6",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card border border-border rounded-xl p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-success/20 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(O,{className:"w-8 h-8 text-success-text"})}),e.jsx("h1",{className:"font-display text-2xl md:text-3xl text-foreground mb-4",children:"Phone Verified!"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Setting up your experience..."}
1),e.jsx(g,{to:"/onboarding/personalize",children:e.jsx(y,{variant:"hero",className:"w-full",children:"Continue"})})]})})})]}):e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[e.jsx(b,{title:"Verify Your Phone",description:"Enter the verification code sent to your phone."}),e.jsx(w,{}),e.jsx("main",{className:"flex-1 flex items-center justify-center pt-20 px-4 py-6",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card border border-border rounded-xl p-6 sm:p-8",children:[e.jsx("div",{className:"text-center mb-6",children:e.jsx("div",{className:"inline-block",children:e.jsx("img",{src:F.url,alt:"FANTAISY",className:"w-12 h-12 object-contain mx-auto"})})}),e.jsx("div",{className:"w-20 h-20 bg-primary/10 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(Y,{className:"w-10 h-10 text-primary"})}),e.jsx("h1",{className:"font-display text-2xl md:text-3xl text-foreground text-center mb-4",children:"Enter Verification Code"}),e.jsx("p",{className:"text-muted-foreground text-center mb-2",children:"We sent a 6-digit code to:"}),a&&e.jsx("p",{className:"text-primary font-medium text-center mb-8",children:a}),e.jsx("div",{className:"mb-6",children:e.jsx(L,{value:S,onChange:o,onComplete:k,disabled:f,error:!!d})}),d&&e.jsxs("div",{className:"flex items-center justify-center gap-2 text-destructive text-sm mb-4",children:[e.jsx(_,{className:"w-4 h-4"}),e.jsx("span",{children:d})]}),f&&e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground mb-4",children:[e.jsx(T,{className:"w-5 h-5 animate-spin text-primary"}),e.jsx("span",{children:"Verifying..."})]}),e.jsx("div",{className:"bg-secondary/50 border border-border rounded-lg p-4 mb-6",children:e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"The code expires in 10 minutes. Standard messaging rates may apply."})}),e.jsx(y,{variant:"outline",className:"w-full",onClick:R,disabled:h||t>0||!a,children:h?e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"w-4 h-4 mr-2 animate-spin"}),"Sending..."]}):t>0?`Resend code in ${t}s`:e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"w-4 h-4 mr-2"}),"Resend Code"]})}),e.jsx("div",{className:"mt-6 pt-6 border-t border-border",children:e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Wrong number?"," ",e.jsx(g,{to:"/signup",className:"text-primary hover:underline",children:"Go back to signup"})]})})]})})})]})};export{q 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.