import{j as e,S,r as x,e as v}from"./app-DB4YCWeF.js";import{G as y}from"./GuestLayout-LP695uwk.js";import{I as d}from"./Input-BfNm_9oA.js";import{C as k}from"./Checkbox-Bn48SEXM.js";import{u as C}from"./useFormChange-B0pYJsvh.js";import"./BaseForm-CkSb_d40.js";function P(s){const{className:t="absolute right-4 top-2 btn btn-sm btn-circle",show:a,setShow:r}=s;return e.jsx("button",{type:"button",className:t,onClick:()=>r(o=>!o),children:e.jsx("i",{className:`fas ${a?"fa-eye-slash":"fa-eye"} text-lg`})})}function B(s){var c,u;const{status:t}=s,{data:a,setData:r,post:o,processing:h,errors:b,reset:f}=S({email:"",password:"",remember:""});x.useEffect(()=>()=>{f("password")},[]);function p(l){let{name:m,value:w}=C(l);r(N=>({...N,[m]:w}))}const j=l=>{l.preventDefault(),o("/login",{onSuccess:({props:m})=>{if(m.auth.user.role=="user")return history.go(-2)}})},n={handleChange:p,data:a,errors:b},[i,g]=x.useState(!1);return e.jsxs(y,{children:[e.jsx(v,{title:"Log in"}),e.jsx("p",{className:"text-lg font-bold text-center",children:"Masuk ke akunmu"}),t&&e.jsx("div",{className:"mb-4 text-sm font-medium text-green-600",children:t}),(c=s.flash)!=null&&c.message?e.jsx("div",{className:"h-full mx-auto mb-4 text-center text-white badge badge-error",children:(u=s.flash)==null?void 0:u.message}):null,e.jsxs("form",{onSubmit:j,children:[e.jsx(d,{type:"text",name:"email",label:"email",...n}),e.jsxs("div",{className:"relative",children:[e.jsx(d,{type:i?"text":"password",name:"password",label:"password",...n}),e.jsx(P,{show:i,setShow:g,className:"absolute right-4 top-11 btn btn-sm btn-circle"})]}),e.jsx("div",{className:"form-control w-max mt-2",children:e.jsx(k,{name:"remember",label:"Ingat Saya",...n})}),e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx("div",{className:"flex flex-col",children:e.jsx("button",{className:"btn btn-sm btn-primary",disabled:h,children:"Masuk"})})})]})]})}export{B as default};
