add: company info & edit company view
This commit is contained in:
34
src/composables/useCompanyProfile.js
Normal file
34
src/composables/useCompanyProfile.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import { ref } from "vue";
|
||||
import { getCompany } from "../services/company";
|
||||
import {useAuthStore} from '../stores/auth'
|
||||
import { useCompanyStore } from "../stores/company";
|
||||
|
||||
|
||||
export default function useCompany() {
|
||||
|
||||
const auth = useAuthStore();
|
||||
const companyStore = useCompanyStore();
|
||||
|
||||
const loading = ref(false);
|
||||
const company = ref(null);
|
||||
|
||||
const getCompanyData = async() => {
|
||||
if(companyStore.company === null) {
|
||||
loading.value = true;
|
||||
const companyId = auth.user.company;
|
||||
console.log(companyId)
|
||||
const resp = await getCompany(companyId);
|
||||
companyStore.company = resp;
|
||||
company.value = resp;
|
||||
loading.value = false;
|
||||
} else {
|
||||
company.value = companyStore.company;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
getCompanyData,
|
||||
loading,
|
||||
company
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user