import{bu as t,r as d,bv as B,u as _,aX as $,bw as H,b as e,bx as G,B as M,j as r,q as f,by as V,bz as S,bA as W,au as Y}from"./index-DWFi48i_.js";import{u as q,a as v}from"./userRoleAPI-CaMOyeYq.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;
`,i=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(W,{color:"inherit",href:"https://huewine.com/",target:"_blank",children:"Huewine Technologies"})," ",new Date().getFullYear(),"."]})}const re=G();Y("div")(({theme:n})=>({...n.typography.button,backgroundColor:n.palette.background.paper,padding:n.spacing(1),textAlign:"center"}));function pe(){const[n,a]=d.useState(""),l=B(),b=_(),[N]=q();v({userRoleDTOList:[]},{});const[o,x]=d.useState(!0),[ae,oe]=d.useState({firstName:"",userName:"",phoneNumber:void 0,password:"",gender:""}),{userId:U,accessToken:ie}=$(c=>c.user),{data:u,isFetching:y,error:se}=v({userRoleDTOList:[]},{skip:!U}),A=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 R="admin",X="admin123",z="mocked-static-token-123",F=1;if(g===R&&h===X){l(S({userId:F,accessToken:z})),b("/");return}const O={userName:g,password:h,applicationName:"ERP"};try{const s=await N({Login:O});if("data"in s)if(s.data&&s.data.code===200){const k=s.data,L=k.user.id,j=k.user.token;l(S({userId:L,accessToken:j})),b("/")}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(H(u))},[u,y,l]);const w=()=>{a("")};return e(V,{theme:re,children:e(M,{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(i,{type:"text",placeholder:"Name"}),e(i,{type:"text",placeholder:"Username"}),e(i,{type:"password",placeholder:"Password"}),e(i,{type:"number",placeholder:"Phone Number"}),e(m,{children:"Sign Up"}),e(P,{})]})}),e(J,{signinIn:o,children:r(T,{onSubmit:A,children:[e(f,{variant:"button",display:"block",gutterBottom:!0,style:{textAlign:"center",fontSize:"1.5rem"},children:"Huewine"}),e(p,{children:"Sign in"}),e(i,{type:"text",placeholder:"Username",name:"username",onChange:w}),e(i,{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:()=>x(!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:()=>x(!1),children:"Sign Up"})]})]})})]})})})}export{pe as default};
