EN-94: fix: Migrate to api v1
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useNotificationsStore } from '../stores/notifications';
|
||||
import { useAuthStore } from '../stores/auth';
|
||||
import { complete_registry } from "../services/auth";
|
||||
import { updateMyUserProfile } from "../services/company"
|
||||
|
||||
const notifications = useNotificationsStore();
|
||||
const auth = useAuthStore();
|
||||
@@ -63,14 +65,36 @@
|
||||
console.log(company);
|
||||
}
|
||||
|
||||
const handleSendRegister = () => {
|
||||
const handleSendRegister = async () => {
|
||||
const error = validatiosUser();
|
||||
if(error != '') {
|
||||
msgError.value = error;
|
||||
clearMessages();
|
||||
return;
|
||||
}
|
||||
console.log(user);
|
||||
const companyData = {
|
||||
company_name : company.name,
|
||||
rfc : company.rfc,
|
||||
categories: company.segments.map((e) => e._id ),
|
||||
company_city: company.cities.map((e) => e.city_name),
|
||||
company_state: company.states.map((e) => e.state_name),
|
||||
truck_type: company.truckTypes.map((e) => e.meta_value),
|
||||
company_description : company.description,
|
||||
company_type : typeCompany.typeCompany,
|
||||
};
|
||||
const result = await complete_registry( companyData );
|
||||
console.log(result);
|
||||
if(result.msg === 'success' && result.data !== null){
|
||||
localStorage.setItem('id', result.data._id);
|
||||
}
|
||||
|
||||
const userData = {
|
||||
"first_name" : user.name,
|
||||
"last_name" : user.lastName,
|
||||
"phone" : user.phone1,
|
||||
"phone2" : user.phone2,
|
||||
};
|
||||
await updateMyUserProfile( userData );
|
||||
/////// Datos debug ///////
|
||||
notifications.show = true;
|
||||
notifications.text = 'Los datos se llenaron correctamente';
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
const resp = await login(data);
|
||||
if(resp.msg === 'success') {
|
||||
console.log(resp.data.user);
|
||||
if(resp.data.user.company) {
|
||||
if( resp.data.user.company ) {
|
||||
localStorage.setItem('session', resp.data.session_token);
|
||||
localStorage.setItem('access', resp.data.accessToken);
|
||||
localStorage.setItem('id', resp.data.user.company);
|
||||
@@ -50,6 +50,13 @@
|
||||
user: resp.data.user,
|
||||
})
|
||||
} else {
|
||||
auth.$patch({
|
||||
sesion: resp.data.session_token,
|
||||
token: resp.data.accessToken,
|
||||
user: resp.data.user,
|
||||
})
|
||||
localStorage.setItem('session', resp.data.session_token);
|
||||
localStorage.setItem('access', resp.data.accessToken);
|
||||
router.push({name: 'register-company'});
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user