Changeset c3d3266


Ignore:
Timestamp:
01/26/25 21:03:40 (3 months ago)
Author:
Aleksandarj03 <138524804+Aleksandarj03@…>
Branches:
master
Children:
840887f
Parents:
231918f
Message:

Ne rabote fetcho

Location:
ReserveNGo-frontend/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ReserveNGo-frontend/src/PiniaStores/UserStore.js

    r231918f rc3d3266  
    5555
    5656
     57
     58  },
     59  getters: {
     60    getToken(){
     61      return 'Bearer ' + this.data.token;
     62    }
    5763  }
    5864
  • ReserveNGo-frontend/src/components/Project/favourite_locals.vue

    r231918f rc3d3266  
    1 <script setup>
    2 import Locale_ from '@/components/Project/Locale_.vue'
     1<script>
     2import { userStore } from '@/PiniaStores/UserStore.js'
     3export default {
     4  data() {
     5    return {
     6      locals:[],
     7      userStore_:userStore(),
     8    }
     9  },
     10  beforeMount() {
     11     fetch(`http://localhost:8080/api/customer/favourite-locals`,{
     12      method: 'GET',
     13      headers: {
     14        'Authorization': this.userStore_.getToken
     15      }
     16    })
     17      .then(res => res.json())
     18      .then(data => this.locals = data)
     19      .catch(err => console.log(err))
     20  },
     21}
    322</script>
    423
    524<template>
    6 
    7   <div id="container " class="border container-xxl">
    8 
    9     <locale_/>
    10     <locale_/>
    11     <locale_/>
    12     <locale_/>
    13     <locale_/>
    14 
     25  <div id="container " class="border container-xxl" v-for="local in locals" :key="local">
     26    <h3>{{local.name}}</h3>
     27    <h3>{{local.address}}</h3>
    1528  </div>
    16 
    1729</template>
    1830
    19 <style scoped>
    20 
    21 </style>
     31<style scoped></style>
  • ReserveNGo-frontend/src/components/Project/local_in_local_listing.vue

    r231918f rc3d3266  
    33
    44import { restaurantStore } from '@/PiniaStores/restaurantStore.js'
     5import { userStore } from '@/PiniaStores/UserStore.js'
    56
    67export default {
     
    1415      }*/
    1516
     17      userStore_: userStore(),
     18    }
    1619
    17     }
    1820  },
    1921  props: {
     
    4850      console.log(restaurantStore().id)
    4951
     52    },
     53    async addToFavorites(){
     54       fetch(`http://localhost:8080/api/customer/favourite-locals/add/${this.local.id}`,{
     55        method: 'POST',
     56        headers: {
     57          'Authorization': this.userStore_.getToken
     58        }
     59      }).catch(error => console.log(error))
    5060    }
    5161  }
     
    6575    </div>
    6676    <div class="like">
    67     <button class="btn btn-dark">Add to favourites</button>
     77    <button class="btn btn-dark" @click="addToFavorites()">Add to favourites</button>
    6878    </div>
    6979  </div>
Note: See TracChangeset for help on using the changeset viewer.