Jelajahi Sumber

Add 404 page also for user pages

sbkwgh 7 tahun lalu
induk
melakukan
15602c3c8b

+ 11 - 1
frontend/src/components/routes/User.vue

@@ -71,7 +71,17 @@
 			this.axios
 				.get(`/api/v1/user/${this.$route.params.username}`)
 				.then(res => this.user = res.data)
-				.catch(AjaxErrorHandler(this.$store))
+				.catch(e => {
+					let invalidId = e.response.data.errors.find(error => {
+						return error.name === 'accountDoesNotExist'
+					})
+
+					if(invalidId) {
+						this.$store.commit('set404Page', true)
+					} else {
+						AjaxErrorHandler(this.$store)(e)
+					}
+				})
 		}
 	}
 </script>

+ 11 - 1
frontend/src/components/routes/UserPosts.vue

@@ -93,7 +93,17 @@
 					this.nextURL = res.data.meta.nextURL
 					this.nextPostsCount = res.data.meta.nextPostsCount
 				})
-				.catch(AjaxErrorHandler(this.$store))
+				.catch(e => {
+					let invalidId = e.response.data.errors.find(error => {
+						return error.name === 'accountDoesNotExist'
+					})
+
+					if(invalidId) {
+						this.$store.commit('set404Page', true)
+					} else {
+						AjaxErrorHandler(this.$store)(e)
+					}
+				})
 
 			logger('userPosts', this.$route.params.username)
 		}

+ 11 - 1
frontend/src/components/routes/UserThreads.vue

@@ -86,7 +86,17 @@
 					this.nextURL = res.data.meta.nextURL
 					this.nextThreadsCount = res.data.meta.nextThreadsCount
 				})
-				.catch(AjaxErrorHandler(this.$store))
+				.catch(e => {
+					let invalidId = e.response.data.errors.find(error => {
+						return error.name === 'accountDoesNotExist'
+					})
+
+					if(invalidId) {
+						this.$store.commit('set404Page', true)
+					} else {
+						AjaxErrorHandler(this.$store)(e)
+					}
+				})
 
 			logger('userThreads', this.$route.params.username)
 		}