Skip to content

Commit a58aeb0

Browse files
committed
message when visiting self or non existing user
1 parent 752ce52 commit a58aeb0

File tree

1 file changed

+12
-4
lines changed
  • frontend/src/components/app/users

1 file changed

+12
-4
lines changed

frontend/src/components/app/users/User.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<template>
22
<!-- eslint-disable max-len -->
33
<div class="sm:mx-16 lg:mx-32">
4-
<div v-if="!user" class="mx-auto flex items-center justify-center mt-32">
4+
<div v-if="error" class="mx-auto flex items-center justify-center mt-32">
5+
{{error}}
6+
</div>
7+
<div v-if="!user && !error" class="mx-auto flex items-center justify-center mt-32">
58
<img class="h-36" src="../../../assets/loading.svg">
69
</div>
7-
<section v-else class="mx-auto">
10+
<section v-if="user && !error" class="mx-auto">
811
<div v-on:click="goBack()" class="sort-button py-0 ml-auto rounded-md text-lg w-20 md:w-16 mr-4 sm:mr-0 mb-4">
912
<h1 class="noSelect">←</h1>
1013
</div>
@@ -26,6 +29,7 @@ export default {
2629
},
2730
data: () => ({
2831
user: null,
32+
error: null,
2933
}),
3034
methods: {
3135
goBack() {
@@ -39,8 +43,12 @@ export default {
3943
},
4044
},
4145
async beforeMount() {
42-
const userRequest = await this.$http.get(`/profile/view/${this.$route.params.id}`);
43-
this.user = userRequest.data.profile;
46+
try {
47+
const userRequest = await this.$http.get(`/profile/view/${this.$route.params.id}`);
48+
this.user = userRequest.data.profile;
49+
} catch (error) {
50+
this.error = error.response.data.error.message;
51+
}
4452
},
4553
};
4654
</script>

0 commit comments

Comments
 (0)