"use strict";(self["webpackChunkTruckShop"]=self["webpackChunkTruckShop"]||[]).push([[9090],{9090:function(e,r,t){t.r(r),t.d(r,{default:function(){return K}});var a=t(6768),o=t(5130),s=t(4232);const l={class:"auth-main v2"},n={class:"auth-wrapper"},i={class:"auth-form"},c={class:"card my-5 mx-3"},d={class:"card-body",style:{direction:"rtl"}},u={class:"text-center mb-4"},p=["src"],g={class:"mb-3"},m={key:0,class:"text-danger"},v={class:"mb-3"},k={key:0,class:"text-danger"},b={class:"d-flex mt-1 justify-content-between align-items-center"},h={class:"d-grid mt-4"},y=["disabled"],f={key:0,class:"alert alert-danger mt-3"};function L(e,r,t,L,w,_){const E=(0,a.g2)("router-link"),x=(0,a.g2)("Rightbar");return(0,a.uX)(),(0,a.CE)(a.FK,null,[(0,a.Lk)("div",l,[r[6]||(r[6]=(0,a.Lk)("div",{class:"bg-overlay bg-dark"},null,-1)),(0,a.Lk)("div",n,[(0,a.Lk)("div",i,[(0,a.Lk)("div",c,[(0,a.Lk)("div",d,[(0,a.Lk)("div",u,[(0,a.Lk)("img",{src:L.logo,alt:"Logo",class:"styled-logo"},null,8,p)]),(0,a.Lk)("div",g,[(0,a.bo)((0,a.Lk)("input",{onInput:r[0]||(r[0]=e=>L.clearError("mobile")),type:"email",class:"form-control",id:"floatingInput",placeholder:"شماره موبایل",style:{direction:"rtl"},"onUpdate:modelValue":r[1]||(r[1]=e=>L.mobile=e)},null,544),[[o.Jo,L.mobile]]),L.errors.mobile?((0,a.uX)(),(0,a.CE)("small",m,(0,s.v_)(L.errors.mobile),1)):(0,a.Q3)("",!0)]),(0,a.Lk)("div",v,[(0,a.bo)((0,a.Lk)("input",{onInput:r[2]||(r[2]=e=>L.clearError("password")),type:"password",class:"form-control",id:"floatingInput1",placeholder:"رمز عبور",style:{direction:"rtl"},"onUpdate:modelValue":r[3]||(r[3]=e=>L.password=e)},null,544),[[o.Jo,L.password]]),L.errors.password?((0,a.uX)(),(0,a.CE)("small",k,(0,s.v_)(L.errors.password),1)):(0,a.Q3)("",!0)]),(0,a.Lk)("div",b,[(0,a.bF)(E,{to:"/forgot-password-v2"},{default:(0,a.k6)((()=>r[5]||(r[5]=[(0,a.Lk)("h6",{class:"text-secondary link-primary f-w-400 mb-0",style:{direction:"rtl"}}," فراموشی رمز عبور؟ ",-1)]))),_:1,__:[5]})]),(0,a.Lk)("div",h,[(0,a.Lk)("button",{type:"button",class:"btn btn-primary",style:{direction:"rtl"},onClick:r[4]||(r[4]=(...e)=>L.handleLogin&&L.handleLogin(...e)),disabled:L.loading},(0,s.v_)(L.loading?"در حال ورود...":"ورود"),9,y)]),L.error?((0,a.uX)(),(0,a.CE)("div",f,(0,s.v_)(L.error),1)):(0,a.Q3)("",!0)])])])])]),(0,a.bF)(x)],64)}t(4114);var w=t(1387),_=t(9317),E=t(144),x=t(782),C=t(4874),R=t.n(C),j={name:"LoginForm",setup(){const e=(0,E.KR)(),r=(0,E.KR)(),t=(0,E.KR)({}),o=(0,x.Pj)(),s=(0,E.KR)(""),l=(0,E.KR)(""),n=(0,E.KR)(!1),i=(0,a.EW)((()=>o.state.error)),c=(0,w.rd)(),d=async()=>{if(n.value=!0,u())try{await o.dispatch("user/loginUser",{mobile:s.value,password:l.value}),n.value=!1,c.push({name:"products"})}catch(i){console.error("Login failed:",i.message),R().fire({icon:"error",title:"شماره تماس یا رمز عبور اشتباه است",text:`${i.message}`,confirmButtonText:"باشه"}),n.value=!1}},u=()=>(t.value={},s.value||(t.value.mobile="موبایل خود را وارد نمایید"),l.value||(t.value.password="رمز عبور خود را وارد نمایید"),0===Object.keys(t.value).length),p=e=>{t.value[e]=""},g=async()=>{r.value=localStorage.getItem("logo");try{const r=await _.A.get("settings/logo_fav");e.value=r.data.data}catch(i){console.error("Error fetching settings:",i)}};return(0,a.sV)((()=>{g()})),{mobile:s,password:l,loading:n,error:i,handleLogin:d,validateForm:u,clearError:p,errors:t,logo:r,settings:e}}},A=t(1241);const I=(0,A.A)(j,[["render",L],["__scopeId","data-v-580c2a92"]]);var K=I},9317:function(e,r,t){t(4114);var a=t(4373),o=t(494);const s="http://85.208.254.227/api/v1/",l=a.A.create({baseURL:s,headers:{Accept:"application/json","Content-Type":"application/json"}});l.interceptors.request.use((e=>{const r=localStorage.getItem("token");return r&&(e.headers["Authorization"]=`Bearer ${r}`),e}),(e=>Promise.reject(e))),l.interceptors.response.use((e=>e),(e=>(401===e?.status&&o.A.push({name:"login-v2"}),Promise.reject(e)))),r.A=l}}]);
//# sourceMappingURL=9090.926fdaec.js.map