Skip to content

Commit

Permalink
feat: loading on create place and reviews count on place view
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielforster committed Jan 23, 2024
1 parent a64a588 commit 0c9e7c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions frontend/src/views/HomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ onMounted(() => {
async function registerPlace() {
try {
isLoading.value = true;
const response = await fetch('https://lmtebcx7dj.execute-api.sa-east-1.amazonaws.com/api' + '/places', {
method: 'POST',
headers: {
Expand All @@ -34,8 +36,6 @@ async function registerPlace() {
if (placeData.error) {
throw new Error('backend:' + placeData.error)
}
isModalOpen.value = false
} catch (error) {
if (error.message.startsWith('backend:')) {
alert(error.message.replace('backend:', ''))
Expand All @@ -48,6 +48,9 @@ async function registerPlace() {
description.value = ''
googleMapsUrl.value = ''
isLoading.value = false
isModalOpen.value = false
fetchData()
}
}
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/views/PlacesView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ async function fetchData() {

<div class="self-start">
<p class="text-xl font-bold">Nota média: {{ data.avarageRating }}</p>
<p class="text-xl">Avaliações: {{ data.reviews.length }}</p>
</div>
</div>

<div v-for="review in data.reviews" class="flex flex-col border rounded py-1 px-2 my-2">
<div v-if="!data.reviews.length">
<p class="text-xl font-bold mt-5 text-center">Sem avaliações por enquanto!</p>
</div>

<div v-else v-for="review in data.reviews" class="flex flex-col border rounded py-1 px-2 my-2">
<div class="flex flex-col">
<div class="flex justify-between font-bold">
<p class="text-lg font-medium pb-1">
Expand Down

0 comments on commit 0c9e7c9

Please sign in to comment.