Bladeren bron

Bid Offer screens & CRUD

master
George Williams 5 jaren geleden
bovenliggende
commit
c8c210327b

+ 68
- 29
src/components/processFlow/makeOffer.vue Bestand weergeven

@@ -1,7 +1,7 @@
1 1
 <template>
2 2
   <!-- eslint-disable max-len -->
3 3
   <div style="padding-left:50px; padding-right:50px; padding-bottom:50px;">
4
-    <div>
4
+    <div v-if="!isSaved">
5 5
       <br />
6 6
       <div v-if="isProperty">
7 7
         <div class="form-group row">
@@ -102,92 +102,131 @@
102 102
           <textarea
103 103
             class="form-control editor form-control-lg form-control-a"
104 104
             name="description"
105
-            v-model="item.comments"
105
+            v-model="item.comment"
106 106
             :disabled="!isMakeOffer"
107 107
           ></textarea>
108 108
         </div>
109 109
       </div>
110 110
     </div>
111
-    <div class="container">
111
+    <div v-if="!isSaved" class="container">
112 112
       <button
113 113
         v-if="isMakeOffer"
114 114
         type="button"
115 115
         @click="SendOffer()"
116 116
         class="btn btn-b-n"
117 117
         style="width: 150px; height:40px;"
118
-        data-dismiss="modal"
119 118
       >Send Offer</button>
120 119
       <button
121
-        v-if="!isMakeOffer && !isDecline"
120
+        v-if="!isMakeOffer && !isDecline && canEdit"
122 121
         type="submit"
123 122
         @click="Accept()"
124 123
         class="btn btn-b-n"
125 124
         style="width: 150px; height:40px;"
126
-        data-dismiss="modal"
127 125
       >Accept</button>
128 126
       <button
129
-        v-if="!isMakeOffer && !isDecline"
127
+        v-if="!isMakeOffer && !isDecline && canEdit"
130 128
         type="button"
131 129
         @click="Decline()"
132 130
         class="btn btn-b-n"
133 131
         style="width: 150px; height:40px;"
134 132
       >Decline</button>
135
-      <div v-if="isDecline" class="form-group row">
136
-        <div class="col-md-12">
137
-          <br />
138
-          <label>Decline Reason</label>
139
-          <textarea class="form-control editor form-control-lg form-control-a" name="description"></textarea>
140
-        </div>
133
+    </div>
134
+    <div v-if="isDecline || item.statusCode === 'E3'" class="form-group row">
135
+      <div class="col-md-12">
136
+        <br />
137
+        <label>Decline Reason</label>
138
+        <textarea
139
+          class="form-control editor form-control-lg form-control-a"
140
+          name="description"
141
+          v-model="item.declineReason"
142
+          :disabled="item.statusCode === 'E3'"
143
+        ></textarea>
144
+      </div>
145
+    </div>
146
+    <button
147
+      v-if="isDecline"
148
+      type="button"
149
+      @click="Complete()"
150
+      class="btn btn-b-n"
151
+      style="width: 150px; height:40px;"
152
+    >Complete</button>
153
+    <div v-if="isSaved">
154
+      <div class="form-group row">
155
+        <br />
156
+        <label>{{ message }}</label>
141 157
       </div>
142 158
       <button
143
-        v-if="isDecline"
159
+        v-if="isSaved"
144 160
         type="button"
145
-        @click="Complete()"
146 161
         class="btn btn-b-n"
147 162
         style="width: 150px; height:40px;"
148 163
         data-dismiss="modal"
149
-      >Complete</button>
164
+      >OK</button>
150 165
     </div>
151 166
   </div>
152 167
 </template>
153 168
 
154 169
 <script>
170
+import { mapState, mapActions } from 'vuex';
171
+
155 172
 export default {
156 173
   name: 'MakeOffer',
157 174
   props: {
158 175
     isMakeOffer: Boolean,
159 176
     isProperty: Boolean,
177
+    canEdit: Boolean,
160 178
     item: Object,
179
+    bidId: Number,
180
+    updateItem: Function,
161 181
   },
162 182
   data() {
163 183
     return {
164 184
       isDecline: false,
185
+      isSaved: false,
186
+      message: '',
165 187
     };
166 188
   },
167 189
   methods: {
190
+    ...mapActions('bid', ['getBid', 'saveBid', 'acceptBid', 'declineBid']),
168 191
     SendOffer() {
169
-      // Save Offer data
192
+      this.getBid(0);
193
+      this.bidItem.id = 0;
194
+      this.bidItem.amount = this.item.offer;
195
+      this.bidItem.comment = this.item.comment;
196
+      if (this.isProperty) {
197
+        this.bidItem.propertyId = this.item.id;
198
+      } else {
199
+        this.bidItem.timeshareWeekId = this.item.id;
200
+      }
201
+      this.saveBid(this.bidItem);
202
+
203
+      this.item = [];
204
+      this.isSaved = true;
205
+      this.message = 'Offer was submitted.';
170 206
     },
171 207
     Accept() {
172
-      // Accept Offer
208
+      this.acceptBid(this.item.id);
209
+      this.isSaved = true;
210
+      this.message = 'Offer Accepted.';
173 211
     },
174 212
     Decline() {
175 213
       this.isDecline = true;
176 214
     },
177 215
     Complete() {
178 216
       this.isDecline = false;
217
+
218
+      const decline = {
219
+        id: this.item.id,
220
+        comment: this.item.declineReason,
221
+      };
222
+
223
+      this.declineBid(decline);
224
+      this.isSaved = true;
225
+      this.message = 'Offer Declined.';
179 226
     },
180
-    Close() {},
227
+  },
228
+  computed: {
229
+    ...mapState('bid', ['bidItem']),
181 230
   },
182 231
 };
183 232
 </script>
184
-
185
-<style scoped>
186
-.myWell {
187
-  width: 100%;
188
-  background-color: rgba(217, 217, 217, 0.85);
189
-  border-radius: 6px;
190
-  padding: 5px;
191
-  margin: 3px;
192
-}
193
-</style>

+ 32
- 38
src/components/processFlow/offers.vue Bestand weergeven

@@ -20,14 +20,21 @@
20 20
           <tr>
21 21
             <th>Type</th>
22 22
             <th>Description</th>
23
+            <th>Status</th>
24
+            <th>Price</th>
25
+            <th>Offered Price</th>
26
+            <th>Offer By</th>
23 27
             <th></th>
24 28
           </tr>
25 29
         </thead>
26 30
         <tbody>
27
-          <tr v-for="(item, i) in items" :key="i">
28
-            <td v-if="item.isProperty">Property</td>
29
-            <td v-else>Timeshare</td>
30
-            <td>{{ item.uid }}</td>
31
+          <tr v-for="(item, i) in bidItems" :key="i">
32
+            <td>{{ item.type }}</td>
33
+            <td>{{ item.shortDescription }}</td>
34
+            <td>{{ item.status }}</td>
35
+            <td>R {{ formatPrice(item.price) }}</td>
36
+            <td>R {{ formatPrice(item.offer) }}</td>
37
+            <td>{{ item.madeBy }}</td>
31 38
             <td>
32 39
               <button
33 40
                 type="button"
@@ -46,7 +53,8 @@
46 53
                       <makeOffer
47 54
                         name="MakeOffer"
48 55
                         :isMakeOffer="false"
49
-                        :isProperty="item.isProperty"
56
+                        :isProperty="item.type === 'Property'"
57
+                        :canEdit="item.statusCode === 'E1'"
50 58
                         :item="item"
51 59
                       />
52 60
                     </div>
@@ -62,6 +70,7 @@
62 70
 </template>
63 71
 
64 72
 <script>
73
+import { mapState, mapActions } from 'vuex';
65 74
 import makeOffer from './makeOffer.vue';
66 75
 
67 76
 export default {
@@ -70,40 +79,25 @@ export default {
70 79
   data() {
71 80
     return {
72 81
       item: {},
73
-      items: [
74
-        {
75
-          isProperty: true,
76
-          uid: '1 - 2 Bedroom House',
77
-          id: 1,
78
-          shortDescription: '2 Bedroom House',
79
-          description: '<div><i>Property Description</i></div>',
80
-          price: 1000,
81
-          offer: 1500,
82
-          comments: 'Bla Bla Bla',
83
-        },
84
-        {
85
-          isProperty: false,
86
-          uid: 'NL N18 359',
87
-          id: 2,
88
-          shortDescription: '',
89
-          description: '',
90
-          price: 85000,
91
-          offer: 90000,
92
-          comments: 'I want to go....',
93
-          resort: 'Ngwenya Lodge',
94
-          unit: '359',
95
-          week: 'N18',
96
-          module: '359/N18 River View',
97
-        },
98
-      ],
99 82
     };
100 83
   },
101
-  //   methods: {
102
-  //     SetItem(data) {
103
-  //       this.item = data;
104
-  //       const element = this.$refs.modal.$el;
105
-  //       $(element).modal('show');
106
-  //     },
107
-  //   },
84
+  methods: {
85
+    ...mapActions('bid', ['getBids']),
86
+    // SetItem(data) {
87
+    //   this.item = data;
88
+    //   const element = this.$refs.modal.$el;
89
+    //   $(element).modal('show');
90
+    // },
91
+    formatPrice(value) {
92
+      const val = (value / 1).toFixed(2);
93
+      return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
94
+    },
95
+  },
96
+  computed: {
97
+    ...mapState('bid', ['bidItems']),
98
+  },
99
+  mounted() {
100
+    this.getBids();
101
+  },
108 102
 };
109 103
 </script>

+ 2
- 2
src/components/property/propertyPage.vue Bestand weergeven

@@ -83,8 +83,7 @@
83 83
                       </li>
84 84
                       <li class="d-flex justify-content-between">
85 85
                         <strong>Status:</strong>
86
-                        <span v-if="property.isSale">Sale</span>
87
-                        <span v-else>Rental</span>
86
+                        <span>{{ property.status.code }} - {{ property.status.description }}</span>
88 87
                       </li>
89 88
                       <li class="d-flex justify-content-between">
90 89
                         <strong>Address:</strong>
@@ -102,6 +101,7 @@
102 101
                     class="btn btn-b-n"
103 102
                     data-toggle="modal"
104 103
                     data-target="#myModal"
104
+                    :disabled="property.status.code === 'E1'"
105 105
                   >Make an Offer</button>
106 106
                   <div id="myModal" class="modal fade" role="dialog">
107 107
                     <div class="modal-dialog modal-lg">

+ 1
- 6
src/components/property/propertySearchPage.vue Bestand weergeven

@@ -55,12 +55,7 @@
55 55
         </div>
56 56
       </div>
57 57
       <div>
58
-        <propertyCard
59
-          v-if="properties.length > 0"
60
-          name="propertyholder"
61
-          :properties="properties"
62
-          :key="propertysearch"
63
-        />
58
+        <propertyCard v-if="properties.length > 0" name="propertyholder" :properties="properties" />
64 59
         <div v-if="properties.length === 0">
65 60
           <img src="../../../public/img/no-homes.gif" />
66 61
           <br />

+ 2
- 6
src/components/property/propertyeditPage.vue Bestand weergeven

@@ -276,12 +276,8 @@
276 276
               @click="SubmitData()"
277 277
               class="btn btn-b-n"
278 278
               style="width: 85px; height:40px;"
279
-            >
280
-              <!-- <span class="spinner-border" role="status" aria-hidden="true"></span>
281
-              <span class="sr-only">Loading...</span>-->
282
-              Save
283
-            </button>
284
-            <label v-if="wait">Please wait...</label>
279
+            >Save</button>
280
+            <div v-if="wait" id="preloader"></div>
285 281
           </form>
286 282
         </div>
287 283
       </div>

+ 2
- 0
src/store/index.js Bestand weergeven

@@ -15,6 +15,7 @@ import PropertyList from './modules/property/propertyLists';
15 15
 import PropertyTypes from './modules/property/propertyTypes';
16 16
 import Register from './modules/user/register';
17 17
 import WeekList from './modules/timeshare/weekList';
18
+import Bid from './modules/processFlow/bid';
18 19
 
19 20
 Vue.use(Vuex);
20 21
 /* eslint no-param-reassign: ["error", { "props": false }] */
@@ -35,5 +36,6 @@ export default new Vuex.Store({
35 36
     registerIndividual: Register,
36 37
     registerAgency: Register,
37 38
     weekList: WeekList,
39
+    bid: Bid,
38 40
   },
39 41
 });

+ 63
- 0
src/store/modules/processFlow/bid.js Bestand weergeven

@@ -0,0 +1,63 @@
1
+import axios from 'axios';
2
+
3
+export default {
4
+  namespaced: true,
5
+  state: {
6
+    bidItem: {},
7
+    bidItems: [],
8
+  },
9
+  mutations: {
10
+    setBid(state, bid) {
11
+      state.bidItem = bid;
12
+    },
13
+    setBids(state, bid) {
14
+      state.bidItems = bid;
15
+    },
16
+    addToBids(state, bid) {
17
+      state.bidItems.push(bid);
18
+    },
19
+    updateBidList(state, bid) {
20
+      state.bidItems.find(item => item.id === bid.id).status = bid.status;
21
+      console.log(JSON.stringify(bid));
22
+    },
23
+  },
24
+  getters: {},
25
+  actions: {
26
+    getBid({ commit }, id) {
27
+      axios
28
+        .get(`/api/bid/${id}`)
29
+        .then(result => commit('addToBids', result.data))
30
+        .catch(console.error);
31
+    },
32
+    getBids({ commit }) {
33
+      axios
34
+        .get('/api/bid/GetBids/hjsdhj')
35
+        .then(result => commit('setBids', result.data))
36
+        .catch(console.error);
37
+    },
38
+    saveBid({ commit }, item) {
39
+      axios
40
+        .post('/api/bid', item)
41
+        .then(result => commit('setBid', result.data))
42
+        .catch(console.error);
43
+    },
44
+    updateBid({ commit }, item) {
45
+      axios
46
+        .put('/api/bid', item)
47
+        .then(result => commit('setBid', item))
48
+        .catch(console.error);
49
+    },
50
+    acceptBid({ commit }, id) {
51
+      axios
52
+        .put(`/api/bid/AcceptBid/${id}`)
53
+        .then(result => commit('updateBidList', result.data))
54
+        .catch(console.error);
55
+    },
56
+    declineBid({ commit }, item) {
57
+      axios
58
+        .put('/api/bid/DeclineBid', item)
59
+        .then(result => commit('updateBidList', result.data))
60
+        .catch(console.error);
61
+    },
62
+  },
63
+};

Laden…
Annuleren
Opslaan