From ad942e7035a8b8f195bb1aa1f16135600c190fa8 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Wed, 12 Jun 2024 08:40:30 +0000 Subject: [PATCH] fix/feat: type and update function --- src/stores/employee/index.ts | 74 +++++++++++++++++++++++++++++++++++- src/stores/employee/types.ts | 4 +- 2 files changed, 75 insertions(+), 3 deletions(-) diff --git a/src/stores/employee/index.ts b/src/stores/employee/index.ts index 4306f85f..32f32ef4 100644 --- a/src/stores/employee/index.ts +++ b/src/stores/employee/index.ts @@ -2,7 +2,14 @@ import { ref } from 'vue'; import { defineStore } from 'pinia'; import { Pagination } from '../types'; import { api } from 'src/boot/axios'; -import { Employee, EmployeeCreate, EmployeeUpdate } from './types'; +import { + Employee, + EmployeeCheckup, + EmployeeCreate, + EmployeeOther, + EmployeeUpdate, + EmployeeWork, +} from './types'; import axios from 'axios'; const useEmployeeStore = defineStore('api-employee', () => { @@ -84,7 +91,7 @@ const useEmployeeStore = defineStore('api-employee', () => { async function editById( id: string, - data: EmployeeUpdate, + data: EmployeeCreate, flow?: { sessionId: string; refTransactionId: string; @@ -137,6 +144,66 @@ const useEmployeeStore = defineStore('api-employee', () => { return false; } + async function fetchCheckup( + id: string, + flow?: { + sessionId: string; + refTransactionId: string; + transactionId: string; + }, + ) { + const res = await api.get(`/employee/${id}/checkup`, { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId, + 'X-Tid': flow?.transactionId, + }, + }); + if (res && res.status === 200) { + return res.data; + } + } + + async function fetchWork( + id: string, + flow?: { + sessionId: string; + refTransactionId: string; + transactionId: string; + }, + ) { + const res = await api.get(`/employee/${id}/work`, { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId, + 'X-Tid': flow?.transactionId, + }, + }); + if (res && res.status === 200) { + return res.data; + } + } + + async function fetchOther( + id: string, + flow?: { + sessionId: string; + refTransactionId: string; + transactionId: string; + }, + ) { + const res = await api.get(`/employee/${id}/other-info`, { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId, + 'X-Tid': flow?.transactionId, + }, + }); + if (res && res.status === 200) { + return res.data; + } + } + return { data, globalOption, @@ -146,6 +213,9 @@ const useEmployeeStore = defineStore('api-employee', () => { create, editById, deleteById, + fetchCheckup, + fetchWork, + fetchOther, }; }); diff --git a/src/stores/employee/types.ts b/src/stores/employee/types.ts index 2c850505..08419b75 100644 --- a/src/stores/employee/types.ts +++ b/src/stores/employee/types.ts @@ -35,6 +35,7 @@ export type Employee = { customerBranchId: string; status: Status; tm6Number: string; + entryDate: Date; createdAt: Date; createdBy: string; updatedAt: Date; @@ -187,7 +188,7 @@ export type EmployeeWorkCreate = { }; export type EmployeeOther = { - birthPlace: string; + motherBirthPlace: string; motherLastNameEN: string; motherFirstNameEN: string; fatherLastNameEN: string; @@ -196,6 +197,7 @@ export type EmployeeOther = { motherFirstName: string; fatherLastName: string; fatherFirstName: string; + fatherBirthPlace: string; citizenId: string; };