refactor: add get api by id of employee

This commit is contained in:
Net 2024-08-05 16:46:27 +07:00
parent 22093c5798
commit 39276bd4cc

View file

@ -22,6 +22,14 @@ const useEmployeeStore = defineStore('api-employee', () => {
const globalOption = ref(); const globalOption = ref();
const ownerOption = ref<CustomerBranch[]>(); const ownerOption = ref<CustomerBranch[]>();
async function fetchById(id: string) {
const res = await api.get<Employee>(`/employee/${id}`);
if (res && res.status === 200) {
return res.data;
}
return false;
}
async function fetchList( async function fetchList(
opts?: { opts?: {
page?: number; page?: number;
@ -515,6 +523,7 @@ const useEmployeeStore = defineStore('api-employee', () => {
globalOption, globalOption,
ownerOption, ownerOption,
fetchById,
fetchList, fetchList,
create, create,
editById, editById,