@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<h3>How did you like todays TLA?</h3>
|
||||
<div>
|
||||
<UButton @click="makeRequest(1)" class="rounded-l-full" :icon="current == 1 ? 'mdi:thumbs-up' : 'mdi:thumbs-up-outline'" size="md" color="neutral" variant="outline">{{ likes }}</UButton>
|
||||
<UButton @click="makeRequest(-1)" class="rounded-r-full" :icon="current == -1 ? 'mdi:thumbs-down' : 'mdi:thumbs-down-outline'" size="md" color="neutral" variant="outline">{{ dislikes }}</UButton>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="css" scoped>
|
||||
|
||||
</style>
|
||||
|
||||
<script lang="ts">
|
||||
import axios from 'axios';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
likes: 0,
|
||||
dislikes: 0,
|
||||
current: 0,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.makeRequest(2)
|
||||
},
|
||||
methods: {
|
||||
makeRequest(type: number) {
|
||||
if (this.current == type){
|
||||
this.current = 0;
|
||||
if (type == 1) this.likes--;
|
||||
else if (type == -1) this.dislikes--;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 1) {
|
||||
this.likes++;
|
||||
if (this.current != 0) this.dislikes--;
|
||||
}
|
||||
else if (type == -1) {
|
||||
this.dislikes++;
|
||||
if (this.current != 0) this.likes--;
|
||||
}
|
||||
|
||||
this.current = type;
|
||||
}
|
||||
|
||||
axios
|
||||
.get("/api/review/en/"+type)
|
||||
.then(response => {
|
||||
this.likes = response.data.likes;
|
||||
this.dislikes = response.data.dislikes;
|
||||
this.current = response.data.current;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user