close sesion question added

This commit is contained in:
Alexandro Uc Santos
2024-03-04 21:29:12 -06:00
parent 6a54ed3dbe
commit 948ba588eb
4 changed files with 28 additions and 12 deletions

View File

@@ -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>

View File

@@ -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([]);

View File

@@ -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;

View File

@@ -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();
}