import{aJ as x,r as o,j as r,f as k}from"./index-7c7a558c.js";import{B as y}from"./Breadcrumb-21e99ae5.js";import{P as j}from"./PageLoader-31c46f94.js";function C(){const[N,m,p]=x(),[b,g]=o.useState(!0),[f,i]=o.useState(!1),[t,l]=o.useState(!1),[e,d]=o.useState({password:"",password_confirmation:""}),[a,c]=o.useState({}),w=()=>{const s={};return e.password||(s.password="Id Number is required"),e.password_confirmation||(s.password_confirmation="Id Number is required"),e.password!=e.password_confirmation&&(s.password_confirmation="Password is not match"),s},h=async s=>{s.preventDefault();const u=w();if(Object.keys(u).length===0)try{const n=await k.post("https://www.bdskilltech.com/backend/public/api/admin/change-password",e,{headers:{Authorization:"Bearer "+m}});console.log(n),d({password:"",password_confirmation:""}),c({}),i(!0)}catch(n){l(n.response.data.error)}else c(u)};return o.useEffect(()=>{setTimeout(()=>{l(""),i(!1)},5e3),setTimeout(()=>{g(!1)},500)},[]),r.jsx(r.Fragment,{children:b?r.jsx(j,{title:p?"Change Password":"Checking Admin Login"}):r.jsxs(r.Fragment,{children:[r.jsx(y,{title:"Change Password"}),r.jsx("div",{className:"my-12 h-screen",children:r.jsxs("div",{className:"relative overflow-x-auto shadow-md sm:rounded-lg section-bg p-2",children:[f&&r.jsx("p",{className:"text-green-800 p-5 font-bold",children:"Password Changed Succesulful"}),t&&r.jsx("p",{className:"text-red-800 p-5 font-bold",children:t}),r.jsxs("form",{className:"p-5",onSubmit:h,children:[r.jsxs("div",{className:"mb-6",children:[r.jsx("label",{htmlFor:"password",className:"block mb-2 text-sm font-medium text-gray-900 dark:text-white",children:"Your password"}),r.jsx("input",{value:e.password,onChange:s=>d({...e,password:s.target.value}),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 ${a.password||t?" border-red-500 dark:border-red-500":" border-gray-300"}`,required:!0}),a.password&&r.jsx("span",{className:"text-red-500",children:a.password})]}),r.jsxs("div",{className:"mb-6",children:[r.jsx("label",{htmlFor:"password_confirmation",className:"block mb-2 text-sm font-medium text-gray-900 dark:text-white",children:"Repeat password"}),r.jsx("input",{value:e.password_confirmation,onChange:s=>d({...e,password_confirmation:s.target.value}),type:"password",id:"password_confirmation",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 ${a.password_confirmation||t?" border-red-500 dark:border-red-500":" border-gray-300"}`,required:!0}),a.password_confirmation&&r.jsx("span",{className:"text-red-500",children:a.password_confirmation})]}),r.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:"Change Password"})]})]})})]})})}export{C as default};
