33 <div class =" mx-4 sm:mx-16 lg:mx-32" >
44 <NavBar v-bind:currentRoute =" 'History'" ></NavBar >
55 <section class =" mx-auto" >
6+ <div class =" flex items-center justify-center md:justify-start w-full mb-4" >
7+ <h1
8+ class =" text-3xl sm:text-5xl my-4 inline-block text-center leading-none onboarding-sub-container-content-heading" >
9+ {{recommendations.length}}</h1 >
10+ <DropdownDisplayChoiceHistory
11+ v-on:save-single-choice =" updateHistory"
12+ class =" inline-block ml-4"
13+ v-bind:name =" 'history'"
14+ v-bind:starting-option =" 'People I viewed'"
15+ v-bind:options =" ['People I viewed', 'People I liked', 'Who viewed me', 'Who liked me', 'Whom I blocked']" ></DropdownDisplayChoiceHistory >
16+ </div >
617 <HistoryRecommendations
718 v-if =" firstTimeAnalysisDone"
8- v-bind:ready =" recommendationsAnalysisDone"
9- v-on:update-history =" updateHistory"
19+ v-bind:ready =" recommendations.length"
1020 v-bind:title =" 'Potential matches'"
1121 v-bind:recommendationsReceived =" recommendations"
1222 v-bind:recommendationsAnalysis =" recommendationsAnalysis" ></HistoryRecommendations >
1929
2030import NavBar from ' @/components/shared/NavBar.vue' ;
2131import HistoryRecommendations from ' @/components/app/recommendations/HistoryRecommendations.vue' ;
32+ import DropdownDisplayChoiceHistory from ' @/components/shared/DropdownDisplayChoiceHistory.vue' ;
2233
2334export default {
2435 name: ' History' ,
2536 props: [' recommendationsFromSettingUp' ],
2637 components: {
2738 NavBar,
2839 HistoryRecommendations,
40+ DropdownDisplayChoiceHistory,
2941 },
3042 data : () => ({
3143 recommendations: [],
@@ -48,9 +60,23 @@ export default {
4860 firstTimeAnalysisDone: false ,
4961 }),
5062 methods: {
51- async fetchUsers () {
52- const recommendationsRequest = await this .$http .get (' /recommendations' );
53- this .recommendations = recommendationsRequest .data .recommendations ;
63+ async fetchUsers (request ) {
64+ if (request === ' People I viewed' ) {
65+ const recommendationsRequest = await this .$http .get (' /history/viewed' );
66+ this .recommendations = recommendationsRequest .data .viewed ;
67+ } else if (request === ' People I liked' ) {
68+ const recommendationsRequest = await this .$http .get (' /history/liked' );
69+ this .recommendations = recommendationsRequest .data .liked ;
70+ } else if (request === ' Who viewed me' ) {
71+ const recommendationsRequest = await this .$http .get (' /history/viewed/me' );
72+ this .recommendations = recommendationsRequest .data .viewed_me ;
73+ } else if (request === ' Who liked me' ) {
74+ const recommendationsRequest = await this .$http .get (' /history/liked/me' );
75+ this .recommendations = recommendationsRequest .data .liked_me ;
76+ } else if (request === ' Whom I blocked' ) {
77+ const recommendationsRequest = await this .$http .get (' /history/blocked' );
78+ this .recommendations = recommendationsRequest .data .bloked ;
79+ }
5480 this .recommendations .sort ((a , b ) => a .distance - b .distance );
5581 for (let i = 0 ; i < this .recommendations .length ; i += 1 ) {
5682 this .recommendations [i].distance = Math .floor (this .recommendations [i].distance );
@@ -100,29 +126,18 @@ export default {
100126 },
101127 updateHistory (... args ) {
102128 const [request ] = args;
103- if (request === ' People I view' ) {
104- console .log (1 );
105- } else if (request === ' People I like' ) {
106- console .log (2 );
107- } else if (request === ' Who views me' ) {
108- console .log (3 );
109- } else if (request === ' Who likes me' ) {
110- console .log (4 );
111- } else if (request === ' Whom I block' ) {
112- console .log (5 );
113- }
114129 this .browseAgain ();
115- this .fetchUsers ();
130+ this .fetchUsers (request );
116131 },
117132 },
118133 async created () {
119- await this .fetchUsers ();
134+ await this .fetchUsers (' People I viewed ' );
120135 },
121136 deactivated () {
122137 if (! this .$route .path .startsWith (' /users' )) {
123138 this .firstTimeAnalysisDone = false ;
124139 this .browseAgain ();
125- this .fetchUsers ();
140+ this .fetchUsers (' People I viewed ' );
126141 this .$el .scrollTop = 0 ;
127142 }
128143 },
0 commit comments