Skip to content

Commit b485109

Browse files
authored
Merge pull request #428 from Seluj78/427-like-permission
2 parents 42b347b + 5afd513 commit b485109

File tree

6 files changed

+44
-26
lines changed

6 files changed

+44
-26
lines changed

frontend/src/components/app/recommendations/RecommendationCard.vue

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
/* eslint-disable no-else-return */
2929
/* eslint-disable max-len */
3030
31+
import imageMan from '../../../assets/recommendations/avatars/man1.png';
32+
import imageWoman from '../../../assets/recommendations/avatars/woman1.png';
33+
import imageOther from '../../../assets/recommendations/avatars/other.png';
34+
3135
export default {
3236
props: ['recommendation'],
3337
methods: {
@@ -48,19 +52,11 @@ export default {
4852
return imageForShowcase;
4953
}
5054
if (this.recommendation.gender === 'male') {
51-
const number = Math.floor(Math.random() * 11);
52-
if (number % 2 === 0) {
53-
return '../../../assets/recommendations/avatars/man1.png';
54-
}
55-
return '../../../assets/recommendations/avatars/man2.png';
55+
return imageMan;
5656
} else if (this.recommendation.gender === 'female') {
57-
const number = Math.floor(Math.random() * 11);
58-
if (number % 2 === 0) {
59-
return '../../../assets/recommendations/avatars/woman1.png';
60-
}
61-
return '../../../assets/recommendations/avatars/woman2.png';
57+
return imageWoman;
6258
}
63-
return '../../../assets/recommendations/avatars/other.png';
59+
return imageOther;
6460
},
6561
},
6662
};

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>

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
class="px-4 py-1 border rounded-xl mr-2 mt-2 text-gray-600 text-sm">{{interest}}</h1>
3636
</div>
3737
</div>
38-
<div class="text-center flex flex-col mx-auto p-8 border-b">
38+
<div v-if="avatarsUploaded()" class="text-center flex flex-col mx-auto p-8 border-b">
3939
<LikeButton
4040
v-if="!likeButtons.superLikeClicked"
4141
v-bind:hasBeenClicked="likeButtons.likeClicked"
@@ -120,6 +120,10 @@ export default {
120120
blocked: false,
121121
}),
122122
methods: {
123+
avatarsUploaded() {
124+
return this.user.images.length > 0
125+
&& this.$store.getters.getLoggedInUser.images.length > 0;
126+
},
123127
preferences() {
124128
if (this.user.orientation === 'heterosexual' && this.user.gender === 'male') {
125129
return 'women';
@@ -219,6 +223,14 @@ export default {
219223
async beforeMount() {
220224
this.checkIfUserIsLiked();
221225
this.checkIfUserIsBlocked();
226+
const interests = this.user.tags;
227+
if (interests) {
228+
for (let j = 0; j < interests.length; j += 1) {
229+
this.userInterests.push(interests[j].name);
230+
}
231+
}
232+
},
233+
async mounted() {
222234
const sliderRangesRequest = await this.$http.get('/search/values');
223235
const maxScore = sliderRangesRequest.data.search_minmax.max_score;
224236
const sliderScore = document.getElementById('sliderScore');
@@ -229,12 +241,6 @@ export default {
229241
} else {
230242
sliderScore.style.marginLeft = `calc(${marginLeft} - ${sliderScoreWidth})`;
231243
}
232-
const interests = this.user.tags;
233-
if (interests) {
234-
for (let j = 0; j < interests.length; j += 1) {
235-
this.userInterests.push(interests[j].name);
236-
}
237-
}
238244
},
239245
};
240246
</script>

frontend/src/router/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import User from '../components/app/users/User.vue';
1616
import History from '../views/app/History.vue';
1717
import Matches from '../views/app/Matches.vue';
1818
import SignOut from '../views/auth/SignOut.vue';
19+
import NotFound from '../views/NotFound.vue';
1920
import store from '../store/index';
2021

2122
Vue.use(VueRouter);
@@ -144,6 +145,11 @@ const routes = [
144145
name: 'SignOut',
145146
beforeEnter: notLoggedInRedirectLogin,
146147
},
148+
{
149+
path: '*',
150+
component: NotFound,
151+
name: 'NotFound',
152+
},
147153
];
148154

149155
const router = new VueRouter({

frontend/src/views/NotFound.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<div class="sm:mx-16 lg:mx-32 mt-32">
3+
<h1 class="text-2xl text-center mx-auto">404 page not found</h1>
4+
</div>
5+
</template>

frontend/src/views/app/History.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,12 @@ export default {
143143
this.filteredCount = count;
144144
},
145145
},
146-
async created() {
147-
await this.fetchUsers('People I viewed');
148-
this.filteredCount = this.recommendations.length;
149-
},
150146
async beforeRouteEnter(to, from, next) {
151147
next(async (vm) => {
152148
if (from.name !== 'Users' || !vm.visitUser) {
153149
vm.browseAgain();
154150
await vm.fetchUsers('People I viewed');
151+
vm.filteredCount = vm.recommendations.length;
155152
vm.$el.scrollTop = 0;
156153
}
157154
vm.prevRoute = from;

0 commit comments

Comments
 (0)