From 39276bd4cca7445268134e8b0b72b00060b69056 Mon Sep 17 00:00:00 2001 From: Net Date: Mon, 5 Aug 2024 16:46:27 +0700 Subject: [PATCH] refactor: add get api by id of employee --- src/stores/employee/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/stores/employee/index.ts b/src/stores/employee/index.ts index fd8ca3c5..a4d2c44b 100644 --- a/src/stores/employee/index.ts +++ b/src/stores/employee/index.ts @@ -22,6 +22,14 @@ const useEmployeeStore = defineStore('api-employee', () => { const globalOption = ref(); const ownerOption = ref(); + async function fetchById(id: string) { + const res = await api.get(`/employee/${id}`); + if (res && res.status === 200) { + return res.data; + } + return false; + } + async function fetchList( opts?: { page?: number; @@ -515,6 +523,7 @@ const useEmployeeStore = defineStore('api-employee', () => { globalOption, ownerOption, + fetchById, fetchList, create, editById,