add: company info & edit company view
This commit is contained in:
38
src/stores/company.js
Normal file
38
src/stores/company.js
Normal 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
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user