diff --git a/src/app/orders/orders.component.html b/src/app/orders/orders.component.html
index af77412..17cff9f 100644
--- a/src/app/orders/orders.component.html
+++ b/src/app/orders/orders.component.html
@@ -81,19 +81,19 @@
Rating
Rating the food will help us give you personalised recommendation
-
Submit Feedback
diff --git a/src/app/orders/orders.component.ts b/src/app/orders/orders.component.ts
index 151febe..dd3dce4 100644
--- a/src/app/orders/orders.component.ts
+++ b/src/app/orders/orders.component.ts
@@ -4,7 +4,7 @@ import * as moment from 'moment';
import { ICart } from '../cart/cart.page';
import { Router } from '@angular/router';
import { ToastService } from '../services/toast.service';
-import { LoadingController } from '@ionic/angular';
+import { IonThumbnail, LoadingController } from '@ionic/angular';
@Component({
selector: 'app-orders',
@@ -25,10 +25,24 @@ export class OrdersComponent implements OnInit {
tempReview = {
app_user: {
- user_id: null
+ user_id: null,
+ uid: null,
},
- comment: '',
- rating: null,
+ orders_id: null,
+ orderstatus: {
+ orderStatus: '',
+ orderstatus_id: null,
+ },
+ rating: {
+ comment: '',
+ createdBy: '',
+ rating: '',
+ soft_delete: true,
+ updatedBy: '',
+ },
+ vendor: {
+ vendor_Id: null
+ }
};
loader: any;
@@ -51,35 +65,25 @@ export class OrdersComponent implements OnInit {
submitFeedbackForOrder() {
- this.tempReview.app_user.user_id = this.userInfo.id;
-
-
let orderToReview: any = JSON.parse(JSON.stringify(this.selectedOrder));
- orderToReview.orderedlist = this.getOrderInUsercardFormat(this.selectedOrder.orderedlist);
-
- orderToReview.rating = this.tempReview;
+ this.tempReview.app_user.user_id = orderToReview.app_user.user_id;
+ this.tempReview.app_user.uid = orderToReview.app_user.usid;
+ this.tempReview.orders_id = orderToReview.orders_id;
+ this.tempReview.orderstatus = orderToReview.orderstatus;
+ this.tempReview.rating.createdBy = orderToReview.app_user.username;
+ this.tempReview.rating.updatedBy = orderToReview.app_user.username;
+ this.tempReview.vendor.vendor_Id = orderToReview.orderedlist[0].outlet_id;
- console.log(orderToReview);
+ console.log(this.tempReview);
- this.orderService.updateOrder(orderToReview).then(() => {
+ this.orderService.orderRating(this.tempReview).then(() => {
this.toastService.presentToast("Review sent", "success");
-
this.selectedOrder.rating = orderToReview.rating;
-
- this.tempReview = {
- app_user: {
- user_id: ''
- },
- comment: '',
- rating: '',
- };
-
this.showAddReview = false;
-
}, () => {
this.toastService.presentToast("Failed to send review", "danger");
- });
+ })
}
getOrderInUsercardFormat(orderedlist: any) {
diff --git a/src/app/services/order.service.ts b/src/app/services/order.service.ts
index a5c3124..efe04f5 100644
--- a/src/app/services/order.service.ts
+++ b/src/app/services/order.service.ts
@@ -107,4 +107,17 @@ export class OrderService {
return await this.http.put(URL + '/api/maioraservice/orders/v1/update', order ,httpOptions).toPromise();
}
+
+ async orderRating(rating: any){
+ const httpOptions = {
+ headers: new HttpHeaders({
+ 'Access-Control-Allow-Origin': '*',
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Bearer ' + localStorage.access_Token
+ })
+ };
+ return await this.http.put(URL + '/api/maioraservice/ratings/v1/update', rating, httpOptions).toPromise();
+ }
+
+
}