import{j as e,r as g,a as N,b as P,n as s}from"./index-7c7a558c.js";import{B as S}from"./Breadcrumb-2eb871e0.js";import{c as C,p as _}from"./trainerApi-cc9df6e9.js";const q=()=>e.jsx("div",{className:"my-12 h-screen",children:e.jsx("div",{className:"relative overflow-x-auto shadow-md sm:rounded-lg bg-white dark:bg-gray-900 p-2 animate-pulse",children:e.jsxs("form",{className:"p-5",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"h-8 w-96 bg-gradient-to-r from-gray-200 dark:from-gray-700 to-gray-100 dark:to-gray-800 rounded-lg mb-2"}),e.jsx("div",{className:"h-8 w-80 bg-gradient-to-r from-gray-200 dark:from-gray-700 to-gray-100 dark:to-gray-800 rounded-lg"})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"h-8 w-96 bg-gradient-to-r from-gray-200 dark:from-gray-700 to-gray-100 dark:to-gray-800 rounded-lg mb-2"}),e.jsx("div",{className:"h-8 w-80 bg-gradient-to-r from-gray-200 dark:from-gray-700 to-gray-100 dark:to-gray-800 rounded-lg"})]}),e.jsx("div",{className:"h-12 w-40 bg-gradient-to-r from-blue-200 dark:from-gray-700 to-blue-100 dark:to-gray-800 rounded-lg mb-6"}),e.jsx("button",{type:"submit",className:"text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 animate-pulse",children:"Change Password"})]})})});function F(){const[u,y]=g.useState(),[r,k]=g.useState(),[m,c]=g.useState(""),[b,f]=g.useState(""),{isLoading:p}=N("getTrainerInfo",()=>C(),{onSuccess:a=>{var t,d,o,l,i,n;(d=(t=a==null?void 0:a.data)==null?void 0:t.data)!=null&&d.instructor&&(k((l=(o=a==null?void 0:a.data)==null?void 0:o.data)==null?void 0:l.instructor),y((n=(i=a==null?void 0:a.data)==null?void 0:i.data)==null?void 0:n.user))}}),{mutate:j,isLoading:h}=P(_,{onSuccess:()=>{s.success("Successfully Saved"),c(""),f("")},onError:a=>{var t,d,o,l,i,n,x,w;(d=(t=a==null?void 0:a.response)==null?void 0:t.data)!=null&&d.error?s.error((l=(o=a==null?void 0:a.response)==null?void 0:o.data)==null?void 0:l.error):(n=(i=a==null?void 0:a.response)==null?void 0:i.data)!=null&&n.message?s.error((w=(x=a==null?void 0:a.response)==null?void 0:x.data)==null?void 0:w.message):s.error("something went wrong!")}}),v=a=>{if(a.preventDefault(),m==""){s.error("Password field is required");return}if(b==""){s.error("Confirm Password field is required");return}if(m!=b){s.error("Password not matched!");return}h||j({Id:r==null?void 0:r.uuid,formdata:{password:m,first_name:r==null?void 0:r.first_name,last_name:r==null?void 0:r.last_name,email:u==null?void 0:u.email}})};return e.jsxs(e.Fragment,{children:[e.jsx(S,{title:"Change Password"}),p?e.jsx(q,{}):e.jsx("div",{className:"my-12 h-screen",children:e.jsx("div",{className:"relative overflow-x-auto shadow-md sm:rounded-lg bg-white dark:bg-gray-900 p-2",children:e.jsxs("form",{className:"p-5",onSubmit:v,children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{htmlFor:"password",className:"block mb-2 text-sm font-medium text-gray-900 dark:text-white",children:"Your password"}),e.jsx("input",{type:"password",id:"password",className:"shadow-sm bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 dark:shadow-sm-light",required:!0,onChange:a=>c(a.target.value)})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{htmlFor:"repeat-password",className:"block mb-2 text-sm font-medium text-gray-900 dark:text-white",children:"Repeat password"}),e.jsx("input",{type:"password",id:"repeat-password",className:"shadow-sm bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 dark:shadow-sm-light",required:!0,onChange:a=>f(a.target.value)})]}),e.jsx("button",{type:"submit",className:"text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800",children:h?"Changing Password...":"Change Password"})]})})})]})}export{F as default};
