close sesion question added
This commit is contained in:
@@ -1,21 +1,27 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||||
import { useAuthStore } from '../stores/auth';
|
import { useAuthStore } from '../stores/auth';
|
||||||
|
import Swal from 'sweetalert2';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const auth = useAuthStore();
|
const auth = useAuthStore();
|
||||||
|
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
// auth.$patch({
|
Swal.fire({
|
||||||
// sesion: '',
|
title: 'Cerrar sesión',
|
||||||
// token: '',
|
text: '¿Estás seguro de cerrar sesión?',
|
||||||
// user: {},
|
icon: 'question',
|
||||||
// });
|
showCancelButton: true,
|
||||||
// localStorage.removeItem('session');
|
cancelButtonColor: "#d33",
|
||||||
// router.push({name: 'login'});
|
confirmButtonText: 'Si',
|
||||||
|
cancelButtonText: 'No',
|
||||||
|
}).then(async(result) => {
|
||||||
|
if(result.isConfirmed) {
|
||||||
auth.logout();
|
auth.logout();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -12,9 +12,6 @@
|
|||||||
|
|
||||||
const companyStore = useCompanyStore()
|
const companyStore = useCompanyStore()
|
||||||
const notifications = useNotificationsStore()
|
const notifications = useNotificationsStore()
|
||||||
|
|
||||||
console.log(companyStore.company?.categories);
|
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const msgError = ref('');
|
const msgError = ref('');
|
||||||
const companyCategories = ref([]);
|
const companyCategories = ref([]);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export const useCompanyStore = defineStore('company', () => {
|
|||||||
|
|
||||||
const getCompanyData = async() => {
|
const getCompanyData = async() => {
|
||||||
const companyId = localStorage.getItem('id');
|
const companyId = localStorage.getItem('id');
|
||||||
|
console.log({companyId});
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
if(!company.value) {
|
if(!company.value) {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|||||||
@@ -6,16 +6,28 @@
|
|||||||
import {getTypeCompany} from '../helpers/type_company'
|
import {getTypeCompany} from '../helpers/type_company'
|
||||||
import {getDateMonthDay} from '../helpers/date_formats'
|
import {getDateMonthDay} from '../helpers/date_formats'
|
||||||
import EditCompanyModal from '../components/ui/EditCompanyModal.vue';
|
import EditCompanyModal from '../components/ui/EditCompanyModal.vue';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
const company = useCompanyStore();
|
const company = useCompanyStore();
|
||||||
|
const { user, authStatus } = storeToRefs(auth);
|
||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
if(user.value) {
|
||||||
getInitialData()
|
getInitialData()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(user, () => {
|
||||||
|
if(user.value) {
|
||||||
|
getInitialData();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const getInitialData = async() => {
|
const getInitialData = async() => {
|
||||||
await auth.authenticationPromise;
|
await auth.authenticationPromise;
|
||||||
|
// await authenticationPromise;
|
||||||
await company.getCompanyData();
|
await company.getCompanyData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user