import{L as h}from"./Loading-c46365ec.js";import{a as o,_ as l,U as g,c as u,r as m,o as d}from"./index-be2d4151.js";const n="https://staging-ahg-hr-api.autohub.ph/api/v1/apps",c="https://staging-ahg-hr-api.autohub.ph/api/v1",r={authorization:"Bearer 4WDVVmNkm31uOdmorUhVJgqO9fhI1wBFbofmA0jUqeMxwxnBbSECuZiPBpwByacw"},f={fetchRecords(t={}){return o.get(`${n}`,{params:t,headers:r})},fetchRecord(t){return o.get(`${n}/${t}`,{headers:r})},async saveAppsStorage(t){return o.post(`${c}/save-apps-storage`,t,{headers:r})},fetchAppsStorage(t={}){return o.get(`${c}/get-apps-storage`,{params:t,headers:r})}},$={components:{Loading:h},data(){return{data:null}},methods:{async fetchStorage(){const t=this.$route.query;await f.fetchAppsStorage({employee_id:t.e,system_id:t.s}).then(s=>{if(s.status==200){let e=JSON.parse(s.data.data);this.data=e,console.log(e.menuItems),e.capabilities&&this.$ability.update(e.capabilities);for(let a in e){let i=typeof e[a]=="object"?JSON.stringify(e[a]):e[a];localStorage.setItem(a,i)}this.$store.userSettings.setActiveUserFromLocal(),this.$store.userSettings.setActiveCompanyFromLocal(),this.$store.userSettings.setActiveDealershipFromLocal(),this.$store.userSettings.setActiveDepartmentFromLocal(),this.$store.userSettings.setDealershipAccessFromLocal(),this.$store.userSettings.setRolesFromLocal(),this.login()}})},async login(){const t=JSON.parse(localStorage.getItem("activeUser"));await g.autoLogin(t.id).then(s=>{if(s.status===200){const e=s.data.authorization.token;console.log("token"),console.log(e),localStorage.removeItem("jwtToken"),localStorage.setItem("jwtToken",e),this.$router.push("/")}}).catch(s=>console.log(s))}},mounted(){this.fetchStorage()}};function S(t,s,e,a,i,v){const p=m("Loading");return d(),u(p,{text:"Redirecting to Dashboard"})}const L=l($,[["render",S]]);export{L as default};