diff --git a/src/components/DeleteButton.tsx b/src/components/DeleteButton.tsx
index 1108e12..0d0c365 100644
--- a/src/components/DeleteButton.tsx
+++ b/src/components/DeleteButton.tsx
@@ -2,7 +2,7 @@ import Button from '@mui/material/Button';
import DeleteIcon from '@mui/icons-material/Delete';
import CheckIcon from '@mui/icons-material/Check';
import { useState } from 'react';
-import axios from 'axios';
+import axios, { AxiosResponse } from 'axios';
interface DeleteButtonProps {
barcode: string;
@@ -18,8 +18,20 @@ const DeleteButton = ({ barcode, imgids }: DeleteButtonProps) => {
if (!isConfirmed) {
setIsConfirmed(true)
} else {
+ const data = new URLSearchParams()
+ data.append('code', barcode)
+ data.append('imgids', imgids)
+ data.append('move_to_override', 'trash')
try {
- axios.delete(deleteUrl)
+ axios.post(
+ deleteUrl,
+ data,
+ {
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ }
+ }
+ )
} catch (err) {
console.error(err)
}
diff --git a/src/components/InfoModal.tsx b/src/components/InfoModal.tsx
index e8a927d..3caeac0 100644
--- a/src/components/InfoModal.tsx
+++ b/src/components/InfoModal.tsx
@@ -45,12 +45,12 @@ export default function ModalInfo({barcode}: ModalInfoProps) {
return `${import.meta.env.VITE_PO_IMAGE_URL}/images/products/${part1}/${part2}/${part3}/${part4}/${imageId}.${def}.jpg`;
}
const handleTicketInfo = () => {
- axios.get(`${import.meta.env.VITE_PO_URL}/api/v2/product/${barcode}.json`).then((res) => {
+ axios.get(`${import.meta.env.VITE_PO_URL}/api/v2/product/${barcode}.json`).then((res) => {
+ console.log(res.data)
const usedData: any = {
name: res.data.product.product_name || null,
barcode: res.data.code || null,
images: {},
- selectedImages: [],
brands: res.data.product.brands || null,
editors_tags: res.data.product.editors_tags || null,
categories: [],
@@ -66,19 +66,6 @@ export default function ModalInfo({barcode}: ModalInfoProps) {
}
});
}
- // loop through the selected images and keep only the url
- const selectedImages = res.data.product.selected_images;
- if (selectedImages) {
- for (const key in selectedImages) {
- if (selectedImages[key].thumb ) {
- for (const lang in selectedImages[key].thumb) {
- if (selectedImages[key].thumb[lang]) {
- usedData.selectedImages.push(selectedImages[key].thumb[lang]);
- }
- }
- }
- }
- }
// loop through the ingredients and keep only the text
const ingredients = res.data.product.ingredients;
if (ingredients) {
@@ -97,6 +84,7 @@ export default function ModalInfo({barcode}: ModalInfoProps) {
}
}
}
+ console.log(usedData)
setTicketInfo(usedData);
setIsLoaded(true);
}).catch((err) => {
@@ -154,7 +142,7 @@ export default function ModalInfo({barcode}: ModalInfoProps) {
style={{objectFit: 'contain'}}
/>
-
+
))}