refactor: add attachment api

This commit is contained in:
Net 2024-09-17 11:01:05 +07:00
parent db1e57fca0
commit 6f54693eb1
2 changed files with 22 additions and 0 deletions

View file

@ -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,
};
});

View file

@ -88,3 +88,11 @@ export interface CreatedBy {
code: string;
id: string;
}
export type UploadFileObject = {
_meta?: Record<string, any>;
name?: string;
group?: string;
url?: string;
file?: File;
}[];