feat: แก้ไข และ ลบ ของ Product

This commit is contained in:
Net 2024-06-19 13:51:45 +07:00
parent e55935ce3a
commit b6e7eb68cd
3 changed files with 91 additions and 15 deletions

View file

@ -326,14 +326,23 @@ const useProductServiceStore = defineStore('api-product-service', () => {
}
}
async function editProduct(productId: string, data: ProductUpdate) {
const { ...payload } = data;
async function editProduct(productId: string, data: ProductCreate) {
const { image, code, ...payload } = data;
const res = await api.put<ProductGroupUpdate>(`/product/${productId}`, {
...payload,
});
const res = await api.put<ProductCreate & { imageUploadUrl: string }>(
`/product/${productId}`,
{
...payload,
},
);
if (!res) return false;
image &&
(await axios
.put(res.data.imageUploadUrl, image, {
headers: { 'Content-Type': image.type },
onUploadProgress: (e) => console.log(e),
})
.catch((e) => console.error(e)));
if (res.status === 200) {
return res.data;

View file

@ -110,6 +110,7 @@ export interface ProductCreate {
}
export interface ProductUpdate {
productTypeId: string;
remark: string;
serviceCharge: number;
agentPrice: number;