From 6f54693eb12f96ffd8f9e55e8654e0d13ac50c07 Mon Sep 17 00:00:00 2001 From: Net Date: Tue, 17 Sep 2024 11:01:05 +0700 Subject: [PATCH] refactor: add attachment api --- src/stores/employee/index.ts | 14 ++++++++++++++ src/stores/types.ts | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/src/stores/employee/index.ts b/src/stores/employee/index.ts index 0c8335c3..6069fa0a 100644 --- a/src/stores/employee/index.ts +++ b/src/stores/employee/index.ts @@ -490,6 +490,18 @@ const useEmployeeStore = defineStore('api-employee', () => { return !(!res || res.status >= 400); } + async function attachment(opts: { + action: 'get' | 'put' | 'delete'; + type: 'passport' | 'visa' | 'in-country-notice'; + id: string; + }) { + const res = await api[opts.action]( + `/employee/file-${opts.type}/${opts.id}`, + ); + + if (res) return res.data; + } + return { data, globalOption, @@ -527,6 +539,8 @@ const useEmployeeStore = defineStore('api-employee', () => { getAttachment, uploadAttachment, deleteAttachment, + + attachment, }; }); diff --git a/src/stores/types.ts b/src/stores/types.ts index 32ab9e3d..7a1ab7a5 100644 --- a/src/stores/types.ts +++ b/src/stores/types.ts @@ -88,3 +88,11 @@ export interface CreatedBy { code: string; id: string; } + +export type UploadFileObject = { + _meta?: Record; + name?: string; + group?: string; + url?: string; + file?: File; +}[];