Pārlūkot izejas kodu

Timeshare to buy search fix

master
George Williams 4 gadus atpakaļ
vecāks
revīzija
03d6cc69c3

+ 76
- 0
src/components/shared/addressAutoComplete.vue Parādīt failu

@@ -0,0 +1,76 @@
1
+<template>
2
+  <div>
3
+    <gmap-autocomplete class="form-control" @place_changed="setPlace"></gmap-autocomplete>
4
+  </div>
5
+</template>
6
+
7
+<script>
8
+export default {
9
+  name: "AddressAutoComplete",
10
+  props: {
11
+    placeholder: {
12
+      default: "ENTER LOCATION"
13
+    }
14
+  },
15
+  data() {
16
+    return {
17
+      streetNumber: "",
18
+      streetName: "",
19
+      suburb: "",
20
+      city: "",
21
+      province: "",
22
+      country: "",
23
+      postalCode: "",
24
+      url: ""
25
+    };
26
+  },
27
+  methods: {
28
+    setPlace(place) {
29
+      this.streetNumber = "";
30
+      this.streetName = "";
31
+      this.suburb = "";
32
+      this.city = "";
33
+      this.province = "";
34
+      this.country = "";
35
+      this.postalCode = "";
36
+      this.url = "";
37
+
38
+      for (let i = 0; i < place.address_components.length; i++) {
39
+        if (place.address_components[i].types[0] === "street_number") {
40
+          this.streetNumber = place.address_components[i].long_name;
41
+        }
42
+        if (place.address_components[i].types[0] === "route") {
43
+          this.streetName = place.address_components[i].long_name;
44
+        }
45
+        if (place.address_components[i].types[0] === "sublocality_level_1") {
46
+          this.suburb = place.address_components[i].long_name;
47
+        }
48
+        if (place.address_components[i].types[0] === "locality") {
49
+          this.city = place.address_components[i].long_name;
50
+        }
51
+        if (place.address_components[i].types[0] === "administrative_area_level_1") {
52
+          this.province = place.address_components[i].long_name;
53
+        }
54
+        if (place.address_components[i].types[0] === "country") {
55
+          this.country = place.address_components[i].long_name;
56
+        }
57
+        if (place.address_components[i].types[0] === "postal_code") {
58
+          this.postalCode = place.address_components[i].long_name;
59
+        }
60
+        this.url = place.url;
61
+
62
+        this.$emit("GoogleAddress", {
63
+          streetNumber: this.streetNumber,
64
+          streetName: this.streetName,
65
+          suburb: this.suburb,
66
+          city: this.city,
67
+          province: this.province,
68
+          country: this.country,
69
+          postalCode: this.postalCode,
70
+          url: this.url
71
+        });
72
+      }
73
+    }
74
+  }
75
+};
76
+</script>

+ 125
- 41
src/components/timeshare/buy/carouselSection.vue Parādīt failu

@@ -11,47 +11,68 @@
11 11
             </p>
12 12
             <div class="row">
13 13
               <div class="form-group col-md-6">
14
+                <div class="input-group">
15
+                  <label v-if="!searchParams.region" class="uniSelectLabel" for="region">REGION</label>
16
+                  <select
17
+                    class="form-control uniSelect"
18
+                    name="region"
19
+                    id="region"
20
+                    v-model="searchParams.region"
21
+                    @change="regionChange"
22
+                  >
23
+                    <option v-for="(region, r) in regions" :key="r">{{ region.regionName }}</option>
24
+                  </select>
25
+                </div>
26
+                <br />
27
+                <label>DATE FROM</label>
14 28
                 <input
15
-                  data-toggle="dropdown"
16
-                  name="region"
17
-                  class="form-control my-2"
18
-                  id="name"
19
-                  placeholder="Resort"
20
-                  aria-haspopup="true"
21
-                  aria-expanded="false"
22
-                />
23
-                <input
24
-                  data-toggle="dropdown"
25
-                  name="resort"
26
-                  class="form-control my-2"
27
-                  id="name"
28
-                  placeholder="Region"
29
-                  aria-haspopup="true"
30
-                  aria-expanded="false"
29
+                  type="date"
30
+                  name="arrival-to"
31
+                  class="form-control my-1 uniSelect"
32
+                  id="arrival-to"
33
+                  placeholder="Date From"
34
+                  v-model="filter.date"
31 35
                 />
32 36
               </div>
33 37
               <div class="form-group col-md-6">
38
+                <div class="input-group">
39
+                  <label
40
+                    v-if="!searchParams.resort"
41
+                    class="uniSelectLabel"
42
+                    for="weekInfoResortSelect"
43
+                  >RESORT</label>
44
+                  <select
45
+                    id="weekInfoResortSelect"
46
+                    class="form-control uniSelect"
47
+                    v-model="searchParams.resort"
48
+                  >
49
+                    <option
50
+                      v-for="(resort, r) in filteredResort"
51
+                      :key="r"
52
+                      :value="resort"
53
+                      @change="resortChange"
54
+                    >
55
+                      {{
56
+                      resort.resortName
57
+                      }}
58
+                    </option>
59
+                  </select>
60
+                </div>
61
+                <br />
62
+                <label>DATE TO</label>
34 63
                 <input
35
-                  data-toggle="dropdown"
36
-                  name="region"
37
-                  class="form-control my-2"
38
-                  id="name"
39
-                  placeholder="Week"
40
-                  aria-haspopup="true"
41
-                  aria-expanded="false"
42
-                />
43
-                <input
44
-                  data-toggle="dropdown"
45
-                  name="resort"
46
-                  class="form-control my-2"
47
-                  id="name"
48
-                  placeholder="Price Range"
49
-                  aria-haspopup="true"
50
-                  aria-expanded="false"
64
+                  type="date"
65
+                  name="arrival-to"
66
+                  class="form-control my-1 uniSelect"
67
+                  id="arrival-to"
68
+                  placeholder="Date To"
69
+                  v-model="filter.ddate"
51 70
                 />
52 71
               </div>
53 72
             </div>
54
-            <a href="resort-page.php" class="btn-solid-blue"><i class="fa fa-search"></i> SEARCH</a>
73
+            <button class="btn-solid-blue" @click="Search()">
74
+              <i class="fa fa-search"></i> SEARCH
75
+            </button>
55 76
           </div>
56 77
         </div>
57 78
       </div>
@@ -67,12 +88,12 @@
67 88
       style="margin-top:-50px"
68 89
       :responsive="{ 0: { items: 1, nav: false }, 600: { items: 1, nav: false } }"
69 90
     >
70
-      <img class="item" src="/img/intro-carousel/timeshare-1.jpg" alt="" />
71
-      <img class="item" src="/img/intro-carousel/timeshare-2.jpg" alt="" />
72
-      <img class="item" src="/img/intro-carousel/timeshare-3.jpg" alt="" />
73
-      <img class="item" src="/img/intro-carousel/timeshare-4.jpg" alt="" />
74
-      <img class="item" src="/img/intro-carousel/timeshare-5.jpg" alt="" />
75
-      <img class="item" src="/img/intro-carousel/timeshare-6.jpg" alt="" />
91
+      <img class="item" src="/img/intro-carousel/timeshare-1.jpg" alt />
92
+      <img class="item" src="/img/intro-carousel/timeshare-2.jpg" alt />
93
+      <img class="item" src="/img/intro-carousel/timeshare-3.jpg" alt />
94
+      <img class="item" src="/img/intro-carousel/timeshare-4.jpg" alt />
95
+      <img class="item" src="/img/intro-carousel/timeshare-5.jpg" alt />
96
+      <img class="item" src="/img/intro-carousel/timeshare-6.jpg" alt />
76 97
     </carousel>
77 98
 
78 99
     <div id="intro-carousel" class="owl-carousel"></div>
@@ -83,10 +104,73 @@
83 104
 /* eslint-disable */
84 105
 
85 106
 import carousel from "vue-owl-carousel";
107
+import { mapState, mapActions, mapGetters } from "vuex";
86 108
 export default {
87 109
   components: {
88
-    carousel
89
-  }
110
+    carousel,
111
+  },
112
+  data() {
113
+    return {
114
+      regionObj: {},
115
+      resortObj: {},
116
+      region: "",
117
+      resort: "",
118
+      priceMin: undefined,
119
+      priceMax: undefined,
120
+    };
121
+  },
122
+  methods: {
123
+    ...mapActions("timeshare", ["initTimeshare", "onResortChange", "saveWeek"]),
124
+    regionChange(item) {
125
+      let reg = this.regions.find((r) => r.regionName === item.target.value);
126
+      this.regionObj = reg;
127
+    },
128
+    resortChange(item) {
129
+      let res = this.resorts.find((r) => r.resortName === item.target.value);
130
+      this.resortObj = res;
131
+    },
132
+    Search() {
133
+      if (this.searchParams.price) {
134
+        this.filter.minPrice = this.searchParams.price;
135
+      }
136
+      if (this.searchParams.week) {
137
+        this.filter.keyword = this.week;
138
+      }
139
+
140
+      if (!this.searchParams.resort) {
141
+        return;
142
+      }
143
+
144
+      this.$router.push(`/resort/${this.searchParams.resort.resortCode}`);
145
+    },
146
+  },
147
+  computed: {
148
+    ...mapState("timeshare", ["resorts", "regions", "detailedRegion"]),
149
+    ...mapState("weekList", ["searchParams", "filter"]),
150
+    filteredResort() {
151
+      let list = [];
152
+      if (this.searchParams.region && this.searchParams.region !== "") {
153
+        const item = this.detailedRegion.find(
154
+          (region) => region.region.regionCode === this.regionObj.regionCode
155
+        );
156
+        if (item) {
157
+          list = item.children;
158
+        }
159
+      } else {
160
+        list = this.resorts;
161
+      }
162
+      return _.sortBy(list, (x) => x.resortName);
163
+    },
164
+  },
165
+  created() {
166
+    this.initTimeshare(this.weekId);
167
+  },
168
+  mounted() {
169
+    this.searchParams.region = null;
170
+    this.searchParams.resort = null;
171
+    this.filter.date = null;
172
+    this.filter.ddate = null;
173
+  },
90 174
 };
91 175
 </script>
92 176
 

+ 23
- 18
src/components/timeshare/buy/searchSection.vue Parādīt failu

@@ -29,20 +29,20 @@
29 29
               v-model="selectedResort"
30 30
               @change="resortEvent()"
31 31
             >
32
-              <option v-for="(resort, i) in selectedRegion.resorts" :key="i" :value="resort">
33
-                {{ resort.resortName }}
34
-              </option>
32
+              <option
33
+                v-for="(resort, i) in selectedRegion.resorts"
34
+                :key="i"
35
+                :value="resort"
36
+              >{{ resort.resortName }}</option>
35 37
             </select>
36 38
           </div>
37 39
           <div v-else class="input-group my-1">
38 40
             <label v-if="selectedResort === null" class="uniSelectLabel" for="resort">Resort</label>
39 41
             <select class="form-control uniSelect" name="resort" id="resort">
40
-              <option disabled>
41
-                Please Select a Region First
42
-              </option>
42
+              <option disabled>Please Select a Region First</option>
43 43
             </select>
44 44
           </div>
45
-          <div class="input-group my-1">
45
+          <!-- <div class="input-group my-1">
46 46
             <label v-if="selectedSeason === null" class="uniSelectLabel" for="season">Season</label>
47 47
             <select
48 48
               class="form-control uniSelect"
@@ -50,9 +50,7 @@
50 50
               id="season"
51 51
               v-model="selectedSeason"
52 52
             >
53
-              <option v-for="season in seasons" :key="season.id" :value="season">
54
-                {{ season.name }}
55
-              </option>
53
+              <option v-for="season in seasons" :key="season.id" :value="season">{{ season.name }}</option>
56 54
             </select>
57 55
           </div>
58 56
 
@@ -97,8 +95,10 @@
97 95
               placeholder="mm/dd/yy"
98 96
               v-model="dateTo"
99 97
             />
100
-          </p>
101
-          <div class="btn-white-border"><i class="fa fa-search"></i> SEARCH</div>
98
+          </p>-->
99
+          <button class="btn-white-border" @click="ShowResort()">
100
+            <i class="fa fa-search"></i> SEARCH
101
+          </button>
102 102
         </div>
103 103
         <div class="col-md-8 p-5">
104 104
           <h2>Search by Province</h2>
@@ -137,7 +137,7 @@ import Alert from "../../shared/alert.vue";
137 137
 export default {
138 138
   name: "TimeshareToBuy",
139 139
   components: {
140
-    Alert
140
+    Alert,
141 141
   },
142 142
   data() {
143 143
     return {
@@ -149,7 +149,7 @@ export default {
149 149
       bedrooms: null,
150 150
       maxPrice: null,
151 151
       dateFrom: "",
152
-      dateTo: ""
152
+      dateTo: "",
153 153
     };
154 154
   },
155 155
   mounted() {
@@ -163,8 +163,8 @@ export default {
163 163
       return `http://maps.google.com/maps?q=${this.myMap}&z=${this.myZoom}&output=embed`;
164 164
     },
165 165
     regions() {
166
-      return _.sortBy(this.detailedRegion, r => r.regionName);
167
-    }
166
+      return _.sortBy(this.detailedRegion, (r) => r.regionName);
167
+    },
168 168
   },
169 169
   methods: {
170 170
     ...mapActions("region", ["init", "getAvail", "getRegions", "getResort"]),
@@ -196,8 +196,13 @@ export default {
196 196
       if (this.maxPrice === "0") {
197 197
         this.maxPrice = null;
198 198
       }
199
-    }
200
-  }
199
+    },
200
+    ShowResort() {
201
+      if (this.selectedResort) {
202
+        this.$router.push(`/resort/${this.selectedResort.resortCode}`);
203
+      }
204
+    },
205
+  },
201 206
 };
202 207
 </script>
203 208
 

+ 51
- 0
src/components/timeshare/buy/toBuySearchResults.vue Parādīt failu

@@ -0,0 +1,51 @@
1
+<template>
2
+  <main id="main" style="margin-top:-20px; padding-bottom:50px">
3
+    <section>
4
+      <div class="container">
5
+        <div class="row pt-5 justify-content-md-center">
6
+          <h3>TIMESHARE TO BUY</h3>
7
+        </div>
8
+        <br />
9
+        <br />
10
+        <br />
11
+        <br />
12
+        <h1>bla</h1>
13
+        <!--<div v-if="properties.length > 0" class="row justify-content-md-center">
14
+          <div
15
+            class="col-lg-3 col-md-6 col-sm-6"
16
+            v-for="currentProperty in properties"
17
+            :key="currentProperty.id"
18
+          >
19
+            <div>
20
+              <div class="portfolio-item">
21
+                <img style="width:255px; height:255px" :src="currentProperty.displayImage" alt />
22
+
23
+                <h4 class="mt-3">{{ currentProperty.suburb }}</h4>
24
+                <p>
25
+                  Opposite Monument Park Spar, Pretoria! Secure Parking. A stand-alone building,
26
+                  situated in the best location. Incredible bargain!
27
+                </p>
28
+                <br />
29
+
30
+                <router-link
31
+                  class="btn-white-border"
32
+                  :to="`/property/commercial/property/${currentProperty.id}`"
33
+                >VIEW</router-link>
34
+              </div>
35
+            </div>
36
+          </div>
37
+        </div>
38
+        <div v-else class="row">
39
+          <div align="center" class="col-md-12">
40
+            <img src="img/no-homes.png" />
41
+            <br />
42
+            <br />
43
+            <p>Sorry no listing where found matching your search</p>
44
+          </div>
45
+        </div>-->
46
+      </div>
47
+    </section>
48
+  </main>
49
+</template>
50
+
51
+

+ 8
- 10
src/components/timeshare/buy/weekListComponent.vue Parādīt failu

@@ -5,7 +5,6 @@
5 5
         <thead>
6 6
           <tr>
7 7
             <th scope="col">Unit</th>
8
-            <th scope="col">Week</th>
9 8
             <th scope="col">Module</th>
10 9
             <th scope="col">Bedrooms</th>
11 10
             <th scope="col">Season</th>
@@ -17,15 +16,14 @@
17 16
           <tr v-for="(item, i) in filteredWeeks" :key="i">
18 17
             <td>{{ item.unitNumber }}</td>
19 18
             <td>{{ item.weekNumber }}</td>
20
-            <td>#module</td>
21 19
             <td>{{ item.bedrooms }}</td>
22
-            <td>#season</td>
20
+            <td>{{ item.season }}</td>
23 21
             <td>{{ item.sellPrice | toCurrency }}</td>
24 22
             <!-- <td>{{ item.region ? item.region.regionName : "" }}</td>
25 23
             <td>{{ item.resort ? item.resort.resortName : "" }}</td>
26 24
 
27 25
             <td>{{ item.arrivalDate | toDate }}</td>
28
-            <td>{{ item.departureDate | toDate }}</td> -->
26
+            <td>{{ item.departureDate | toDate }}</td>-->
29 27
 
30 28
             <!-- <td>{{item.status ? item.status.description : ''}}</td> -->
31 29
 
@@ -34,7 +32,7 @@
34 32
             </td>
35 33
             <!-- <div class="col-md-12">
36 34
                 <button type="button" class="btn btn-b-n" >View</button>
37
-              </div> -->
35
+            </div>-->
38 36
           </tr>
39 37
         </tbody>
40 38
       </table>
@@ -68,15 +66,15 @@ import { mapState, mapActions, mapGetters } from "vuex";
68 66
 export default {
69 67
   props: {
70 68
     resortCode: undefined,
71
-    userId: undefined
69
+    userId: undefined,
72 70
   },
73 71
   components: {},
74 72
   computed: {
75 73
     ...mapState("weekList", ["weeks", "status"]),
76 74
     ...mapGetters({
77 75
       filteredWeeks: "weekList/filteredWeeks",
78
-      getRegions: "weekList/getRegions"
79
-    })
76
+      getRegions: "weekList/getRegions",
77
+    }),
80 78
   },
81 79
   mounted() {
82 80
     if (this.resortCode) {
@@ -88,8 +86,8 @@ export default {
88 86
     View(item) {
89 87
       this.$router.push(`/resort/${item.resort.resortCode}/${item.unitNumber}`);
90 88
     },
91
-    ...mapActions("weekList", ["getWeeks", "applyResortFilter"])
92
-  }
89
+    ...mapActions("weekList", ["getWeeks", "applyResortFilter"]),
90
+  },
93 91
 };
94 92
 </script>
95 93
 

+ 7
- 11
src/components/timeshare/resort/carouselSection.vue Parādīt failu

@@ -4,7 +4,7 @@
4 4
       <carousel
5 5
         :nav="false"
6 6
         :dots="false"
7
-        :items="1"
7
+        :items="10"
8 8
         :autoplay="true"
9 9
         :loop="true"
10 10
         :autoHeight="true"
@@ -12,13 +12,9 @@
12 12
         style="margin-top:-50px;"
13 13
         :responsive="{ 0: { items: 1, nav: false }, 600: { items: 1, nav: false } }"
14 14
       >
15
-        <img
16
-          class="item"
17
-          style="object-fit:cover"
18
-          v-for="(image, i) in resortImages"
19
-          :src="image"
20
-          :key="i"
21
-        />
15
+        <div v-for="(image, i) in resortImages" :key="i">
16
+          <img class="item" style="object-fit:cover" :src="image" :key="i" />
17
+        </div>
22 18
       </carousel>
23 19
     </div>
24 20
   </section>
@@ -29,11 +25,11 @@
29 25
 import carousel from "vue-owl-carousel";
30 26
 export default {
31 27
   components: {
32
-    carousel
28
+    carousel,
33 29
   },
34 30
   props: {
35
-    resortImages: {}
36
-  }
31
+    resortImages: {},
32
+  },
37 33
 };
38 34
 </script>
39 35
 

+ 6
- 6
src/components/timeshare/resort/resortPage.vue Parādīt failu

@@ -15,15 +15,15 @@ import contentSection from "./contentSection";
15 15
 export default {
16 16
   components: {
17 17
     carouselSection,
18
-    contentSection
18
+    contentSection,
19 19
   },
20 20
   data() {
21 21
     return {
22
-      boolLoaded: false
22
+      boolLoaded: false,
23 23
     };
24 24
   },
25 25
   props: {
26
-    resortCode: {}
26
+    resortCode: {},
27 27
   },
28 28
   async created() {
29 29
     this.initResort(this.resortCode).then(() => {
@@ -36,14 +36,14 @@ export default {
36 36
       return this.resort
37 37
         ? `http://maps.google.com/maps?q=${this.resort.prLatitude},${this.resort.prLongitude}&z=15&output=embed`
38 38
         : "";
39
-    }
39
+    },
40 40
   },
41 41
   methods: {
42 42
     ...mapActions("resort", ["initResort"]),
43 43
     routerGoTo(goto) {
44 44
       this.$router.push(goto);
45
-    }
46
-  }
45
+    },
46
+  },
47 47
 };
48 48
 </script>
49 49
 

+ 32
- 21
src/components/timeshare/searchTimeshare.vue Parādīt failu

@@ -3,17 +3,13 @@
3 3
     <h2>Filter Weeks</h2>
4 4
     <p>*Select at least 1 filter field</p>
5 5
     <div class="input-group mt-2">
6
-      <label v-if="selectedSeason === null" class="uniSelectLabel" for="season">Season</label>
7
-      <select class="form-control" name="season" id="season" v-model="selectedSeason">
8
-        <option v-for="season in seasons" :key="season.id" :value="season">
9
-          {{ season.name }}
10
-        </option>
6
+      <label v-if="!filter.season" class="uniSelectLabel" for="season">Season</label>
7
+      <select class="form-control" name="season" id="season" v-model="filter.season">
8
+        <option v-for="season in seasons" :key="season.id" :value="season">{{ season.name }}</option>
11 9
       </select>
12 10
     </div>
13 11
     <div class="input-group mt-2">
14
-      <label v-if="!filter.bedrooms" class="uniSelectLabel" for="weekInfoRegionSelect"
15
-        >Bedrooms</label
16
-      >
12
+      <label v-if="!filter.bedrooms" class="uniSelectLabel" for="weekInfoRegionSelect">Bedrooms</label>
17 13
       <select class="form-control" name="bedrooms" v-model="filter.bedrooms">
18 14
         <option v-for="(item, i) in resortBedrooms" :key="i">{{ item }}</option>
19 15
       </select>
@@ -27,7 +23,7 @@
27 23
       v-model="filter.maxPrice"
28 24
     />
29 25
     <p class="mt-2">
30
-      Filter Arrival Date from
26
+      Date from
31 27
       <input
32 28
         type="date"
33 29
         name="arrival-from"
@@ -38,16 +34,22 @@
38 34
       />
39 35
     </p>
40 36
     <p>
41
-      Filter Arrival Date to
37
+      Date to
42 38
       <input
43 39
         type="date"
44 40
         name="arrival-to"
45 41
         class="form-control my-1"
46 42
         id="arrival-to"
47 43
         placeholder="mm/dd/yy"
44
+        v-model="filter.ddate"
48 45
       />
49 46
     </p>
50
-    <div class="btn-white-border"><i class="fa fa-search"></i> FILTER</div>
47
+    <button class="btn-white-border" @click="ClearFilter()">
48
+      <i class="fa fa-eraser"></i> CLEAR
49
+    </button>
50
+    <!-- <div class="btn-white-border">
51
+      <i class="fa fa-search"></i> FILTER
52
+    </div>-->
51 53
   </div>
52 54
 </template>
53 55
 
@@ -59,11 +61,11 @@ import _ from "lodash";
59 61
 export default {
60 62
   props: {
61 63
     hideTop: undefined,
62
-    keyword: undefined
64
+    keyword: undefined,
63 65
   },
64 66
   data() {
65 67
     return {
66
-      selectedSeason: null
68
+      selectedSeason: null,
67 69
     };
68 70
   },
69 71
   created() {
@@ -75,24 +77,33 @@ export default {
75 77
       "regions",
76 78
       "detailedRegion",
77 79
       "resortBedrooms",
78
-      "maxSleep"
80
+      "maxSleep",
79 81
     ]),
80
-    ...mapState("weekList", ["filter"]),
82
+    ...mapState("weekList", ["filter", "searchParams"]),
81 83
     ...mapState("timeshare", ["seasons"]),
82 84
     filteredResorts() {
83 85
       if (this.selectedRegion) {
84
-        const list = _.find(this.detailedRegion, i => i.region.regionName === this.selectedRegion)
85
-          .children;
86
-        return _.sortBy(list, r => r.resortName);
86
+        const list = _.find(
87
+          this.detailedRegion,
88
+          (i) => i.region.regionName === this.selectedRegion
89
+        ).children;
90
+        return _.sortBy(list, (r) => r.resortName);
87 91
       }
88 92
       return this.resorts;
89
-    }
93
+    },
90 94
   },
91 95
   methods: {
92 96
     ...mapActions("timeshare", ["initTimeshare"]),
93 97
     ...mapActions("weekList", ["clearFilter"]),
94
-    ...mapActions("timeshare", ["getSeasons"])
95
-  }
98
+    ...mapActions("timeshare", ["getSeasons"]),
99
+    ClearFilter() {
100
+      this.filter.season = null;
101
+      this.filter.bedrooms = null;
102
+      this.filter.maxPrice = null;
103
+      this.filter.date = null;
104
+      this.filter.ddate = null;
105
+    },
106
+  },
96 107
 };
97 108
 </script>
98 109
 

+ 6
- 0
src/router/index.js Parādīt failu

@@ -45,6 +45,7 @@ import agentManagementPage from "../components/admin/status/agentsUserManagement
45 45
 
46 46
 import ResortPage from "../components/timeshare/resort/resortPage.vue";
47 47
 import UnitPage from "../components/timeshare/resort/unit/unitPage.vue";
48
+import ToBuySearch from "../components/timeshare/buy/toBuySearchResults.vue";
48 49
 
49 50
 import ContactUs from "../components/misc/contactUs.vue";
50 51
 import PrivacyPolicy from "../components/misc//privacyPolicy/privacyPolicyPage.vue";
@@ -393,6 +394,11 @@ export default new Router({
393 394
       path: "/CampaignExpired",
394 395
       name: "CampaignExpired",
395 396
       component: MarketingPageExp
397
+    },
398
+    {
399
+      path: "/toBuyResults",
400
+      name: "ToBuySearch",
401
+      component: ToBuySearch
396 402
     }
397 403
   ]
398 404
 });

+ 32
- 15
src/store/modules/timeshare/weekList.js Parādīt failu

@@ -3,7 +3,7 @@
3 3
 /* eslint-disable no-restricted-syntax */
4 4
 /* eslint-disable guard-for-in */
5 5
 import axios from "axios";
6
-import _ from "lodash";
6
+import _, { min } from "lodash";
7 7
 
8 8
 export default {
9 9
   namespaced: true,
@@ -11,17 +11,25 @@ export default {
11 11
     weeks: [],
12 12
     status: undefined,
13 13
     filter: {
14
+      season: undefined,
14 15
       status: undefined,
15 16
       region: undefined,
16 17
       resort: undefined,
17 18
       bedrooms: undefined,
18 19
       date: undefined,
20
+      ddate: undefined,
19 21
       minPrice: undefined,
20 22
       maxPrice: undefined,
21 23
       keyword: undefined
22 24
     },
23 25
     prevFilter: undefined,
24
-    difFilter: undefined
26
+    difFilter: undefined,
27
+    searchParams: {
28
+      region: undefined,
29
+      resort: undefined,
30
+      fromDate: undefined,
31
+      toDate: undefined
32
+    }
25 33
   },
26 34
   mutations: {
27 35
     onLoading(state) {
@@ -81,21 +89,20 @@ export default {
81 89
           );
82 90
         }
83 91
         if (filter.bedrooms) {
84
-          weekList = _.filter(weekList, x => x.bedrooms && x.bedrooms == filter.bedrooms);
92
+          if (filter.bedrooms === "Studio") {
93
+            weekList = _.filter(weekList, x => (x.bedrooms && x.bedrooms === "0") || !x.bedrooms);
94
+          } else {
95
+            weekList = _.filter(weekList, x => x.bedrooms && x.bedrooms === filter.bedrooms);
96
+          }
85 97
         }
86 98
         if (filter.date) {
87 99
           const minDate = new Date(filter.date);
88
-          minDate.setDate(minDate.getDate() - 7);
89
-          const maxDate = new Date(filter.date);
90
-          maxDate.setDate(maxDate.getDate() + 7);
91
-          weekList = _.filter(
92
-            weekList,
93
-            x =>
94
-              new Date(x.arrivalDate) &&
95
-              new Date(x.departureDate) &&
96
-              new Date(x.arrivalDate) >= minDate &&
97
-              new Date(x.arrivalDate) <= maxDate
98
-          );
100
+          minDate.setDate(minDate.getDate() - 1);
101
+          weekList = _.filter(weekList, x => new Date(x.arrivalDate) >= minDate);
102
+        }
103
+        if (filter.ddate) {
104
+          const maxDate = new Date(filter.ddate);
105
+          weekList = _.filter(weekList, x => new Date(x.departureDate) <= maxDate);
99 106
         }
100 107
         if (filter.minPrice && filter.minPrice !== 0) {
101 108
           weekList = _.filter(weekList, x => x.sellPrice && x.sellPrice >= filter.minPrice);
@@ -103,6 +110,9 @@ export default {
103 110
         if (filter.maxPrice && filter.maxPrice !== 0) {
104 111
           weekList = _.filter(weekList, x => x.sellPrice && x.sellPrice <= filter.maxPrice);
105 112
         }
113
+        if (filter.season) {
114
+          weekList = _.filter(weekList, x => x.season === filter.season.name);
115
+        }
106 116
       }
107 117
       return _.sortBy(_.sortBy(weekList, "arrivalDate"), "resort.resortName");
108 118
     },
@@ -149,7 +159,6 @@ export default {
149 159
                 resortName: rootGetters["timeshare/getResortName"](code),
150 160
                 resortCode: code
151 161
               };
152
-              arr2.push(myItem);
153 162
             }
154 163
           }
155 164
           commit("setWeeks", arr2);
@@ -157,6 +166,14 @@ export default {
157 166
         })
158 167
         .catch(console.error);
159 168
     },
169
+    // getWeeks({ commit }) {
170
+    //   axios.get("api/timeshareweek").then(result =>
171
+    //     commit(
172
+    //       "setWeeks",
173
+    //       result.data.filter(x => x.region !== null)
174
+    //     )
175
+    //   );
176
+    // },
160 177
     clearFilter({ commit }, filter) {
161 178
       commit("onClearFilter", filter);
162 179
     }

Notiek ielāde…
Atcelt
Saglabāt