import{q as P,r as i,S,j as s}from"./app-DB4YCWeF.js";import{I as c}from"./Input-BfNm_9oA.js";import"./BaseForm-CkSb_d40.js";function I({className:l=""}){const{has_password:d}=P().props.auth,u=i.useRef(),m=i.useRef(),{data:f,setData:w,errors:x,post:h,reset:n,processing:p,recentlySuccessful:j}=S({current_password:"",password:"",password_confirmation:""}),g=o=>{o.preventDefault(),h("/profile?update-password=true",{preserveScroll:!0,onSuccess:()=>n(),onError:a=>{var r,e;a.password&&(n("password","password_confirmation"),(r=u.current)==null||r.focus()),a.current_password&&(n("current_password"),(e=m.current)==null||e.focus())}})};function b(o){const{name:a,value:r}=o.target;let e=r;w(N=>({...N,[a]:e}))}const t={handleChange:b,data:f,errors:x};return s.jsxs("section",{className:l,children:[s.jsx("header",{children:s.jsxs("h2",{className:"text-lg font-medium text-gray-900 ",children:[d?"Ganti":"Tambahkan"," Password"]})}),s.jsxs("form",{onSubmit:g,className:"space-y-6",children:[s.jsxs("div",{className:"grid gap-2",children:[d?s.jsx(c,{type:"password",name:"current_password",label:"Password Sekarang",...t}):null,s.jsx(c,{type:"password",name:"password",label:"Password Baru",...t}),s.jsx(c,{type:"password",name:"password_confirmation",label:"Konfirmasi Password Baru",...t})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("button",{disabled:p,className:"btn btn-primary btn-sm",children:[p&&s.jsx("span",{className:"loading"}),s.jsx("span",{children:"Simpan"})]}),j?s.jsxs("div",{className:"badge badge-success gap-2 badge-lg",children:[s.jsx("i",{className:"fas fa-check"}),s.jsx("span",{children:"Berhasil Disimpan"})]}):null]})]})]})}export{I as default};
