Skip to content

Commit d1a0a3b

Browse files
committed
display error message if 0 results
1 parent 6761c88 commit d1a0a3b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

frontend/src/assets/search.png

399 KB
Loading

frontend/src/views/app/Search.vue

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
v-bind:recommendationsReceived="recommendations"
1212
v-bind:recommendationsAnalysis="filters"></Recommendations>
1313
</section>
14-
<section v-if="!recommendationsAnalysisDone && sliderValuesFetched" class="flex flex-col my-8 md:my-12">
14+
<section v-on:click="setError(null)"
15+
v-if="!recommendationsAnalysisDone && sliderValuesFetched"
16+
class="flex flex-col my-8 md:my-12">
17+
<div><img src="../../assets/search.png" class="w-20 mb-4 mx-auto"></div>
1518
<div>
1619
<FilterSlider
1720
v-bind:min="sliders.age.min"
@@ -46,8 +49,10 @@
4649
'astrology', 'board games', 'craft beer', 'coffee', 'writer',
4750
]"
4851
v-bind:name="'interests'"
52+
v-bind:info="'If no selected, all are accounted.'"
4953
v-on:saveFilterMultiple="saveFilterMultiple"></MultipleFilters>
5054
</div>
55+
<div class="auth-sub-container-error mx-auto max-w-md" v-if="error"><h1 class="auth-sub-container-error-message">{{ error }}</h1></div>
5156
<div class="mx-auto w-full max-w-md">
5257
<h1 v-on:click="search()" class="onboarding-sub-container-content-button-outline w-48 text-lg font-normal max-w-full bg-purple-matcha w-full text-white-matcha mx-auto">
5358
Search</h1>
@@ -99,6 +104,7 @@ export default {
99104
interests: [],
100105
},
101106
recommendationsAnalysisDone: false,
107+
error: null,
102108
}),
103109
methods: {
104110
saveFilter(...range) {
@@ -137,6 +143,10 @@ export default {
137143
];
138144
}
139145
this.recommendations = searchRequest.data.search_results;
146+
if (this.recommendations.length === 0) {
147+
this.setError('0 profiles found. Please, try expanding your search criteria.');
148+
return;
149+
}
140150
this.recommendations.sort((a, b) => a.distance - b.distance);
141151
for (let i = 0; i < this.recommendations.length; i += 1) {
142152
if (this.recommendations[i].age < 18) {
@@ -150,10 +160,23 @@ export default {
150160
}
151161
}
152162
this.recommendationsAnalysisDone = true;
163+
this.scrollToTop();
153164
},
154165
searchAgain() {
166+
this.filters.age.min = null;
167+
this.filters.age.max = null;
168+
this.filters.popularity.min = null;
169+
this.filters.popularity.max = null;
170+
this.filters.distance.max = null;
171+
this.filters.interests = [];
155172
this.recommendationsAnalysisDone = false;
156173
},
174+
setError(message) {
175+
this.error = message;
176+
},
177+
scrollToTop() {
178+
window.scrollTo(0, 0);
179+
},
157180
},
158181
async mounted() {
159182
const sliderRangesRequest = await this.$http.get('/search/values');

0 commit comments

Comments
 (0)