Your IP : 216.73.216.93


Current Path : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/
Upload File :
Current File : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/Login-CAikyNgg.js

import{r as t,j as e,E as j,H as G,x as u,a2 as T,G as W,C as q}from"./index-C50MwByD.js";import{u as f,I as J,b as N,A as U}from"./index-Ntz7vSIm.js";import{h as V,u as Y,S as m,F as b,L as $,M as K,b as Q,a as X,c as Z,g as _,d as ee,e as se}from"./index.esm-BgKkBPdO.js";import{F as oe}from"./ForgetPassword-DNtz98E5.js";import{F as w,d as S,I as y}from"./input-BS5AKlHW.js";import{B as C}from"./visually-hidden.style-C5P7rhbc.js";import{I as ae}from"./input-group-CydZNcsv.js";import{I as te}from"./input-element-BOjIoCl2.js";import{R as ne,a as re}from"./radio-BBfwax5w.js";import"./useMutation-DiBhxv_U.js";import"./split-CzYrjwZo.js";function ie(){return q().add(24,"hours").valueOf()}function be(){const{register:r,handleSubmit:F}=V(),p=Y(),[k,i]=t.useState(!1),[h,O]=t.useState([]),[l,R]=t.useState(null),{isOpen:E,onOpen:P,onClose:d}=f(),[g,v]=t.useState(),[n,I]=t.useState(!1),{isOpen:M,onOpen:L,onClose:B}=f(),D=()=>{I(!n)},z=async s=>{i(!0);try{const o=(await T.post(`${W}/login`,s)).data;i(!1),o.response===200?!o.data.role||o.data.role.length===0?c("You do not have permission to access the admin panel. Please contact the administrator if you believe this is an error."):o.data.role.length>1?(O(o.data.role),v({data:o.data,token:o.token}),P()):x(o.data,o.token,o.data.role[0]):c("Wrong Email Or Password.")}catch(a){i(!1),c("An error occurred during login. Please try again."),console.error(a)}},x=(s,a,o)=>{const H={...s,role:o,token:a,exp:ie()};localStorage.setItem("admin",JSON.stringify(H)),p({title:"Login Success.",status:"success",duration:9e3,isClosable:!0,position:"top"}),window.location.reload("/")},c=s=>{p({title:s,status:"error",duration:9e3,isClosable:!0,position:"top"})},A=()=>{const s=h.find(a=>a.name===l);s&&(x(g.data,g.token,s),d())};return e.jsxs(e.Fragment,{children:[e.jsxs(m,{minH:"100vh",direction:{base:"column",md:"row"},background:"url('/admin/loginbg.png')",backgroundSize:"cover",backgroundPosition:"center",children:[" ",e.jsx(w,{p:8,flex:1,align:"center",justify:"center",flexDir:"column",children:e.jsxs(m,{spacing:4,w:"full",maxW:"md",as:"form",onSubmit:F(z),bg:"gray.50",padding:8,borderRadius:8,minW:"600px",color:j("gray.800","gray.800"),children:[e.jsx(G,{fontSize:"2xl",children:"Sign in to your account"}),e.jsxs(S,{children:[e.jsxs(b,{children:["Email",e.jsx(C,{bg:"transparent",color:"red",children:"*"})]}),e.jsx(y,{type:"email",isRequired:!0,isFocused:!0,placeholder:"Email",...r("email")})]}),e.jsxs(S,{mt:5,children:[e.jsxs(b,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[e.jsxs("span",{children:["Password",e.jsx(C,{bg:"transparent",color:"red",children:"*"})]}),e.jsx($,{fontSize:14,color:"blue.500",onClick:L,children:"Forget password?"})]}),e.jsxs(ae,{size:"md",children:[e.jsx(y,{type:n?"text":"password",placeholder:"Enter password",isRequired:!0,isFocused:!0,...r("password")}),e.jsx(te,{width:"3rem",children:e.jsx(J,{variant:"ghost",h:"1.75rem",size:"md",onClick:D,icon:n?e.jsx(N,{}):e.jsx(U,{}),"aria-label":n?"Hide password":"Show password",color:j("gray.800","gray.800")})})]})]}),e.jsx(u,{colorScheme:"blue",w:"100%",mt:10,type:"submit",isLoading:k,children:"Sign in"})]})}),e.jsx(w,{flex:1})]}),e.jsxs(K,{isOpen:E,onClose:d,isCentered:!0,children:[e.jsx(Q,{}),e.jsxs(X,{children:[e.jsx(Z,{children:"Login As - "}),e.jsx(_,{}),e.jsx(ee,{children:e.jsx(ne,{onChange:R,value:l,children:e.jsxs(m,{children:[" ",h.map(s=>e.jsx(re,{value:s.name,children:s.name},s.id))]})})}),e.jsxs(se,{children:[e.jsx(u,{colorScheme:"blue",mr:3,onClick:A,isDisabled:!l,children:"Continue"}),e.jsx(u,{variant:"ghost",onClick:d,children:"Cancel"})]})]})]}),e.jsx(oe,{isOpen:M,onClose:B})]})}export{be as default};