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