Bladeren bron

Only show logout when logged in

master
LeneS 5 jaren geleden
bovenliggende
commit
bb8e9a0121

+ 8
- 0
src/assets/staticData/alertTypes.js Bestand weergeven

@@ -0,0 +1,8 @@
1
+const types = Object.freeze({
2
+  SUCCESS: 'Success',
3
+  INFO: 'Info',
4
+  WARNING: 'Warning',
5
+  ERROR: 'Error',
6
+});
7
+
8
+export default types;

+ 44
- 0
src/components/shared/alert.vue Bestand weergeven

@@ -0,0 +1,44 @@
1
+<template>
2
+  <div class="container">
3
+    <!-- eslint-disable max-len -->
4
+    <div class="alert alert-success" v-if="type === 'SUCCESS'">
5
+      <eva-icon name="checkmark-outline"></eva-icon>
6
+      <strong>{{ text }}</strong>
7
+    </div>
8
+    <div class="alert alert-info" v-if="type === 'INFO'">
9
+      <eva-icon name="info-outline"></eva-icon>
10
+      <strong>{{ text }}</strong>
11
+    </div>
12
+    <div class="alert alert-warning" v-if="type === 'WARNING'">
13
+      <eva-icon name="alert-circle-outline"></eva-icon>
14
+      <strong>{{ text }}</strong>
15
+    </div>
16
+    <div class="alert alert-danger" v-if="type === 'ERROR'">
17
+      <eva-icon name="slash-outline"></eva-icon>
18
+      <strong>{{ text }}</strong>
19
+    </div>
20
+  </div>
21
+</template>
22
+
23
+<script>
24
+export default {
25
+  name: 'Alert',
26
+  data() {
27
+    return {
28
+      alertTypes: {
29
+        SUCCESS: 'Success',
30
+        INFO: 'Info',
31
+        WARNING: 'Warning',
32
+        ERROR: 'Error',
33
+      },
34
+    };
35
+  },
36
+  props: {
37
+    text: null,
38
+    type: null,
39
+  },
40
+};
41
+</script>
42
+
43
+<style>
44
+</style>

+ 20
- 5
src/components/shared/navBar.vue Bestand weergeven

@@ -60,6 +60,7 @@
60 60
                   @click="routerGoTo('/timeshare/sell')"
61 61
                 >To Sell</a>
62 62
                 <a
63
+                  v-if="showLogout"
63 64
                   class="dropdown-item cursor-pointer"
64 65
                   @click="routerGoTo('/timeshare/sell')"
65 66
                 >My Timeshare Weeks</a>
@@ -103,12 +104,14 @@
103 104
                   class="dropdown-item cursor-pointer"
104 105
                   @click="routerGoTo('/property/Residential/Rental')"
105 106
                 >To Rent Residential Properties</a>
106
-                <hr />
107
+                <hr v-if="showLogout" />
107 108
                 <a
109
+                  v-if="showLogout"
108 110
                   class="dropdown-item cursor-pointer"
109 111
                   @click="routerGoTo('/property/list/Commercial/MyListings')"
110 112
                 >My Commercial Properties</a>
111 113
                 <a
114
+                  v-if="showLogout"
112 115
                   class="dropdown-item cursor-pointer"
113 116
                   @click="routerGoTo('/property/list/Residential/MyListings')"
114 117
                 >My Residential Properties</a>
@@ -179,6 +182,7 @@
179 182
             <li class="nav-item dropdown">
180 183
               <a
181 184
                 class="nav-link"
185
+                v-if="hideLogin"
182 186
                 @click="routerGoTo('/user/login')"
183 187
                 id="navbarDropdown"
184 188
                 role="button"
@@ -187,6 +191,18 @@
187 191
                 aria-expanded="false"
188 192
               >Login</a>
189 193
             </li>
194
+            <li class="nav-item dropdown">
195
+              <span v-if="showLogout">
196
+                <a class="nav-link" @click="logout()">Logout</a>
197
+              </span>
198
+              <span v-else></span>
199
+            </li>
200
+            <li>
201
+              <span v-if="showLogout">
202
+                <a>Welcome! {{ }}</a>
203
+              </span>
204
+              <span v-else></span>
205
+            </li>
190 206
           </ul>
191 207
         </div>
192 208
       </div>
@@ -202,10 +218,6 @@
202 218
         </button>
203 219
       </div>
204 220
     </div>
205
-    <span v-if="showLogout">
206
-      <a @click="logout()">Logout</a>
207
-    </span>
208
-    <span v-else></span>
209 221
   </nav>
210 222
 </template>
211 223
 
@@ -220,6 +232,9 @@ export default {
220 232
     showLogout() {
221 233
       return this.$store.state.authentication.status === 'success';
222 234
     },
235
+    hideLogin() {
236
+      return this.$store.state.authentication.status !== 'success';
237
+    },
223 238
     Logout() {
224 239
       return this.$store.state.authentication.methods.logout;
225 240
     },

+ 10
- 2
src/components/user/loginPage.vue Bestand weergeven

@@ -8,6 +8,11 @@
8 8
             <h4>Login</h4>
9 9
             <br />
10 10
           </div>
11
+          <!-- <alert :text="'Login successful'" :type="'SUCCESS'" />
12
+          <alert :text="'User does not exist, please register'" :type="'ERROR'" />
13
+          <alert :text="'Username is incorrect'" :type="'WARNING'" />
14
+          <alert :text="'Password is incorrect'" :type="'WARNING'" />
15
+          <alert :text="'Caps Lock is on'" :type="'INFO'" />-->
11 16
           <div class="row">
12 17
             <div class="col-md-11" style="margin-bottom: 1em">
13 18
               <div class="input-group mb-3">
@@ -76,6 +81,7 @@
76 81
         <div class="form">
77 82
           <h5>Trouble signing in?</h5>
78 83
           <div>
84
+            <!-- <alert :text="'Username & password request email sent'" :type="'SUCCESS'" /> -->
79 85
             <div class="row">
80 86
               <div class="input-group-prepend">
81 87
                 <span class="input-group-text">
@@ -97,11 +103,13 @@
97 103
 
98 104
 <script>
99 105
 import { mapActions, mapState } from 'vuex';
100
-// import axios from 'axios';
101
-// import User from '../../assets/Log';
106
+import alert from '../shared/alert.vue';
102 107
 
103 108
 export default {
104 109
   name: 'Login',
110
+  components: {
111
+    alert,
112
+  },
105 113
   data() {
106 114
     return {
107 115
       username: '',

+ 1
- 1
vue.config.js Bestand weergeven

@@ -2,7 +2,7 @@ module.exports = {
2 2
   devServer: {
3 3
     proxy: {
4 4
       '/api': {
5
-        target: 'http://192.168.6.188:5000',
5
+        target: 'http://localhost:57260',
6 6
         changeOrigin: true,
7 7
       },
8 8
     },

Laden…
Annuleren
Opslaan