Changeset c3d3266
- Timestamp:
- 01/26/25 21:03:40 (3 months ago)
- Branches:
- master
- Children:
- 840887f
- Parents:
- 231918f
- Location:
- ReserveNGo-frontend/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ReserveNGo-frontend/src/PiniaStores/UserStore.js
r231918f rc3d3266 55 55 56 56 57 58 }, 59 getters: { 60 getToken(){ 61 return 'Bearer ' + this.data.token; 62 } 57 63 } 58 64 -
ReserveNGo-frontend/src/components/Project/favourite_locals.vue
r231918f rc3d3266 1 <script setup> 2 import Locale_ from '@/components/Project/Locale_.vue' 1 <script> 2 import { userStore } from '@/PiniaStores/UserStore.js' 3 export 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 } 3 22 </script> 4 23 5 24 <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> 15 28 </div> 16 17 29 </template> 18 30 19 <style scoped> 20 21 </style> 31 <style scoped></style> -
ReserveNGo-frontend/src/components/Project/local_in_local_listing.vue
r231918f rc3d3266 3 3 4 4 import { restaurantStore } from '@/PiniaStores/restaurantStore.js' 5 import { userStore } from '@/PiniaStores/UserStore.js' 5 6 6 7 export default { … … 14 15 }*/ 15 16 17 userStore_: userStore(), 18 } 16 19 17 }18 20 }, 19 21 props: { … … 48 50 console.log(restaurantStore().id) 49 51 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)) 50 60 } 51 61 } … … 65 75 </div> 66 76 <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> 68 78 </div> 69 79 </div>
Note:
See TracChangeset
for help on using the changeset viewer.