From cfb585d8e0dbbd00472845f622b69dc8d7c7b84f Mon Sep 17 00:00:00 2001 From: kj1352 Date: Thu, 3 Dec 2020 17:09:27 +0530 Subject: [PATCH] Add Review API connection and UI --- src/app/orders/orders.component.html | 25 +++++++++-------- src/app/orders/orders.component.scss | 42 ++++++++++++++++++++++++++-- src/app/orders/orders.component.ts | 32 +++++++++++++++++++-- src/app/services/order.service.ts | 13 +++++++++ src/global.scss | 1 - 5 files changed, 96 insertions(+), 17 deletions(-) diff --git a/src/app/orders/orders.component.html b/src/app/orders/orders.component.html index 8073654..afc9e8f 100644 --- a/src/app/orders/orders.component.html +++ b/src/app/orders/orders.component.html @@ -50,28 +50,31 @@
Reorder - Rate & Review + Rate & Review
-
-
Rate & Review
+
+
Rate & Review
Rating

Rating the food will help us give you personalised recommendation

-
- - - - - +
+ + + + +
Review
- +
- Submit Feedback + Submit Feedback
diff --git a/src/app/orders/orders.component.scss b/src/app/orders/orders.component.scss index 7785cd0..bd8b0f7 100644 --- a/src/app/orders/orders.component.scss +++ b/src/app/orders/orders.component.scss @@ -162,7 +162,45 @@ ul.orders { } .star-holder { - text-align: center; + text-align: center; + + &.star1 { + ion-icon:first-child { + color: #fbae17; + } + } + + &.star2 { + @for $i from 1 through 2 { + ion-icon:nth-child(#{$i}) { + color: #fbae17; + } + } + } + + &.star3 { + @for $i from 1 through 3 { + ion-icon:nth-child(#{$i}) { + color: #fbae17; + } + } + } + + &.star4 { + @for $i from 1 through 4 { + ion-icon:nth-child(#{$i}) { + color: #fbae17; + } + } + } + + &.star5 { + @for $i from 1 through 5 { + ion-icon:nth-child(#{$i}) { + color: #fbae17; + } + } + } ion-icon { color: var(--brand-grey); @@ -204,6 +242,6 @@ ul.orders { --background: var(--brand-blue); font-size: 12px; width: calc(100% - 30px); - margin: 0 auto 15px; + margin: 0 auto 65px; } } diff --git a/src/app/orders/orders.component.ts b/src/app/orders/orders.component.ts index 244ac10..f73f582 100644 --- a/src/app/orders/orders.component.ts +++ b/src/app/orders/orders.component.ts @@ -13,20 +13,46 @@ import { ToastService } from '../services/toast.service'; export class OrdersComponent implements OnInit { userOrders: any = []; selected_order: any; - selected_rating: number = 0; - userInfo: any; - show_rate_modal: boolean = false; + userInfo: any; userCart: ICart = { orderedlist: [] }; allOrderStatus: any = []; + selectedOrder: any; + + tempReview = { + app_user: { + user_id: null + }, + comment: '', + rating: null, + }; + constructor( private orderService: OrderService, private router: Router, private toastService: ToastService ) { } + submitFeedbackForOrder() { + this.tempReview.app_user.user_id = this.userInfo.id; + this.selectedOrder.rating = this.tempReview; + console.log(this.selectedOrder); + this.orderService.updateOrder(this.selectedOrder).then(() => { + this.selectedOrder = null; + this.tempReview = { + app_user: { + user_id: null + }, + comment: '', + rating: null, + }; + }, () => { + this.toastService.presentToast("Failed to send review, please try again", "danger"); + }) + } + ngOnInit() { this.userInfo = JSON.parse(localStorage.userInfo)['User Info']; diff --git a/src/app/services/order.service.ts b/src/app/services/order.service.ts index 7404d89..a5c3124 100644 --- a/src/app/services/order.service.ts +++ b/src/app/services/order.service.ts @@ -94,4 +94,17 @@ export class OrderService { return await this.http.get(URL + '/api/maioraservice/orders/getallOrderStatus', httpOptions).toPromise(); } + + + async updateOrder(order: 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/orders/v1/update', order ,httpOptions).toPromise(); + } } diff --git a/src/global.scss b/src/global.scss index 7df9f3c..b54ddb5 100644 --- a/src/global.scss +++ b/src/global.scss @@ -175,7 +175,6 @@ figure { padding: 15px; font-size: 14px; align-items: center; - position: sticky; position: -webkit-sticky; top: 0; z-index: 1;