refactor: create payment file
This commit is contained in:
parent
00a04edd1d
commit
5774dfcf5c
2 changed files with 47 additions and 61 deletions
|
|
@ -5,7 +5,7 @@ import { ComposerTranslation } from 'vue-i18n';
|
|||
import { defineStore } from 'pinia';
|
||||
import { Ref, ref } from 'vue';
|
||||
import { getRole } from 'src/services/keycloak';
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { AxiosInstance, AxiosProgressEvent } from 'axios';
|
||||
|
||||
export const baseUrl = import.meta.env.VITE_API_BASE_URL;
|
||||
|
||||
|
|
@ -251,7 +251,11 @@ export function resetScrollBar(elementId: string) {
|
|||
}
|
||||
}
|
||||
|
||||
export function manageAttachment(api: AxiosInstance, base: string) {
|
||||
export function manageAttachment(
|
||||
api: AxiosInstance,
|
||||
base: string,
|
||||
option?: { onUploadProgress?: (e: AxiosProgressEvent) => void },
|
||||
) {
|
||||
return {
|
||||
listAttachment: async (opts: { parentId: string }) => {
|
||||
const res = await api.get<string[]>(
|
||||
|
|
@ -290,7 +294,9 @@ export function manageAttachment(api: AxiosInstance, base: string) {
|
|||
opts.file,
|
||||
{
|
||||
headers: { 'Content-Type': opts.file.type },
|
||||
onUploadProgress: (e) => console.log(e),
|
||||
onUploadProgress: option?.onUploadProgress
|
||||
? option.onUploadProgress
|
||||
: (e) => console.log(e),
|
||||
},
|
||||
);
|
||||
if (res.status < 400) return true;
|
||||
|
|
@ -306,7 +312,11 @@ export function manageAttachment(api: AxiosInstance, base: string) {
|
|||
};
|
||||
}
|
||||
|
||||
export function manageFile<T extends string>(api: AxiosInstance, base: string) {
|
||||
export function manageFile<T extends string>(
|
||||
api: AxiosInstance,
|
||||
base: string,
|
||||
option?: { onUploadProgress?: (e: AxiosProgressEvent) => void },
|
||||
) {
|
||||
return {
|
||||
listFile: async (opts: { group: T; parentId: string }) => {
|
||||
const res = await api.get<string[]>(
|
||||
|
|
@ -347,7 +357,9 @@ export function manageFile<T extends string>(api: AxiosInstance, base: string) {
|
|||
opts.file,
|
||||
{
|
||||
headers: { 'Content-Type': opts.file.type },
|
||||
onUploadProgress: (e) => console.log(e),
|
||||
onUploadProgress: option?.onUploadProgress
|
||||
? option.onUploadProgress
|
||||
: (e) => console.log(e),
|
||||
},
|
||||
);
|
||||
if (res.status < 400) return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue