1import{u as I,a as y,U as k,T as C,b as L,c as F,d as c,r as u,e as p,j as s,L as h,f as w,F as T,g as A,z as f,h as B}from"./index-BvNIJ_c2.js";import{d as x,e as P}from"./cripto-CZbCueA5.js";import{S as E}from"./index-Ba0BrPSg.js";import{s as N}from"./userSession-D0Mnx0yC.js";import{V as n}from"./validationRules-Eb6EGYXU.js";import{A as U,a as q}from"./AuthFormCard-CGkH1DTU.js";import{F as R}from"./FloatingInput-DsLQekTv.js";import{F as V}from"./FloatingPasswordInput-I4pgKNdc.js";import"./index-IEJD0KmR.js";const D="/assets/ramsteinlate-CarlCX3B.jpg",K=()=>{const{t:e,i18n:v}=I(),S=y(),{setUser:j}=k(),{setToken:b}=C(),a=L({initialValues:{email:"",password:""},validationSchema:F({email:c().trim().lowercase().email(e("loginPage.validation.emailInvalid")).max(n.email.max,e("loginPage.validation.emailInvalid")).required(e("loginPage.validation.emailRequired")),password:c().required(e("loginPage.validation.passwordRequired")).min(n.password.min,e("loginPage.validation.passwordMin")).max(n.password.max,e("loginPage.validation.passwordMin")).matches(n.password.pattern,e("loginPage.validation.passwordSpecial"))}),onSubmit:async(t,{setSubmitting:r})=>{var l,g,m,d;try{t.deviceType="web";const{data:o}=await w.post(T.endPoint(),t);localStorage.setItem("email",P(t.email)),localStorage.setItem("password",P(t.password)),b((g=(l=o==null?void 0:o.result)==null?void 0:l.token)==null?void 0:g.accessToken),j((m=o==null?void 0:o.result)==null?void 0:m.user);const i=(d=o==null?void 0:o.result)==null?void 0:d.user;i&&(N(i),i.language&&["sv","en"].includes(i.language)&&(localStorage.setItem("language",i.language),v.changeLanguage(i.language))),w.post(A.endPoint()).catch(()=>{}),f.success(o.message||e("loginPage.loginSuccess")),S("/dashboard"),p()}catch(o){f.error(B(o))}finally{r(!1)}}});return u.useEffect(()=>{p()},[]),u.useEffect(()=>{const t=x(localStorage.getItem("email")||""),r=x(localStorage.getItem("password")||"");t&&r&&a.setValues({email:t,password:r})},[]),s.jsxs(U,{bannerImage:D,children:[s.jsx(E,{title:e("seo.login.title"),description:e("seo.login.description"),path:"/login",
1noindex:!0}),s.jsxs(q,{children:[s.jsx("div",{className:"auth-title",children:s.jsx("h1",{children:e("loginPage.title")})}),s.jsxs("form",{onSubmit:a.handleSubmit,autoComplete:"on",children:[s.jsx(R,{id:"login-email",name:"email",type:"email",label:e("loginPage.email"),value:a.values.email,onChange:a.handleChange,onBlur:a.handleBlur,error:a.errors.email,touched:a.touched.email,autoComplete:"email"}),s.jsx(V,{id:"login-password",name:"password",label:e("loginPage.password"),value:a.values.password,onChange:a.handleChange,onBlur:a.handleBlur,error:a.errors.password,touched:a.touched.password,autoComplete:"current-password"}),s.jsx("div",{style:{textAlign:"right",marginBottom:"24px"},children:s.jsx(h,{to:"/forgot-password",className:"auth-link",children:e("loginPage.forgotPassword")})}),s.jsx("button",{type:"submit",className:"auth-btn-primary",disabled:a.isSubmitting,children:e("loginPage.loginButton")})]}),s.jsxs("p",{className:"auth-footer",children:[e("loginPage.noAccount")," ",s.jsx(h,{to:"/company-signup",state:{fresh:!0},children:e("loginPage.signUpLink")})]})]})]})};export{K as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.