|
3 | 3 | <div class="profileContainer"> |
4 | 4 | <div id="sliderScoreContainer" class="text-center w-full rounded-lt-md heatScore relative h-6"> |
5 | 5 | <div id="sliderScore" class="bg-purple-matcha absolute top-0 flex flex-col items-center justify-center h-12 w-auto rounded-b-md"> |
6 | | - <h1 class="text-white-matcha px-2"><span class="font-bold">{{user.heat_score}}</span> likes</h1> |
| 6 | + <h1 class="text-white-matcha px-2"><span class="font-bold">{{getHeatScore}}</span> likes</h1> |
7 | 7 | </div> |
8 | 8 | </div> |
9 | 9 | <div class="text-center text-wrap p-8 mt-4 border-b"> |
|
35 | 35 | <div class="text-center flex flex-col mx-auto p-8 border-b"> |
36 | 36 | <LikeButton |
37 | 37 | v-if="!likeButtons.superLikeClicked" |
| 38 | + v-bind:name="'like'" |
38 | 39 | v-bind:startImage="likeImage" |
39 | 40 | v-bind:hoverImage="likeImageHover" |
40 | 41 | v-bind:clickedImage="likeImageClicked" |
41 | 42 | v-bind:text="'Like'" |
42 | 43 | v-bind:textRevert="'Unlike'" |
43 | | - v-on:clicked="likeButtons.likeClicked = true" |
44 | | - v-on:revert="likeButtons.likeClicked = false"></LikeButton> |
| 44 | + v-on:clicked="buttonClicked" |
| 45 | + v-on:revert="buttonRevert"></LikeButton> |
45 | 46 | <LikeButton |
46 | 47 | v-if="!likeButtons.likeClicked && superLikesLeft()" |
| 48 | + v-bind:name="'superLike'" |
47 | 49 | v-bind:class="{'mt-8': !likeButtons.superLikeClicked}" |
48 | 50 | v-bind:startImage="superLikeImage" |
49 | 51 | v-bind:hoverImage="superLikeImageHover" |
50 | 52 | v-bind:clickedImage="superLikeImageClicked" |
51 | 53 | v-bind:text="'Super Like'" |
52 | 54 | v-bind:textRevert="'Unlike'" |
53 | 55 | v-bind:description="`Worth 10 likes, and ${user.first_name} sees your extra interest`" |
54 | | - v-on:clicked="likeButtons.superLikeClicked = true" |
55 | | - v-on:revert="likeButtons.superLikeClicked = false"></LikeButton> |
| 56 | + v-on:clicked="buttonClicked" |
| 57 | + v-on:revert="buttonRevert"></LikeButton> |
56 | 58 | </div> |
57 | 59 | <div class="text-center p-8 border-b relative"> |
58 | 60 | <DropdownDisplayChoice |
@@ -124,12 +126,43 @@ export default { |
124 | 126 | superLikesLeft() { |
125 | 127 | return true; |
126 | 128 | }, |
| 129 | + async buttonClicked(...args) { |
| 130 | + const [name] = args; |
| 131 | + if (name === 'like') { |
| 132 | + await this.$http.post(`/like/${this.user.id}`, { is_superlike: false }); |
| 133 | + this.likeButtons.likeClicked = true; |
| 134 | + } else if (name === 'superLike') { |
| 135 | + await this.$http.post(`/like/${this.user.id}`, { is_superlike: true }); |
| 136 | + this.likeButtons.superLikeClicked = true; |
| 137 | + } |
| 138 | + }, |
| 139 | + async buttonRevert(...args) { |
| 140 | + const [name] = args; |
| 141 | + if (name === 'like') { |
| 142 | + await this.$http.post(`/unlike/${this.user.id}`, { is_superlike: false }); |
| 143 | + this.likeButtons.likeClicked = false; |
| 144 | + } else if (name === 'superLike') { |
| 145 | + await this.$http.post(`/unlike/${this.user.id}`, { is_superlike: true }); |
| 146 | + this.likeButtons.superLikeClicked = false; |
| 147 | + } |
| 148 | + }, |
127 | 149 | saveSingleChoice(...args) { |
128 | 150 | const [key, value] = args; |
129 | 151 | console.log(key); |
130 | 152 | console.log(value); |
131 | 153 | }, |
132 | 154 | }, |
| 155 | + computed: { |
| 156 | + getHeatScore() { |
| 157 | + if (this.likeButtons.likeClicked) { |
| 158 | + return this.user.heat_score + 1; |
| 159 | + } |
| 160 | + if (this.likeButtons.superLikeClicked) { |
| 161 | + return this.user.heat_score + 10; |
| 162 | + } |
| 163 | + return this.user.heat_score; |
| 164 | + }, |
| 165 | + }, |
133 | 166 | async beforeMount() { |
134 | 167 | const sliderRangesRequest = await this.$http.get('/search/values'); |
135 | 168 | const maxScore = sliderRangesRequest.data.search_minmax.max_score; |
|
0 commit comments