import{co as t,r as d,cp as B,u as _,cq as $,cr as S,bt as H,cs as G,b as e,ct as M,B as V,j as r,s as f,cu as W,cv as v,cw as Y,aB as q}from"./index-BiWH3VAt.js";const K=t.div`
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  position: relative;
  overflow: hidden;
  width: 678px;
  max-width: 100%;
  min-height: 500px;
`,Q=t.div`
  position: absolute;
  top: 0;
  height: 100%;
  transition: all 0.6s ease-in-out;
  left: 0;
  width: 50%;
  opacity: 0;
  z-index: 1;
  ${n=>!n.signinIn&&`
    transform: translateX(100%);
    opacity: 1;
    z-index: 5;
  `}
`,J=t.div`
  position: absolute;
  top: 0;
  height: 100%;
  transition: all 0.6s ease-in-out;
  left: 0;
  width: 50%;
  z-index: 2;
  ${n=>n.signinIn?null:"transform: translateX(100%);"}
`,T=t.form`
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 0 30px;
  height: 100%;
  text-align: center;
`,p=t.h1`
  font-weight: bold;
  margin: 0;
`,s=t.input`
  background-color: #eee;
  border: none;
  padding: 12px 15px;
  margin: 8px 0;
  width: 100%;
`,m=t.button`
  border-radius: 20px;
  border: 1px solid #196ae5;
  background-color: #196ae5;
  color: #ffffff;
  font-size: 12px;
  cursor: pointer;
  font-weight: bold;
  padding: 12px 45px;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: transform 80ms ease-in;
  &:active {
    transform: scale(0.95);
  }
  &:focus {
    outline: none;
  }
`,C=t(m)`
  background-color: transparent;
  border-color: #ffffff;
  cursor: pointer;
`;t.a`
  color: #333;
  font-size: 14px;
  text-decoration: none;
  margin: 15px 0;
`;const Z=t.div`
  position: absolute;
  top: 0;
  left: 50%;
  width: 50%;
  height: 100%;
  overflow: hidden;
  transition: transform 0.6s ease-in-out;
  z-index: 100;
  ${n=>n.signinIn?null:"transform: translateX(-100%);"}
`,ee=t.div`
  background: #b060bc;
  background: -webkit-linear-gradient(45deg, #b060bcba, #23a6d5c2);
  background: linear-gradient(45deg, #b060bcba, #23a6d5c2);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: 0 0;
  color: #ffffff;
  position: relative;
  left: -100%;
  height: 100%;
  width: 200%;
  transform: translateX(0);
  transition: transform 0.6s ease-in-out;
  ${n=>n.signinIn?null:"transform: translateX(50%);"}
`,E=t.div`
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 0 40px;
  text-align: center;
  top: 0;
  height: 100%;
  width: 50%;
  transform: translateX(0);
  transition: transform 0.6s ease-in-out;
`,ne=t(E)`
  transform: translateX(-20%);
  ${n=>n.signinIn?null:"transform: translateX(0);"}
`,te=t(E)`
  right: 0;
  transform: translateX(0);
  ${n=>n.signinIn?null:"transform: translateX(20%);"}
`,D=t.p`
  font-size: 14px;
  font-weight: 100;
  line-height: 20px;
  letter-spacing: 0.5px;
  margin: 20px 0 30px;
`;function P(n){return r(f,{variant:"body2",color:"text.secondary",align:"center",...n,mt:2,children:["Copyright © ",e(Y,{color:"inherit",href:"https://huewine.com/",target:"_blank",children:"Huewine Technologies"})," ",new Date().getFullYear(),"."]})}const re=M();q("div")(({theme:n})=>({...n.typography.button,backgroundColor:n.palette.background.paper,padding:n.spacing(1),textAlign:"center"}));function de(){const[n,a]=d.useState(""),l=B(),x=_(),[N]=$();S({userRoleDTOList:[]},{});const[o,b]=d.useState(!0),[ae,oe]=d.useState({firstName:"",userName:"",phoneNumber:void 0,password:"",gender:""}),{userId:U,accessToken:se}=H(c=>c.user),{data:u,isFetching:y,error:ie}=S({userRoleDTOList:[]},{skip:!U}),R=async c=>{c.preventDefault();const I=new FormData(c.currentTarget),g=I.get("username"),h=I.get("password");if(g.trim()){if(!h.trim()){a("Please enter your password.");return}}else{a("Please enter your username.");return}const A="admin",X="admin123",z="mocked-static-token-123",F=1;if(g===A&&h===X){l(v({userId:F,accessToken:z})),x("/");return}const O={userName:g,password:h,applicationName:"ERP"};try{const i=await N({Login:O});if("data"in i)if(i.data&&i.data.code===200){const k=i.data,L=k.user.id,j=k.user.token;l(v({userId:L,accessToken:j})),x("/")}else a("Login Failed. Invalid credentials.");else a("Login Failed. Please try again.")}catch{a("Login Failed. Please try again.")}};d.useEffect(()=>{u&&!y&&l(G(u))},[u,y,l]);const w=()=>{a("")};return e(W,{theme:re,children:e(V,{display:"flex",justifyContent:"center",alignItems:"center",className:"loginpage",sx:{height:"100%",width:"100%"},children:r(K,{children:[e(Q,{signinIn:o,children:r(T,{className:"no-spinner",onSubmit:()=>{},children:[e(p,{children:"Create Account"}),e(s,{type:"text",placeholder:"Name"}),e(s,{type:"text",placeholder:"Username"}),e(s,{type:"password",placeholder:"Password"}),e(s,{type:"number",placeholder:"Phone Number"}),e(m,{children:"Sign Up"}),e(P,{})]})}),e(J,{signinIn:o,children:r(T,{onSubmit:R,children:[e(f,{variant:"button",display:"block",gutterBottom:!0,style:{textAlign:"center",fontSize:"1.5rem"},children:"Huewine"}),e(p,{children:"Sign in"}),e(s,{type:"text",placeholder:"Username",name:"username",onChange:w}),e(s,{type:"password",autoComplete:"off",placeholder:"Password",name:"password",onChange:w}),n.length>0&&e(f,{style:{color:"red",margin:"10px 0px"},children:n}),e(m,{type:"submit",style:{marginTop:"10px"},children:"Sign In"}),e(P,{})]})}),e(Z,{signinIn:o,children:r(ee,{signinIn:o,children:[r(ne,{signinIn:o,children:[e(p,{children:"Welcome Back!"}),e(D,{children:"To keep connected with us please login with your personal info"}),e(C,{onClick:()=>b(!0),children:"Sign In"})]}),r(te,{signinIn:o,children:[e(p,{children:"Hello, Friend!"}),e(D,{children:"Enter Your personal details and start a journey with us"}),e(C,{onClick:()=>b(!1),children:"Sign Up"})]})]})})]})})})}export{de as default};
