PageSourceSearch

https://www.smallbizagent.ai/assets/join-D660Ab3w.js

js smallbizagent.ai collected 2026-10-05 15:06:12 UTC 5,385 bytes, 6 lines download raw bytes

1import{r as n,u as q,d as F,j as e}from"./vendor-query-CnAhr2B8.js";import{c as I,aX as R,u as $,a as B,H as J,ak as y,p as b,q as C,o as z,r as N,aT as k,s as E,B as f,aC as d,I as m,aG as D}from"./index-CLUtDhnY.js";import{E as G}from"./eye-Dal3N8ej.js";import"./vendor-ui-CYA7SV0W.js";import"./vendor-charts-CPMWc2oJ.js";import"./vendor-forms-UY-il7MQ.js";/**
2 * @license lucide-react v0.453.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const H=I("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);function Y(){const[,u]=R("/staff/join/:code"),[,P]=$(),{toast:j}=B(),c=(u==null?void 0:u.code)||"",[h,S]=n.useState(""),[p,w]=n.useState(""),[a,L]=n.useState(""),[g,O]=n.useState(""),[i,A]=n.useState(!1),{data:t,isLoading:T,error:l}=q({queryKey:["/api/staff-invite",c],queryFn:async()=>{const s=await fetch(`/api/staff-invite/${c}`);if(!s.ok){const o=await s.json();throw new Error(o.message||"Invalid invite")}return s.json()},enabled:!!c,retry:!1});n.useEffect(()=>{t!=null&&t.email&&w(t.email)},[t]);const x=F({mutationFn:async()=>(await J("POST",`/api/staff-invite/${c}/accept`,{username:h,email:p,password:a})).json(),onSuccess:()=>{j({title:"Account Created!",description:"Welcome to your staff portal. Redirecting..."}),setTimeout(()=>{window.location.href="/staff/dashboard"},1500)},onError:s=>{j({title:"Error",description:s.message||"Failed to create account",variant:"destructive"})}}),r={length:a.length>=12,uppercase:/[A-Z]/.test(a),lowercase:/[a-z]/.test(a),number:/[0-9]/.test(a),special:/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(a),match:a===g&&a.length>0},v=h.length>=3&&p.includes("@")&&Object.values(r).every(Boolean),M=s=>{s.preventDefault(),v&&x.mutate()};return T?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(y,{className:"h-8 w-8 animate-spin"})}):l||!(t!=null&&t.valid)?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(b,{className:"w-full max-w-md",children:[e.jsxs(C,{className:"text-center",children:[e.jsx(z,{className:"h-12 w-12 mx-auto mb-2 text-destructive"}),e.jsx(N,{children:"Invalid Invite"}),e.jsx(k,{children:(l==null?void 0:l.message)||"This invite link is invalid, expired, or has already been used."})]}),e.jsx(E,{className:"text-center",children:e.jsx(f,{variant:"outline",onClick:()=>P("/auth"),children:"Go to Login"})})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(b,{className:"w-full max-w-md",children:[e.jsxs(C,{className:"text-center",children:[e.jsxs(N,{className:"text-2xl",children:["Join ",t.businessName]}),e.jsxs(k,{children:["You've been invited to join as ",e.jsx("strong",{children:t.staffName}),". Create your account to access your staff portal."]})]}),e.jsxs(E,{children:[e.jsxs("form",{onSubmit:M,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Username"}),e.jsx(m,{value:h,onChange:s=>S(s.target.value.toLowerCase()),placeholder:"Choose a username",autoComplete:"username"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Email"}),e.jsx(m,{type:"email",value:p,onChange:s=>w(s.target.value),placeholder:"[email protected]",autoComplete:"email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(m,{type:i?"text":"password",value:a,onChange:s=>L(s.target.value),placeholder:"Create a password",autoComplete:"new-password"}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",className:"absolute right-1 top-1 h-7 w-7 p-0",onClick:()=>A(!i),children:i?e.jsx(H,{className:"h-4 w-4"}):e.jsx(G,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Confirm Password"}),e.jsx(m,{type:i?"text":"password",value:g,onChange:s=>O(s.target.value),placeholder:"Confirm your password",autoComplete:"new-password"})]}),a.length>0&&e.jsx("div",{className:"text-xs space-y-1 p-3 bg-muted rounded-lg",children:[{check:r.length,label:"At least 12 characters"},{check:r.uppercase,label:"One uppercase letter"},{check:r.lowercase,label:"One lowercase letter"},{check:r.number,label:"One number"},{check:r.special,label:"One special character"},{check:r.match,label:"Passwords match"}].map(({check:s,label:o})=>e.jsxs("div",{className:`flex items-center gap-2 ${s?"text-green-600":"text-muted-foreground"}`,children:[s?e.jsx(D,{className:"h-3 w-3"}):e.jsx("span",{className:"h-3 w-3 rounded-full border inline-block"}),o]},o))}),e.jsx(f,{type:"submit",className:"w-full",disabled:!v||x.isPending,children:x.isPending?e.jsxs(e.Fragment,{children:[e.jsx(y,{className:"h-4 w-4 mr-2 animate-spin"}),"Creating Account..."]}):"Create Account & Join"})]}),e.jsxs("div",{className:"mt-4 text-center text-sm text-muted-foreground",children:["Already have an account?"," ",e.jsx("a",{href:"/auth",className:"text-primary underline",children:"Log in"})]})]})]})})}export{Y 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.