feat: import prodect from file
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 6s

This commit is contained in:
Thanaphon Frappet 2025-04-22 13:58:26 +07:00
parent 74291c0552
commit 8d8ad40de1
3 changed files with 70 additions and 6 deletions

View file

@ -194,6 +194,23 @@ const useProductServiceStore = defineStore('api-product-service', () => {
return false;
}
async function importProduct(
productGroupId: string,
files: File[],
fetch: (...args: unknown[]) => void,
) {
const importTasks = files.map((f) => {
const formData = new FormData();
formData.append('file', f);
return api.post('/product/import-product', formData, {
params: { productGroupId },
});
});
await Promise.all(importTasks);
fetch?.();
}
async function fetchListProductById(productId: string) {
const res = await api.get<Product>(`/product/${productId}`);
@ -549,6 +566,8 @@ const useProductServiceStore = defineStore('api-product-service', () => {
fetchImageListById,
addImageList,
deleteImageByName,
importProduct,
};
});