ソースを参照

Cart & Orders WIP

master
George Williams 4年前
コミット
5c1e1737d8

+ 4166
- 0
package-lock.json
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 1
- 0
package.json ファイルの表示

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

+ 1
- 1
public/index.html ファイルの表示

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

+ 3
- 3
src/App.vue ファイルの表示

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

+ 20
- 17
src/assets/Log.js ファイルの表示

@@ -1,12 +1,12 @@
1 1
 const items = {
2 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 8
   tokenExpired() {
9
-    const item = this.getJSONObject('token');
9
+    const item = this.getJSONObject("token");
10 10
     if (!item && !item.expires && item.expires !== null) {
11 11
       const today = new Date();
12 12
       const date = `${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`;
@@ -17,11 +17,11 @@ const items = {
17 17
     return true;
18 18
   },
19 19
   updateTokenExpiry() {
20
-    const item = this.getJSONObject('token');
20
+    const item = this.getJSONObject("token");
21 21
     if (!item && !item.expires) {
22 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 27
   getJSONObject(itemString) {
@@ -39,22 +39,25 @@ const items = {
39 39
     return new Date(dateTime + 15 * 60000);
40 40
   },
41 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 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 50
   restaurantId() {
51
-    return 1;
51
+    return 2;
52
+  },
53
+  userId() {
54
+    return 4;
52 55
   },
53 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 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 63
 export default items;

+ 10
- 9
src/components/customer/customerDetails.vue ファイルの表示

@@ -261,15 +261,16 @@
261 261
 <script>
262 262
 import Map from "../shared/mapSetLocation";
263 263
 import { mapState, mapActions } from "vuex";
264
+import Log from "../../assets/Log";
264 265
 
265 266
 export default {
266 267
   name: "CustomerDetails",
267 268
   components: {
268
-    Map
269
+    Map,
269 270
   },
270 271
   data() {
271 272
     return {
272
-      complex: false
273
+      complex: false,
273 274
     };
274 275
   },
275 276
   methods: {
@@ -284,7 +285,7 @@ export default {
284 285
       this.$modal.hide("map");
285 286
     },
286 287
     UpdateAddress(address) {
287
-      console.log(JSON.stringify(address));
288
+      this.userAddress.userId = this.user.id;
288 289
       this.userAddress.streetNumber = address.streetNumber;
289 290
       this.userAddress.streetName = address.streetName;
290 291
       this.userAddress.suburb = address.suburb;
@@ -303,21 +304,21 @@ export default {
303 304
     },
304 305
     Close() {
305 306
       this.$router.push("/");
306
-    }
307
+    },
307 308
   },
308 309
   computed: {
309 310
     ...mapState("user", ["user", "userAddress"]),
310 311
     mapCoords() {
311 312
       var coords = {
312 313
         lat: this.userAddress.latitude,
313
-        lng: this.userAddress.longitude
314
+        lng: this.userAddress.longitude,
314 315
       };
315 316
       return coords;
316
-    }
317
+    },
317 318
   },
318 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 324
 </script>

+ 27
- 9
src/components/home/menuItems.vue ファイルの表示

@@ -25,7 +25,7 @@
25 25
               <h4 class="card-info-title">
26 26
                 <img src="/img/delivery-truck-with-dollar.png" height="30px" width="30px" />
27 27
               </h4>
28
-              <span>{{ menu.deliveryFee }}</span>
28
+              <span>{{ menu.deliveryFee | toCurrency }}</span>
29 29
             </li>
30 30
             <li>
31 31
               <h4 class="card-info-title">
@@ -74,6 +74,14 @@
74 74
                     class="img-b img-fluid"
75 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 85
                 </div>
78 86
                 <div class="card-overlay">
79 87
                   <div class="card-header-b">
@@ -98,7 +106,11 @@
98 106
       </div>
99 107
     </div>
100 108
     <div v-else>
101
-      <MenuOptions :showItem="CurrentOption" @CloseOptions="CloseOptions" />
109
+      <MenuOptions
110
+        :showItem="CurrentOption"
111
+        :restaurantId="restaurantId"
112
+        @CloseOptions="CloseOptions"
113
+      />
102 114
     </div>
103 115
   </div>
104 116
 </template>
@@ -110,34 +122,40 @@ import MenuOptions from "./menuOptions";
110 122
 export default {
111 123
   name: "MenuLayout",
112 124
   components: {
113
-    MenuOptions
125
+    MenuOptions,
114 126
   },
115 127
   data() {
116 128
     return {
117 129
       wait: true,
118 130
       radio: "",
119
-      showOptions: false
131
+      showOptions: false,
132
+      restaurantId: this.$route.params.restautantid,
120 133
     };
121 134
   },
122 135
   methods: {
123 136
     ...mapActions("homeMenu", ["getMenu", "getOptions"]),
124 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 143
     CloseOptions(value) {
129 144
       this.showOptions = value;
130
-    }
145
+    },
131 146
   },
132 147
   computed: {
133 148
     ...mapState("homeMenu", ["menu", "options"]),
134 149
     CurrentOption() {
135 150
       return this.options;
136
-    }
151
+    },
152
+    DeliveryFee() {
153
+      return this.menu.deliveryFee;
154
+    },
137 155
   },
138 156
   mounted() {
139 157
     this.getMenu(this.$route.params.restautantid);
140
-  }
158
+  },
141 159
   // watch: {
142 160
   //   options: {
143 161
   //     immediate: true,

+ 25
- 13
src/components/home/menuOptions.vue ファイルの表示

@@ -130,10 +130,11 @@ import optionSelector from "../orders/orderOptionSelection";
130 130
 export default {
131 131
   name: "MenuOptions",
132 132
   props: {
133
-    showItem: { default: {} }
133
+    showItem: { default: {} },
134
+    restaurantId: { default: 0 },
134 135
   },
135 136
   components: {
136
-    optionSelector
137
+    optionSelector,
137 138
   },
138 139
   data() {
139 140
     return {
@@ -141,7 +142,7 @@ export default {
141 142
       item: {},
142 143
       qty: 1,
143 144
       subTotal: 0,
144
-      selection: []
145
+      selection: [],
145 146
     };
146 147
   },
147 148
   methods: {
@@ -175,18 +176,29 @@ export default {
175 176
       }
176 177
     },
177 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 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 189
       const cartItem = {
182 190
         id: this.item.id,
183 191
         description: this.item.description,
184 192
         image: this.item.image,
185 193
         name: this.item.name,
186
-        subTotal: this.subTotal,
187
-        specialInstructions: this.specialInstructions,
194
+        subTotal: this.SubTotal,
195
+        specialInstructions: this.item.specialInstructions,
188 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 204
       this.cartItems.push(cartItem);
@@ -194,10 +206,10 @@ export default {
194 206
       this.selection = [];
195 207
       this.qty = 1;
196 208
       this.$emit("CloseOptions", false);
197
-    }
209
+    },
198 210
   },
199 211
   computed: {
200
-    ...mapState("cart", ["cartItems"]),
212
+    ...mapState("cart", ["cartItems", "deliveryFee"]),
201 213
     SubTotal() {
202 214
       var price = this.item.price * this.qty;
203 215
 
@@ -208,7 +220,7 @@ export default {
208 220
         }
209 221
       }
210 222
       return price;
211
-    }
223
+    },
212 224
   },
213 225
   watch: {
214 226
     showItem: {
@@ -218,8 +230,8 @@ export default {
218 230
           this.item = val;
219 231
           this.subTotal = this.item.price;
220 232
         }
221
-      }
222
-    }
223
-  }
233
+      },
234
+    },
235
+  },
224 236
 };
225 237
 </script>

+ 83
- 4
src/components/orders/cart.vue ファイルの表示

@@ -19,10 +19,64 @@
19 19
         @onEdit="Edit"
20 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 79
     </div>
23
-    <modal name="menu" :width="600" :height="auto">
24
-      <Cart :showItem="CurrentItem" />
25
-    </modal>
26 80
   </div>
27 81
 </template>
28 82
 
@@ -46,6 +100,7 @@ export default {
46 100
     };
47 101
   },
48 102
   methods: {
103
+    ...mapActions("cart", ["getDeliveryFee"]),
49 104
     New() {},
50 105
     Edit(item) {
51 106
       this.item = item;
@@ -54,12 +109,36 @@ export default {
54 109
     Delete(item) {
55 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 125
   computed: {
59
-    ...mapState("cart", ["cartItems"]),
126
+    ...mapState("cart", ["cartItems", "deliveryFee"]),
60 127
     CurrentItem() {
61 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 144
 </script>

+ 105
- 129
src/components/orders/cartItem.vue ファイルの表示

@@ -1,123 +1,120 @@
1 1
 <template>
2 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 34
                   </div>
33 35
                 </div>
34 36
               </div>
35 37
             </div>
36 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 70
               </div>
69 71
             </div>
70 72
           </div>
71 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 83
                 </div>
82 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 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 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 107
             </div>
105 108
           </div>
106 109
         </div>
107 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 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 118
       </div>
122 119
     </div>
123 120
   </div>
@@ -145,13 +142,6 @@ export default {
145 142
     };
146 143
   },
147 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 145
     Plus() {
156 146
       this.qty = this.qty + 1;
157 147
     },
@@ -161,9 +151,6 @@ export default {
161 151
         this.qty = 1;
162 152
       }
163 153
     },
164
-    CheckItem(value) {
165
-      alert(JSON.stringify(value));
166
-    },
167 154
     UpdateSelection(value) {
168 155
       if (value.value) {
169 156
         this.selection.push(value.field);
@@ -178,28 +165,18 @@ export default {
178 165
     UpdateSelectionQty(value) {
179 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 178
   computed: {
201 179
     ...mapState("cart", ["cartItems"]),
202
-    ...mapState("homeMenu", ["options"]),
203 180
     SubTotal() {
204 181
       var price = this.item.price * this.qty;
205 182
 
@@ -218,10 +195,9 @@ export default {
218 195
       handler(val, oldVal) {
219 196
         if (val) {
220 197
           this.item = val;
221
-          this.subTotal = this.item.price;
198
+          this.subTotal = this.item.price * this.item.qty;
222 199
           this.qty = this.item.qty;
223 200
           this.selection = this.item.selection;
224
-          this.getOptions(val);
225 201
         }
226 202
       },
227 203
     },

+ 92
- 0
src/components/orders/confirmOrder.vue ファイルの表示

@@ -0,0 +1,92 @@
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 ファイルの表示

@@ -0,0 +1,272 @@
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 ファイルの表示

@@ -0,0 +1,78 @@
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 ファイルの表示

@@ -0,0 +1,10 @@
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 ファイルの表示

@@ -22,7 +22,7 @@
22 22
         <label>{{ choice.description }}</label>
23 23
       </div>
24 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 26
         <input
27 27
           class="form-control"
28 28
           type="number"
@@ -45,20 +45,28 @@
45 45
 export default {
46 46
   name: "optionSelection",
47 47
   props: {
48
-    item: { type: Object, default: () => {} }
48
+    item: { type: Object, default: () => {} },
49
+    savedSelection: { type: Array, default: () => [] },
49 50
   },
50 51
   data() {
51 52
     return {
52 53
       selection: [],
53
-      qtys: []
54
+      qtys: [],
54 55
     };
55 56
   },
56 57
   methods: {
57 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 66
       this.qtys[index] = 1;
59 67
       const item = {
60 68
         field: field,
61
-        value: this.selection[index]
69
+        value: this.selection[index],
62 70
       };
63 71
 
64 72
       item.field.qty = this.qtys[index];
@@ -66,14 +74,30 @@ export default {
66 74
       if (!item.value) {
67 75
         this.qtys[index] = "Undefined";
68 76
       }
77
+
69 78
       this.$emit("UpdateSelection", item);
70 79
     },
71 80
     UpdateSelectionQty(field, index) {
72 81
       field.qty = Number(this.qtys[index]);
73
-
74
-      //alert(JSON.stringify(field));
75 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 103
 </script>

+ 19
- 19
src/components/shared/mapSetLocation.vue ファイルの表示

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

+ 7
- 6
src/components/shared/navBar.vue ファイルの表示

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

+ 9
- 2
src/router/index.js ファイルの表示

@@ -19,13 +19,14 @@ import RestaurantMenuCategories from "../components/restaurants/restaurantMenuCa
19 19
 import RestaurantMenu from "../components/restaurants/restaurantMenu.vue";
20 20
 import RestaurantMenuOptions from "../components/restaurants/restaurantMenuOptions.vue";
21 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 23
 import RestaurantMenuItemOptions from "../components/restaurants/restaurantMenuItemOptions.vue";
24 24
 import MenuItems from "../components/home/menuItems.vue";
25 25
 import Cart from "../components/orders/cart.vue";
26 26
 import RestaurantUsers from "../components/restaurants/restaurantUsers.vue";
27 27
 import RestaurantRoles from "../components/restaurants/restaurantRoles.vue";
28 28
 import RestaurantRole from "../components/restaurants/restaurantRole.vue";
29
+import OrderConfirmation from "../components/orders/confirmOrder.vue";
29 30
 
30 31
 Vue.use(Router);
31 32
 
@@ -37,7 +38,8 @@ export default new Router({
37 38
       y: 0
38 39
     };
39 40
   },
40
-  routes: [{
41
+  routes: [
42
+    {
41 43
       path: "/",
42 44
       name: "Home",
43 45
       component: Home
@@ -151,6 +153,11 @@ export default new Router({
151 153
       path: "/RestaurantRole/:id",
152 154
       name: "RestaurantRole",
153 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 ファイルの表示

@@ -1,20 +1,21 @@
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 20
 Vue.use(Vuex);
20 21
 /* eslint no-param-reassign: ["error", { "props": false }] */
@@ -33,6 +34,7 @@ export default new Vuex.Store({
33 34
     homeMenu: HomeMenu,
34 35
     cart: Cart,
35 36
     restaurantUser: RestaurantUser,
36
-    restaurantRoles: RestaurantRoles
37
-  },
37
+    restaurantRoles: RestaurantRoles,
38
+    order: Order
39
+  }
38 40
 });

+ 16
- 5
src/store/modules/orders/cart.js ファイルの表示

@@ -1,11 +1,22 @@
1
-import axios from 'axios'
1
+import axios from "axios";
2 2
 
3 3
 export default {
4 4
   namespaced: true,
5 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 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 ファイルの表示

@@ -0,0 +1,45 @@
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 ファイルの表示

@@ -1,7 +1,5 @@
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 4
 export default {
7 5
   namespaced: true,
@@ -9,7 +7,8 @@ export default {
9 7
     restaurants: [],
10 8
     restaurant: {},
11 9
     tradingHour: {},
12
-    tradingHours: []
10
+    tradingHours: [],
11
+    methodsOfPayment: []
13 12
   },
14 13
   mutations: {
15 14
     setRestaurants(state, restaurants) {
@@ -20,43 +19,36 @@ export default {
20 19
     },
21 20
     setTradingHours(state, thours) {
22 21
       state.tradingHours = thours;
22
+    },
23
+    setMethodsOfPayment(state, mops) {
24
+      state.methodsOfPayment = mops;
23 25
     }
24 26
   },
25 27
   getters: {},
26 28
   actions: {
27
-    getRestaurants({
28
-      commit
29
-    }) {
29
+    getRestaurants({ commit }) {
30 30
       axios
31
-        .get('/api/restaurant/getrestaurants')
31
+        .get("/api/restaurant/getrestaurants")
32 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 38
       axios
45 39
         .get(`/api/restaurant/GetTradingHours/${id}`)
46 40
         .then(result => commit("setTradingHours", result.data));
47 41
     },
48
-    updateRestaurant({
49
-      commit
50
-    }, restaurant) {
42
+    getMethodsOfPayment({ commit }, id) {
51 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
+};

読み込み中…
キャンセル
保存