1import{u as L,a as k,n as B,r,j as e,m as q,L as A,a1 as E,B as f,f as D}from"./index-BTFpJOLG.js";import{C as R,b as T,c as F,d as Y,a as H}from"./card-8AhoKK5G.js";import{P as m}from"./PasswordField-CNweWrgH.js";import{P as M}from"./PublicHeader-6ZOuGiRP.js";import{P as O}from"./PublicFooter-DDk4-z1q.js";import{A as I}from"./arrow-left-DkPPUCOj.js";import{C as K}from"./circle-check-big-CrmW5jJI.js";import"./input-Di4d8hu6.js";import"./label-CEzSKDR9.js";import"./eye-off-CszhKear.js";import"./eye-Cv0RCvR7.js";import"./sheet-tb6rN8p6.js";import"./index-Cx3RkizE.js";import"./send-37ZLJgA4.js";function re(){const{isAuthenticated:x,isLoading:b}=L(),{toast:n}=k(),[,h]=B(),[l,g]=r.useState(""),[a,C]=r.useState(""),[t,j]=r.useState(""),[p,c]=r.useState(void 0),[o,w]=r.useState(!1),[d,N]=r.useState(!1);if(b)return null;if(!x)return e.jsx(q,{to:"/login"});const u=(s,i)=>{if(i&&s!==i)return"Passwords do not match"},P=s=>{C(s),c(u(s,t))},v=s=>{j(s),c(u(a,s))},y=async s=>{if(s.preventDefault(),!l||!a||!t){n({title:"All fields are required",variant:"destructive"});return}if(a.length<8){n({title:"New password must be at least 8 characters",variant:"destructive"});return}const i=u(a,t);if(i){c(i);return}w(!0);try{await D("POST","/api/auth/change-password",{currentPassword:l,newPassword:a,confirmNewPassword:t}),N(!0),n({title:"Password changed successfully"}),setTimeout(()=>h("/dashboard"),2e3)}catch(S){n({title:"Password change failed",description:S?.message||"Please try again.",variant:"destructive"})}finally{w(!1)}};return e.jsxs("div",{className:"flex min-h-screen flex-col font-mono text-sm selection:bg-primary selection:text-black",children:[e.jsx(M,{subtitle:"My Dashboard"}),e.jsxs("main",{className:"mx-auto w-full max-w-lg flex-1 p-6",children:[e.jsx("div",{className:"mb-6",children:e.jsxs(A,{href:"/dashboard",className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-primary",children:[e.jsx(I,{className:"h-4 w-4"}),"Back to dashboard"]})}),e.jsxs(R,{className:"border-border shadow-sm",children:[e.jsxs(T,{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[d?e.jsx(K,{className:"h-5 w-5 text-primary"}):e.jsx(E,{className:"h-5 w-5 text-primary"}),e.jsx(F,{className:"text-xl font-bold",children:d?"Password changed":"Change password"})]}),e.jsx(Y,{children:d?"You will be redirected to the dashboard.":"Enter your current password and choose a new one."})]}),e.jsx(H,{children:d?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border border-primary/30 bg-primary/10 p-4",children:e.jsx("p",{className:"text-sm",children:"Your password has been updated successfully. Log in again if your session expires."})}),e.jsx(f,{className:"w-full",onClick:()=>h("/dashboard"),children:"Back to dashboard"})]}):e.jsxs("form",{onSubmit:y,className:"space-y-5",noValidate:!0,children:[e.jsx(m,{label:"Current password",id:"currentPassword",value:l,onChange:s=>g(s.target.value),disabled:o,autoComplete:"current-password",required:!0,autoFocus:!0}),e.jsx(m,{label:"New password",id:"newPassword",hint:"Minimum 8 characters",value:a,onChange:s=>P(s.target.value),disabled:o,autoComplete:"new-password",required:!0,minLength:8}),e.jsx(m,{label:"Confirm new password",id:"confirmNewPassword",error:p,value:t,onChange:s=>v(s.target.value),disabled:o,autoComplete:"new-password",required:!0}),e.jsx(f,{type:"submit",className:"w-full",disabled:o||!!p,children:o?"Saving...":"Change password"})]})})]})]}),e.jsx(O,{tagline:"Your Domain Operations"})]})}export{re 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.