From 39272000a71d1961684e6ea9b01cd0885c990959 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Fri, 28 Jun 2024 08:09:37 +0000 Subject: [PATCH] feat: employee history type & function --- src/stores/employee/index.ts | 21 +++++++++++++++++++++ src/stores/employee/types.ts | 25 +++++++++++++++++++++++++ src/stores/options/index.ts | 1 + 3 files changed, 47 insertions(+) diff --git a/src/stores/employee/index.ts b/src/stores/employee/index.ts index 1ed0ca8f..e0530176 100644 --- a/src/stores/employee/index.ts +++ b/src/stores/employee/index.ts @@ -256,6 +256,26 @@ const useEmployeeStore = defineStore('api-employee', () => { } } + async function getEditHistory( + employeeId: string, + flow?: { + sessionId?: string; + refTransactionId?: string; + transactionId?: string; + }, + ) { + const res = await api.get(`/employee/${employeeId}/edit-history`, { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId || flowStore.rtid, + 'X-Tid': flow?.transactionId, + }, + }); + if (res && res.status === 200) { + return res.data; + } + } + return { data, globalOption, @@ -270,6 +290,7 @@ const useEmployeeStore = defineStore('api-employee', () => { fetchOther, getStatsEmployee, getStatsEmployeeGender, + getEditHistory, }; }); diff --git a/src/stores/employee/types.ts b/src/stores/employee/types.ts index 8c079d9c..fccf0c6d 100644 --- a/src/stores/employee/types.ts +++ b/src/stores/employee/types.ts @@ -214,3 +214,28 @@ export type EmployeeOtherCreate = { fatherBirthPlace?: string; citizenId?: string; }; + +export type EmployeeHistory = { + masterId: string; + updatedBy: string; + updatedByUserId: string; + timestamp: Date; + valueAfter: string; + valueBefore: string; + field: string; + updatedAt: Date; + id: string; +}; + +export type NewEmployeeHistory = { + date: string; + data: { + masterId: string; + updatedBy: string; + updatedByUserId: string; + timestamp: Date; + updatedAt: Date; + id: string; + history: { valueAfter: string; valueBefore: string; field: string }[]; + }[]; +}; diff --git a/src/stores/options/index.ts b/src/stores/options/index.ts index 77bbf4c2..44a3d4aa 100644 --- a/src/stores/options/index.ts +++ b/src/stores/options/index.ts @@ -13,6 +13,7 @@ const useOptionStore = defineStore('optionStore', () => { if (option) return option.label; } } + return value; } return {