Browse Source

Cart & Orders WIP

master
George Williams 4 years ago
parent
commit
5c1e1737d8

+ 4166
- 0
package-lock.json
File diff suppressed because it is too large
View File


+ 1
- 0
package.json View File

36
     "vue-js-modal": "^1.3.35",
36
     "vue-js-modal": "^1.3.35",
37
     "vue-json-excel": "^0.2.98",
37
     "vue-json-excel": "^0.2.98",
38
     "vue-router": "^3.1.5",
38
     "vue-router": "^3.1.5",
39
+    "vue-stepper": "^1.4.2",
39
     "vue-switches": "^2.0.1",
40
     "vue-switches": "^2.0.1",
40
     "vue-trix": "^1.1.7",
41
     "vue-trix": "^1.1.7",
41
     "vue2-editor": "^2.10.2",
42
     "vue2-editor": "^2.10.2",

+ 1
- 1
public/index.html View File

7
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
7
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
8
     <link rel="icon" href="<%= BASE_URL %>favicon.png">
8
     <link rel="icon" href="<%= BASE_URL %>favicon.png">
9
     <link href="img/univate.PNG" rel="apple-touch-icon">
9
     <link href="img/univate.PNG" rel="apple-touch-icon">
10
-    <title>Restaurants</title>
10
+    <title>Fork-ing Fast</title>
11
 
11
 
12
     <link
12
     <link
13
       href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700"
13
       href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700"

+ 3
- 3
src/App.vue View File

19
   name: "app",
19
   name: "app",
20
   components: {
20
   components: {
21
     NavBar,
21
     NavBar,
22
-    FooterSection
22
+    FooterSection,
23
   },
23
   },
24
   methods: {
24
   methods: {
25
     routerGoTo(goTo) {
25
     routerGoTo(goTo) {
26
       this.$router.push(goTo);
26
       this.$router.push(goTo);
27
-    }
28
-  }
27
+    },
28
+  },
29
 };
29
 };
30
 </script>
30
 </script>
31
 
31
 

+ 20
- 17
src/assets/Log.js View File

1
 const items = {
1
 const items = {
2
   setValues(item) {
2
   setValues(item) {
3
-    localStorage.setItem('user', JSON.stringify(item.user));
4
-    localStorage.setItem('token', JSON.stringify(item.token));
5
-    localStorage.setItem('person', JSON.stringify(item.person));
6
-    localStorage.setItem('agency', JSON.stringify(item.agency));
3
+    localStorage.setItem("user", JSON.stringify(item.user));
4
+    localStorage.setItem("token", JSON.stringify(item.token));
5
+    localStorage.setItem("person", JSON.stringify(item.person));
6
+    localStorage.setItem("agency", JSON.stringify(item.agency));
7
   },
7
   },
8
   tokenExpired() {
8
   tokenExpired() {
9
-    const item = this.getJSONObject('token');
9
+    const item = this.getJSONObject("token");
10
     if (!item && !item.expires && item.expires !== null) {
10
     if (!item && !item.expires && item.expires !== null) {
11
       const today = new Date();
11
       const today = new Date();
12
       const date = `${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`;
12
       const date = `${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`;
17
     return true;
17
     return true;
18
   },
18
   },
19
   updateTokenExpiry() {
19
   updateTokenExpiry() {
20
-    const item = this.getJSONObject('token');
20
+    const item = this.getJSONObject("token");
21
     if (!item && !item.expires) {
21
     if (!item && !item.expires) {
22
       item.expires = this.addMinutes();
22
       item.expires = this.addMinutes();
23
-      localStorage.removeItem('token');
24
-      localStorage.setItem('token', JSON.stringify(item));
23
+      localStorage.removeItem("token");
24
+      localStorage.setItem("token", JSON.stringify(item));
25
     }
25
     }
26
   },
26
   },
27
   getJSONObject(itemString) {
27
   getJSONObject(itemString) {
39
     return new Date(dateTime + 15 * 60000);
39
     return new Date(dateTime + 15 * 60000);
40
   },
40
   },
41
   clearValues() {
41
   clearValues() {
42
-    localStorage.removeItem('user');
43
-    localStorage.removeItem('token');
44
-    localStorage.removeItem('person');
45
-    localStorage.removeItem('agency');
42
+    localStorage.removeItem("user");
43
+    localStorage.removeItem("token");
44
+    localStorage.removeItem("person");
45
+    localStorage.removeItem("agency");
46
   },
46
   },
47
   isLoggedIn() {
47
   isLoggedIn() {
48
-    return localStorage.getItem('token') !== undefined && localStorage.getItem('token') !== null;
48
+    return localStorage.getItem("token") !== undefined && localStorage.getItem("token") !== null;
49
   },
49
   },
50
   restaurantId() {
50
   restaurantId() {
51
-    return 1;
51
+    return 2;
52
+  },
53
+  userId() {
54
+    return 4;
52
   },
55
   },
53
   getUser() {
56
   getUser() {
54
-    return localStorage.getItem('user') ? JSON.parse(localStorage.getItem('user')) : {};
57
+    return localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {};
55
   },
58
   },
56
   getPerson() {
59
   getPerson() {
57
-    return localStorage.getItem('person') ? JSON.parse(localStorage.getItem('person')) : {};
58
-  },
60
+    return localStorage.getItem("person") ? JSON.parse(localStorage.getItem("person")) : {};
61
+  }
59
 };
62
 };
60
 export default items;
63
 export default items;

+ 10
- 9
src/components/customer/customerDetails.vue View File

261
 <script>
261
 <script>
262
 import Map from "../shared/mapSetLocation";
262
 import Map from "../shared/mapSetLocation";
263
 import { mapState, mapActions } from "vuex";
263
 import { mapState, mapActions } from "vuex";
264
+import Log from "../../assets/Log";
264
 
265
 
265
 export default {
266
 export default {
266
   name: "CustomerDetails",
267
   name: "CustomerDetails",
267
   components: {
268
   components: {
268
-    Map
269
+    Map,
269
   },
270
   },
270
   data() {
271
   data() {
271
     return {
272
     return {
272
-      complex: false
273
+      complex: false,
273
     };
274
     };
274
   },
275
   },
275
   methods: {
276
   methods: {
284
       this.$modal.hide("map");
285
       this.$modal.hide("map");
285
     },
286
     },
286
     UpdateAddress(address) {
287
     UpdateAddress(address) {
287
-      console.log(JSON.stringify(address));
288
+      this.userAddress.userId = this.user.id;
288
       this.userAddress.streetNumber = address.streetNumber;
289
       this.userAddress.streetNumber = address.streetNumber;
289
       this.userAddress.streetName = address.streetName;
290
       this.userAddress.streetName = address.streetName;
290
       this.userAddress.suburb = address.suburb;
291
       this.userAddress.suburb = address.suburb;
303
     },
304
     },
304
     Close() {
305
     Close() {
305
       this.$router.push("/");
306
       this.$router.push("/");
306
-    }
307
+    },
307
   },
308
   },
308
   computed: {
309
   computed: {
309
     ...mapState("user", ["user", "userAddress"]),
310
     ...mapState("user", ["user", "userAddress"]),
310
     mapCoords() {
311
     mapCoords() {
311
       var coords = {
312
       var coords = {
312
         lat: this.userAddress.latitude,
313
         lat: this.userAddress.latitude,
313
-        lng: this.userAddress.longitude
314
+        lng: this.userAddress.longitude,
314
       };
315
       };
315
       return coords;
316
       return coords;
316
-    }
317
+    },
317
   },
318
   },
318
   mounted() {
319
   mounted() {
319
-    this.getUser(2); //Will need to replace with auth object's ID
320
-    this.getUserAddress(2);
321
-  }
320
+    this.getUser(Log.userId()); //Will need to replace with auth object's ID
321
+    this.getUserAddress(Log.userId());
322
+  },
322
 };
323
 };
323
 </script>
324
 </script>

+ 27
- 9
src/components/home/menuItems.vue View File

25
               <h4 class="card-info-title">
25
               <h4 class="card-info-title">
26
                 <img src="/img/delivery-truck-with-dollar.png" height="30px" width="30px" />
26
                 <img src="/img/delivery-truck-with-dollar.png" height="30px" width="30px" />
27
               </h4>
27
               </h4>
28
-              <span>{{ menu.deliveryFee }}</span>
28
+              <span>{{ menu.deliveryFee | toCurrency }}</span>
29
             </li>
29
             </li>
30
             <li>
30
             <li>
31
               <h4 class="card-info-title">
31
               <h4 class="card-info-title">
74
                     class="img-b img-fluid"
74
                     class="img-b img-fluid"
75
                     style="object-fit: cover;"
75
                     style="object-fit: cover;"
76
                   />
76
                   />
77
+                  <!--  -->
78
+                  <p
79
+                    v-if="iMenuItem.outOfStock"
80
+                    class="top-left pendingOffer"
81
+                    style="text-align: center;"
82
+                  >
83
+                    <strong>Out Of Stock</strong>
84
+                  </p>
77
                 </div>
85
                 </div>
78
                 <div class="card-overlay">
86
                 <div class="card-overlay">
79
                   <div class="card-header-b">
87
                   <div class="card-header-b">
98
       </div>
106
       </div>
99
     </div>
107
     </div>
100
     <div v-else>
108
     <div v-else>
101
-      <MenuOptions :showItem="CurrentOption" @CloseOptions="CloseOptions" />
109
+      <MenuOptions
110
+        :showItem="CurrentOption"
111
+        :restaurantId="restaurantId"
112
+        @CloseOptions="CloseOptions"
113
+      />
102
     </div>
114
     </div>
103
   </div>
115
   </div>
104
 </template>
116
 </template>
110
 export default {
122
 export default {
111
   name: "MenuLayout",
123
   name: "MenuLayout",
112
   components: {
124
   components: {
113
-    MenuOptions
125
+    MenuOptions,
114
   },
126
   },
115
   data() {
127
   data() {
116
     return {
128
     return {
117
       wait: true,
129
       wait: true,
118
       radio: "",
130
       radio: "",
119
-      showOptions: false
131
+      showOptions: false,
132
+      restaurantId: this.$route.params.restautantid,
120
     };
133
     };
121
   },
134
   },
122
   methods: {
135
   methods: {
123
     ...mapActions("homeMenu", ["getMenu", "getOptions"]),
136
     ...mapActions("homeMenu", ["getMenu", "getOptions"]),
124
     ShowOptions(item) {
137
     ShowOptions(item) {
125
-      this.getOptions(item);
126
-      this.showOptions = true;
138
+      if (!item.outOfStock) {
139
+        this.getOptions(item);
140
+        this.showOptions = true;
141
+      }
127
     },
142
     },
128
     CloseOptions(value) {
143
     CloseOptions(value) {
129
       this.showOptions = value;
144
       this.showOptions = value;
130
-    }
145
+    },
131
   },
146
   },
132
   computed: {
147
   computed: {
133
     ...mapState("homeMenu", ["menu", "options"]),
148
     ...mapState("homeMenu", ["menu", "options"]),
134
     CurrentOption() {
149
     CurrentOption() {
135
       return this.options;
150
       return this.options;
136
-    }
151
+    },
152
+    DeliveryFee() {
153
+      return this.menu.deliveryFee;
154
+    },
137
   },
155
   },
138
   mounted() {
156
   mounted() {
139
     this.getMenu(this.$route.params.restautantid);
157
     this.getMenu(this.$route.params.restautantid);
140
-  }
158
+  },
141
   // watch: {
159
   // watch: {
142
   //   options: {
160
   //   options: {
143
   //     immediate: true,
161
   //     immediate: true,

+ 25
- 13
src/components/home/menuOptions.vue View File

130
 export default {
130
 export default {
131
   name: "MenuOptions",
131
   name: "MenuOptions",
132
   props: {
132
   props: {
133
-    showItem: { default: {} }
133
+    showItem: { default: {} },
134
+    restaurantId: { default: 0 },
134
   },
135
   },
135
   components: {
136
   components: {
136
-    optionSelector
137
+    optionSelector,
137
   },
138
   },
138
   data() {
139
   data() {
139
     return {
140
     return {
141
       item: {},
142
       item: {},
142
       qty: 1,
143
       qty: 1,
143
       subTotal: 0,
144
       subTotal: 0,
144
-      selection: []
145
+      selection: [],
145
     };
146
     };
146
   },
147
   },
147
   methods: {
148
   methods: {
175
       }
176
       }
176
     },
177
     },
177
     UpdateSelectionQty(value) {
178
     UpdateSelectionQty(value) {
178
-      this.selection.find(s => s.id == value.id).qty = value.qty;
179
+      this.selection.find((s) => s.id == value.id).qty = value.qty;
179
     },
180
     },
180
     AddToCart() {
181
     AddToCart() {
182
+      if (this.cartItems.length > 0) {
183
+        if (this.cartItems[0].restaurantId != this.restaurantId) {
184
+          alert("Cannot place orders to multiple restaurants");
185
+          return;
186
+        }
187
+      }
188
+
181
       const cartItem = {
189
       const cartItem = {
182
         id: this.item.id,
190
         id: this.item.id,
183
         description: this.item.description,
191
         description: this.item.description,
184
         image: this.item.image,
192
         image: this.item.image,
185
         name: this.item.name,
193
         name: this.item.name,
186
-        subTotal: this.subTotal,
187
-        specialInstructions: this.specialInstructions,
194
+        subTotal: this.SubTotal,
195
+        specialInstructions: this.item.specialInstructions,
188
         qty: this.qty,
196
         qty: this.qty,
189
-        selection: this.selection
197
+        selection: this.selection,
198
+        options: this.item.options,
199
+        price: this.item.price,
200
+        displayPrice: this.item.displayPrice,
201
+        restaurantId: this.restaurantId,
190
       };
202
       };
191
 
203
 
192
       this.cartItems.push(cartItem);
204
       this.cartItems.push(cartItem);
194
       this.selection = [];
206
       this.selection = [];
195
       this.qty = 1;
207
       this.qty = 1;
196
       this.$emit("CloseOptions", false);
208
       this.$emit("CloseOptions", false);
197
-    }
209
+    },
198
   },
210
   },
199
   computed: {
211
   computed: {
200
-    ...mapState("cart", ["cartItems"]),
212
+    ...mapState("cart", ["cartItems", "deliveryFee"]),
201
     SubTotal() {
213
     SubTotal() {
202
       var price = this.item.price * this.qty;
214
       var price = this.item.price * this.qty;
203
 
215
 
208
         }
220
         }
209
       }
221
       }
210
       return price;
222
       return price;
211
-    }
223
+    },
212
   },
224
   },
213
   watch: {
225
   watch: {
214
     showItem: {
226
     showItem: {
218
           this.item = val;
230
           this.item = val;
219
           this.subTotal = this.item.price;
231
           this.subTotal = this.item.price;
220
         }
232
         }
221
-      }
222
-    }
223
-  }
233
+      },
234
+    },
235
+  },
224
 };
236
 };
225
 </script>
237
 </script>

+ 83
- 4
src/components/orders/cart.vue View File

19
         @onEdit="Edit"
19
         @onEdit="Edit"
20
         @onDelete="Delete"
20
         @onDelete="Delete"
21
       />
21
       />
22
+      <div class="row">
23
+        <div class="col-md-12" style="margin-bottomL 1em">
24
+          <!-- RestaurantFeeDel -->
25
+        </div>
26
+      </div>
27
+      <div class="row">
28
+        <div class="col-md-2 offset-md-8" style="margin-bottomL 1em">
29
+          <label style="margin-top: 0.5em">
30
+            <b>Delivery Fee:</b>
31
+          </label>
32
+        </div>
33
+        <div class="col-md-2" style="margin-bottomL 1em">
34
+          <label style="margin-top: 0.5em">
35
+            <b>{{deliveryFee | toCurrency}}</b>
36
+          </label>
37
+        </div>
38
+      </div>
39
+      <div class="row">
40
+        <div class="col-md-2 offset-md-8" style="margin-bottomL 1em">
41
+          <label style="margin-top: 0.5em">
42
+            <b>Order Total:</b>
43
+          </label>
44
+        </div>
45
+        <div class="col-md-2" style="margin-bottomL 1em">
46
+          <label style="margin-top: 0.5em">
47
+            <b>{{OrderTotal | toCurrency}}</b>
48
+          </label>
49
+        </div>
50
+      </div>
51
+      <modal name="menu" :width="800" :height="600">
52
+        <Cart :showItem="CurrentItem" @Close="CloseItem" />
53
+      </modal>
54
+      <br />
55
+      <div class="row">
56
+        <div class="col-md-12" style="margin-bottomL 1em">
57
+          <div class="row offset-md-4">
58
+            <div class="col-md-3">
59
+              <button
60
+                @click="CheckOut()"
61
+                class="btn btn-b-n"
62
+                type="button"
63
+                data-dismiss="modal"
64
+                :disabled="cartItems.length == 0"
65
+              >Check Out</button>
66
+            </div>
67
+            <div class="col-md-3">
68
+              <button
69
+                @click="ClearCart()"
70
+                class="btn btn-b-n"
71
+                type="button"
72
+                data-dismiss="modal"
73
+                :disabled="cartItems.length == 0"
74
+              >Clear Cart</button>
75
+            </div>
76
+          </div>
77
+        </div>
78
+      </div>
22
     </div>
79
     </div>
23
-    <modal name="menu" :width="600" :height="auto">
24
-      <Cart :showItem="CurrentItem" />
25
-    </modal>
26
   </div>
80
   </div>
27
 </template>
81
 </template>
28
 
82
 
46
     };
100
     };
47
   },
101
   },
48
   methods: {
102
   methods: {
103
+    ...mapActions("cart", ["getDeliveryFee"]),
49
     New() {},
104
     New() {},
50
     Edit(item) {
105
     Edit(item) {
51
       this.item = item;
106
       this.item = item;
54
     Delete(item) {
109
     Delete(item) {
55
       this.cartItems.pop(item);
110
       this.cartItems.pop(item);
56
     },
111
     },
112
+    CloseItem(value) {
113
+      if (value) {
114
+        this.$modal.hide("menu");
115
+      }
116
+    },
117
+    CheckOut() {
118
+      this.$router.push("/ConfirmOrder");
119
+    },
120
+    ClearCart() {
121
+      this.deliveryFee = 0;
122
+      this.cartItems.splice(0, this.cartItems.length);
123
+    },
57
   },
124
   },
58
   computed: {
125
   computed: {
59
-    ...mapState("cart", ["cartItems"]),
126
+    ...mapState("cart", ["cartItems", "deliveryFee"]),
60
     CurrentItem() {
127
     CurrentItem() {
61
       return this.item;
128
       return this.item;
62
     },
129
     },
130
+    OrderTotal() {
131
+      var tot = 0;
132
+      for (let i = 0; i < this.cartItems.length; i++) {
133
+        tot = tot + this.cartItems[i].subTotal;
134
+      }
135
+      return tot + this.deliveryFee;
136
+    },
137
+  },
138
+  mounted() {
139
+    if (this.cartItems.length > 0) {
140
+      this.getDeliveryFee(this.cartItems[0].restaurantId);
141
+    }
63
   },
142
   },
64
 };
143
 };
65
 </script>
144
 </script>

+ 105
- 129
src/components/orders/cartItem.vue View File

1
 <template>
1
 <template>
2
   <div class="container">
2
   <div class="container">
3
-    <div class="row" style="text-align:left">
4
-      <!--Column 1 -->
5
-      <div class="col-md-6" style="margin-bottomL 1em">
6
-        <div class="row" style="text-align:left">
7
-          <div class="carousel-item-c">
8
-            <div class="card-box-b card-shadow news-box">
9
-              <div class="img-box-b">
10
-                <img v-if="item.image !== ''" :src="item.image" alt class="img-b img-fluid" />
11
-                <img
12
-                  v-else
13
-                  src="../../../public/img/DefaultImg.png"
14
-                  alt
15
-                  class="img-b img-fluid"
16
-                  style="object-fit: cover;"
17
-                />
18
-              </div>
19
-              <div class="card-overlay">
20
-                <div class="card-header-b">
21
-                  <div class="card-title-b">
22
-                    <h2 class="title-2" style="color: #ffffff;">{{ item.name }}</h2>
23
-                  </div>
24
-                  <div class="card-date">
25
-                    <span class="date-a">{{ item.description }}</span>
26
-                  </div>
27
-                  <br />
28
-                  <div class="card-category-b">
29
-                    <span class="category-b">
30
-                      <b>{{ item.displayPrice }}</b>
31
-                    </span>
3
+    <div class="container">
4
+      <div class="row" style="text-align:left">
5
+        <!--Column 1 -->
6
+        <div class="col-md-6" style="margin-bottomL 1em">
7
+          <div class="row" style="text-align:left">
8
+            <div class="carousel-item-c">
9
+              <div class="card-box-b card-shadow news-box">
10
+                <div class="img-box-b">
11
+                  <img v-if="item.image !== ''" :src="item.image" alt class="img-b img-fluid" />
12
+                  <img
13
+                    v-else
14
+                    src="../../../public/img/DefaultImg.png"
15
+                    alt
16
+                    class="img-b img-fluid"
17
+                    style="object-fit: cover;"
18
+                  />
19
+                </div>
20
+                <div class="card-overlay">
21
+                  <div class="card-header-b">
22
+                    <div class="card-title-b">
23
+                      <h2 class="title-2" style="color: #ffffff;">{{ item.name }}</h2>
24
+                    </div>
25
+                    <div class="card-date">
26
+                      <span class="date-a">{{ item.description }}</span>
27
+                    </div>
28
+                    <br />
29
+                    <div class="card-category-b">
30
+                      <span class="category-b">
31
+                        <b>{{ item.displayPrice }}</b>
32
+                      </span>
33
+                    </div>
32
                   </div>
34
                   </div>
33
                 </div>
35
                 </div>
34
               </div>
36
               </div>
35
             </div>
37
             </div>
36
           </div>
38
           </div>
37
-        </div>
38
-        <div class="row">
39
-          <div class="col-md-12" style="margin-top: 1em">
40
-            <div class="row">
41
-              <div class="col-sm-3">
42
-                <button
43
-                  @click="Minus()"
44
-                  class="btn btn-b-n"
45
-                  type="button"
46
-                  style="border-radius:50px"
47
-                >
48
-                  <eva-icon name="minus-outline" fill="white"></eva-icon>
49
-                </button>
50
-              </div>
51
-              <div class="col-sm-1">
52
-                <label style="margin-top: 0.5em">{{qty}}</label>
53
-              </div>
54
-              <div class="col-sm-3">
55
-                <button
56
-                  @click="Plus()"
57
-                  class="btn btn-b-n"
58
-                  type="button"
59
-                  style="border-radius:50px"
60
-                >
61
-                  <eva-icon name="plus-outline" fill="white"></eva-icon>
62
-                </button>
63
-              </div>
64
-              <div class="col-sm-2">
65
-                <label style="margin-top: 0.5em">
66
-                  <b>{{subTotal | toCurrency}}</b>
67
-                </label>
39
+          <div class="row">
40
+            <div class="col-md-12" style="margin-top: 1em">
41
+              <div class="row">
42
+                <div class="col-sm-2">
43
+                  <button
44
+                    @click="Minus()"
45
+                    class="btn btn-b-n"
46
+                    type="button"
47
+                    style="border-radius:50px"
48
+                  >
49
+                    <eva-icon name="minus-outline" fill="white"></eva-icon>
50
+                  </button>
51
+                </div>
52
+                <div class="col-sm-1">
53
+                  <label style="margin-top: 0.5em">{{qty}}</label>
54
+                </div>
55
+                <div class="col-sm-2">
56
+                  <button
57
+                    @click="Plus()"
58
+                    class="btn btn-b-n"
59
+                    type="button"
60
+                    style="border-radius:50px"
61
+                  >
62
+                    <eva-icon name="plus-outline" fill="white"></eva-icon>
63
+                  </button>
64
+                </div>
65
+                <div class="col-sm-3">
66
+                  <label style="margin-top: 0.5em">
67
+                    <b>{{SubTotal | toCurrency}}</b>
68
+                  </label>
69
+                </div>
68
               </div>
70
               </div>
69
             </div>
71
             </div>
70
           </div>
72
           </div>
71
         </div>
73
         </div>
72
-      </div>
73
-      <!--Column 2 -->
74
-      <div class="col-md-6" style="margin-bottomL 1em">
75
-        <div class="row" style="text-align:left">
76
-          <div class="container" v-for="(item, i) in options" :key="i">
77
-            <div class="row">
78
-              <div class="col-sm-12">
79
-                <div class="title-box-d">
80
-                  <h3 class="title-d">{{ item.description }}</h3>
74
+        <!--Column 2 -->
75
+        <div class="col-md-6" style="margin-bottomL 1em">
76
+          <div class="row" style="text-align:left">
77
+            <div class="container" v-for="(item, i) in item.options" :key="i">
78
+              <div class="row">
79
+                <div class="col-sm-12">
80
+                  <div class="title-box-d">
81
+                    <h3 class="title-d">{{ item.description }}</h3>
82
+                  </div>
81
                 </div>
83
                 </div>
82
               </div>
84
               </div>
85
+              <div class="row" v-if="item.subTitle">
86
+                <div class="col-sm-12">{{ item.subTitle }}</div>
87
+              </div>
88
+              <hr v-if="item.subTitle" />
89
+              <optionSelector
90
+                :item="item"
91
+                :savedSelection="selection"
92
+                @UpdateSelection="UpdateSelection"
93
+                @UpdateSelectionQty="UpdateSelectionQty"
94
+              />
83
             </div>
95
             </div>
84
-            <div class="row" v-if="item.subTitle">
85
-              <div class="col-sm-12">{{ item.subTitle }}</div>
86
-            </div>
87
-            <hr v-if="item.subTitle" />
88
-            <optionSelector
89
-              :item="item"
90
-              @UpdateSelection="UpdateSelection"
91
-              @UpdateSelectionQty="UpdateSelectionQty"
92
-            />
93
           </div>
96
           </div>
94
-        </div>
95
-        <hr />
96
-        <div class="row">
97
-          <div class="col-sm-12">
98
-            <label>Special Instructions</label>
99
-            <div class="input-group-prepend">
100
-              <textarea
101
-                class="form-control editor form-control-lg form-control-a"
102
-                v-model="item.specialInstructions"
103
-              />
97
+          <hr />
98
+          <div class="row">
99
+            <div class="col-sm-12">
100
+              <label>Special Instructions</label>
101
+              <div class="input-group-prepend">
102
+                <textarea
103
+                  class="form-control editor form-control-lg form-control-a"
104
+                  v-model="item.specialInstructions"
105
+                />
106
+              </div>
104
             </div>
107
             </div>
105
           </div>
108
           </div>
106
         </div>
109
         </div>
107
       </div>
110
       </div>
108
-    </div>
109
-    <div class="row">
110
-      <br />
111
-    </div>
112
-
113
-    <div class="row">
114
-      <div class="col-md-12" style="margin-top: 1em">
115
-        <button @click="AddToCart()" class="btn btn-b-n" type="button">Add To Cart</button>
111
+      <div class="row">
112
+        <br />
116
       </div>
113
       </div>
117
-    </div>
118
-    <div class="row">
119
-      <div class="col-md-12" style="margin-top: 1em">
120
-        <button @click="Close()" class="btn btn-b-n" type="button">Back</button>
114
+      <div class="row">
115
+        <div class="col-md-2 offset-md-5" style="margin-top: 1em">
116
+          <button @click="Update()" class="btn btn-b-n" type="button">Update</button>
117
+        </div>
121
       </div>
118
       </div>
122
     </div>
119
     </div>
123
   </div>
120
   </div>
145
     };
142
     };
146
   },
143
   },
147
   methods: {
144
   methods: {
148
-    ...mapActions("homeMenu", ["getOptions"]),
149
-    Close() {
150
-      this.item.specialInstructions = "";
151
-      this.selection = [];
152
-      this.qty = 1;
153
-      this.$emit("CloseOptions", false);
154
-    },
155
     Plus() {
145
     Plus() {
156
       this.qty = this.qty + 1;
146
       this.qty = this.qty + 1;
157
     },
147
     },
161
         this.qty = 1;
151
         this.qty = 1;
162
       }
152
       }
163
     },
153
     },
164
-    CheckItem(value) {
165
-      alert(JSON.stringify(value));
166
-    },
167
     UpdateSelection(value) {
154
     UpdateSelection(value) {
168
       if (value.value) {
155
       if (value.value) {
169
         this.selection.push(value.field);
156
         this.selection.push(value.field);
178
     UpdateSelectionQty(value) {
165
     UpdateSelectionQty(value) {
179
       this.selection.find((s) => s.id == value.id).qty = value.qty;
166
       this.selection.find((s) => s.id == value.id).qty = value.qty;
180
     },
167
     },
181
-    AddToCart() {
182
-      const cartItem = {
183
-        id: this.item.id,
184
-        description: this.item.description,
185
-        image: this.item.image,
186
-        name: this.item.name,
187
-        subTotal: this.subTotal,
188
-        specialInstructions: this.specialInstructions,
189
-        qty: this.qty,
190
-        selection: this.selection,
191
-      };
168
+    Update() {
169
+      this.item.qty = this.qty;
170
+      this.item.subTotal = this.SubTotal;
171
+
172
+      const item = this.cartItems.find((c) => c.id === this.item.id);
173
+      Object.assign(item, this.item);
192
 
174
 
193
-      this.cartItems.push(cartItem);
194
-      this.item.specialInstructions = "";
195
-      this.selection = [];
196
-      this.qty = 1;
197
-      this.$emit("CloseOptions", false);
175
+      this.$emit("Close", true);
198
     },
176
     },
199
   },
177
   },
200
   computed: {
178
   computed: {
201
     ...mapState("cart", ["cartItems"]),
179
     ...mapState("cart", ["cartItems"]),
202
-    ...mapState("homeMenu", ["options"]),
203
     SubTotal() {
180
     SubTotal() {
204
       var price = this.item.price * this.qty;
181
       var price = this.item.price * this.qty;
205
 
182
 
218
       handler(val, oldVal) {
195
       handler(val, oldVal) {
219
         if (val) {
196
         if (val) {
220
           this.item = val;
197
           this.item = val;
221
-          this.subTotal = this.item.price;
198
+          this.subTotal = this.item.price * this.item.qty;
222
           this.qty = this.item.qty;
199
           this.qty = this.item.qty;
223
           this.selection = this.item.selection;
200
           this.selection = this.item.selection;
224
-          this.getOptions(val);
225
         }
201
         }
226
       },
202
       },
227
     },
203
     },

+ 92
- 0
src/components/orders/confirmOrder.vue View File

1
+<template>
2
+  <div class="container">
3
+    <div class="container">
4
+      <div class="row">
5
+        <div class="col-md-12 col-lg-8">
6
+          <div class="title-box-d">
7
+            <br />
8
+            <h1 class="title-d" style="text-align:left; font-size: 250%">Order Confirmation</h1>
9
+          </div>
10
+        </div>
11
+      </div>
12
+
13
+      <div class="column is-8 is-offset-2">
14
+        <horizontal-stepper
15
+          :steps="demoSteps"
16
+          @completed-step="completeStep"
17
+          @active-step="isStepActive"
18
+          @stepper-finished="alert"
19
+        ></horizontal-stepper>
20
+      </div>
21
+    </div>
22
+  </div>
23
+</template>
24
+
25
+<script>
26
+import HorizontalStepper from "vue-stepper";
27
+
28
+// This components will have the content for each stepper step.
29
+import StepOne from "./orderConf/confAddress";
30
+import StepTwo from "./orderConf/makePayment";
31
+import StepThree from "./orderConf/orderPlaced";
32
+
33
+export default {
34
+  components: {
35
+    HorizontalStepper,
36
+  },
37
+  data() {
38
+    return {
39
+      demoSteps: [
40
+        {
41
+          icon: "my_location",
42
+          name: "first",
43
+          title: "Confrim Address",
44
+          subtitle: "for delivery",
45
+          component: StepOne,
46
+          completed: false,
47
+        },
48
+        {
49
+          icon: "payment",
50
+          name: "second",
51
+          title: "Make Payment",
52
+          subtitle: "",
53
+          component: StepTwo,
54
+          completed: false,
55
+        },
56
+        {
57
+          icon: "done",
58
+          name: "second",
59
+          title: "Completed",
60
+          subtitle: "",
61
+          component: StepThree,
62
+          completed: false,
63
+        },
64
+      ],
65
+    };
66
+  },
67
+  methods: {
68
+    // Executed when @completed-step event is triggered
69
+    completeStep(payload) {
70
+      this.demoSteps.forEach((step) => {
71
+        if (step.name === payload.name) {
72
+          step.completed = true;
73
+        }
74
+      });
75
+    },
76
+    // Executed when @active-step event is triggered
77
+    isStepActive(payload) {
78
+      this.demoSteps.forEach((step) => {
79
+        if (step.name === payload.name) {
80
+          if (step.completed === true) {
81
+            step.completed = false;
82
+          }
83
+        }
84
+      });
85
+    },
86
+    // Executed when @stepper-finished event is triggered
87
+    alert(payload) {
88
+      alert("end");
89
+    },
90
+  },
91
+};
92
+</script>

+ 272
- 0
src/components/orders/orderConf/confAddress.vue View File

1
+<template>
2
+  <div class="container">
3
+    <div class="row" style="text-align:left">
4
+      <div class="col-md-4" style="margin-bottom: 1em">
5
+        <div class="custom-control custom-switch">
6
+          <label>Do you live in a complex or block of flats?</label>
7
+          <input
8
+            style="margin-left: 1px"
9
+            type="checkbox"
10
+            class="custom-control-input"
11
+            id="thCloseSwitch"
12
+            :checked="userAddress.isComplex"
13
+            @change="selectionChanged"
14
+          />
15
+          <label class="custom-control-label" for="thCloseSwitch" style="margin-left: 40px">
16
+            {{
17
+            isComplex ? "Yes" : "No"
18
+            }}
19
+          </label>
20
+        </div>
21
+      </div>
22
+    </div>
23
+    <div class="row" style="text-align:left">
24
+      <div class="col-md-4" style="margin-bottom: 1em">
25
+        <button
26
+          @click="ShowMap()"
27
+          class="btn btn-b-n"
28
+          type="button"
29
+          data-dismiss="modal"
30
+        >Update Address</button>
31
+      </div>
32
+      <div class="col-md-4" style="margin-bottom: 1em">
33
+        <button
34
+          @click="GetLocation()"
35
+          class="btn btn-b-n"
36
+          type="button"
37
+          data-dismiss="modal"
38
+        >Use My Location</button>
39
+      </div>
40
+    </div>
41
+    <div v-if="userAddress.isComplex" class="row" style="text-align:left">
42
+      <div class="col-md-6" style="margin-bottom: 1em">
43
+        <label>Complex Name</label>
44
+        <div class="input-group-prepend">
45
+          <span class="input-group-text">
46
+            <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
47
+          </span>
48
+          <input
49
+            class="form-control"
50
+            type="text"
51
+            name="FirstName"
52
+            v-model="userAddress.complexName"
53
+          />
54
+        </div>
55
+      </div>
56
+      <div class="col-md-6" style="margin-bottom: 1em">
57
+        <label>Unit Number</label>
58
+        <div class="input-group-prepend">
59
+          <span class="input-group-text">
60
+            <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
61
+          </span>
62
+          <input class="form-control" type="text" name="Surname" v-model="userAddress.unitNumber" />
63
+        </div>
64
+      </div>
65
+    </div>
66
+    <div class="row" style="text-align:left">
67
+      <div class="col-md-6" style="margin-bottomL 1em">
68
+        <div class="row" style="text-align:left">
69
+          <div class="col-md-12" style="margin-bottom: 1em">
70
+            <label>Street Number</label>
71
+            <div class="input-group-prepend">
72
+              <span class="input-group-text">
73
+                <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
74
+              </span>
75
+              <input
76
+                class="form-control"
77
+                type="text"
78
+                name="FirstName"
79
+                v-model="userAddress.streetNumber"
80
+                disabled
81
+              />
82
+            </div>
83
+          </div>
84
+        </div>
85
+        <div class="row" style="text-align:left">
86
+          <div class="col-md-12" style="margin-bottom: 1em">
87
+            <label>Street Name</label>
88
+            <div class="input-group-prepend">
89
+              <span class="input-group-text">
90
+                <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
91
+              </span>
92
+              <input
93
+                class="form-control"
94
+                type="text"
95
+                name="FirstName"
96
+                v-model="userAddress.streetName"
97
+                disabled
98
+              />
99
+            </div>
100
+          </div>
101
+        </div>
102
+        <div class="row" style="text-align:left">
103
+          <div class="col-md-12" style="margin-bottom: 1em">
104
+            <label>Suburb</label>
105
+            <div class="input-group-prepend">
106
+              <span class="input-group-text">
107
+                <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
108
+              </span>
109
+              <input
110
+                class="form-control"
111
+                type="text"
112
+                name="FirstName"
113
+                v-model="userAddress.suburb"
114
+                disabled
115
+              />
116
+            </div>
117
+          </div>
118
+        </div>
119
+        <div class="row" style="text-align:left">
120
+          <div class="col-md-12" style="margin-bottom: 1em">
121
+            <label>City</label>
122
+            <div class="input-group-prepend">
123
+              <span class="input-group-text">
124
+                <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
125
+              </span>
126
+              <input
127
+                class="form-control"
128
+                type="text"
129
+                name="FirstName"
130
+                v-model="userAddress.city"
131
+                disabled
132
+              />
133
+            </div>
134
+          </div>
135
+        </div>
136
+        <div class="row" style="text-align:left">
137
+          <div class="col-md-12" style="margin-bottom: 1em">
138
+            <label>Province</label>
139
+            <div class="input-group-prepend">
140
+              <span class="input-group-text">
141
+                <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
142
+              </span>
143
+              <input
144
+                class="form-control"
145
+                type="text"
146
+                name="FirstName"
147
+                v-model="userAddress.province"
148
+                disabled
149
+              />
150
+            </div>
151
+          </div>
152
+        </div>
153
+        <div class="row" style="text-align:left">
154
+          <div class="col-md-12" style="margin-bottom: 1em">
155
+            <label>Postal Code</label>
156
+            <div class="input-group-prepend">
157
+              <span class="input-group-text">
158
+                <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
159
+              </span>
160
+              <input
161
+                class="form-control"
162
+                type="text"
163
+                name="FirstName"
164
+                v-model="userAddress.postalCode"
165
+                disabled
166
+              />
167
+            </div>
168
+          </div>
169
+        </div>
170
+        <div class="row">
171
+          <div class="col-md-4" style="margin-bottom: 1em">
172
+            <button @click="Continue" class="btn btn-b-n" type="button">Use Above Address</button>
173
+          </div>
174
+        </div>
175
+      </div>
176
+      <div class="col-md-6" style="margin-bottomL 1em">
177
+        <Map :showAutoComplete="false" :showLocationLabel="false" :setLocation="mapCoords" />
178
+      </div>
179
+    </div>
180
+
181
+    <modal name="map" :width="600" :height="620">
182
+      <div class="container">
183
+        <h2>Update Location</h2>
184
+        <br />
185
+        <Map :showLocationLabel="false" @GoogleAddress="UpdateAddress" />
186
+        <div class="row" style="text-align:left">
187
+          <div class="col-md-4" style="margin-bottom: 1em">
188
+            <button @click="HideMap()" class="btn btn-b-n" type="button" data-dismiss="modal">Close</button>
189
+          </div>
190
+        </div>
191
+      </div>
192
+    </modal>
193
+  </div>
194
+</template>
195
+
196
+<script>
197
+import Map from "../../shared/mapSetLocation";
198
+import { mapState, mapActions } from "vuex";
199
+import Log from "../../../assets/Log";
200
+
201
+export default {
202
+  name: "confirmAddress",
203
+  components: {
204
+    Map,
205
+  },
206
+  data() {
207
+    return {
208
+      varbla: false,
209
+    };
210
+  },
211
+  methods: {
212
+    ...mapActions("user", ["getUserAddress"]),
213
+    selectionChanged() {
214
+      this.userAddress.isComplex = !this.userAddress.isComplex;
215
+    },
216
+    ShowMap() {
217
+      this.$modal.show("map");
218
+    },
219
+    HideMap() {
220
+      this.$modal.hide("map");
221
+    },
222
+    GetLocation() {
223
+      navigator.geolocation.getCurrentPosition((position) => {
224
+        // this.center = {
225
+        //   lat: position.coords.latitude,
226
+        //   lng: position.coords.longitude,
227
+        // };
228
+        alert(JSON.stringify(position));
229
+      });
230
+    },
231
+    Continue() {
232
+      this.order.deliveryAddress = this.userAddress;
233
+      this.order.items = this.cartItems;
234
+      this.$emit("can-continue", { value: true });
235
+    },
236
+    UpdateAddress(address) {
237
+      this.userAddress.streetNumber = address.streetNumber;
238
+      this.userAddress.streetName = address.streetName;
239
+      this.userAddress.suburb = address.suburb;
240
+      this.userAddress.city = address.city;
241
+      this.userAddress.province = address.province;
242
+      this.userAddress.country = address.country;
243
+      this.userAddress.postalCode = address.postalCode;
244
+      this.userAddress.googleMapUrl = address.url;
245
+      this.userAddress.latitude = address.coordinates.lat;
246
+      this.userAddress.longitude = address.coordinates.lng;
247
+      this.$emit("can-continue", { value: true });
248
+    },
249
+  },
250
+  computed: {
251
+    ...mapState("user", ["userAddress"]),
252
+    ...mapState("cart", ["cartItems"]),
253
+    ...mapState("order", ["order"]),
254
+    mapCoords() {
255
+      var coords = {
256
+        lat: this.userAddress.latitude,
257
+        lng: this.userAddress.longitude,
258
+      };
259
+      return coords;
260
+    },
261
+    CurrentPosition() {
262
+      this.$getLocation(options).then((coordinates) => {
263
+        alert(coordinates);
264
+      });
265
+    },
266
+  },
267
+  mounted() {
268
+    this.getUserAddress(Log.userId());
269
+    this.CurrentPosition();
270
+  },
271
+};
272
+</script>

+ 78
- 0
src/components/orders/orderConf/makePayment.vue View File

1
+<template>
2
+  <div class="container">
3
+    <!-- Place holder for payment gateway -->
4
+    <div class="row" style="text-align:left">
5
+      <div class="col-md-12" style="margin-bottom: 1em">
6
+        <div class="input-group-prepend">
7
+          <label>Method Of Payment:</label>
8
+          <secion>
9
+            <ul>
10
+              <li v-for="(mop, i) in methodsOfPayment" :key="i">
11
+                <input
12
+                  type="radio"
13
+                  :id="mop"
14
+                  :value="mop"
15
+                  name="RadioOption"
16
+                  v-model="selectedMop"
17
+                  @change="UpdateSelection(mop)"
18
+                />
19
+                <label :for="mop">{{ mop }}</label>
20
+              </li>
21
+            </ul>
22
+          </secion>
23
+        </div>
24
+      </div>
25
+    </div>
26
+    <div v-if="showGateWay" class="row">
27
+      <div class="col-md-12" style="margin-bottom: 1em">
28
+        <iframe src="https://www.w3schools.com" title="W3Schools Free Online Web Tutorials"></iframe>
29
+      </div>
30
+    </div>
31
+    <div class="row">
32
+      <div class="col-md-4" style="margin-bottom: 1em">
33
+        <button @click="Continue" class="btn btn-b-n" type="button">Payment Made</button>
34
+      </div>
35
+    </div>
36
+  </div>
37
+</template>
38
+
39
+<script>
40
+import { mapState, mapActions } from "vuex";
41
+import Log from "../../../assets/Log";
42
+
43
+export default {
44
+  name: "makePayment",
45
+  data() {
46
+    return {
47
+      selectedMop: "",
48
+      showGateWay: false,
49
+    };
50
+  },
51
+  methods: {
52
+    ...mapActions("restaurant", ["getMethodsOfPayment"]),
53
+    UpdateSelection(value) {
54
+      if (value === "Account" || value === "Cash On Delivery") {
55
+        this.showGateWay = false;
56
+      } else {
57
+        this.showGateWay = true;
58
+      }
59
+      this.$emit("can-continue", { value: !this.showGateWay });
60
+    },
61
+    Continue() {
62
+      this.order.mop = this.selectedMop;
63
+      this.order.payment = {};
64
+
65
+      console.log(JSON.stringify(this.order));
66
+      this.$emit("can-continue", { value: true });
67
+    },
68
+  },
69
+  computed: {
70
+    ...mapState("restaurant", ["methodsOfPayment"]),
71
+    ...mapState("cart", ["cartItems"]),
72
+    ...mapState("order", ["order"]),
73
+  },
74
+  mounted() {
75
+    this.getMethodsOfPayment(this.cartItems[0].restaurantId); //check how the ID is passed...
76
+  },
77
+};
78
+</script>

+ 10
- 0
src/components/orders/orderConf/orderPlaced.vue View File

1
+<template>
2
+  <div class="container">
3
+    <div class="col-md-6">
4
+      <div class="row">order list here</div>
5
+    </div>
6
+    <div class="col-md-6">
7
+      <div class="row">Delivery Address Here</div>
8
+    </div>
9
+  </div>
10
+</template>

+ 32
- 8
src/components/orders/orderOptionSelection.vue View File

22
         <label>{{ choice.description }}</label>
22
         <label>{{ choice.description }}</label>
23
       </div>
23
       </div>
24
       <!-- Qty -->
24
       <!-- Qty -->
25
-      <div class="col-sm-3" v-if="choice.price > 0">
25
+      <div class="col-sm-3" v-if="choice.price > 0 && choice.showQty">
26
         <input
26
         <input
27
           class="form-control"
27
           class="form-control"
28
           type="number"
28
           type="number"
45
 export default {
45
 export default {
46
   name: "optionSelection",
46
   name: "optionSelection",
47
   props: {
47
   props: {
48
-    item: { type: Object, default: () => {} }
48
+    item: { type: Object, default: () => {} },
49
+    savedSelection: { type: Array, default: () => [] },
49
   },
50
   },
50
   data() {
51
   data() {
51
     return {
52
     return {
52
       selection: [],
53
       selection: [],
53
-      qtys: []
54
+      qtys: [],
54
     };
55
     };
55
   },
56
   },
56
   methods: {
57
   methods: {
57
     UpdateSelection(field, index) {
58
     UpdateSelection(field, index) {
59
+      if (this.item.optionType === "Single") {
60
+        // // this.qtys.splice(0, this.qtys.length);
61
+        // // this.selection.splice(0, this.selection.length);
62
+        // this.selection = [];
63
+        // this.qtys = [];
64
+      }
65
+
58
       this.qtys[index] = 1;
66
       this.qtys[index] = 1;
59
       const item = {
67
       const item = {
60
         field: field,
68
         field: field,
61
-        value: this.selection[index]
69
+        value: this.selection[index],
62
       };
70
       };
63
 
71
 
64
       item.field.qty = this.qtys[index];
72
       item.field.qty = this.qtys[index];
66
       if (!item.value) {
74
       if (!item.value) {
67
         this.qtys[index] = "Undefined";
75
         this.qtys[index] = "Undefined";
68
       }
76
       }
77
+
69
       this.$emit("UpdateSelection", item);
78
       this.$emit("UpdateSelection", item);
70
     },
79
     },
71
     UpdateSelectionQty(field, index) {
80
     UpdateSelectionQty(field, index) {
72
       field.qty = Number(this.qtys[index]);
81
       field.qty = Number(this.qtys[index]);
73
-
74
-      //alert(JSON.stringify(field));
75
       this.$emit("UpdateSelectionQty", field);
82
       this.$emit("UpdateSelectionQty", field);
76
-    }
77
-  }
83
+    },
84
+  },
85
+  watch: {
86
+    savedSelection: {
87
+      immediate: true,
88
+      handler(val, oldVal) {
89
+        if (val) {
90
+          for (let i = 0; i < this.item.options.length; i++) {
91
+            for (let j = 0; j < val.length; j++) {
92
+              if (val[j].id == this.item.options[i].id) {
93
+                this.qtys[i] = 1;
94
+                this.selection[i] = this.item.options[i];
95
+              }
96
+            }
97
+          }
98
+        }
99
+      },
100
+    },
101
+  },
78
 };
102
 };
79
 </script>
103
 </script>

+ 19
- 19
src/components/shared/mapSetLocation.vue View File

28
   name: "MapLocation",
28
   name: "MapLocation",
29
   props: {
29
   props: {
30
     showMap: {
30
     showMap: {
31
-      default: true
31
+      default: true,
32
     },
32
     },
33
     showLocationLabel: {
33
     showLocationLabel: {
34
-      default: true
34
+      default: true,
35
     },
35
     },
36
     showAutoComplete: {
36
     showAutoComplete: {
37
-      default: true
37
+      default: true,
38
     },
38
     },
39
     setLocation: {
39
     setLocation: {
40
-      default: {}
41
-    }
40
+      default: {},
41
+    },
42
   },
42
   },
43
   data() {
43
   data() {
44
     return {
44
     return {
45
       coordinates: {
45
       coordinates: {
46
         lat: 0,
46
         lat: 0,
47
-        lng: 0
47
+        lng: 0,
48
       },
48
       },
49
       center: { lat: 0, lng: 0 },
49
       center: { lat: 0, lng: 0 },
50
       markers: [],
50
       markers: [],
57
       province: "",
57
       province: "",
58
       country: "",
58
       country: "",
59
       postalCode: "",
59
       postalCode: "",
60
-      url: ""
60
+      url: "",
61
     };
61
     };
62
   },
62
   },
63
   created() {
63
   created() {
64
     this.$getLocation({})
64
     this.$getLocation({})
65
-      .then(coord => {
65
+      .then((coord) => {
66
         this.coordinates = coord;
66
         this.coordinates = coord;
67
         //this.markers.push({ position: coord })
67
         //this.markers.push({ position: coord })
68
       })
68
       })
69
-      .catch(error => alert(error));
69
+      .catch((error) => alert(error));
70
   },
70
   },
71
 
71
 
72
   mounted() {
72
   mounted() {
117
       if (this.currentPlace) {
117
       if (this.currentPlace) {
118
         const marker = {
118
         const marker = {
119
           lat: this.currentPlace.geometry.location.lat(),
119
           lat: this.currentPlace.geometry.location.lat(),
120
-          lng: this.currentPlace.geometry.location.lng()
120
+          lng: this.currentPlace.geometry.location.lng(),
121
         };
121
         };
122
         this.markers = [];
122
         this.markers = [];
123
         this.places = [];
123
         this.places = [];
135
           country: this.country,
135
           country: this.country,
136
           postalCode: this.postalCode,
136
           postalCode: this.postalCode,
137
           url: this.url,
137
           url: this.url,
138
-          coordinates: marker
138
+          coordinates: marker,
139
         });
139
         });
140
       }
140
       }
141
     },
141
     },
142
-    geolocate: function() {
143
-      navigator.geolocation.getCurrentPosition(position => {
142
+    geolocate: function () {
143
+      navigator.geolocation.getCurrentPosition((position) => {
144
         this.center = {
144
         this.center = {
145
           lat: position.coords.latitude,
145
           lat: position.coords.latitude,
146
-          lng: position.coords.longitude
146
+          lng: position.coords.longitude,
147
         };
147
         };
148
       });
148
       });
149
-    }
149
+    },
150
   },
150
   },
151
   watch: {
151
   watch: {
152
     setLocation: {
152
     setLocation: {
153
       immediate: true,
153
       immediate: true,
154
       handler(val, oldVal) {
154
       handler(val, oldVal) {
155
-        if (val) {
155
+        if (val && val.lat) {
156
           this.coordinates = val;
156
           this.coordinates = val;
157
           this.markers = [];
157
           this.markers = [];
158
           this.markers.push({ position: val });
158
           this.markers.push({ position: val });
159
         }
159
         }
160
-      }
161
-    }
162
-  }
160
+      },
161
+    },
162
+  },
163
 };
163
 };
164
 </script>
164
 </script>

+ 7
- 6
src/components/shared/navBar.vue View File

175
     isLoggedIn() {
175
     isLoggedIn() {
176
       // console.log(Log.isLoggedIn());
176
       // console.log(Log.isLoggedIn());
177
       // return Log.isLoggedIn();
177
       // return Log.isLoggedIn();
178
-      return true;
178
+      return false;
179
     },
179
     },
180
     NAME() {
180
     NAME() {
181
       //return Log.getPerson().name;
181
       //return Log.getPerson().name;
182
       return "UserName";
182
       return "UserName";
183
     },
183
     },
184
     SystemRole() {
184
     SystemRole() {
185
-      //return "Customer";
185
+      return "Customer";
186
       //return "SuperAdmin";
186
       //return "SuperAdmin";
187
-      return "RestaurantAdmin";
187
+
188
+      //return "RestaurantAdmin";
188
     },
189
     },
189
     // eslint-disable-next-line vue/return-in-computed-property
190
     // eslint-disable-next-line vue/return-in-computed-property
190
     Logout() {
191
     Logout() {
192
     },
193
     },
193
     CartCount() {
194
     CartCount() {
194
       return this.cartItems.length;
195
       return this.cartItems.length;
195
-    }
196
+    },
196
   },
197
   },
197
   methods: {
198
   methods: {
198
     //...mapActions("authentication", ["logout"]),
199
     //...mapActions("authentication", ["logout"]),
204
     },
205
     },
205
     GoToCart() {
206
     GoToCart() {
206
       this.$router.push("/Cart");
207
       this.$router.push("/Cart");
207
-    }
208
-  }
208
+    },
209
+  },
209
 };
210
 };
210
 </script>
211
 </script>
211
 <style scoped>
212
 <style scoped>

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

19
 import RestaurantMenu from "../components/restaurants/restaurantMenu.vue";
19
 import RestaurantMenu from "../components/restaurants/restaurantMenu.vue";
20
 import RestaurantMenuOptions from "../components/restaurants/restaurantMenuOptions.vue";
20
 import RestaurantMenuOptions from "../components/restaurants/restaurantMenuOptions.vue";
21
 import RestaurantMenuOption from "../components/restaurants/restaurantMenuOption.vue";
21
 import RestaurantMenuOption from "../components/restaurants/restaurantMenuOption.vue";
22
-import RestaurantMenuItem from "../components/restaurants/restaurantMenuItem.vue"
22
+import RestaurantMenuItem from "../components/restaurants/restaurantMenuItem.vue";
23
 import RestaurantMenuItemOptions from "../components/restaurants/restaurantMenuItemOptions.vue";
23
 import RestaurantMenuItemOptions from "../components/restaurants/restaurantMenuItemOptions.vue";
24
 import MenuItems from "../components/home/menuItems.vue";
24
 import MenuItems from "../components/home/menuItems.vue";
25
 import Cart from "../components/orders/cart.vue";
25
 import Cart from "../components/orders/cart.vue";
26
 import RestaurantUsers from "../components/restaurants/restaurantUsers.vue";
26
 import RestaurantUsers from "../components/restaurants/restaurantUsers.vue";
27
 import RestaurantRoles from "../components/restaurants/restaurantRoles.vue";
27
 import RestaurantRoles from "../components/restaurants/restaurantRoles.vue";
28
 import RestaurantRole from "../components/restaurants/restaurantRole.vue";
28
 import RestaurantRole from "../components/restaurants/restaurantRole.vue";
29
+import OrderConfirmation from "../components/orders/confirmOrder.vue";
29
 
30
 
30
 Vue.use(Router);
31
 Vue.use(Router);
31
 
32
 
37
       y: 0
38
       y: 0
38
     };
39
     };
39
   },
40
   },
40
-  routes: [{
41
+  routes: [
42
+    {
41
       path: "/",
43
       path: "/",
42
       name: "Home",
44
       name: "Home",
43
       component: Home
45
       component: Home
151
       path: "/RestaurantRole/:id",
153
       path: "/RestaurantRole/:id",
152
       name: "RestaurantRole",
154
       name: "RestaurantRole",
153
       component: RestaurantRole
155
       component: RestaurantRole
156
+    },
157
+    {
158
+      path: "/ConfirmOrder",
159
+      name: "OrderConfirmation",
160
+      component: OrderConfirmation
154
     }
161
     }
155
   ]
162
   ]
156
 });
163
 });

+ 20
- 18
src/store/index.js View File

1
-import Vue from 'vue';
2
-import Vuex from 'vuex';
1
+import Vue from "vue";
2
+import Vuex from "vuex";
3
 
3
 
4
-import Registration from './modules/accounts/registration';
5
-import Authentication from './modules/accounts/authentication';
6
-import RestaurantSearch from './modules/restaurants/restaurantSearch';
7
-import RestaurantCategories from './modules/restaurants/restaurantCategories';
8
-import Restaurant from './modules/restaurants/restaurant';
9
-import MOPs from './modules/shared/restaurantMOP'
10
-import User from './modules/users/user';
11
-import MenuCategories from './modules/restaurants/restaurantMenuCategories';
12
-import MenuOptions from './modules/restaurants/restaurantMenuOptions';
13
-import Menu from './modules/restaurants/restaurantMenu';
14
-import HomeMenu from './modules/restaurants/menu';
15
-import Cart from './modules/orders/cart';
16
-import RestaurantUser from './modules/restaurants/restaurantUsers';
17
-import RestaurantRoles from './modules/restaurants/restaurantRoles';
4
+import Registration from "./modules/accounts/registration";
5
+import Authentication from "./modules/accounts/authentication";
6
+import RestaurantSearch from "./modules/restaurants/restaurantSearch";
7
+import RestaurantCategories from "./modules/restaurants/restaurantCategories";
8
+import Restaurant from "./modules/restaurants/restaurant";
9
+import MOPs from "./modules/shared/restaurantMOP";
10
+import User from "./modules/users/user";
11
+import MenuCategories from "./modules/restaurants/restaurantMenuCategories";
12
+import MenuOptions from "./modules/restaurants/restaurantMenuOptions";
13
+import Menu from "./modules/restaurants/restaurantMenu";
14
+import HomeMenu from "./modules/restaurants/menu";
15
+import Cart from "./modules/orders/cart";
16
+import RestaurantUser from "./modules/restaurants/restaurantUsers";
17
+import RestaurantRoles from "./modules/restaurants/restaurantRoles";
18
+import Order from "./modules/orders/order";
18
 
19
 
19
 Vue.use(Vuex);
20
 Vue.use(Vuex);
20
 /* eslint no-param-reassign: ["error", { "props": false }] */
21
 /* eslint no-param-reassign: ["error", { "props": false }] */
33
     homeMenu: HomeMenu,
34
     homeMenu: HomeMenu,
34
     cart: Cart,
35
     cart: Cart,
35
     restaurantUser: RestaurantUser,
36
     restaurantUser: RestaurantUser,
36
-    restaurantRoles: RestaurantRoles
37
-  },
37
+    restaurantRoles: RestaurantRoles,
38
+    order: Order
39
+  }
38
 });
40
 });

+ 16
- 5
src/store/modules/orders/cart.js View File

1
-import axios from 'axios'
1
+import axios from "axios";
2
 
2
 
3
 export default {
3
 export default {
4
   namespaced: true,
4
   namespaced: true,
5
   state: {
5
   state: {
6
-    cartItems: []
6
+    cartItems: [],
7
+    deliveryFee: 0
8
+  },
9
+  mutations: {
10
+    setDeliveryFee(state, fee) {
11
+      state.deliveryFee = fee;
12
+    }
7
   },
13
   },
8
-  mutations: {},
9
   getters: {},
14
   getters: {},
10
-  actions: {}
11
-}
15
+  actions: {
16
+    getDeliveryFee({ commit }, restaurantId) {
17
+      axios
18
+        .get(`/api/restaurant/GetDeliveryFee/${restaurantId}`)
19
+        .then(restult => commit("setDeliveryFee", restult.data));
20
+    }
21
+  }
22
+};

+ 45
- 0
src/store/modules/orders/order.js View File

1
+import axios from "axios";
2
+
3
+export default {
4
+  namespaced: true,
5
+  state: {
6
+    order: {},
7
+    orders: [],
8
+    orderItems: []
9
+  },
10
+  mutations: {
11
+    setOrder(state, order) {
12
+      state.order = order;
13
+    },
14
+    setOrders(state, orders) {
15
+      state.orders = orders;
16
+    },
17
+    setOrderItems(state, items) {
18
+      state.orderItems = items;
19
+    }
20
+  },
21
+  getters: {},
22
+  actions: {
23
+    getOrder({ commit }, id) {
24
+      axios.get(`/api/order/${id}`).then(result => commit("setOrder", result.data));
25
+    },
26
+    getUserOrders({ commit }, userId) {
27
+      axios
28
+        .get(`/api/order/GetUserOrders/${userId}`)
29
+        .then(result => commit("setOrders", result.data));
30
+    },
31
+    getRestaurantOrders({ commit }, restaurantId) {
32
+      axios
33
+        .get(`/api/order/GetRestaurantOrders/${restaurantId}`)
34
+        .then(result => commit("setOrders", result.data));
35
+    },
36
+    getOrderItems({ commit }, orderId) {
37
+      axios
38
+        .get(`/api/order/GetOrderItems/${orderId}`)
39
+        .then(result => commit("setOrderItems", result.data));
40
+    },
41
+    saveOrder({ commit }, order) {
42
+      axios.post("/api/order", order).then(result => commit("setOrders", result.data));
43
+    }
44
+  }
45
+};

+ 21
- 29
src/store/modules/restaurants/restaurant.js View File

1
-import axios from 'axios'
2
-import {
3
-  result
4
-} from 'lodash';
1
+import axios from "axios";
2
+import { result } from "lodash";
5
 
3
 
6
 export default {
4
 export default {
7
   namespaced: true,
5
   namespaced: true,
9
     restaurants: [],
7
     restaurants: [],
10
     restaurant: {},
8
     restaurant: {},
11
     tradingHour: {},
9
     tradingHour: {},
12
-    tradingHours: []
10
+    tradingHours: [],
11
+    methodsOfPayment: []
13
   },
12
   },
14
   mutations: {
13
   mutations: {
15
     setRestaurants(state, restaurants) {
14
     setRestaurants(state, restaurants) {
20
     },
19
     },
21
     setTradingHours(state, thours) {
20
     setTradingHours(state, thours) {
22
       state.tradingHours = thours;
21
       state.tradingHours = thours;
22
+    },
23
+    setMethodsOfPayment(state, mops) {
24
+      state.methodsOfPayment = mops;
23
     }
25
     }
24
   },
26
   },
25
   getters: {},
27
   getters: {},
26
   actions: {
28
   actions: {
27
-    getRestaurants({
28
-      commit
29
-    }) {
29
+    getRestaurants({ commit }) {
30
       axios
30
       axios
31
-        .get('/api/restaurant/getrestaurants')
31
+        .get("/api/restaurant/getrestaurants")
32
         .then(result => commit("setRestaurants", result.data));
32
         .then(result => commit("setRestaurants", result.data));
33
     },
33
     },
34
-    getRestaurant({
35
-      commit
36
-    }, id) {
37
-      axios
38
-        .get(`/api/restaurant/${id}`)
39
-        .then(result => commit("setRestaurant", result.data));
34
+    getRestaurant({ commit }, id) {
35
+      axios.get(`/api/restaurant/${id}`).then(result => commit("setRestaurant", result.data));
40
     },
36
     },
41
-    getTradingHours({
42
-      commit
43
-    }, id) {
37
+    getTradingHours({ commit }, id) {
44
       axios
38
       axios
45
         .get(`/api/restaurant/GetTradingHours/${id}`)
39
         .get(`/api/restaurant/GetTradingHours/${id}`)
46
         .then(result => commit("setTradingHours", result.data));
40
         .then(result => commit("setTradingHours", result.data));
47
     },
41
     },
48
-    updateRestaurant({
49
-      commit
50
-    }, restaurant) {
42
+    getMethodsOfPayment({ commit }, id) {
51
       axios
43
       axios
52
-        .put('/api/Restaurant', restaurant)
53
-        .then(result => commit("setRestaurant", restaurant))
44
+        .get(`/api/restaurant/GetMethodsOfPayment/${id}`)
45
+        .then(result => commit("setMethodsOfPayment", result.data));
54
     },
46
     },
55
-    removeTradingHours({
56
-      commit
57
-    }, id) {
58
-      axios
59
-        .delete(`/api/Restaurant/RemoveTradingHours/${id}`)
47
+    updateRestaurant({ commit }, restaurant) {
48
+      axios.put("/api/Restaurant", restaurant).then(result => commit("setRestaurant", restaurant));
49
+    },
50
+    removeTradingHours({ commit }, id) {
51
+      axios.delete(`/api/Restaurant/RemoveTradingHours/${id}`);
60
     }
52
     }
61
   }
53
   }
62
-}
54
+};

Loading…
Cancel
Save