Browse Source

FEAT: dynamic score on details page

master
valere 5 months ago
parent
commit
c37835dc33
2 changed files with 17 additions and 3 deletions
  1. +14
    -2
      components/comment/form.vue
  2. +3
    -1
      components/comment/list.vue

+ 14
- 2
components/comment/form.vue View File

@@ -6,7 +6,8 @@
<label for="score"> <label for="score">
Note: Note:
</label> </label>
<input type="range" name="score" min="1" max="10" id="score" class="w-full">
{{ score }}%
<input type="range" name="score" min="0" max="100" step="1" id="score" class="w-full" v-model="score">
</div> </div>
<button type="submit" <button type="submit"
class="bg-white rounded-md p-2 inline-flex items-center justify-center text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500">envoyer</button> class="bg-white rounded-md p-2 inline-flex items-center justify-center text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500">envoyer</button>
@@ -17,14 +18,25 @@
const store = useCommentStore() const store = useCommentStore()
const props = defineProps(['filmId']) const props = defineProps(['filmId'])


const username = ref('')
const message = ref('')
const score = ref(50)

const resetForm = () => {
username.value = ''
message.value = ''
score.value = 5
}

const sendComment = () => { const sendComment = () => {
store.add({ store.add({
username: username.value, username: username.value,
message: message.value, message: message.value,
score: document.getElementById('score').value,
score: score.value,
filmId: props.filmId, filmId: props.filmId,
added: Date.now(), added: Date.now(),
}) })
resetForm()
} }
</script> </script>




+ 3
- 1
components/comment/list.vue View File

@@ -5,7 +5,9 @@
{{ comment.message }} {{ comment.message }}
</p> </p>
<p> <p>
{{ comment.username }} - {{ useDateFormat(comment.added, 'D MMM YYYY') }}
<UiPerson class="h-10 inline-block" /> {{ comment.username }} -
{{ useDateFormat(comment.added, 'D MMM YYYY') }}
{{ comment.score }}%
</p> </p>
</li> </li>
</ul> </ul>


Loading…
Cancel
Save