add: company info & edit company view

This commit is contained in:
Alexandro Uc Santos
2023-11-29 21:07:46 -06:00
parent dd674b053b
commit df8aff2745
18 changed files with 548 additions and 48 deletions

38
src/stores/company.js Normal file
View File

@@ -0,0 +1,38 @@
import { defineStore } from "pinia";
import { ref, watch, onMounted } from "vue";
import { useAuthStore } from "./auth";
import { getCompany } from "../services/company";
export const useCompanyStore = defineStore('company', () => {
const auth = useAuthStore();
const company = ref(null)
const loading = ref(false);
const getCompanyData = async() => {
loading.value = true;
if(!company.value) {
console.log('Se ejecuta');
loading.value = true;
const companyId = auth.user?.company;
console.log({companyId});
const resp = await getCompany(companyId);
console.log(resp);
company.value = resp;
}
loading.value = false;
}
const clear = () => {
company.value = null;
loading.value = false;
}
return {
company,
loading,
getCompanyData,
clear
}
});