PageSourceSearch

https://knuckl.com/assets/VerifyEmail-HGPzCcd8.js

js knuckl.com collected 2026-09-24 14:47:06 UTC 4,311 bytes, 1 lines download raw bytes

1import{a,j as e}from"./vendor-query-BxlSJxfF.js";import{u as _,a as z,I as F,B as p,L as b,ab as B,C as y,s as g,e as l}from"./index-DO0aGFYL.js";import{K as D}from"./KnucklLogo-DmAzyuOm.js";import{H}from"./Head-CFjoxvyt.js";import{u as K}from"./vendor-react-DdNhUK9-.js";import{M}from"./mail-jw7BVI6D.js";import{C as P}from"./chevron-right-n5eCbV2c.js";import"./vendor-supabase-Csx7YFID.js";function G(){const{user:i}=_(),m=K(),{t}=z(),[n,C]=a.useState(""),[u,v]=a.useState(!1),[w,j]=a.useState(!1),[S,d]=a.useState(!1),[h,L]=a.useState(!0),E=a.useRef(null),N=a.useRef(null),c=(i==null?void 0:i.email)||"",f=c.endsWith("@knuckl.phone");a.useEffect(()=>{if(!i)return;(async()=>{if(f){const x=await y(i.id);m(x==="contractor"?"/contractor":"/worker",{replace:!0});return}const[{data:r},o]=await Promise.all([g.from("profiles").select("email_verified").eq("user_id",i.id).single(),y(i.id)]);if(r!=null&&r.email_verified){m(o==="contractor"?"/contractor":"/worker",{replace:!0});return}L(!1)})()},[i,m,f]);const k=async()=>{var s;if(!(!c||f)){j(!0);try{const{data:r,error:o}=await g.functions.invoke("phone-auth",{body:{action:"send_email_otp",email:c}});if(o){if((s=o.message)!=null&&s.includes("429")){l.info(t.verifyEmail.alreadySent),d(!0);return}throw o}if(r!=null&&r.error){if(r.error.toLowerCase().includes("wait")||r.error.toLowerCase().includes("too many")){l.info(t.verifyEmail.waitBefore),d(!0);return}throw new Error(r.error)}l.success(t.verifyEmail.codeSent({email:c})),d(!0)}catch(r){l.error(r.message||t.verifyEmail.failedSend)}finally{j(!1)}}},R=async s=>{if(s.preventDefault(),!n.trim()){l.error(t.verifyEmail.enterCode);return}v(!0);try{const{data:r,error:o}=await g.functions.invoke("phone-auth",{body:{action:"verify_account_email",email:c,otp:n.trim()}});if(o)throw o;if(r!=null&&r.error)throw new Error(r.error);l.success(t.verifyEmail.emailVerified);const x=await y(i.id);m(x==="contractor"?"/contractor":"/worker",{replace:!0})}catch(r){l.error(r.message||t.verifyEmail.verifyFailed)}finally{v(!1)}};return a.useEffect(()=>{!h&&!S&&c&&!f&&k()},[h]),a.useEffect(()=>{var s;u||n.length===6&&N.current!==n&&(N.current=n,(s=E.current)==null||s.requestSubmit())},[n,u]),h?e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):e.jsxs("div",{className:"min-h-screen bg-background flex flex-col items-center justify-center px-4",children:[e.jsx(H,{title:t.verifyEmail.headTitle,description:t.verifyEmail.headDescription,noindex:!0}),e.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx(D,{size:"md"}),e.jsx("div",{className:"w-14 h-14 rounded-card bg-primary/15 border-2 border-primary/30 flex items-center justify-center mx-auto",children:e.jsx(M,{className:"w-7 h-7 text-primary"})}),e.jsx("h1",{className:"font-display text-2xl text-foreground",children:t.verifyEmail.heading}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.verifyEmail.sentTo," ",e.jsx("span",{className:"font-medium text-foreground",children:c})]})]}),e.jsxs("form",{ref:E,onSubmit:R,className:"space-y-4",children:[e.jsx(F,{value:n,onChange:s=>C(s.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"000000",className:"text-center text-2xl tracking-[0.5em] h-14 font-mono",maxLength:6,inputMode:"numeric",autoComplete:"one-time-code",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,enterKeyHint:"done",pattern:"\\d{6}",autoFocus:!0}),e.jsx(p,{type:"submit",disabled:u||n.length<6,className:"w-full h-12 font-display text-lg tracking-wider",children:u?e.jsx(b,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:[t.verifyEmail.verify," ",e.jsx(P,{className:"w-4 h-4 ml-1"})]})})]}),e.jsxs("div",{className:"text-center space-y-1",children:[e.jsxs(p,{variant:"ghost",size:"sm",onClick:k,disabled:w,className:"text-muted-foreground hover:text-foreground",children:[w?e.jsx(b,{className:"w-3 h-3 animate-spin mr-1"}):e.jsx(B,{className:"w-3 h-3 mr-1"}),t.verifyEmail.resend]}),e.jsx("div",{children:e.jsx(p,{variant:"link",size:"sm",onClick:()=>m("/auth?mode=signup"),className:"text-muted-foreground hover:text-primary text-xs",children:t.verifyEmail.backToSignup})})]})]})]})}export{G 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.