Browse Source

Merge issues

master
Kobus 5 years ago
parent
commit
8ceb70efe7

+ 13
- 0
package-lock.json View File

@@ -2413,6 +2413,11 @@
2413 2413
       "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=",
2414 2414
       "dev": true
2415 2415
     },
2416
+    "browser-downloads": {
2417
+      "version": "0.2.0",
2418
+      "resolved": "https://registry.npmjs.org/browser-downloads/-/browser-downloads-0.2.0.tgz",
2419
+      "integrity": "sha512-0tQntpixIPo8ZuOufMjPbZIp2jZMvCUz00rCiaf/T3LzLxcbt6j0r6Ef8Ao3lNP3bYh/ibLoWVoLCJ7SCvxrSA=="
2420
+    },
2416 2421
     "browserify-aes": {
2417 2422
       "version": "1.2.0",
2418 2423
       "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
@@ -11821,6 +11826,14 @@
11821 11826
         "vue": "^2.5.17"
11822 11827
       }
11823 11828
     },
11829
+    "vue-excel-export": {
11830
+      "version": "0.1.3",
11831
+      "resolved": "https://registry.npmjs.org/vue-excel-export/-/vue-excel-export-0.1.3.tgz",
11832
+      "integrity": "sha512-vjCKrVocZ9Q4Y1BJsuDiLR9E9x97vHY+ew7oSigxg7WDh6AsTbH5v4TFpCD65WwYy2jt1tQU6fsAIpKjVOXibw==",
11833
+      "requires": {
11834
+        "browser-downloads": "^0.2.0"
11835
+      }
11836
+    },
11824 11837
     "vue-hot-reload-api": {
11825 11838
       "version": "2.3.3",
11826 11839
       "resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.3.tgz",

+ 1
- 0
package.json View File

@@ -25,6 +25,7 @@
25 25
     "v-file-upload": "^3.1.7",
26 26
     "vue": "^2.6.10",
27 27
     "vue-eva-icons": "^1.1.1",
28
+    "vue-excel-export": "^0.1.3",
28 29
     "vue-router": "^3.0.7",
29 30
     "vue-trix": "^1.0.0",
30 31
     "vuetify": "^1.5.5",

BIN
public/img/Commercial-Property.jpg View File


+ 62
- 23
src/components/admin/logs/SearchLogs.vue View File

@@ -2,7 +2,6 @@
2 2
   <!-- eslint-disable max-len -->
3 3
   <div>
4 4
     <div class="container">
5
-      <!-- <section class="intro-single"> -->
6 5
       <div class="container">
7 6
         <br />
8 7
         <br />
@@ -16,7 +15,45 @@
16 15
           </div>
17 16
         </div>
18 17
       </div>
19
-      <!-- </section> -->
18
+    </div>
19
+    <div class="container">
20
+      <div class="form-group row">
21
+        <div class="col-md-1">
22
+          <label>Filter</label>
23
+        </div>
24
+        <div class="col-md-3">
25
+          <select class="form-control" name="fields" id="fields" v-model="filter.by">
26
+            <option v-for="(item, i) in fields" :key="i">{{item}}</option>
27
+          </select>
28
+        </div>
29
+        <div class="col-md-8 text-left">
30
+          <div class="input-group mb-8">
31
+            <input class="form-control" type="text" @change="filter()" v-model="filter.value" />
32
+            <div class="input-group-append" @click="clearFilter()">
33
+              <span class="input-group-text cursor-pointer" style="color: #60CBEB">
34
+                <b>X</b>
35
+              </span>
36
+            </div>
37
+          </div>
38
+        </div>
39
+      </div>
40
+    </div>
41
+    <div class="container">
42
+      <div class="form-group row">
43
+        <div class="col-md-12" align="right">
44
+          <export-excel
45
+            class="btn btn-b-n"
46
+            :data="list"
47
+            :fields="exportFields"
48
+            type="csv"
49
+            worksheet="My Worksheet"
50
+            name="SearchLog.csv"
51
+          >
52
+            Download
53
+            <eva-icon name="download"></eva-icon>
54
+          </export-excel>
55
+        </div>
56
+      </div>
20 57
     </div>
21 58
     <div class="container">
22 59
       <table class="table table-bordered">
@@ -25,28 +62,19 @@
25 62
             <th>Date</th>
26 63
             <th>Time</th>
27 64
             <th>User</th>
28
-            <th>Keyword</th>
29
-            <th>Sales Type</th>
30
-            <th>Property Usage Type</th>
31
-            <th>Property Type</th>
32
-            <th>Province</th>
33
-            <th>City</th>
34
-            <th>Suburb</th>
65
+            <th>Type</th>
66
+            <th>Field</th>
67
+            <th>Value</th>
35 68
           </tr>
36 69
         </thead>
37 70
         <tbody>
38
-          <tr v-for="(item, i) in propertySearch" :key="i">
71
+          <tr v-for="(item, i) in list" :key="i">
39 72
             <td>{{ formatDate(item.date) }}</td>
40 73
             <td>{{ formatTime(item.date) }}</td>
41
-            <td v-if="item.user">{{ item.user }}</td>
42
-            <td v-else>No User</td>
43
-            <td>{{ item.keyword === 'All' ? '' : item.keyword }}</td>
44
-            <td>{{ item.salesType === 'All' ? '' : item.salesType }}</td>
45
-            <td>{{ item.propertyUsageType === 'All' ? '' : item.propertyUsageType }}</td>
46
-            <td>{{ item.propertyType === 'All' ? '' : item.propertyType }}</td>
47
-            <td>{{ item.province === 'All' ? '' : item.province }}</td>
48
-            <td>{{ item.city === 'All' ? '' : item.city }}</td>
49
-            <td>{{ item.suburb === 'All' ? '' : item.suburb }}</td>
74
+            <td>{{ item.userName }}</td>
75
+            <td>{{ item.type }}</td>
76
+            <td>{{ item.property }}</td>
77
+            <td>{{ item.value }}</td>
50 78
           </tr>
51 79
         </tbody>
52 80
       </table>
@@ -56,16 +84,24 @@
56 84
 </template>
57 85
 
58 86
 <script>
59
-import { mapState, mapActions } from 'vuex';
87
+import { mapState, mapActions, mapGetters } from 'vuex';
60 88
 import moment from 'moment';
61 89
 
62 90
 export default {
63 91
   name: 'searchLog',
64 92
   data() {
65
-    return {};
93
+    return {
94
+      exportFields: {
95
+        Date: 'date',
96
+        User: 'userName',
97
+        Type: 'type',
98
+        Field: 'property',
99
+        Value: 'value',
100
+      },
101
+    };
66 102
   },
67 103
   methods: {
68
-    ...mapActions('searchLog', ['getPropertySearchLogs']),
104
+    ...mapActions('searchLog', ['getPropertySearchLogs', 'clearFilter']),
69 105
     formatDate(value) {
70 106
       return moment(String(value)).format('YYYY/MM/DD');
71 107
     },
@@ -77,7 +113,10 @@ export default {
77 113
     this.getPropertySearchLogs();
78 114
   },
79 115
   computed: {
80
-    ...mapState('searchLog', ['propertySearch']),
116
+    ...mapState('searchLog', ['list', 'fields', 'filter']),
117
+    ...mapGetters({
118
+      list: 'searchLog/filterList',
119
+    }),
81 120
   },
82 121
 };
83 122
 </script>

+ 59
- 8
src/components/property/propertySearchFields.vue View File

@@ -10,7 +10,7 @@
10 10
             </span>
11 11
           </div>
12 12
           <select
13
-            class="form-control form-control-lg form-control-a"
13
+            class="form-control"
14 14
             id="forSelector"
15 15
             v-model="propertySearch.salesType"
16 16
             @change="salesTypeSelected"
@@ -29,7 +29,7 @@
29 29
             </span>
30 30
           </div>
31 31
           <select
32
-            class="form-control form-control-lg form-control-a"
32
+            class="form-control"
33 33
             id="forSelector"
34 34
             v-model="resType"
35 35
             @change="PropertyTypeSelected"
@@ -56,7 +56,7 @@
56 56
             </span>
57 57
           </div>
58 58
           <select
59
-            class="form-control form-control-lg form-control-a"
59
+            class="form-control"
60 60
             id="forSelector"
61 61
             v-model="comType"
62 62
             @change="PropertyTypeSelected"
@@ -83,7 +83,7 @@
83 83
             </span>
84 84
           </div>
85 85
           <select
86
-            class="form-control form-control-lg form-control-a"
86
+            class="form-control"
87 87
             id="provinceselector"
88 88
             @change="ProvinceSelected"
89 89
             v-model="propertySearch.province"
@@ -109,7 +109,7 @@
109 109
             </span>
110 110
           </div>
111 111
           <select
112
-            class="form-control form-control-lg form-control-a"
112
+            class="form-control"
113 113
             id="cityselector"
114 114
             @change="CitySelected"
115 115
             v-model="propertySearch.city"
@@ -135,7 +135,7 @@
135 135
             </span>
136 136
           </div>
137 137
           <select
138
-            class="form-control form-control-lg form-control-a"
138
+            class="form-control"
139 139
             id="suburbselector"
140 140
             v-model="propertySearch.suburb"
141 141
             @change="SuburbSeleted"
@@ -151,6 +151,58 @@
151 151
         </div>
152 152
       </div>
153 153
     </div>
154
+    <div class="container text-left">
155
+      <div class="form-group">
156
+        <div class="row">
157
+          <div class="col-md-6 text-left">
158
+            <label>Minimum Price</label>
159
+            <div class="input-group mb-3">
160
+              <div class="input-group-prepend">
161
+                <span class="input-group-text" style="color: #60CBEB">
162
+                  <b>R</b>
163
+                </span>
164
+              </div>
165
+              <input
166
+                class="form-control"
167
+                type="number"
168
+                step="any"
169
+                id="minPrice"
170
+                name="minPrice"
171
+                v-model="propertySearch.minPrice"
172
+              />
173
+              <div class="input-group-append" @click="clearFilter('minPrice')">
174
+                <span class="input-group-text cursor-pointer" style="color: #60CBEB">
175
+                  <b>X</b>
176
+                </span>
177
+              </div>
178
+            </div>
179
+          </div>
180
+          <div class="col-md-6 text-left">
181
+            <label>Maximum Price</label>
182
+            <div class="input-group mb-3">
183
+              <div class="input-group-prepend">
184
+                <span class="input-group-text" style="color: #60CBEB">
185
+                  <b>R</b>
186
+                </span>
187
+              </div>
188
+              <input
189
+                class="form-control"
190
+                type="number"
191
+                step="any"
192
+                id="maxPrice"
193
+                name="maxPrice"
194
+                v-model="propertySearch.maxPrice"
195
+              />
196
+              <div class="input-group-append" @click="clearFilter('maxPrice')">
197
+                <span class="input-group-text cursor-pointer" style="color: #60CBEB">
198
+                  <b>X</b>
199
+                </span>
200
+              </div>
201
+            </div>
202
+          </div>
203
+        </div>
204
+      </div>
205
+    </div>
154 206
   </div>
155 207
 </template>
156 208
 
@@ -171,7 +223,6 @@ export default {
171 223
     this.getProvince();
172 224
     this.getPropertyTypesRes();
173 225
     this.getPropertyTypesCom();
174
-    this.getPropertySearchObject();
175 226
     setTimeout(() => {
176 227
       this.propertySearch.propertyUsageType = this.propertyType;
177 228
     }, 100);
@@ -184,7 +235,7 @@ export default {
184 235
   methods: {
185 236
     ...mapActions('searchTab', ['getProvince', 'getCities', 'getSuburbs']),
186 237
     ...mapActions('property', ['getPropertyTypesRes', 'getPropertyTypesCom']),
187
-    ...mapActions('propertySearch', ['getPropertySearchObject', 'clearFilter']),
238
+    ...mapActions('propertySearch', ['clearFilter']),
188 239
     clearResType() {
189 240
       this.clearFilter('propertyType');
190 241
       this.resType = 'All';

+ 7
- 22
src/components/property/propertySearchPage.vue View File

@@ -145,23 +145,16 @@ export default {
145 145
   },
146 146
   data() {
147 147
     return {
148
-      type: '',
149
-      propertyType: '',
150
-      propertyTypeparam: '',
151
-      province: '',
152
-      city: '',
153
-      suburb: '',
154
-      proptype: '',
155
-      keyword: '',
156 148
       propertySearch: {
157
-        userID: 0,
158
-        keyword: '',
149
+        userName: '',
159 150
         salesType: 'All',
160 151
         propertyUsageType: 'All',
161 152
         propertyType: 'All',
162 153
         province: 'All',
163 154
         city: 'All',
164 155
         suburb: 'All',
156
+        minPrice: 0,
157
+        maxPrice: 0,
165 158
       },
166 159
     };
167 160
   },
@@ -171,22 +164,14 @@ export default {
171 164
   computed: {
172 165
     ...mapState('propertySearch', ['properties']),
173 166
     ParamsChanged() {
174
-      // eslint-disable-next-line vue/no-side-effects-in-computed-properties
175
-      this.propertySearch = {
176
-        userID: 0,
177
-        keyword: '',
178
-        salesType: 'All',
179
-        propertyUsageType: 'All',
180
-        propertyType: 'All',
181
-        province: 'All',
182
-        city: 'All',
183
-        suburb: 'All',
184
-      };
185
-
186 167
       if (Object.keys(this.$route.params).length > 0) {
187 168
         if (this.$route.params.propertyUsageType) {
188 169
           // eslint-disable-next-line vue/no-side-effects-in-computed-properties
189 170
           this.propertySearch.propertyUsageType = this.$route.params.propertyUsageType;
171
+          // eslint-disable-next-line vue/no-side-effects-in-computed-properties
172
+          this.propertySearch.keyword = 'All';
173
+          // eslint-disable-next-line vue/no-side-effects-in-computed-properties
174
+          this.propertySearch.salesType = 'All';
190 175
         }
191 176
       }
192 177
       if (Object.keys(this.$route.query).length > 0) {

+ 14
- 6
src/components/property/propertyeditPage.vue View File

@@ -5,6 +5,14 @@
5 5
       <div class="col-sm-12">
6 6
         <div class="tobuy-img-box">
7 7
           <img
8
+            v-if="propertyType === 'Commercial'"
9
+            src="img/Commercial-Property.jpg"
10
+            alt="Timeshare To Buy"
11
+            class="img-fluid"
12
+            style="width:800px;height:400px; border-radius:10px"
13
+          />
14
+          <img
15
+            v-else
8 16
             src="img/Listing3.2.jpg"
9 17
             alt="Timeshare To Buy"
10 18
             class="img-fluid"
@@ -355,12 +363,12 @@ export default {
355 363
 
356 364
       setTimeout(
357 365
         () => this.$router.push({
358
-          path: '/property/search',
359
-          query: {
360
-            salesType: this.salesType,
361
-            propertyUsageType: this.propertyType,
362
-          },
363
-        }),
366
+            path: '/property/search',
367
+            query: {
368
+              salesType: this.salesType,
369
+              propertyUsageType: this.propertyType,
370
+            },
371
+          }),
364 372
         3000,
365 373
       );
366 374
     },

+ 16
- 8
src/components/shared/navBar.vue View File

@@ -185,10 +185,9 @@
185 185
                 <a class="dropdown-item cursor-pointer" @click="routerGoTo('/Offers')">Offers</a>
186 186
               </div>
187 187
             </li>
188
-            <li class="nav-item dropdown">
188
+            <li class="nav-item dropdown" v-if="hideLogin">
189 189
               <a
190 190
                 class="nav-link"
191
-                v-if="hideLogin"
192 191
                 @click="routerGoTo('/user/login')"
193 192
                 id="navbarDropdown"
194 193
                 role="button"
@@ -197,15 +196,19 @@
197 196
                 aria-expanded="false"
198 197
               >Login</a>
199 198
             </li>
200
-            <li class="nav-item dropdown">
201
-              <span v-if="showLogout">
202
-                <a class="nav-link" @click="logout()">Logout</a>
199
+            <li class="nav-item dropdown" v-if="showLogout">
200
+              <span>
201
+                <a class="nav-link" @click="logout(routerGoTo('/user/login'))">Logout</a>
203 202
               </span>
204
-              <span v-else></span>
203
+              <!-- <span v-else></span> -->
205 204
             </li>
206 205
             <li>
207 206
               <span v-if="showLogout">
208
-                <a>Welcome! {{ }}</a>
207
+                <a>
208
+                  Welcome!
209
+                  <br />
210
+                  {{ username }}
211
+                </a>
209 212
               </span>
210 213
               <span v-else></span>
211 214
             </li>
@@ -232,15 +235,20 @@ import { mapGetters, mapActions } from 'vuex';
232 235
 
233 236
 export default {
234 237
   data() {
235
-    return {};
238
+    return {
239
+      username: sessionStorage.getItem('name'),
240
+    };
236 241
   },
237 242
   computed: {
238 243
     showLogout() {
244
+      // eslint-disable-next-line vue/no-side-effects-in-computed-properties
245
+      this.username = sessionStorage.getItem('name');
239 246
       return this.$store.state.authentication.status === 'success';
240 247
     },
241 248
     hideLogin() {
242 249
       return this.$store.state.authentication.status !== 'success';
243 250
     },
251
+    // eslint-disable-next-line vue/return-in-computed-property
244 252
     Logout() {
245 253
       return this.$store.state.authentication.methods.logout;
246 254
     },

+ 9
- 6
src/components/shared/searchTab.vue View File

@@ -13,9 +13,9 @@
13 13
               <label for="Type">Keyword</label>
14 14
               <input
15 15
                 type="text"
16
-                class="form-control form-control-a"
16
+                class="form-control"
17 17
                 placeholder="Keyword"
18
-                v-model="filter.keyword"
18
+                v-model="propertySearch.keyword"
19 19
               />
20 20
             </div>
21 21
           </div>
@@ -81,7 +81,7 @@
81 81
                 role="tabpanel"
82 82
                 aria-labelledby="pills-map-tab"
83 83
               >
84
-                <propertySearch propertyType="Commercial" />
84
+                <propertySearch propertyType="Commercial" @updateSearch="updateSearch" />
85 85
               </div>
86 86
             </div>
87 87
           </div>
@@ -95,7 +95,7 @@
95 95
 </template>
96 96
 
97 97
 <script>
98
-import { mapState, mapActions } from 'vuex';
98
+import { mapState } from 'vuex';
99 99
 import propertySearch from '../property/propertySearchFields.vue';
100 100
 import timeshareSearch from '../timeshare/searchTimeshare.vue';
101 101
 
@@ -108,13 +108,16 @@ export default {
108 108
     return {
109 109
       selectedPropertyType: 'timeshare',
110 110
       propertySearch: {
111
-        userID: 0,
111
+        keyword: '',
112
+        userName: '',
112 113
         salesType: 'Sale',
113 114
         propertyUsageType: 'All',
114 115
         propertyType: 'All',
115 116
         province: 'All',
116 117
         city: 'All',
117 118
         suburb: 'All',
119
+        minPrice: 0,
120
+        maxPrice: 0,
118 121
       },
119 122
     };
120 123
   },
@@ -134,11 +137,11 @@ export default {
134 137
       if (this.selectedPropertyType === 'timeshare') {
135 138
         this.$router.push('/timeshare/search/');
136 139
       } else {
140
+        // this.$router.push('/property/search');
137 141
         this.$router.push({
138 142
           path: '/property/search',
139 143
           query: this.propertySearch,
140 144
         });
141
-        // this.$router.push('/property/search');
142 145
       }
143 146
     },
144 147
   },

+ 0
- 1
src/components/timeshare/sell/sellPage.vue View File

@@ -314,7 +314,6 @@
314 314
             <BankDetails :bankingDetails="sellItem.owner.bankingDetails" />
315 315
             <hr />
316 316
           </div>
317
-          <hr />
318 317
           <br />
319 318
           <div class="myWell">
320 319
             <h4>Share transfer information</h4>

+ 1
- 1
src/components/user/logOut.vue View File

@@ -11,7 +11,7 @@ export default {
11 11
     ...mapActions('authentication', ['logout']),
12 12
     Logout() {
13 13
       this.logout('logout').then(() => {
14
-        this.$router.push('/users/login');
14
+        this.$router.push('/user/login');
15 15
       });
16 16
     },
17 17
   },

+ 2
- 2
src/components/user/loginPage.vue View File

@@ -8,7 +8,7 @@
8 8
             <h4>Login</h4>
9 9
             <br />
10 10
           </div>
11
-          <!-- <alert :text="'Login successful'" :type="'SUCCESS'" />
11
+          <!--<alert :text="'Login successful'" :type="'SUCCESS'" />
12 12
           <alert :text="'User does not exist, please register'" :type="'ERROR'" />
13 13
           <alert :text="'Username is incorrect'" :type="'WARNING'" />
14 14
           <alert :text="'Password is incorrect'" :type="'WARNING'" />
@@ -81,7 +81,7 @@
81 81
         <div class="form">
82 82
           <h5>Trouble signing in?</h5>
83 83
           <div>
84
-            <!-- <alert :text="'Username & password request email sent'" :type="'SUCCESS'" /> -->
84
+            <!--<alert :text="'Username & password request email sent'" :type="'SUCCESS'" />-->
85 85
             <div class="row">
86 86
               <div class="input-group-prepend">
87 87
                 <span class="input-group-text">

+ 10
- 2
src/components/user/registerAgencySection.vue View File

@@ -200,7 +200,11 @@
200 200
               <button @click="SubmitData()" class="btn btn-b-n" type="button">Submit</button>
201 201
             </div>
202 202
             <div class="col-md-2 offset-md-1">
203
-              <button @click="Cancel()" class="btn btn-b-n" type="button">Cancel</button>
203
+              <button
204
+                @click="Close(routerGoTo('/user/login'))"
205
+                class="btn btn-b-n"
206
+                type="button"
207
+              >Cancel</button>
204 208
             </div>
205 209
           </div>
206 210
         </div>
@@ -244,6 +248,10 @@ export default {
244 248
       'clearAgency',
245 249
     ]),
246 250
 
251
+    routerGoTo(goTo) {
252
+      this.$emit('routerGoTo', goTo);
253
+    },
254
+
247 255
     togglePassword() {
248 256
       this.showPassword = true;
249 257
       this.isPasswordShown = 'text';
@@ -257,7 +265,7 @@ export default {
257 265
       this.$router.push('/user/login');
258 266
     },
259 267
     Close() {
260
-      this.$router.push('/registerAgency/');
268
+      this.$router.push('/user/login');
261 269
     },
262 270
   },
263 271
 };

+ 10
- 2
src/components/user/registerPage.vue View File

@@ -146,7 +146,11 @@
146 146
               <button @click="SubmitData()" class="btn btn-b-n" type="submit">Submit</button>
147 147
             </div>
148 148
             <div class="col-md-2 offset-md-1">
149
-              <button @click="Cancel()" class="btn btn-b-n" type="submit">Cancel</button>
149
+              <button
150
+                @click="Close(routerGoTo('/user/login'))"
151
+                class="btn btn-b-n"
152
+                type="submit"
153
+              >Cancel</button>
150 154
             </div>
151 155
           </div>
152 156
         </div>
@@ -192,6 +196,10 @@ export default {
192 196
       'clearIndividual',
193 197
     ]),
194 198
 
199
+    routerGoTo(goTo) {
200
+      this.$emit('routerGoTo', goTo);
201
+    },
202
+
195 203
     togglePassword() {
196 204
       this.showPassword = true;
197 205
       this.isPasswordShown = 'text';
@@ -206,7 +214,7 @@ export default {
206 214
       this.$router.push('/user/login');
207 215
     },
208 216
     Close() {
209
-      this.$router.push('/registerIndividual/');
217
+      this.$router.push('/user/login');
210 218
     },
211 219
   },
212 220
 };

+ 2
- 1
src/router/index.js View File

@@ -52,7 +52,8 @@ export default new Router({
52 52
       y: 0,
53 53
     };
54 54
   },
55
-  routes: [{
55
+  routes: [
56
+    {
56 57
       path: '/',
57 58
       name: 'Home',
58 59
       component: HomePage,

+ 46
- 6
src/store/modules/logs/searchLog.js View File

@@ -1,24 +1,64 @@
1
-// api/searchLog/property
2 1
 import axios from 'axios';
2
+import _ from 'lodash';
3 3
 
4 4
 export default {
5 5
   namespaced: true,
6 6
   state: {
7
-    propertySearch: {},
7
+    list: [],
8
+    fields: [],
9
+    filter: {
10
+      by: undefined,
11
+      value: undefined,
12
+    },
8 13
   },
9 14
   mutations: {
10 15
     updateSearch(state, data) {
11
-      state.propertySearch = [];
12
-      state.propertySearch = data;
16
+      state.list = [];
17
+      state.fields = [];
18
+      state.list = data;
19
+      data.forEach((item) => {
20
+        state.fields.push(item.property);
21
+      });
22
+      state.fields = state.fields.filter((x, i, a) => a.indexOf(x) === i);
23
+    },
24
+    onClearFilter(state) {
25
+      state.filter = {
26
+        by: undefined,
27
+        value: undefined,
28
+      };
29
+    },
30
+  },
31
+  getters: {
32
+    filterList: (state) => {
33
+      let lst = state.list;
34
+      const { filter } = state;
35
+      if (filter) {
36
+        if (filter.by) {
37
+          lst = _.filter(lst, x => x.property === filter.by);
38
+          if (filter.value) {
39
+            lst = _.filter(lst, x => x.value.toUpperCase().includes(filter.value.toUpperCase()));
40
+          }
41
+        } else if (filter.value) {
42
+          lst = _.filter(
43
+            lst,
44
+            x => x.value.toUpperCase().includes(filter.value.toUpperCase())
45
+              || x.userName.toUpperCase().includes(filter.value.toUpperCase())
46
+              || x.type.toUpperCase().includes(filter.value.toUpperCase()),
47
+          );
48
+        }
49
+      }
50
+      return lst;
13 51
     },
14 52
   },
15
-  getters: {},
16 53
   actions: {
17 54
     getPropertySearchLogs({ commit }) {
18 55
       axios
19
-        .get('/api/searchLog/property')
56
+        .get('/api/searchLog')
20 57
         .then(result => commit('updateSearch', result.data))
21 58
         .catch(console.error);
22 59
     },
60
+    clearFilter({ commit }) {
61
+      commit('onClearFilter');
62
+    },
23 63
   },
24 64
 };

+ 69
- 6
src/store/modules/property/propertySearch.js View File

@@ -1,17 +1,21 @@
1
+/* eslint-disable max-len */
2
+/* eslint-disable indent */
1 3
 import axios from 'axios';
4
+import _ from 'lodash';
2 5
 
3 6
 export default {
4 7
   namespaced: true,
5 8
   state: {
6 9
     propertySearch: {
7
-      userID: 0,
8
-      keyword: '',
10
+      userName: '',
9 11
       salesType: 'Sale',
10 12
       propertyUsageType: 'All',
11 13
       propertyType: 'All',
12 14
       province: 'All',
13 15
       city: 'All',
14 16
       suburb: 'All',
17
+      minPrice: 0,
18
+      maxPrice: 0,
15 19
     },
16 20
     properties: [],
17 21
     latestProperties: [],
@@ -31,21 +35,77 @@ export default {
31 35
       state.propertySearch[filter] = 'All';
32 36
     },
33 37
   },
34
-  getters: {},
38
+  // getters: {
39
+  //   filterProperties: (state) => {
40
+  //     let list = state.properties;
41
+  //     const { propertySearch } = state;
42
+  //     if (propertySearch) {
43
+  //       if (propertySearch.salesType === 'Sale') {
44
+  //         list = _.filter(list, x => x.isSale);
45
+  //       } else {
46
+  //         list = _.filter(list, x => !x.isSale);
47
+  //       }
48
+  //       if (propertySearch.propertyUsageType && propertySearch.propertyUsageType !== 'All') {
49
+  //         list = _.filter(list, x => x.propertyUsageType
50
+  //             .toUpperCase()
51
+  //             // eslint-disable-next-line comma-dangle
52
+  //             .includes(propertySearch.propertyUsageType.toUpperCase()));
53
+  //       }
54
+  //       if (propertySearch.propertyType && propertySearch.propertyType !== 'All') {
55
+  //         list = _.filter(list, x => x.propertyType
56
+  //             .toUpperCase()
57
+  //             // eslint-disable-next-line comma-dangle
58
+  //             .includes(propertySearch.propertyType.toUpperCase()));
59
+  //       }
60
+  //       if (propertySearch.province && propertySearch.province !== 'All') {
61
+  //         list = _.filter(list, x => x.province
62
+  //             .toUpperCase()
63
+  //             // eslint-disable-next-line comma-dangle
64
+  //             .includes(propertySearch.province.toUpperCase()));
65
+  //       }
66
+  //       if (propertySearch.city && propertySearch.city !== 'All') {
67
+  //         list = _.filter(list, x => x.city
68
+  //             .toUpperCase()
69
+  //             // eslint-disable-next-line comma-dangle
70
+  //             .includes(propertySearch.city.toUpperCase()));
71
+  //       }
72
+  //       if (propertySearch.suburb && propertySearch.suburb !== 'All') {
73
+  //         list = _.filter(list, x => x.suburb
74
+  //             .toUpperCase()
75
+  //             // eslint-disable-next-line comma-dangle
76
+  //             .includes(propertySearch.suburb.toUpperCase()));
77
+  //       }
78
+  //       if (propertySearch.suburb && propertySearch.suburb !== 'All') {
79
+  //         list = _.filter(list, x => x.suburb
80
+  //             .toUpperCase()
81
+  //             // eslint-disable-next-line comma-dangle
82
+  //             .includes(propertySearch.suburb.toUpperCase()));
83
+  //       }
84
+  //       if (propertySearch.minPrice) {
85
+  //         list = _.filter(list, x => x.price >= propertySearch.minPrice);
86
+  //       }
87
+  //       if (propertySearch.maxPrice) {
88
+  //         list = _.filter(list, x => x.price <= propertySearch.maxPrice);
89
+  //       }
90
+  //     }
91
+  //     return list;
92
+  //   },
93
+  // },
35 94
   actions: {
36 95
     clearFilter({ commit }, filter) {
37 96
       commit('onClearFilter', filter);
38 97
     },
39 98
     getPropertySearchObject({ commit }) {
40 99
       const search = {
41
-        userID: 0,
42
-        keyword: 'All',
100
+        userName: '',
43 101
         salesType: 'Sale',
44 102
         propertyUsageType: 'All',
45 103
         propertyType: 'All',
46 104
         province: 'All',
47 105
         city: 'All',
48 106
         suburb: 'All',
107
+        minPrice: 0,
108
+        maxPrice: 0,
49 109
       };
50 110
       commit('setPropertySearch', search);
51 111
     },
@@ -53,9 +113,12 @@ export default {
53 113
       if (item.keyword === '') {
54 114
         item.keyword = 'All';
55 115
       }
116
+      if (item.userName === '') {
117
+        item.userName = 'Unknown';
118
+      }
56 119
       axios
57 120
         .get(
58
-          `/api/Property/Search/${item.userID}/${item.keyword}/${item.salesType}/${item.propertyUsageType}/${item.propertyType}/${item.province}/${item.city}/${item.suburb}`,
121
+          `/api/Property/Search/${item.userName}/${item.keyword}/${item.salesType}/${item.propertyUsageType}/${item.propertyType}/${item.province}/${item.city}/${item.suburb}/${item.minPrice}/${item.maxPrice}`,
59 122
         )
60 123
         .then(result => commit('updateSearch', result.data))
61 124
         .catch(console.error);

+ 13
- 10
src/store/modules/user/authentication.js View File

@@ -7,8 +7,9 @@ export default {
7 7
   namespaced: true,
8 8
   state: {
9 9
     status: '',
10
-    token: localStorage.getItem('token') || '',
10
+    token: sessionStorage.getItem('token') || '',
11 11
     user: {},
12
+    individual: {},
12 13
   },
13 14
   mutations: {
14 15
     auth_request(state) {
@@ -32,9 +33,7 @@ export default {
32 33
     authStatus: state => state.status,
33 34
   },
34 35
   actions: {
35
-    login({
36
-      commit,
37
-    }, user) {
36
+    login({ commit }, user) {
38 37
       return new Promise((reject) => {
39 38
         commit('auth_request');
40 39
         axios({
@@ -44,22 +43,26 @@ export default {
44 43
         })
45 44
           .then((resp) => {
46 45
             console.log(resp.data);
47
-            localStorage.setItem('token', resp.data.token);
46
+            sessionStorage.setItem('token', resp.data.token);
47
+            sessionStorage.setItem('username', resp.data.username);
48
+            sessionStorage.setItem('name', resp.data.name);
48 49
             commit('auth_success', resp.data.token, resp.data);
49 50
           })
50 51
           .catch((err) => {
51 52
             commit('auth_error');
52
-            localStorage.removeItem('token');
53
+            sessionStorage.removeItem('token');
54
+            sessionStorage.removeItem('username');
55
+            sessionStorage.removeItem('name');
53 56
             reject(err);
54 57
           });
55 58
       });
56 59
     },
57
-    logout({
58
-      commit,
59
-    }) {
60
+    logout({ commit }) {
60 61
       return new Promise(() => {
61 62
         commit('logout');
62
-        localStorage.removeItem('token');
63
+        sessionStorage.removeItem('token');
64
+        sessionStorage.removeItem('username');
65
+        sessionStorage.removeItem('name');
63 66
         delete axios.defaults.headers.common.Authorization;
64 67
       });
65 68
     },

+ 1
- 1
vue.config.js View File

@@ -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
     },

Loading…
Cancel
Save