PageSourceSearch

https://joggle.it/assets/auth-CxXWv4es.js

js joggle.it collected 2026-10-09 22:55:12 UTC 7,002 bytes, 1 lines download raw bytes

1import{r as n,j as e}from"./react-vendor-6-uVh9lA.js";import{o as D,u as L,R as w,J as b,c as p}from"./index-Dj8rAq6V.js";import{C as P,F,G as I,a as J,L as c,I as d,B as E,ay as A}from"./ui-primitives-lzo5gGe9.js";import{u as O}from"./ui-root-DBDUP2Wa.js";import{aJ as y,k as R,aq as T,b2 as q,aG as W}from"./icons-vendor-CNaJirIZ.js";import"./query-vendor-B4HfZuV6.js";import"./ui-vendor-root-CmPLdN-9.js";import"./ui-vendor-CcmWsAw-.js";import"./form-vendor-DNXU13ZK.js";function V(){const{user:x,isLoading:u}=D(),{toast:l}=O(),[f]=L(),[s,v]=n.useState(!0),[j,S]=n.useState(!1),[h,g]=n.useState(!1),[t,N]=n.useState({email:"",password:"",firstName:"",lastName:""});if(n.useEffect(()=>{if(new URLSearchParams(f.split("?")[1]||"").get("signup")==="true"){v(!1);const i=localStorage.getItem("joggleSignupData");if(i){const o=JSON.parse(i);N(C=>({...C,email:o.email||"",firstName:o.firstName||"",lastName:o.lastName||""}))}}},[f]),!u&&x)return e.jsx(w,{to:"/"});if(!u&&!x)return e.jsx(w,{to:"/found"});const k=async a=>{a.preventDefault(),g(!0);try{if(s){const r=await p("/api/auth/login","POST",{email:t.email,password:t.password});l({title:"Welcome back!",description:"You have successfully signed in."}),r?.isAdmin?window.location.href="/admin":window.location.href="/"}else{const r=localStorage.getItem("joggleSignupData"),i=r?JSON.parse(r):{};if(await p("/api/register","POST",{email:t.email,password:t.password,firstName:t.firstName,lastName:t.lastName}),l({title:"Account created!",description:"Welcome to Joggle. Setting up your assistant..."}),i.joggleName)try{const o=await p("/api/users/setup","POST",{username:i.joggleName,websiteUrl:i.businessWebsite||"",signupData:r});localStorage.removeItem("joggleSignupData"),l({title:"Check your email!",description:o?.message||"Please verify your email to complete setup."}),setTimeout(()=>{window.location.href="/verify-email"},2e3)}catch(o){console.error("Setup error:",o),window.location.href="/"}else window.location.href="/"}}catch(r){l({title:s?"Login failed":"Registration failed",description:r.message,variant:"destructive"})}finally{g(!1)}},m=(a,r)=>{N(i=>({...i,[a]:r}))};return u?e.jsx("div",{className:"min-h-screen bg-[var(--j-paper)] flex items-center justify-center font-[var(--j-font-sans)]",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-8 h-8 border-4 border-[var(--j-mist)] border-t-[var(--j-ink)] rounded-full animate-spin mx-auto mb-4"}),e.jsx("p",{className:"text-[var(--j-mid)]",children:"Loading..."})]})}):e.jsxs("div",{className:"min-h-screen bg-[var(--j-paper)] flex items-center justify-center p-8 relative font-[var(--j-font-sans)]",children:[e.jsx("div",{className:"absolute top-4 left-4",children:e.jsx(b,{className:"h-10 w-10"})}),e.jsxs(P,{className:"w-full max-w-md bg-[var(--j-card)] border-[var(--j-mist)]",children:[e.jsxs(F,{className:"text-center pb-8",children:[e.jsxs("div",{className:"mx-auto mb-6 flex items-center justify-center gap-2",children:[e.jsx(b,{variant:"dark",className:"h-10 w-10"}),e.jsx("span",{className:"text-2xl font-bold text-[var(--j-orange)]",children:"Joggle"})]}),e.jsx(I,{className:"text-2xl font-semibold text-[var(--j-ink)] font-[var(--j-font-display)]",children:s?"Welcome back":"Create your account"}),e.jsx("p",{className:"text-[var(--j-mid)] mt-2",children:s?"Sign in to your Joggle account":"Start building your AI assistant today"})]}),e.jsxs(J,{children:[e.jsxs("form",{onSubmit:k,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[!s&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"firstName",className:"text-sm font-medium text-[var(--j-ink-soft)]",children:"First name"}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-[var(--j-stone)] h-4 w-4"}),e.jsx(d,{id:"firstName",type:"text",placeholder:"John",value:t.firstName,onChange:a=>m("firstName",a.target.value),className:"pl-10 h-12 rounded-[var(--j-radius-md)] border-[var(--j-mist)] focus:border-[var(--j-ink)] focus:ring-[var(--j-ink)]",autocomplete:"given-name"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"lastName",className:"text-sm font-medium text-[var(--j-ink-soft)]",children:"Last name"}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-[var(--j-stone)] h-4 w-4"}),e.jsx(d,{id:"lastName",type:"text",placeholder:"Doe",value:t.lastName,onChange:a=>m("lastName",a.target.value),className:"pl-10 h-12 rounded-[var(--j-radius-md)] border-[var(--j-mist)] focu
1s:border-[var(--j-ink)] focus:ring-[var(--j-ink)]",autocomplete:"family-name"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"email",className:"text-sm font-medium text-[var(--j-ink-soft)]",children:"Email address"}),e.jsxs("div",{className:"relative",children:[e.jsx(R,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-[var(--j-stone)] h-4 w-4"}),e.jsx(d,{id:"email",type:"email",placeholder:"[email protected]",value:t.email,onChange:a=>m("email",a.target.value),className:"pl-10 h-12 rounded-[var(--j-radius-md)] border-[var(--j-mist)] focus:border-[var(--j-ink)] focus:ring-[var(--j-ink)]",autocomplete:"email",required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"password",className:"text-sm font-medium text-[var(--j-ink-soft)]",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(T,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-[var(--j-stone)] h-4 w-4"}),e.jsx(d,{id:"password",type:j?"text":"password",placeholder:"Enter your password",value:t.password,onChange:a=>m("password",a.target.value),className:"pl-10 pr-10 h-12 rounded-[var(--j-radius-md)] border-[var(--j-mist)] focus:border-[var(--j-ink)] focus:ring-[var(--j-ink)]",autocomplete:s?"current-password":"new-password",required:!0,minLength:6}),e.jsx("button",{type:"button",onClick:()=>S(!j),className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-[var(--j-stone)] hover:text-[var(--j-mid)]",children:j?e.jsx(q,{className:"h-4 w-4"}):e.jsx(W,{className:"h-4 w-4"})})]}),!s&&e.jsx("p",{className:"text-xs text-[var(--j-stone)]",children:"Must be at least 6 characters"})]})]}),e.jsx(E,{type:"submit",disabled:h,className:"w-full h-12 bg-[var(--j-orange)] hover:bg-[var(--j-orange-deep)] text-white font-medium rounded-[var(--j-radius-pill)]",children:h?"Please wait...":s?"Sign in":"Create account"})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx(A,{className:"my-4"}),e.jsx("div",{className:"text-center",children:e.jsxs("p",{className:"text-sm text-[var(--j-mid)]",children:[s?"Don't have an account?":"Already have an account?"," ",e.jsx("button",{type:"button",onClick:()=>v(!s),className:"font-medium text-[var(--j-ink)] hover:text-[var(--j-ink-soft)] underline",children:s?"Sign up":"Sign in"})]})})]})]})]})]})}export{V 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.