diff --git a/src/stores/employee/index.ts b/src/stores/employee/index.ts index cd891ca3..eee90156 100644 --- a/src/stores/employee/index.ts +++ b/src/stores/employee/index.ts @@ -95,6 +95,168 @@ const useEmployeeStore = defineStore('api-employee', () => { return res.data; } + async function createEmployeeCheckup( + employeeId: string, + data: EmployeeCreate, + flow?: { + sessionId?: string; + refTransactionId?: string; + transactionId?: string; + }, + ) { + const { code, image, ...payload } = data; + const res = await api.post( + `/employee/${employeeId}/checkup`, + { ...payload.employeeCheckup }, + { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId || flowStore.rtid, + 'X-Tid': flow?.transactionId, + }, + }, + ); + + if (!res) return false; + + return res.data; + } + + async function createEmployeeWork( + employeeId: string, + data: EmployeeCreate, + flow?: { + sessionId?: string; + refTransactionId?: string; + transactionId?: string; + }, + ) { + const { code, image, ...payload } = data; + const res = await api.post( + `/employee/${employeeId}/work`, + { ...payload.employeeWork }, + { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId || flowStore.rtid, + 'X-Tid': flow?.transactionId, + }, + }, + ); + + if (!res) return false; + + return res.data; + } + + async function createEmployeeOtherInfo( + employeeId: string, + data: EmployeeCreate, + flow?: { + sessionId?: string; + refTransactionId?: string; + transactionId?: string; + }, + ) { + const { code, image, ...payload } = data; + const res = await api.post( + `/employee/${employeeId}/other-info`, + { ...payload.employeeOtherInfo }, + { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId || flowStore.rtid, + 'X-Tid': flow?.transactionId, + }, + }, + ); + + if (!res) return false; + + return res.data; + } + + async function editByIdEmployeeCheckup( + employeeId: string, + data: Partial, + flow?: { + sessionId?: string; + refTransactionId?: string; + transactionId?: string; + }, + ) { + const { code, image, ...payload } = data; + const res = await api.put( + `/employee/${employeeId}/checkup}`, + { ...payload.employeeCheckup }, + { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId || flowStore.rtid, + 'X-Tid': flow?.transactionId, + }, + }, + ); + + if (!res) return false; + + return res.data; + } + + async function editByIdEmployeeWork( + employeeId: string, + data: Partial, + flow?: { + sessionId?: string; + refTransactionId?: string; + transactionId?: string; + }, + ) { + const { code, image, ...payload } = data; + const res = await api.put( + `/employee/${employeeId}/work}`, + { ...payload.employeeWork }, + { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId || flowStore.rtid, + 'X-Tid': flow?.transactionId, + }, + }, + ); + + if (!res) return false; + + return res.data; + } + + async function editByIdEmployeeOtherInfo( + employeeId: string, + data: Partial, + flow?: { + sessionId?: string; + refTransactionId?: string; + transactionId?: string; + }, + ) { + const { code, image, ...payload } = data; + const res = await api.put( + `/employee/${employeeId}/other-info}`, + { ...payload.employeeWork }, + { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId || flowStore.rtid, + 'X-Tid': flow?.transactionId, + }, + }, + ); + + if (!res) return false; + + return res.data; + } + async function editById( id: string, data: Partial, @@ -304,6 +466,15 @@ const useEmployeeStore = defineStore('api-employee', () => { getStatsEmployee, getStatsEmployeeGender, getEditHistory, + + createEmployeeCheckup, + editByIdEmployeeCheckup, + + createEmployeeWork, + editByIdEmployeeWork, + + createEmployeeOtherInfo, + editByIdEmployeeOtherInfo, }; });