Changeset 17bf12d
- Timestamp:
- 01/25/25 00:58:19 (3 months ago)
- Branches:
- master
- Children:
- 4894099
- Parents:
- a520992
- Location:
- ReserveNGo-frontend/src
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
ReserveNGo-frontend/src/App.vue
ra520992 r17bf12d 3 3 import NavBar from './components/Project/Nav_bar_new.vue' 4 4 import Footer_ from '@/components/Project/Footer_.vue' 5 6 7 8 9 5 10 6 11 </script> -
ReserveNGo-frontend/src/components/Project/Nav_bar_new.vue
ra520992 r17bf12d 2 2 3 3 4 import { userStore } from '@/PiniaStores/UserStore.js' 5 6 export default { 7 data() { 8 return { 9 userStore_: userStore() 10 } 11 } 12 } 4 13 5 14 … … 57 66 <!-- navbar links --> 58 67 <div class="collapse navbar-collapse justify-content-end align-center" id="main-nav"> 68 59 69 <ul class="navbar-nav"> 70 60 71 <li class="nav-item"> 61 <router-link to="/favourite_locals" class="nav-link">Favourite locals </router-link>72 <router-link v-if="this.userStore_.data.role==='ROLE_CUSTOMER'" to="/favourite_locals" class="nav-link">Favourite locals </router-link> 62 73 </li> 63 74 <li class="nav-item"> 64 <router-link to="/my_reservations" class="nav-link">My reservations </router-link>75 <router-link v-if="this.userStore_.data.role==='ROLE_CUSTOMER'" to="/my_reservations" class="nav-link">My reservations </router-link> 65 76 </li> 77 66 78 <li class="nav-item ms-2 d-none d-md-inline"> 67 79 <router-link to="/login" > -
ReserveNGo-frontend/src/components/Project/login_.vue
ra520992 r17bf12d 1 <script setup> 1 <script> 2 3 4 import { userStore } from '@/PiniaStores/UserStore.js' 5 6 export default { 7 data() { 8 return { 9 form_info:{ 10 email: '', 11 password: '' 12 }, 13 14 url: 'http://localhost:8080/api/auth/login', 15 16 userStore_: userStore(), 17 18 } 19 }, 20 methods: { 21 /*async makeLogin() { 22 23 await fetch(this.url, { 24 method: 'POST', 25 headers: { 'Content-Type': 'application/x-www-form-urlencoded'}, 26 body: new URLSearchParams({ 27 email: this.form_info.email, 28 password: this.form_info.password 29 }) 30 }).then((response) => response.json()) 31 .then(json => ) 32 33 }*/ 34 } 35 } 2 36 3 37 </script> … … 10 44 <div class="row justify-content-center "> 11 45 46 <!-- <form action="http://localhost:8080/api/auth/login" method="POST">--> 12 47 <div class="col-3"> 13 <form action="http://localhost:8080/api/auth/login" method="POST">48 <form v-on:submit.prevent="makeLogin"> 14 49 15 <label for="email" class="form-label">Email</label>16 <input name="email" id="email" class="form-control" type="email">50 <label for="email" class="form-label">Email</label> 51 <input v-model="this.form_info.email" name="email" id="email" class="form-control" type="email"> 17 52 18 53 <label for="password" class="form-label">Password</label> 19 <input name="password" id="password" type="password" class="form-control">54 <input v-model="this.form_info.password" name="password" id="password" type="password" class="form-control"> 20 55 21 56 <button type="submit" class="btn btn-dark mt-2">Login</button> -
ReserveNGo-frontend/src/components/Project/register_.vue
ra520992 r17bf12d 1 1 <script> 2 2 3 4 import { userStore } from '@/PiniaStores/UserStore.js' 3 5 4 6 export default { … … 7 9 path: '', 8 10 url: 'http://localhost:8080/api/auth/register/', 11 9 12 form_info:{ 10 13 firstName: '', … … 15 18 16 19 }, 17 data: {} 20 /* data: { 21 id: 0, 22 firstName: "", 23 lastName: "", 24 email: "", 25 phoneNumber: "", 26 role: "", 27 token: "" 28 },*/ 29 userStore_: userStore(), 30 31 //NE ZABORAVAJ TREBA DA SREDIS VCITUVANJE NA data od userStore na pocetok na stranicata 18 32 19 33 } … … 21 35 22 36 methods: { 23 register() {24 fetch(this.url+this.path, {37 async register() { 38 await fetch(this.wholeUrl, { 25 39 method: 'POST', 26 headers: { "Content-Type": "application/json" }, 27 body: JSON.stringify({firstName: this.firstName, lastName: this.lastName, email: this.email, password: this.password}) 28 }).then((response) => {response.json()}) 29 .then((json) => this.data = json) 40 headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, 41 body: new URLSearchParams({ 42 firstName: this.form_info.firstName, 43 lastName: this.form_info.lastName, 44 email: this.form_info.email, 45 password: this.form_info.password, 46 phoneNumber: this.form_info.phoneNumber}) 47 }).then((response) => response.json()) 48 .then((json) => {this.userStore_.setLocalStorage(json)}) 49 //console.log("Data received:", this.data); 50 //this.userStore_.setLocalStorage(json) 51 //console.log(json) 30 52 53 //console.log(this.userStore_.data) 31 54 } 32 55 33 56 }, 34 /*computed: {35 somevariabletest(){57 computed: { 58 wholeUrl(){ 36 59 return this.url+this.path; 60 }, 61 testJson(){ 62 return JSON.stringify({ 63 firstName: this.form_info.firstName, 64 lastName: this.form_info.lastName, 65 email: this.form_info.email, 66 password: this.form_info.password, 67 phoneNumber: this.form_info.phoneNumber}) 37 68 } 38 } */69 } 39 70 40 71 … … 49 80 <div class="row justify-content-center"> 50 81 82 <!-- <form @submit.prevent="register" method="POST">--> 83 <!-- <form v-bind:action="wholeUrl" method="POST">--> 51 84 52 85 <div class="col-3"> 53 <form @submit.prevent="register ()" method="POST">86 <form @submit.prevent="register" method="POST"> 54 87 <label for="name" class="form-label" >Name</label> 55 <input v-model=" form_info.firstName" type="text" id="name" name="firstName" class="form-control" placeholder="Name" required>88 <input v-model="this.form_info.firstName" type="text" id="name" name="firstName" class="form-control" placeholder="Name" required> 56 89 57 90 <label for="surname" class="form-label">Surname</label>
Note:
See TracChangeset
for help on using the changeset viewer.