diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..046a1aa --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + + + + { + "type": "pwa-node", + "request": "launch", + "name": "Launch Program", + "skipFiles": [ + "/**" + ], + "program": "${workspaceFolder}\\server.js" + } + ] +} \ No newline at end of file diff --git a/controllers/EventsController.js b/controllers/EventsController.js index b276c00..8aeac0b 100644 --- a/controllers/EventsController.js +++ b/controllers/EventsController.js @@ -86,9 +86,10 @@ export const updateEvent = async (req, res) => { description: req.body.description, location: req.body.location, }; - const files = req.files.image; - if (req.files.image !== "") { + + if (req.files) { + const files = req.files.image; const getEvent = await Events.findById(req.params.id); const imageId = getEvent.image.public_id; diff --git a/controllers/NewsController.js b/controllers/NewsController.js index bd34af0..3c6bc2c 100644 --- a/controllers/NewsController.js +++ b/controllers/NewsController.js @@ -84,10 +84,11 @@ export const updateNews = async (req, res) => { title: req.body.title, description: req.body.description, }; - console.log() - const files = req.files.image; + //console.log(req.files) + + if (req.files) { + const files = req.files.image; - if (req.files.image !== "") { const newsImage = await News.findById(req.params.id); const imgId = newsImage.image.public_id; @@ -105,6 +106,7 @@ export const updateNews = async (req, res) => { url: myCloud.secure_url, }; } + console.log(newNewsData) //req.user.id, const ModifyNews = await News.findByIdAndUpdate(req.params.id, newNewsData, @@ -119,7 +121,7 @@ export const updateNews = async (req, res) => { }); } catch (error) { - // console.log(error) + console.log(error) res.status(500).json({ success: false, msg: "Failled to UpDate !!" diff --git a/controllers/categoryController.js b/controllers/categoryController.js index 19d0e65..bd1bb00 100644 --- a/controllers/categoryController.js +++ b/controllers/categoryController.js @@ -82,9 +82,10 @@ export const updateCategory = async (req, res) => { const newCategoryData = { name: req.body.name, }; - const files = req.files.image; - if (req.files.image !== "") { + + if (req.files) { + const categ = await Category.findById(req.params.id); const imageId = categ.image.public_id; @@ -92,6 +93,7 @@ export const updateCategory = async (req, res) => { //delete image from claudinary await cloudinary.uploader.destroy(imageId) // await cloudinary.uploader.destroy(imageId, function (result) { console.log(result) }); + const files = req.files.image; const myCloud = await cloudinary.uploader.upload(files.tempFilePath, { folder: "image", }, diff --git a/tmp/tmp-1-1655118440699 b/tmp/tmp-1-1655118440699 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1655118440699 differ diff --git a/tmp/tmp-1-1655118594429 b/tmp/tmp-1-1655118594429 new file mode 100644 index 0000000..62743be Binary files /dev/null and b/tmp/tmp-1-1655118594429 differ diff --git a/tmp/tmp-1-1655119127152 b/tmp/tmp-1-1655119127152 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1655119127152 differ diff --git a/tmp/tmp-1-1655119363158 b/tmp/tmp-1-1655119363158 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1655119363158 differ diff --git a/tmp/tmp-1-1655119458662 b/tmp/tmp-1-1655119458662 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1655119458662 differ diff --git a/tmp/tmp-1-1655119503942 b/tmp/tmp-1-1655119503942 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1655119503942 differ diff --git a/tmp/tmp-1-1655119552520 b/tmp/tmp-1-1655119552520 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1655119552520 differ diff --git a/tmp/tmp-1-1655119614211 b/tmp/tmp-1-1655119614211 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1655119614211 differ diff --git a/tmp/tmp-1-1655119671253 b/tmp/tmp-1-1655119671253 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1655119671253 differ diff --git a/tmp/tmp-1-1655119703079 b/tmp/tmp-1-1655119703079 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1655119703079 differ diff --git a/tmp/tmp-1-1655119791268 b/tmp/tmp-1-1655119791268 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1655119791268 differ diff --git a/tmp/tmp-1-1655119861401 b/tmp/tmp-1-1655119861401 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-1-1655119861401 differ diff --git a/tmp/tmp-1-1655120128960 b/tmp/tmp-1-1655120128960 new file mode 100644 index 0000000..f61ad05 Binary files /dev/null and b/tmp/tmp-1-1655120128960 differ diff --git a/tmp/tmp-2-1655118461621 b/tmp/tmp-2-1655118461621 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-2-1655118461621 differ diff --git a/tmp/tmp-2-1655118808779 b/tmp/tmp-2-1655118808779 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-2-1655118808779 differ diff --git a/tmp/tmp-2-1655119191564 b/tmp/tmp-2-1655119191564 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-2-1655119191564 differ diff --git a/tmp/tmp-2-1655119523178 b/tmp/tmp-2-1655119523178 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-2-1655119523178 differ diff --git a/tmp/tmp-3-1655118463051 b/tmp/tmp-3-1655118463051 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-3-1655118463051 differ diff --git a/tmp/tmp-3-1655118880504 b/tmp/tmp-3-1655118880504 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-3-1655118880504 differ diff --git a/tmp/tmp-4-1655118463253 b/tmp/tmp-4-1655118463253 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-4-1655118463253 differ diff --git a/tmp/tmp-4-1655118936552 b/tmp/tmp-4-1655118936552 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-4-1655118936552 differ diff --git a/tmp/tmp-5-1655118463479 b/tmp/tmp-5-1655118463479 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-5-1655118463479 differ diff --git a/tmp/tmp-5-1655119079603 b/tmp/tmp-5-1655119079603 new file mode 100644 index 0000000..6fb99c9 Binary files /dev/null and b/tmp/tmp-5-1655119079603 differ