Files
boc/landvex-site/assets/ResetPassword-UPJcC126.js
T
Bernt 48ea61cdcc docs: add quixzoom-auth-core product to AAMOS
- Product documentation in docs/products/
- Updated MEMORY.md with product info
- quiXzoom Auth Core as AAMOS Identity product
2026-07-14 09:58:53 +00:00

3 lines
4.8 KiB
JavaScript

import{u as F,aQ as K,r as t,s as R,w as o,j as e,p as h,v as w,q as g,t as y,I as j}from"./index-CZD3_4lD.js";import{C as B}from"./circle-check-60AjePHB.js";import{E as v}from"./eye-off-CHF4QKq3.js";import{E as N}from"./eye-IKrhkOAd.js";const J=()=>{const n=F(),[b]=K(),l=b.get("token"),[c,k]=t.useState(""),[f,P]=t.useState(""),[d,S]=t.useState(!1),[m,C]=t.useState(!1),[p,x]=t.useState(!1),[E,L]=t.useState(!0),[T,q]=t.useState(!1),[O,$]=t.useState(!1),[r,u]=t.useState({}),z=R().min(6,"Lösenordet måste vara minst 6 tecken");t.useEffect(()=>{if(!l){o.error("Ogiltig eller saknad återställningslänk"),n("/auth");return}async function s(){try{const i=await(await fetch(`https://api.quixzoom.com/api/qz/auth/reset-password/verify?token=${l}`)).json();i.ok?q(!0):(o.error(i.error||"Länken har gått ut eller är ogiltig"),setTimeout(()=>n("/auth"),2e3))}catch{o.error("Kunde inte verifiera länken"),setTimeout(()=>n("/auth"),2e3)}finally{L(!1)}}s()},[l,n]);const V=()=>{const s={},a=z.safeParse(c);return a.success||(s.password=a.error.errors[0].message),c!==f&&(s.confirmPassword="Lösenorden matchar inte"),u(s),Object.keys(s).length===0},D=async s=>{if(s.preventDefault(),!!V()){x(!0);try{const i=await(await fetch("https://api.quixzoom.com/api/qz/auth/reset-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:l,newPassword:c})})).json();i.ok?($(!0),o.success("Lösenordet har uppdaterats!")):o.error(i.error||"Kunde inte uppdatera lösenordet")}catch{o.error("Kunde inte ansluta till servern")}finally{x(!1)}}};return E?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx("div",{className:"animate-pulse text-muted-foreground",children:"Verifierar länk..."})}):O?e.jsx("div",{className:"min-h-screen bg-background flex flex-col items-center justify-center p-4",children:e.jsxs(h.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"text-center space-y-4",children:[e.jsx(B,{className:"w-16 h-16 text-green-500 mx-auto"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Lösenordet uppdaterat!"}),e.jsx("p",{className:"text-muted-foreground",children:"Du kan nu logga in med ditt nya lösenord."}),e.jsx(w,{onClick:()=>n("/auth"),className:"w-full max-w-sm",children:"Gå till inloggning"})]})}):T?e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[e.jsxs("div",{className:"bg-gradient-to-br from-primary to-primary/80 text-primary-foreground p-6 pt-[calc(env(safe-area-inset-top)+1.5rem)]",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Välj nytt lösenord"}),e.jsx("p",{className:"text-primary-foreground/70 text-sm mt-1",children:"Ange ett nytt säkert lösenord för ditt konto."})]}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:e.jsx(h.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4},className:"w-full max-w-sm",children:e.jsxs("form",{onSubmit:D,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"password",className:"text-sm text-muted-foreground",children:"Nytt lösenord"}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(j,{id:"password",type:d?"text":"password",placeholder:"••••••••",value:c,onChange:s=>{k(s.target.value),r.password&&u(a=>({...a,password:void 0}))},className:`pl-10 pr-10 ${r.password?"border-destructive":""}`}),e.jsx("button",{type:"button",onClick:()=>S(!d),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:d?e.jsx(v,{className:"w-4 h-4"}):e.jsx(N,{className:"w-4 h-4"})})]}),r.password&&e.jsx("p",{className:"text-xs text-destructive",children:r.password})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"confirmPassword",className:"text-sm text-muted-foreground",children:"Bekräfta nytt lösenord"}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(j,{id:"confirmPassword",type:m?"text":"password",placeholder:"••••••••",value:f,onChange:s=>{P(s.target.value),r.confirmPassword&&u(a=>({...a,confirmPassword:void 0}))},className:`pl-10 pr-10 ${r.confirmPassword?"border-destructive":""}`}),e.jsx("button",{type:"button",onClick:()=>C(!m),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:m?e.jsx(v,{className:"w-4 h-4"}):e.jsx(N,{className:"w-4 h-4"})})]}),r.confirmPassword&&e.jsx("p",{className:"text-xs text-destructive",children:r.confirmPassword})]}),e.jsx(w,{type:"submit",className:"w-full",disabled:p,children:p?"Uppdaterar...":"Uppdatera lösenord"})]})})})]}):null};export{J as default};
//# sourceMappingURL=ResetPassword-UPJcC126.js.map