瀏覽代碼

Update order + Get orders by user id API integrations

master
kj1352 5 年之前
父節點
當前提交
89c9efb805
共有 3 個檔案被更改,包括 38 行新增3 行删除
  1. +1
    -1
      src/app/orders/orders.component.html
  2. +14
    -2
      src/app/orders/orders.component.ts
  3. +23
    -0
      src/app/services/order.service.ts

+ 1
- 1
src/app/orders/orders.component.html 查看文件

@@ -51,7 +51,7 @@
</td> </td>
<td> <td>
<div class="action-buttons" *ngIf="order.orderstatus.orderstatus_id === 6"> <div class="action-buttons" *ngIf="order.orderstatus.orderstatus_id === 6">
<button class="round-button"> Confirm </button>
<button class="round-button" (click)="order.orderstatus.orderstatus_id = 1; updateOrder(order)"> Confirm </button>
<button class="round-button" (click)="showRejectionPopup = true"> Reject </button> <button class="round-button" (click)="showRejectionPopup = true"> Reject </button>
</div> </div>
<div class="status" [ngClass]="{'success': order.orderstatus.orderstatus_id === 1, <div class="status" [ngClass]="{'success': order.orderstatus.orderstatus_id === 1,


+ 14
- 2
src/app/orders/orders.component.ts 查看文件

@@ -32,7 +32,10 @@ export class OrdersComponent implements OnInit {
id: 'today' id: 'today'
}]; }];


console.log(JSON.parse(localStorage.vendor_info))

let vendor_info = JSON.parse(localStorage.vendor_info);

console.log(vendor_info);


this.orderService.getOrders().then((data) => { this.orderService.getOrders().then((data) => {
console.log(data); console.log(data);
@@ -50,7 +53,7 @@ export class OrdersComponent implements OnInit {
this.orderStatus = data; this.orderStatus = data;
}, () => { }, () => {
alert("Error getting the order statuses"); alert("Error getting the order statuses");
})
});
} }


getFormattedDate(date: any, format: string) { getFormattedDate(date: any, format: string) {
@@ -67,4 +70,13 @@ export class OrdersComponent implements OnInit {
}); });
} }


updateOrder(order) {
this.orderService.updateOrder(order).then((data) => {
console.log(data);
}, (err) => {
console.log(err)
alert("Failed to update order");
})
}

} }

+ 23
- 0
src/app/services/order.service.ts 查看文件

@@ -31,4 +31,27 @@ export class OrderService {
}; };
return this.http.get(URL + '/api/maioraservice/orders/getallOrderStatus', httpOptions).toPromise(); return this.http.get(URL + '/api/maioraservice/orders/getallOrderStatus', httpOptions).toPromise();
} }


getOrdersByUserId(uid: string | number) {
const httpOptions = {
headers: new HttpHeaders({
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + localStorage.vendor_token
})
};
return this.http.get(URL + '/api/maioraservice/orders/getorders/user_id/' + uid + '/', httpOptions).toPromise();
}

updateOrder(data: any) {
const httpOptions = {
headers: new HttpHeaders({
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + localStorage.vendor_token
})
};
return this.http.post(URL + '/api/maioraservice/orders/v1/update', data , httpOptions).toPromise();
}
} }

Loading…
取消
儲存