| @@ -81,19 +81,19 @@ | |||||
| <div class="rating"> | <div class="rating"> | ||||
| <div class="semi-heading"> Rating </div> | <div class="semi-heading"> Rating </div> | ||||
| <p> Rating the food will help us give you personalised recommendation </p> | <p> Rating the food will help us give you personalised recommendation </p> | ||||
| <div class="star-holder" [ngClass]="{ 'star1' : tempReview.rating === 1, | |||||
| 'star2' : tempReview.rating === 2, 'star3' : tempReview.rating === 3, | |||||
| 'star4' : tempReview.rating === 4, 'star5': tempReview.rating === 5}"> | |||||
| <ion-icon name="star" (click)="tempReview.rating = 1"></ion-icon> | |||||
| <ion-icon name="star" (click)="tempReview.rating = 2"></ion-icon> | |||||
| <ion-icon name="star" (click)="tempReview.rating = 3"></ion-icon> | |||||
| <ion-icon name="star" (click)="tempReview.rating = 4"></ion-icon> | |||||
| <ion-icon name="star" (click)="tempReview.rating = 5"></ion-icon> | |||||
| <div class="star-holder" [ngClass]="{ 'star1' : tempReview.rating.rating === 1, | |||||
| 'star2' : tempReview.rating.rating === 2, 'star3' : tempReview.rating.rating === 3, | |||||
| 'star4' : tempReview.rating.rating === 4, 'star5': tempReview.rating.rating === 5}"> | |||||
| <ion-icon name="star" (click)="tempReview.rating.rating = 1"></ion-icon> | |||||
| <ion-icon name="star" (click)="tempReview.rating.rating = 2"></ion-icon> | |||||
| <ion-icon name="star" (click)="tempReview.rating.rating = 3"></ion-icon> | |||||
| <ion-icon name="star" (click)="tempReview.rating.rating = 4"></ion-icon> | |||||
| <ion-icon name="star" (click)="tempReview.rating.rating = 5"></ion-icon> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <div class="review"> | <div class="review"> | ||||
| <div class="semi-heading"> Review </div> | <div class="semi-heading"> Review </div> | ||||
| <textarea placeholder="Please tell something about the food..." [(ngModel)]="tempReview.comment"></textarea> | |||||
| <textarea placeholder="Please tell something about the food..." [(ngModel)]="tempReview.rating.comment"></textarea> | |||||
| </div> | </div> | ||||
| <ion-button size="block" shape="round" | <ion-button size="block" shape="round" | ||||
| (click)="submitFeedbackForOrder()"> Submit Feedback </ion-button> | (click)="submitFeedbackForOrder()"> Submit Feedback </ion-button> | ||||
| @@ -4,7 +4,7 @@ import * as moment from 'moment'; | |||||
| import { ICart } from '../cart/cart.page'; | import { ICart } from '../cart/cart.page'; | ||||
| import { Router } from '@angular/router'; | import { Router } from '@angular/router'; | ||||
| import { ToastService } from '../services/toast.service'; | import { ToastService } from '../services/toast.service'; | ||||
| import { LoadingController } from '@ionic/angular'; | |||||
| import { IonThumbnail, LoadingController } from '@ionic/angular'; | |||||
| @Component({ | @Component({ | ||||
| selector: 'app-orders', | selector: 'app-orders', | ||||
| @@ -25,10 +25,24 @@ export class OrdersComponent implements OnInit { | |||||
| tempReview = { | tempReview = { | ||||
| app_user: { | 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; | loader: any; | ||||
| @@ -51,35 +65,25 @@ export class OrdersComponent implements OnInit { | |||||
| submitFeedbackForOrder() { | submitFeedbackForOrder() { | ||||
| this.tempReview.app_user.user_id = this.userInfo.id; | |||||
| let orderToReview: any = JSON.parse(JSON.stringify(this.selectedOrder)); | 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.toastService.presentToast("Review sent", "success"); | ||||
| this.selectedOrder.rating = orderToReview.rating; | this.selectedOrder.rating = orderToReview.rating; | ||||
| this.tempReview = { | |||||
| app_user: { | |||||
| user_id: '' | |||||
| }, | |||||
| comment: '', | |||||
| rating: '', | |||||
| }; | |||||
| this.showAddReview = false; | this.showAddReview = false; | ||||
| }, () => { | }, () => { | ||||
| this.toastService.presentToast("Failed to send review", "danger"); | this.toastService.presentToast("Failed to send review", "danger"); | ||||
| }); | |||||
| }) | |||||
| } | } | ||||
| getOrderInUsercardFormat(orderedlist: any) { | getOrderInUsercardFormat(orderedlist: any) { | ||||
| @@ -107,4 +107,17 @@ export class OrderService { | |||||
| return await this.http.put(URL + '/api/maioraservice/orders/v1/update', order ,httpOptions).toPromise(); | 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(); | |||||
| } | |||||
| } | } | ||||