diff --git a/pages/admin/brands/_item.vue b/pages/admin/brands/_item.vue index 55c5acc..e9ee693 100644 --- a/pages/admin/brands/_item.vue +++ b/pages/admin/brands/_item.vue @@ -1,103 +1,112 @@ - - - - - - +} + + diff --git a/pages/admin/brands/index.vue b/pages/admin/brands/index.vue index 6a3c2d9..1fe8ae6 100644 --- a/pages/admin/brands/index.vue +++ b/pages/admin/brands/index.vue @@ -20,7 +20,7 @@ @@ -30,13 +30,13 @@ @@ -91,7 +91,7 @@ }, beforeMount(){ - this.$axios.get('/api/public//brand').then(res=>{ + this.$axios.get('/api/public/brand').then(res=>{ this.brands = res.data console.log(res.data) diff --git a/server/controllers/brandController.js b/server/controllers/brandController.js index 7af329e..21fc29d 100644 --- a/server/controllers/brandController.js +++ b/server/controllers/brandController.js @@ -2,6 +2,7 @@ const Brand = require("../models/Brand"); const { checkValidations } = require("../plugins/controllersHelperFunctions") const { body, validationResult } = require('express-validator') const { _sr } = require("../plugins/serverResponses") +const maxAttachmentSize = 2048 //@desc Create a brand @@ -93,8 +94,8 @@ const updatebrand = [ title, link, description, } - if (req.files?.image) { - const image = req.files.image + if (req.files?.logo) { + const image = req.files.logo const fileName = 'brands' + Date.now() + '.' + image.name const acceptableFormats = ['png', 'jpg', 'jpeg', 'webp'] if (!acceptableFormats.includes(image.mimetype.split('/')[1])) @@ -103,7 +104,7 @@ const updatebrand = [ return res .status(422) .json({ validation: { image: { msg: `حجم تصویر نباید بیشتر از ${maxAttachmentSize} KB باشد.` } } }) - data.image = fileName + data.logo = fileName await image.mv(`./static/uploads/images/brands/${fileName}`) } diff --git a/static/uploads/images/brands/brands1707499279564.png-apple-logo-9741.png b/static/uploads/images/brands/brands1707499279564.png-apple-logo-9741.png new file mode 100644 index 0000000..0d77f09 Binary files /dev/null and b/static/uploads/images/brands/brands1707499279564.png-apple-logo-9741.png differ diff --git a/static/uploads/images/brands/brands1707499292249.samsung-logo-png-1304.png b/static/uploads/images/brands/brands1707499292249.samsung-logo-png-1304.png new file mode 100644 index 0000000..11fc4c4 Binary files /dev/null and b/static/uploads/images/brands/brands1707499292249.samsung-logo-png-1304.png differ