handle all not found errors

This commit is contained in:
Amir Mohamadi
2021-12-31 17:01:17 +03:30
parent 5c07791225
commit 064d642b7e
47 changed files with 3386 additions and 3238 deletions
+3 -3
View File
@@ -86,7 +86,7 @@ module.exports.login = [
if (!errors.isEmpty()) return res.status(422).json({validation: errors.mapped()})
Admin.findOne({username: req.body.username}, (err, user) => {
if (err) console.log(err)
if (err) return res.status(404).json({message: err})
bcrypt.compare(req.body.password, user.password, (err, isMatch) => {
if (err) console.log(err)
if (!isMatch) return res.status(422).json({validation: {password: {msg: v_m['fa'].not_found.password}}})
@@ -111,7 +111,7 @@ module.exports.logout = [
const token = req.headers.authorization
if (token) {
Admin.findOneAndUpdate({token: token}, {token: null}, (err, oldData) => {
if (err) console.log(err)
if (err) return res.status(404).json({message: err})
if (oldData) return res.json({message: v_m['fa'].response.logged_out})
return res.status(401).json({message: v_m['fa'].response.not_logged_in})
})
@@ -130,7 +130,7 @@ module.exports.getUser = [
jwt.verify(token, config.secretKey, (err, decoded) => {
if (err) return res.status(401).json({message: 'unauthenticated'})
Admin.findById(decoded._id, (err, data) => {
if (err) console.log(err)
if (err) return res.status(404).json({message: err})
return res.json({user: data})
})
})
+4 -4
View File
@@ -105,7 +105,7 @@ module.exports.update = [
updated_at: dateformat(Date.now(), 'yyyy-mm-dd HH:MM:ss')
}
BlogCategory.findByIdAndUpdate(req.params.id, data, (err, oldData) => {
if (err) console.log(err)
if (err) return res.status(404).json({message: err})
return res.json({message: v_m['fa'].response.success_save})
})
}
@@ -115,10 +115,10 @@ module.exports.update = [
module.exports.delete = [
(req, res) => {
BlogPost.find({category: req.params.id}, (err, posts) => {
if (err) console.log(err)
if (!posts.length) {
BlogCategory.findByIdAndDelete(req.params.id, (err) => {
if (err) return res.status(404).json({message: err})
if (!posts.length) {
BlogCategory.findByIdAndDelete(req.params.id, (err1) => {
if (err1) return res.status(404).json({message: err1})
return res.json({message: v_m['fa'].response.success_save})
})
} else {
+15 -9
View File
@@ -80,6 +80,9 @@ module.exports.create = [
.cover(thumbWith, thumbHeight)
.write(`./static/uploads/images/blog/thumb_${coverName}`)
})
.catch(err => {
console.log(err)
})
const data = {
post_details: {
@@ -112,7 +115,7 @@ module.exports.create = [
module.exports.getAll = [
(req, res) => {
BlogPost.find({}).sort({_id: -1}).exec((err, posts) => {
if (err) console.log(err)
if (err) return res.status(500).json({message: err})
return res.json(posts)
})
}
@@ -122,7 +125,7 @@ module.exports.getAll = [
module.exports.getOne = [
(req, res) => {
BlogPost.findById(req.params.id, (err, post) => {
if (err) console.log(err)
if (err) return res.status(404).json({message: err})
return res.json(post)
})
}
@@ -213,10 +216,13 @@ module.exports.update = [
.cover(thumbWith, thumbHeight)
.write(`./static/uploads/images/blog/thumb_${coverName}`)
})
.catch(err => {
console.log(err)
})
}
BlogPost.findByIdAndUpdate(req.params.id, data, (err, oldData) => {
if (err) console.log(err)
if (err) return res.status(404).json({message: err})
if (cover && cover.data) {
fs.unlink(`./static/${oldData.cover}`, err => {
if (err) console.log(err)
@@ -225,8 +231,8 @@ module.exports.update = [
if (err) console.log(err)
})
}
BlogPost.findById(oldData._id, (err, newData) => {
if (err) console.log(err)
BlogPost.findById(oldData._id, (err1, newData) => {
if (err1) return res.status(404).json({message: err1})
return res.json(newData)
})
})
@@ -238,11 +244,11 @@ module.exports.delete = [
(req, res) => {
BlogPost.findByIdAndDelete(req.params.id, (err, post) => {
if (err) return res.status(404).json({message: err})
fs.unlink(`./static/${post.cover}`, err => {
if (err) console.log(err)
fs.unlink(`./static/${post.cover}`, err1 => {
if (err1) console.log(err1)
})
fs.unlink(`./static/${post.thumb}`, err => {
if (err) console.log(err)
fs.unlink(`./static/${post.thumb}`, err2 => {
if (err2) console.log(err2)
})
return res.json({message: v_m['fa'].response.success_remove})
})
+2 -2
View File
@@ -92,7 +92,7 @@ module.exports.getAll = [
})
.catch(err => {
console.log(err)
return res.status(500).json(err)
return res.status(500).json({message: err})
})
}
]
@@ -107,7 +107,7 @@ module.exports.getOne = [
return res.json(message)
})
.catch(err => {
return res.status(404).json(err)
return res.status(404).json({message: err})
})
}
]
+1 -1
View File
@@ -51,7 +51,7 @@ module.exports.getAll = [
module.exports.delete = [
(req, res) => {
Reason.findByIdAndDelete(req.params.id, (err, reason) => {
if (err) console.log(err)
if (err) return res.status(404).json({message: err})
return res.json({message: v_m['fa'].response.success_remove})
})
}
+3 -3
View File
@@ -84,7 +84,7 @@ module.exports.getAll = [
module.exports.getOne = [
(req, res) => {
History.findById(req.params.id, (err, data) => {
if (err) return res.status(404).json(err)
if (err) return res.status(404).json({message: err})
return res.json(data)
})
}
@@ -151,7 +151,7 @@ module.exports.update = [
})
} else {
History.findByIdAndUpdate(req.params.id, data, (err, oldData) => {
if (err) console.log(err)
if (err) return res.status(404).json({message: err})
return res.json(v_m['fa'].response.success_save)
})
}
@@ -162,7 +162,7 @@ module.exports.update = [
module.exports.delete = [
(req, res) => {
History.findByIdAndDelete(req.params.id, (err, data) => {
if (err) console.log(err)
if (err) return res.status(404).json({message: err})
fs.unlink(`./static/${data.image}`, err => {
if (err) console.log(err)
return res.json(v_m['fa'].response.success_remove)
+1 -4
View File
@@ -8,11 +8,10 @@ module.exports.create = [
if (!req.files || !req.files.pdf) return res.status(422).json({validation: {pdf: {msg: v_m['fa'].required.file}}})
if (req.files.pdf.mimetype.split('/')[1] !== 'pdf') return res.status(422).json({validation: {pdf: {msg: v_m['fa'].file_types.pdf}}})
MainCatalog.find({}, (err, catalogs) => {
if (err) console.log(err)
if (catalogs.length) {
let firstFile = catalogs[0]
if (firstFile.file[req.body.locale]) fs.unlink(`./static/${firstFile.file[req.body.locale]}`, err => {
if (err) console.log(err)
})
@@ -24,8 +23,6 @@ module.exports.create = [
req.files.pdf.mv(`./static/uploads/pdf/${req.body.locale}_${req.files.pdf.name}`)
return res.json(firstFile)
})
} else {
const data = {created_at: dateformat(Date.now(), 'yyyy-mm-dd HH:MM:ss'), file: {}}
data.file[req.body.locale] = req.body.locale + '_' + req.files.pdf.name
+41 -2
View File
@@ -168,6 +168,9 @@ module.exports.createProduct = [
.quality(thumbQuality)
.write(`./static/uploads/images/products/${thumb}`)
})
.catch(err => {
console.log(err)
})
}
if (req.files.more_section_image1) {
await jimp.read(req.files.more_section_image1.data)
@@ -178,6 +181,9 @@ module.exports.createProduct = [
.quality(moreSectionQuality)
.write(`./static/uploads/images/products/${more_section_image1}`)
})
.catch(err => {
console.log(err)
})
}
if (req.files.more_section_image2) {
await jimp.read(req.files.more_section_image2.data)
@@ -188,6 +194,9 @@ module.exports.createProduct = [
.quality(moreSectionQuality)
.write(`./static/uploads/images/products/${more_section_image2}`)
})
.catch(err => {
console.log(err)
})
}
if (req.files.render_image1) {
await jimp.read(req.files.render_image1.data)
@@ -198,6 +207,9 @@ module.exports.createProduct = [
.quality(renderImageQuality)
.write(`./static/uploads/images/products/${render_image1}`)
})
.catch(err => {
console.log(err)
})
}
if (req.files.render_image2) {
await jimp.read(req.files.render_image2.data)
@@ -208,6 +220,9 @@ module.exports.createProduct = [
.quality(renderImageQuality)
.write(`./static/uploads/images/products/${render_image2}`)
})
.catch(err => {
console.log(err)
})
}
if (req.files.chart_image) {
await jimp.read(req.files.chart_image.data)
@@ -216,6 +231,9 @@ module.exports.createProduct = [
.quality(chartImageQuality)
.write(`./static/uploads/images/products/${chart_image}`)
})
.catch(err => {
console.log(err)
})
}
}
@@ -249,8 +267,8 @@ module.exports.getAllProducts = [
]
module.exports.getOneProduct = [
async (req, res) => {
await Product.findById(req.params.id, async (err, product) => {
(req, res) => {
Product.findById(req.params.id, (err, product) => {
if (err) return res.status(404).json({message: err})
return res.json(product)
})
@@ -394,6 +412,9 @@ module.exports.updateProduct = [
.quality(thumbQuality)
.write(`./static/uploads/images/products/${thumb}`)
})
.catch(err => {
console.log(err)
})
}
if (req.files.more_section_image1) {
@@ -406,6 +427,9 @@ module.exports.updateProduct = [
.quality(moreSectionQuality)
.write(`./static/uploads/images/products/${more_section_image1}`)
})
.catch(err => {
console.log(err)
})
}
if (req.files.more_section_image2) {
@@ -418,6 +442,9 @@ module.exports.updateProduct = [
.quality(moreSectionQuality)
.write(`./static/uploads/images/products/${more_section_image2}`)
})
.catch(err => {
console.log(err)
})
}
if (req.files.render_image1) {
@@ -430,6 +457,9 @@ module.exports.updateProduct = [
.quality(renderImageQuality)
.write(`./static/uploads/images/products/${render_image1}`)
})
.catch(err => {
console.log(err)
})
}
if (req.files.render_image2) {
@@ -442,6 +472,9 @@ module.exports.updateProduct = [
.quality(renderImageQuality)
.write(`./static/uploads/images/products/${render_image2}`)
})
.catch(err => {
console.log(err)
})
}
if (req.files.chart_image) {
@@ -452,6 +485,9 @@ module.exports.updateProduct = [
.quality(chartImageQuality)
.write(`./static/uploads/images/products/${chart_image}`)
})
.catch(err => {
console.log(err)
})
}
}
@@ -584,6 +620,9 @@ module.exports.createProductImage = [
return res.json(product)
})
})
.catch(err => {
console.log(err)
})
} else {
return res.status(422).json({validation: {images: {image: {msg: v_m['fa'].required.image}}}})
+7 -3
View File
@@ -74,7 +74,7 @@ module.exports.getAll = [
module.exports.getOne = [
(req, res) => {
Project.findById(req.params.id, (err, project) => {
if (err) return res.json({errors: err})
if (err) return res.status(404).json({errors: err})
return res.json(project)
})
}
@@ -128,7 +128,7 @@ module.exports.update = [
}
Project.findByIdAndUpdate(req.params.id, data, (err, oldData) => {
if (err) console.log(err)
if (err) return res.status(404).json({message: err})
return res.json({message: v_m['fa'].response.success_save})
})
}
@@ -138,11 +138,15 @@ module.exports.update = [
module.exports.delete = [
(req, res) => {
Project.findByIdAndRemove(req.params.id, (err, data) => {
if (err) return res.json({error: err})
if (err) return res.status(404).json({message: err})
data.images.forEach(async item => {
try {
await fs.unlink(`./static/${item.image}`, err => {
if (err) console.log(err)
})
} catch (e) {
console.log(e)
}
})
return res.json({message: v_m['fa'].response.success_remove})
})
+5 -1
View File
@@ -37,7 +37,7 @@
<nuxt-link :to="{name: 'lang',params: {lang: $route.params.lang}}" tag="li" exact class="">
<a>{{ staticData.home }}</a>
</nuxt-link>
<nuxt-link :to="{name: 'lang-about',params: {lang: $route.params.lang}}" tag="li" exact class="">
<nuxt-link :to="{name: 'lang-about',params: {lang: $route.params.lang}}" tag="li" class="">
<a>{{ staticData.about }}</a>
</nuxt-link>
<nuxt-link :to="{name: 'lang-services',params: {lang: $route.params.lang}}" tag="li" exact class="">
@@ -114,8 +114,12 @@ export default {
}
},
async fetch() {
try {
let catalog = await this.$axios.get('/api/public/catalog')
this.catalog = catalog.data
} catch (e) {
this.$nuxt.context.error({status: 404, message: 'Catalog file not found'})
}
},
computed: {
staticData() {
+6 -2
View File
@@ -44,7 +44,7 @@
</div>
</section>
<section class="s2" v-if="history.length">
<section class="s2" v-if="history.length" id="history_timeline">
<div class="container">
<div class="row">
<div class="col-12">
@@ -157,11 +157,15 @@ export default {
title: this.staticData.hero
}
},
async asyncData({$axios}) {
async asyncData({$axios, error}) {
try {
const history = await $axios.get(`/api/public/history`)
return {
history: history.data
}
} catch (e) {
error({status: 404, message: 'There is problem here'})
}
}
}
</script>
+5 -1
View File
@@ -84,13 +84,17 @@ export default {
title: this.post.post_details[this.$route.params.lang].title
}
},
async asyncData({$axios, params}) {
async asyncData({$axios, params, error}) {
try {
const post = await $axios.get(`/api/public/blog/${params.post}`)
const blogCategories = await $axios.get(`/api/public/blogCategories`)
return {
post: post.data,
blogCategories: blogCategories.data
}
} catch (e) {
error({status: 404, message: 'Page not found'})
}
}
}
</script>
+5 -1
View File
@@ -119,13 +119,17 @@ export default {
title: this.staticData.hero
}
},
async asyncData({$axios, store}) {
async asyncData({$axios, store, error}) {
try {
let posts = await $axios.get(`/api/public/blog`)
const blogCategories = await $axios.get(`/api/public/blogCategories`)
return {
posts: posts.data,
blogCategories: blogCategories.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+5 -1
View File
@@ -179,11 +179,15 @@ export default {
title: this.staticData.hero
}
},
async asyncData({$axios}) {
async asyncData({$axios, error}) {
try {
const reasons = await $axios.get(`/api/public/contact/reason`)
return {
reasons: reasons.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+6 -2
View File
@@ -42,7 +42,7 @@
<div class="col-12">
<p>{{ staticData.s1_2.t2 }}</p>
<p>{{ staticData.s1_2.t3 }}</p>
<nuxt-link :to="{name: 'lang-about',params: {lang: $route.params.lang}}" class="btn btn-primary">{{ staticData.s1_2.link }}</nuxt-link>
<nuxt-link :to="{name: 'lang-about',params: {lang: $route.params.lang},hash: '#history_timeline'}" class="btn btn-primary">{{ staticData.s1_2.link }}</nuxt-link>
</div>
</div>
</div>
@@ -247,7 +247,8 @@ export default {
title: this.staticData.title
}
},
async asyncData({$axios}) {
async asyncData({$axios, error}) {
try {
const slider = await $axios.get('/api/public/slider')
const favoriteProducts = await $axios.get(`/api/public/favoriteProducts`)
const catalog = await $axios.get('/api/public/catalog')
@@ -257,6 +258,9 @@ export default {
favoriteProducts: favoriteProducts.data,
catalog: catalog.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+5 -1
View File
@@ -177,13 +177,17 @@ export default {
title: this.product.product_details[this.$route.params.lang].name
}
},
async asyncData({$axios, params}) {
async asyncData({$axios, params, error}) {
try {
let product = await $axios.get(`/api/public/product/${params.product}`)
let productCategories = await $axios.get(`/api/public/productCategories`)
return {
product: product.data,
productCategories: productCategories.data
}
} catch (e) {
error({status: 404, message: 'Page not found'})
}
}
}
</script>
+5 -1
View File
@@ -106,7 +106,8 @@ export default {
title: this.staticData.hero
}
},
async asyncData({$axios, store}) {
async asyncData({$axios, store, error}) {
try {
const products = await $axios.get(`/api/public/products`)
const productCategories = await $axios.get(`/api/public/productCategories`)
const catalog = await $axios.get('/api/public/catalog')
@@ -116,6 +117,9 @@ export default {
productCategories: productCategories.data,
catalog: catalog.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+5 -1
View File
@@ -107,11 +107,15 @@ export default {
title: this.staticData.hero
}
},
async asyncData({$axios}) {
async asyncData({$axios, error}) {
try {
const projects = await $axios.get(`/api/public/projects`)
return {
projects: projects.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+5 -1
View File
@@ -180,13 +180,17 @@ export default {
}
},
layout: 'admin',
async asyncData({$axios, params}) {
async asyncData({$axios, params, error}) {
try {
const post = await $axios.get(`/api/public/blog/${params.post}`)
const blogCategories = await $axios.get(`/api/public/blogCategories`)
return {
post: post.data,
blogCategories: blogCategories.data
}
} catch (e) {
error({status: 404, message: 'Page not found'})
}
}
}
</script>
+5 -1
View File
@@ -92,11 +92,15 @@
}
},
layout: 'admin',
async asyncData({$axios, params}) {
async asyncData({$axios, params, error}) {
try {
const category = await $axios.get(`/api/public/blogCategories/${params.category}`)
return {
formData: category.data
}
} catch (e) {
error({status: 404, message: 'Page not found'})
}
}
}
</script>
+5 -1
View File
@@ -87,11 +87,15 @@
}
},
layout: 'admin',
async asyncData({$axios}) {
async asyncData({$axios, error}) {
try {
let blogCategories = await $axios.get(`/api/public/blogCategories`)
return {
blogCategories: blogCategories.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+1 -3
View File
@@ -89,11 +89,9 @@
})
} else {
this.$alert(error.response.data.message, 'خطا', {
confirmButtonText: 'باشه',
confirmButtonText: 'باشه'
})
}
})
}
},
+5 -1
View File
@@ -120,13 +120,17 @@
}
},
layout: 'admin',
async asyncData({$axios, store}) {
async asyncData({$axios, store, error}) {
try {
let posts = await $axios.get(`/api/public/blog`)
const blogCategories = await $axios.get(`/api/public/blogCategories`)
return {
posts: posts.data,
blogCategories: blogCategories.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+6 -2
View File
@@ -188,7 +188,7 @@
})
},
preview(event) {
this.post.cover = URL.createObjectURL(event.target.files[0]);
this.post.cover = URL.createObjectURL(event.target.files[0])
}
},
head() {
@@ -197,11 +197,15 @@
}
},
layout: 'admin',
async asyncData({$axios, store}) {
async asyncData({$axios, store, error}) {
try {
const blogCategories = await $axios.get(`/api/public/blogCategories`)
return {
blogCategories: blogCategories.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+5 -1
View File
@@ -104,11 +104,15 @@ export default {
}
},
layout: 'admin',
async asyncData({$axios}) {
async asyncData({$axios, error}) {
try {
let catalog = await $axios.get('/api/public/catalog')
return {
catalog: catalog.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+5 -1
View File
@@ -127,11 +127,15 @@
}
},
layout: 'admin',
async asyncData({$axios, route}) {
async asyncData({$axios, route, error}) {
try {
const history = await $axios.get(`/api/public/history/${route.params.history}`)
return {
formData: history.data
}
} catch (e) {
error({status: 404, message: 'Page not found'})
}
}
}
</script>
+5 -1
View File
@@ -102,11 +102,15 @@
}
},
layout: 'admin',
async asyncData({$axios, store}) {
async asyncData({$axios, store, error}) {
try {
let history = await $axios.get(`/api/public/history`)
return {
history: history.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+1 -1
View File
@@ -124,7 +124,7 @@
})
},
preview(event) {
this.formData.image = URL.createObjectURL(event.target.files[0]);
this.formData.image = URL.createObjectURL(event.target.files[0])
}
},
head() {
-2
View File
@@ -11,8 +11,6 @@
<script>
export default {
mounted() {
},
layout: 'admin'
}
</script>
+5 -1
View File
@@ -62,11 +62,15 @@
}
},
layout: 'admin',
async asyncData({$axios, params}) {
async asyncData({$axios, params, error}) {
try {
const message = await $axios.get(`/api/private/contact/${params.message}`)
return {
message: message.data
}
} catch (e) {
error({status: 404, message: 'Page not found'})
}
}
}
</script>
+5 -1
View File
@@ -163,13 +163,17 @@
}
},
layout: 'admin',
async asyncData({$axios}) {
async asyncData({$axios, error}) {
try {
let messages = await $axios.get('/api/private/contact')
let reasons = await $axios.get('/api/public/contact/reason')
return {
messages: messages.data,
reasons: reasons.data
}
} catch (e) {
error({status: 404, message: 'there is a problem here'})
}
}
}
</script>
+5 -1
View File
@@ -589,13 +589,17 @@ export default {
}
},
layout: 'admin',
async asyncData({$axios, params}) {
async asyncData({$axios, params, error}) {
try {
let product = await $axios.get(`/api/public/product/${params.product}`)
let productCategories = await $axios.get(`/api/public/productCategories`)
return {
formData: product.data,
productCategories: productCategories.data
}
} catch (e) {
error({status: 404, message: 'Page not found'})
}
}
}
</script>
+5 -1
View File
@@ -94,11 +94,15 @@
}
},
layout: 'admin',
async asyncData({$axios, params}) {
async asyncData({$axios, params, error}) {
try {
const category = await $axios.get(`/api/public/productCategories/${params.category}`)
return {
formData: category.data
}
} catch (e) {
error({status: 404, message: 'Page not found'})
}
}
}
</script>
+5 -1
View File
@@ -88,11 +88,15 @@
}
},
layout: 'admin',
async asyncData({$axios}) {
async asyncData({$axios, error}) {
try {
let categories = await $axios.get(`/api/public/productCategories`);
return {
categories: categories.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+1 -2
View File
@@ -85,8 +85,7 @@
})
} else {
this.$alert(error.response.data.message, 'خطا', {
confirmButtonText: 'باشه',
confirmButtonText: 'باشه'
})
}
})
+5 -1
View File
@@ -130,13 +130,17 @@ export default {
}
},
layout: 'admin',
async asyncData({$axios, store}) {
async asyncData({$axios, store, error}) {
try {
let products = await $axios.get(`/api/public/products`)
let productCategories = await $axios.get(`/api/public/productCategories`)
return {
products: products.data,
productCategories: productCategories.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+5 -1
View File
@@ -435,11 +435,15 @@ export default {
}
},
layout: 'admin',
async asyncData({$axios, store}) {
async asyncData({$axios, store, error}) {
try {
let productCategories = await $axios.get(`/api/public/productCategories`)
return {
productCategories: productCategories.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+5 -1
View File
@@ -195,11 +195,15 @@
}
},
layout: 'admin',
async asyncData({$axios, params}) {
async asyncData({$axios, params, error}) {
try {
let project = await $axios.get(`/api/public/projects/${params.project}`)
return {
formData: project.data
}
} catch (e) {
error({status: 404, message: 'Page not found'})
}
}
}
</script>
+5 -1
View File
@@ -115,11 +115,15 @@
}
},
layout: 'admin',
async asyncData({$axios, store}) {
async asyncData({$axios, store, error}) {
try {
let projects = await $axios.get(`/api/public/projects`)
return {
projects: projects.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+1 -2
View File
@@ -120,8 +120,7 @@
})
} else {
this.$alert(error.response.data.message, 'خطا', {
confirmButtonText: 'باشه',
confirmButtonText: 'باشه'
})
}
})
+7 -5
View File
@@ -104,15 +104,13 @@
})
} else {
this.$alert(error.response.data.error.message, 'خطا', {
confirmButtonText: 'باشه',
confirmButtonText: 'باشه'
})
}
})
},
preview(event) {
this.formData.image = URL.createObjectURL(event.target.files[0]);
this.formData.image = URL.createObjectURL(event.target.files[0])
}
},
head() {
@@ -121,11 +119,15 @@
}
},
layout: 'admin',
async asyncData({$axios, route}) {
async asyncData({$axios, route, error}) {
try {
const slide = await $axios.get(`/api/public/slider/${route.params.slide}`)
return {
formData: slide.data
}
} catch (e) {
error({status: 404, message: 'Page not found'})
}
}
}
</script>
+5 -1
View File
@@ -97,11 +97,15 @@
}
},
layout: 'admin',
async asyncData({$axios, store}) {
async asyncData({$axios, store, error}) {
try {
let slides = await $axios.get(`/api/public/slider`)
return {
slides: slides.data
}
} catch (e) {
error({status: 404, message: 'There is a problem here'})
}
}
}
</script>
+2 -4
View File
@@ -108,15 +108,13 @@
})
} else {
this.$alert(error.response.data.error.message, 'خطا', {
confirmButtonText: 'باشه',
confirmButtonText: 'باشه'
})
}
})
},
preview(event) {
this.formData.image = URL.createObjectURL(event.target.files[0]);
this.formData.image = URL.createObjectURL(event.target.files[0])
}
},
head() {