Commit 90456a1d by Adarsh K

feat: customer app

parent 016250bb
File deleted
......@@ -130,6 +130,10 @@ const routes: Routes = [
loadChildren: './changeaddress/changeaddress.module#ChangeaddressPageModule'
},
{
path: 'return',
loadChildren: './return/return.module#ReturnPageModule'
},
{
path: 'verficationnumber',
loadChildren:
'./verficationnumber/verficationnumber.module#VerficationnumberPageModule'
......
......@@ -90,12 +90,25 @@
<div class="clear"></div>
</h5>
<ion-grid class="p0" *ngIf="cartService.carts && cartService.carts.length > 0">
<ion-row>
<ion-col size="6" class="p0">
<h6 class="textLeft">Item</h6>
</ion-col>
<ion-col size="2" class="p0">
<h6 class="textRight"><strong>Qty</strong></h6>
</ion-col>
<ion-col size="4" class="p0">
<h6 class="textRight">
<strong>Unit Price</strong>
</h6>
</ion-col>
</ion-row>
<ion-row *ngFor="let carts of cartService.carts">
<ion-col size="6" class="p0">
<h6 class="textLeft">{{unEscape(carts.prodName)}}</h6>
</ion-col>
<ion-col size="2" class="p0">
<h6 class="textRight"><strong>{{carts.qty}} X</strong></h6>
<h6 class="textRight"><strong>{{carts.qty}}X</strong></h6>
</ion-col>
<ion-col size="4" class="p0">
<h6 class="textRight">
......@@ -194,8 +207,12 @@
</span>
<span *ngIf="discountApplied == 2" class="promo-error">Invalid Promocode</span>
</div>
<br />
<div class="doorstep-input">
<input class="styled-checkbox" id="door" type="checkbox" (click)="changeOrder()" />
<label for="door"><span>Leave this order at the door
</span></label>
</div>
<hr />
<h6>
<span class="floatLeft">PRODUCT COST</span>
......@@ -213,7 +230,7 @@
<h6>
<span class="floatLeft">GST/TAX</span>
<span class="floatRight" *ngIf="cartService.cartTotal">A$
{{service.formatNumber(getTax(cartService.cartTotal))}}</span>
{{service.formatNumber(cartService.totalGst.toFixed(2))}}</span>
<div class="clear"></div>
</h6>
<h6 *ngIf="discountApplied">
......
......@@ -204,6 +204,56 @@
}
}
}
.doorstep-input {
text-align: left;
margin-top: 10px;
span {
position: relative;
top: 5px;
}
.styled-checkbox {
opacity: 0;
display: none;
&+label {
position: relative;
cursor: pointer;
padding: 0;
}
&+label:before {
content: '';
margin-right: 10px;
display: inline-block;
vertical-align: text-top;
width: 30px;
height: 30px;
border-radius: 10px;
background: white;
border: 1px solid rgba(215, 213, 228, 1);
}
&:checked+label:before {
background: #29285b;
}
&:disabled+label {
color: #b8b8b8;
cursor: auto;
}
&:disabled+label:before {
box-shadow: none;
background: #ddd;
}
&:checked+label:after {
content: '';
position: absolute;
left: 10px;
top: 15px;
background: white;
width: 2px;
height: 2px;
box-shadow: 2px 0 0 white, 4px 0 0 white, 4px -2px 0 white, 4px -4px 0 white, 4px -6px 0 white, 4px -8px 0 white;
transform: rotate(45deg);
}
}
}
.coupon_code {
padding-top: 20px;
padding-bottom: 40px;
......
......@@ -54,6 +54,9 @@ export class CartPage implements OnInit {
paymentMethod: any;
lat: number;
lng: number;
contactLess: boolean;
promoId: string;
promoCode: string;
constructor(
private router: Router,
......@@ -76,6 +79,7 @@ export class CartPage implements OnInit {
this.discountApplied = 0;
this.discount = 0;
this.paymentMethod = 'PayPal';
this.contactLess = false;
// this.cartService.cartList();
this.loader = true;
const users = this.service.get('user').then(data => {
......@@ -146,10 +150,6 @@ export class CartPage implements OnInit {
return this.deliveryCharge.toFixed(2);
}
getTax(amount) {
return (this.taxAmount = (amount * 10) / 100).toFixed(2);
}
getwaypayk() {
this.gateway = 3;
this.paymentMethod = 'PayK';
......@@ -160,6 +160,10 @@ export class CartPage implements OnInit {
this.paymentMethod = 'Credit Card';
}
changeOrder() {
this.contactLess = !this.contactLess;
}
async finishpop() {
const modal = await this.modalController.create({
component: DeliverypopPage
......@@ -203,12 +207,17 @@ export class CartPage implements OnInit {
if (this.addressService.custAddress.nearest === true) {
const otherCharges = {
deliveryCharge: this.deliveryCharge,
taxAmount: this.taxAmount,
taxAmount: this.cartService.totalGst,
discount: this.discount,
discountApplied: this.discountApplied === 1 ? true : false,
totalAmt: this.totalAmt,
custAddress: this.addressService.custAddress,
paymentMethod: this.paymentMethod
paymentMethod: this.paymentMethod,
contactLess: this.contactLess,
promoCode: this.promoCode,
promoId: this.promoId,
transaction: '',
transId: ''
};
this.service.popupMsg = 'New Order has been successfully Placed!';
this.service.popupSub = 'Order Placed Successfully';
......@@ -304,7 +313,7 @@ export class CartPage implements OnInit {
getTotal(total) {
const actualTotal =
this.deliveryCharge + this.taxAmount + total - this.discount;
this.deliveryCharge + this.cartService.totalGst + total - this.discount;
this.totalAmt = actualTotal;
return actualTotal.toFixed(2);
}
......@@ -312,6 +321,7 @@ export class CartPage implements OnInit {
promoApply(code) {
console.log(code);
this.cartService.checkPromo(code).subscribe(value => {
console.log(value);
if (value.length > 0) {
const promo = value[0];
this.discountApplied = 1;
......@@ -326,6 +336,8 @@ export class CartPage implements OnInit {
this.discount = value[0].amount;
}
this.discount.toFixed(2);
this.promoId = promo.promoId;
this.promoCode = promo.promoCode;
} else {
this.discountApplied = 0;
this.discount = 0;
......@@ -371,6 +383,10 @@ export class CartPage implements OnInit {
);
}
getGST(price, gst) {
return ((price * gst) / 100).toFixed(2);
}
unEscape(text: string) {
const regex = '%uFFFD';
return unescape(text.replace(/%uFFFD/g, ''));
......
......@@ -76,7 +76,7 @@
</ion-slides>
</div>
<div class="home_sub_header">
<span class="floatLeft">Nearby Shopping Centers</span>
<span class="floatLeft">Nearby Retailers</span>
<!-- <span class="floatRight">
<div class="nearby_icon" (click)="goToPage('nearby')"></div>
</span> -->
......
......@@ -20,41 +20,45 @@
<li *ngFor="let order of myorder.orders; let i = index">
<div class="order_info">
<h5 class="floatLeft">{{order.orderCode}}</h5>
<button class="order_track floatRight" *ngIf="order.orderStatus >= 3 && order.orderStatus < 7" (click)="orderDetails(i)">
<h6 class="floatRight" *ngIf="order.orderDate">
{{ order.orderDate.seconds * 1000 | date:'MMMM dd, y' }}
</h6>
<div class="clear"></div>
<button class="order_track floatRight" (click)="orderDetails(i)" *ngIf="order.riderStatus > 0 && order.riderStatus <= 4 ">
Track Order
</button>
<div class="clear"></div>
<br/>
<div class="clear"></div>
</div>
<div *ngFor="let product of order.product" (click)="viewOrder(order)">
<div class="order_image">
<img [src]="product.image" onerror="" />
</div>
<div class="order_detail">
<h5 class="floatLeft">{{unEscape(product.prodName)}}</h5>
<div class="clear"></div>
<h5>
<span *ngIf="product.color !== 'No-Color'">{{product.color}},
<div class="product-wrapper" *ngFor="let shopper of order.shopper">
<div *ngFor="let product of shopper.product" class="order-inn-box" (click)="viewOrder(order.orderId, shopper.shopperId)">
<div class="order_image">
<img [src]="product.image" onerror="" />
</div>
<div class="order_detail">
<h5 class="floatLeft">{{unEscape(product.prodName)}}</h5>
<div class="clear"></div>
<h5>
<span *ngIf="product.color !== 'No-Color'">{{product.color}},
</span>
<span *ngIf="product.size !== 'Any-Size'">{{product.size}}</span>&nbsp;<span>{{product.qty}}</span>
</h5>
<span *ngIf="product.size !== 'Any-Size'">{{product.size}}</span>&nbsp;<span>{{product.qty}}</span>
</h5>
<p *ngIf="product.price">A$ {{service.formatNumber(product.price.toFixed(2))}}</p>
</div>
<div class="order_other">
<h6 class="floatRight" *ngIf="order.bookDate">
{{ order.bookDate.seconds * 1000 | date:'MMMM dd, y' }}
</h6>
<span class="floatRight" *ngIf="order.orderStatus < 3 || order.orderStatus >= 7" (click)="acceptOrder(order)">{{getStatus(order.orderStatus)}}</span>
<div class="clear"></div>
<!-- <button class="track_btn" *ngIf="order.orderStatus >= 3 && order.orderStatus < 7" (click)="orderDetails(i)">TRACK</button> -->
<p *ngIf="product.price">A$ {{service.formatNumber(product.price.toFixed(2))}}</p>
</div>
<div class="order_other">
<span class="floatRight" (click)="acceptOrder(order)">{{getStatus(order.orderStatus)}}</span>
<div class="clear"></div>
<!-- <button class="track_btn" *ngIf="order.orderStatus >= 3 && order.orderStatus < 7" (click)="orderDetails(i)">TRACK</button> -->
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
<hr />
</div>
<div class="order_info">
<h5 class="floatRight">TOTAL PRICE : {{getProductTotal(order.product)}}</h5>
<h5 class="floatRight">TOTAL PRICE : {{priceFormat(order.amount)}}</h5>
<div class="clear"></div>
</div>
......
.myorder_wrapper {
ul {
margin: 0px;
padding: 10px;
li {
list-style: none;
padding: 10px;
padding-bottom: 15px;
.order_info {
padding-top: 10px;
padding-bottom: 10px;
h5 {
margin: 0px;
padding: 0px;
ul {
margin: 0px;
padding: 10px;
li {
list-style: none;
padding: 10px;
padding-bottom: 0px;
border: 1px solid #c5c5c5;
margin-bottom: 20px;
.order_info {
// padding-top: 10px;
padding-bottom: 10px;
h5 {
margin: 0px;
padding: 0px;
font-weight: 800;
color: #29285b;
}
h6 {
margin: 0;
font-weight: 800;
color: #29285b;
}
.order_track {
background-color: rgba(53, 203, 171, 1);
color: #fff;
border-radius: 3px;
padding: 3px;
padding-left: 10px;
padding-right: 10px;
}
}
.product-wrapper {
border: 1px solid #dadada;
padding: 10px 10px 0 10px;
margin-bottom: 10px;
.order-inn-box {
margin-bottom: 10px;
.order_image {
width: 90px;
height: 90px;
float: left;
border-radius: 8px;
background-color: #a8a8a8;
img {
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
}
}
.order_detail {
width: calc(100% - 190px);
float: left;
padding-left: 20px;
h5 {
margin: 0px;
padding: 0px;
color: rgba(176, 174, 199, 1);
font-size: 16px;
padding-top: 3px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
span {
color: #29285b;
}
}
h6 {
margin: 0px;
padding: 0px;
color: rgba(176, 174, 199, 1);
font-size: 12px;
padding-top: 9px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
p {
margin: 0px;
padding: 0px;
color: rgba(59, 57, 77, 1);
font-weight: 900;
padding-top: 10px;
font-size: 20px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.order_other {
width: 100px;
float: right;
span {
margin-right: 10px;
}
h6 {
margin: 0px;
padding: 0px;
color: rgba(176, 174, 199, 1);
font-size: 12px;
padding-top: 9px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding-bottom: 10px;
}
h5 {
margin: 0px;
padding: 0px;
color: rgba(206, 153, 76, 1);
font-size: 16px;
font-weight: bold;
}
.track_btn {
background: #29285b;
color: #fff;
float: right;
padding: 12px;
font-size: 18px;
border-radius: 5px;
padding-left: 15px;
padding-right: 15px;
}
}
}
}
}
.order_track {
background-color: rgba(53, 203, 171, 1);
color: #fff;
border-radius: 3px;
padding: 3px;
padding-left: 10px;
padding-right: 10px;
}
}
.order_image {
width: 90px;
height: 90px;
float: left;
border-radius: 8px;
background-color: #a8a8a8;
}
.empty-wishlist-wrapper {
text-align: center;
padding-top: 25%;
img {
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
}
}
.order_detail {
width: calc(100% - 190px);
float: left;
padding-left: 20px;
h5 {
margin: 0px;
padding: 0px;
color: rgba(176, 174, 199, 1);
font-size: 16px;
padding-top: 3px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
span {
color: #29285b;
}
}
h6 {
margin: 0px;
padding: 0px;
color: rgba(176, 174, 199, 1);
font-size: 12px;
padding-top: 9px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
p {
margin: 0px;
padding: 0px;
color: rgba(59, 57, 77, 1);
font-weight: 900;
padding-top: 10px;
font-size: 20px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100px;
}
}
.order_other {
width: 100px;
float: right;
h6 {
margin: 0px;
padding: 0px;
color: rgba(176, 174, 199, 1);
font-size: 12px;
padding-top: 9px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding-bottom: 10px;
h1 {
font-size: 18px;
font-weight: bolder;
text-transform: uppercase;
color: #3b394d;
}
h5 {
margin: 0px;
padding: 0px;
color: rgba(206, 153, 76, 1);
font-size: 16px;
font-weight: bold;
button {
background-color: #29285b;
border-radius: 8px;
height: 50px;
width: 48%;
color: #fff;
font-size: 18px;
font-weight: lighter;
text-transform: uppercase;
margin-top: 10px;
}
.track_btn {
background: #29285b;
color: #fff;
float: right;
padding: 12px;
font-size: 18px;
border-radius: 5px;
padding-left: 15px;
padding-right: 15px;
}
}
}
}
.empty-wishlist-wrapper {
text-align: center;
padding-top: 25%;
img {
width: 100px;
}
h1 {
font-size: 18px;
font-weight: bolder;
text-transform: uppercase;
color: #3b394d;
}
button {
background-color: #29285b;
border-radius: 8px;
height: 50px;
width: 48%;
color: #fff;
font-size: 18px;
font-weight: lighter;
text-transform: uppercase;
margin-top: 10px;
}
}
}
}
\ No newline at end of file
......@@ -68,8 +68,8 @@ export class MyorderPage implements OnInit {
}
}
viewOrder(data) {
console.log(data);
viewOrder(orderId, shopperId) {
const data = {orderId, shopperId};
this.service.set('order', data);
this.router.navigateByUrl('orderplaced', { queryParams: data });
document.body.scrollTop = document.documentElement.scrollTop = 0;
......@@ -81,37 +81,22 @@ export class MyorderPage implements OnInit {
return 'Booked';
break;
case 2:
return 'Shop Accepted';
return 'Processing';
break;
case 3:
return 'Rider Assigned';
return 'Completed';
break;
case 4:
return 'Reached Shop';
return 'Cancelled';
break;
case 5:
return 'Picked Up';
break;
case 6:
return 'Reached Location';
break;
case 7:
return 'Delivered';
break;
case 9:
return 'Completed';
break;
case 8:
return 'Rejected';
break;
case 10:
return 'Not Received';
break;
case 0:
return 'Cancelled';
case 6:
return 'Returned';
break;
default:
return 'Finished';
return '';
}
}
......@@ -128,4 +113,8 @@ export class MyorderPage implements OnInit {
const totalAmt: number = parseFloat(amtPrice.toFixed(2));
return 'A$' + (this.service.formatNumber(totalAmt));
}
priceFormat(amount) {
return 'A$ ' + (this.service.formatNumber(amount));
}
}
......@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
import { Router, ActivatedRoute } from '@angular/router';
import { ServiceService } from './../../config/service.service';
import { MyordersService } from './../../config/myorder.service';
@Component({
selector: 'app-ordercancelled',
......@@ -15,11 +16,10 @@ export class OrdercancelledPage implements OnInit {
private router: Router,
private route: ActivatedRoute,
private location: Location,
private service: ServiceService
private service: ServiceService,
private myOrder: MyordersService
) {
this.service.get('order').then(val => {
this.data = val;
});
this.data = this.myOrder.selItem;
}
ngOnInit() {}
......
<ion-content>
<div class="cart_wrapper" *ngIf="data">
<div class="cart_wrapper" *ngIf="myOrder.selItem">
<div class="cart_head">
<div class="nav_header">
<ion-grid class="no-gutter">
......@@ -22,13 +22,13 @@
</div>
<img src="../assets/white_tick.png" />
<h4>ORDER IS PLACED</h4>
<p>{{ data.bookDate.seconds * 1000 | date:'MMMM dd, y' }}</p>
<p>{{ myOrder.selItem.orderDate.seconds * 1000 | date:'MMMM dd, y' }}</p>
</div>
<div class="order_status">
<div class="clear"></div>
<div class="status_div go_green">
<h4>{{data.orderCode}}</h4>
<h6>{{ data.bookDate.seconds * 1000 | date:'MMMM dd, y' }}</h6>
<h4>{{myOrder.selItem.orderCode}}</h4>
<h6>{{ myOrder.selItem.orderDate.seconds * 1000 | date:'MMMM dd, y' }}</h6>
</div>
<!-- <div class="status_gap go_green">
</div>
......@@ -65,8 +65,8 @@
</div> -->
</div>
<div class="nearby_shop_list">
<ul>
<li *ngFor="let product of data.product; let i = index">
<ul *ngIf="myOrder.selItem.shopper">
<li *ngFor="let product of myOrder.selItem.shopper.product; let i = index">
<div class="nearby_image">
<img [src]="product.image" onerror="this.src='../assets/[email protected]'" />
</div>
......@@ -82,8 +82,8 @@
</div>
<div class="clear"></div>
<div class="product_detail">
<h5 *ngIf="data.orderStatus >= 3 || data.orderStatus < 7 && i == 0">
Delivery time : <span><b>{{deliveryTime}}</b></span>
<h5 *ngIf="myOrder.selItem.orderStatus >= 3 || myOrder.selItem.orderStatus < 7 && i == 0">
Delivery time : <span><b>{{myOrder.deliveryTime}}</b></span>
</h5>
<h6>
<!-- <span *ngIf="product.color !== 'No-Color'">Product: {{unEscape(product.prodName)}},
......@@ -93,10 +93,21 @@
</h6>
<h5>Quantity : <span>{{product.qty}}</span></h5>
<h5>
Amount : <strong>A$ {{service.formatNumber(product.price)}}</strong>
Unit Price: <strong>A$ {{service.formatNumber(product.price)}}</strong>
</h5>
<h5>Order Status : <span>{{getStatus(data.orderStatus)}}</span></h5>
<h5>
GST/TAX: <strong>{{service.formatNumber(getGst(product.price, product.gst))}}</strong>
</h5>
<h5>
Total: <strong>A$ {{service.formatNumber(((product.price + ((product.price * product.gst) /100)) * product.qty).toFixed(2)) }}</strong>
</h5>
<button class="cancel_btn" (click)="returnOrder(myOrder.selItem.orderId, product.itemId)"
*ngIf="myOrder.selItem.orderStatus === 3">
RETURN ITEM
</button>
</div>
</li>
</ul>
......@@ -104,88 +115,35 @@
<div class="product_detail">
<h5>Order Status: <span>{{getStatus(myOrder.selItem.orderStatus)}}</span></h5>
<h5 *ngIf="checkRetrailer(myOrder.selItem.shopper.shopperStatus, myOrder.selItem.orderStatus)">Retailer Status: <span>{{getShopperStatus(myOrder.selItem.shopper.shopperStatus)}}</span></h5>
<h5 *ngIf="checkRider(myOrder.selItem.riderStatus)">Rider Status: <span>{{getRiderStatus(myOrder.selItem.riderStatus)}}</span></h5>
<h2 *ngIf="myOrder.selItem.contactLess">DelLeave in the Doorstep Delivery</h2>
<div class="delivery-wrap">
<h4 class="floatLeft">DELIVERY</h4>
<span class="floatRight"
*ngIf="cancelDelivery > 0 && data.orderStatus != 0 && data.orderStatus != 8"><img
class="ng-tns-c3-0" src="../../assets/edit.png" (click)="changeAddress(data.orderId)" /></span>
*ngIf="myOrder.cancelDelivery > 0 && myOrder.selItem.orderStatus != 0 && myOrder.selItem.orderStatus != 8"><img
class="ng-tns-c3-0" src="../../assets/edit.png" (click)="changeAddress(myOrder.selItem.orderId)" /></span>
<div class="clear"></div>
</div>
<h5 *ngIf="data.deliveryAddress">
{{data.deliveryAddress.addressType}},
<!-- ,<br />{{data.deliveryAddress.address}} -->
<br /> {{data.deliveryAddress.building}}<span
*ngIf="data.deliveryAddress.landmark && data.deliveryAddress.landmark!==''"><br />,
{{data.deliveryAddress.landmark}}</span>
<h5 *ngIf="myOrder.selItem.deliveryAddress">
{{myOrder.selItem.deliveryAddress.addressType}},
<!-- ,<br />{{myOrder.selItem.deliveryAddress.address}} -->
<br /> {{myOrder.selItem.deliveryAddress.building}}<div
*ngIf="myOrder.selItem.deliveryAddress.landmark && myOrder.selItem.deliveryAddress.landmark!==''">
{{myOrder.selItem.deliveryAddress.landmark}}</div>
</h5>
<!-- <hr /> -->
</div>
<!-- <div class="related_product_slider">
<h5>
<span class="floatLeft">Related Products</span><span class="floatRight">MORE</span>
<div class="clear"></div>
</h5>
<ul>
<ion-slides pager="false" [options]="relatedProd">
<ion-slide>
<li (click)="goToPage('productdetail')">
<div class="product_image">
<img src="../assets/[email protected]">
<div class="fav_icon">
</div>
</div>
<h5>European Style V Neck</h5>
<p>AU$99.00</p>
</li>
</ion-slide>
<ion-slide>
<li (click)="goToPage('productdetail')">
<div class="product_image">
<img src="../assets/Recommended-Ball-Gown-Floor-Length-V-Neck-Lace-Organza-Prom-Dress-OD850662@3x.png">
<div class="fav_icon">
</div>
</div>
<h5>European Style V Neck</h5>
<p>AU$99.00</p>
</li>
</ion-slide>
<ion-slide>
<li (click)="goToPage('productdetail')">
<div class="product_image">
<img src="../assets/[email protected]">
<div class="fav_icon">
</div>
</div>
<h5>European Style V Neck</h5>
<p>AU$99.00 <span class="offer">-8%</span></p>
</li>
</ion-slide>
<ion-slide>
<li (click)="goToPage('productdetail')">
<div class="product_image">
<img src="../assets/[email protected]">
<div class="fav_icon">
</div>
<div class="featured_badge">Featured</div>
</div>
<h5>European Style V Neck</h5>
<p>AU$99.00<span>AU$110.00</span></p>
</li>
</ion-slide>
</ion-slides>
</ul>
</div> -->
</div>
</ion-content>
<ion-footer>
<ion-footer *ngIf="myOrder.selItem">
<div class="footer-btn">
<button class="cancel_btn" (click)="cancelOrder(data.orderId)"
*ngIf="cancelDelivery > 0 && data.orderStatus != 0 && data.orderStatus != 8">
<button class="cancel_btn" (click)="cancellOrder(myOrder.selItem.orderId)"
*ngIf="myOrder.selItem.orderStatus === 1">
CANCEL THIS ORDER
</button>
</div>
......
......@@ -160,6 +160,11 @@
padding-top: 20px;
padding-bottom: 10px;
}
h2 {
font-weight: bold;
color: #29285b;
font-size: 18px;
}
.delivery-wrap {
img {
width: 20px;
......
......@@ -34,13 +34,16 @@ export class OrderplacedPage implements OnInit {
ionViewWillEnter() {
this.deliveryTime = '00:00:00';
this.service.get('order').then(val => {
console.log('My Orders value', val);
this.data = val;
const This = this;
console.log(Math.round(Date.now() / 1000) + ' < ' + this.data.bookDate.seconds);
this.timeinterval = setInterval(() => {
This.getDeliveryTime(this.data.bookDate.seconds, this.data.time);
}, 1000);
console.log(val);
this.myOrder.getOrder(val).then(orderData => {
console.log('My Orders value', this.myOrder.selItem);
this.data = this.myOrder.selItem;
const This = this;
console.log(Math.round(Date.now() / 1000) + ' < ' + this.data.orderDate.seconds);
this.timeinterval = setInterval(() => {
This.getDeliveryTime(this.data.orderDate.seconds, this.data.time);
}, 1000);
});
});
}
......@@ -88,11 +91,6 @@ export class OrderplacedPage implements OnInit {
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
cancelOrder(orderId) {
this.service.set('orderId', orderId);
this.router.navigateByUrl('contact');
}
changeAddress(orderId) {
this.service.set('orderId', orderId);
this.router.navigateByUrl('changeaddress');
......@@ -103,14 +101,22 @@ export class OrderplacedPage implements OnInit {
this.location.back();
}
returnOrder(orderId, itemId) {
}
cancellOrder(orderId) {
console.log(orderId);
this.myOrder.cancelOrder(orderId).then(() => {
this.service.showToast('Order cancelled!', 'top', 'my-toast', 1000);
const This = this;
setTimeout(() => {
This.goToPage('ordercancelled');
}, 1100);
this.myOrder.cancelOrder(orderId).then((resp) => {
if (resp) {
this.service.showToast('Order cancelled!', 'top', 'my-toast', 1000);
const This = this;
setTimeout(() => {
// This.goToPage('ordercancelled', { queryParams: this.myOrder.selItem });
}, 1100);
} else {
this.service.showToast('Order cancellation failed!', 'top', 'my-error', 1000);
}
});
}
......@@ -120,37 +126,87 @@ export class OrderplacedPage implements OnInit {
return 'Booked';
break;
case 2:
return 'Shop Accepted';
return 'Processing';
break;
case 3:
return 'Rider Assigned';
return 'Completed';
break;
case 4:
return 'Reached Shop';
return 'Cancelled';
break;
case 5:
return 'Picked Up';
return 'Rejected';
break;
case 6:
return 'Reached Location';
return 'Returned';
break;
case 7:
return 'Delivered';
default:
return '';
}
}
getShopperStatus(status: number) {
switch (status) {
case 0:
return 'Not accepted yet';
break;
case 9:
return 'Completed';
case 1:
return 'Order preparing';
break;
case 8:
case 2:
return 'Order packed';
break;
case 3:
return 'Delivered to rider';
break;
case 5:
return 'Rejected';
break;
case 10:
return 'Not Received';
default:
return '';
}
}
//0: Not Accepted, 1: Accepted, 2: arrived store, 3: On the way to customer, 4: reached customer location, 6: order completed
getRiderStatus(status: number) {
switch (status) {
case 1:
return 'On the way to retailer store';
break;
case 0:
return 'Cancelled';
case 2:
return 'Arrived and waiting for the order';
break;
case 3:
return 'On the way to your location';
break;
case 4:
return 'Reached your location';
break;
default:
return 'Finished';
return '';
}
}
checkRider(riderStatus) {
if (riderStatus === 0 || riderStatus > 4) {
return false;
} else {
return true;
}
}
checkRetrailer(retailerStatus, OrderStatus) {
if (retailerStatus !== 4 && OrderStatus !== 4 && OrderStatus !== 3) {
return true;
} else {
return false;
}
}
getGst(price: number, gst: number) {
const prodGst = ((price * gst) / 100).toFixed(2);
return prodGst;
}
}
......@@ -3,8 +3,6 @@ import { Location } from '@angular/common';
import { Router, ActivatedRoute } from '@angular/router';
import { Products } from './../../config/services/product';
import { Slides } from './../../config/services/slides';
import { Order } from './../../config/services/order';
import { CartsService } from './../../config/cart.service';
import { ProductsService } from './../../config/products.service';
import { ServiceService } from './../../config/service.service';
......@@ -21,7 +19,6 @@ export class ProductdetailPage implements OnInit {
disCart = true;
slide: Slides;
product: Products;
order: Order;
data: any;
slideData: any[];
loader: boolean;
......@@ -91,6 +88,7 @@ export class ProductdetailPage implements OnInit {
}
getProd(params) {
console.log(params);
if (params) {
let slideItem = [];
slideItem.push(params.image);
......@@ -118,7 +116,8 @@ export class ProductdetailPage implements OnInit {
shopper: params.shopper,
skuCode: params.skuCode,
status: params.status,
size: params.size
size: params.size,
gst: params.gst
};
this.product = prod;
this.prodService.fetchGallery(params.skuCode).then((galleryData: any) => {
......
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { ReturnPage } from './return.page';
const routes: Routes = [
{
path: '',
component: ReturnPage
}
];
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild(routes)
],
declarations: [ReturnPage]
})
export class ReturnPageModule {}
<ion-header>
<div class="nav_header">
<ion-grid class="no-gutter">
<ion-row class="no-gutter">
<ion-col class="no-gutter" size="2">
<button class="nav_btn nav_back floatLeft" (click)="goBack()">
<img src="../assets/Group17_2.png" />
</button>
</ion-col>
<ion-col class="no-gutter" size="8">
<div class="nav_title floatLeft">
<h4>Send Us</h4>
</div>
</ion-col>
<ion-col class="no-gutter" size="2"></ion-col>
</ion-row>
</ion-grid>
</div>
</ion-header>
<ion-content>
<form novalidate #contactUsForm="ngForm" class="contact_wrapper" *ngIf="userData && contactData">
<div class="form_div">
<div class="row">
<p>Write Us</p>
<textarea required name="writeUs" [(ngModel)]="contactData.message" #writeUs="ngModel" class="form-control" rows="8" placeholder="Type here.."></textarea>
<div class="md-errors-spacer" [hidden]="writeUs.valid || submitted == false" class="ion-padding-start">
This is required.
</div>
</div>
<div class="row">
<button (click)="onContactSubmit(contactUsForm)" class="login_btn">
SEND
</button>
</div>
<div class="row">
<span>or</span>
</div>
<div class="row">
<button (click)="callUs()" class="login_btn" [disabled]="submitted">
Call Us
</button>
</div>
</div>
</form>
</ion-content>
<div class="loader" *ngIf="contactService.loader">
<div class="lds-ripple">
<div></div>
<div></div>
</div>
</div>
\ No newline at end of file
.contact_wrapper {
width: 80%;
margin: 0 auto;
padding-top: 30px;
.form_div {
.row {
margin: 20px;
.form-control {
border: 1px solid rgba(215, 213, 228, 1);
background: transparent;
color: #333;
width: 100%;
border-radius: 8px;
font-size: 16px;
padding: 11px 15px;
resize: none;
&::placeholder {
color: rgba(215, 213, 228, 1);
}
}
.login_btn {
width: 100%;
background-color: #29285b;
color: #fff;
border-radius: 8px;
height: 45px;
font-size: 16px;
}
p {
text-align: left;
color: rgba(59, 57, 77, 1);
margin: 0px;
font-weight: bolder;
padding-bottom: 10px;
}
span {
opacity: 0.6;
text-align: center !important;
display: block;
}
}
}
}
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ReturnPage } from './return.page';
describe('ReturnPage', () => {
let component: ReturnPage;
let fixture: ComponentFixture<ReturnPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ReturnPage ],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ReturnPage);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
import { Return } from 'src/config/services/return';
import { SubjectService } from '../../config/subject.service';
import { NgForm } from '@angular/forms';
import { ReturnService } from 'src/config/return.service';
import { ServiceService } from '../../config/service.service';
import { CallNumber } from '@ionic-native/call-number/ngx';
@Component({
selector: 'app-return',
templateUrl: './return.page.html',
styleUrls: ['./return.page.scss']
})
export class ReturnPage implements OnInit {
submitted = false;
userData: any;
/* contactData: Return = {
/*from: '',
message: '',
contactId: ''
};*/
constructor(
private location: Location,
public subjectService: SubjectService,
public returnService: ReturnService,
public service: ServiceService,
private callNumber: CallNumber
) {
// Gets userdata
this.subjectService.getUserData().subscribe(userData => {
if (userData) {
this.userData = JSON.parse(userData);
// this.contactData.from = JSON.parse(userData).emailId;
console.log(userData);
} else {
console.log(userData);
}
});
}
ngOnInit() { }
callUs() {
this.callNumber
.callNumber('+61411622880', true)
.then(res => console.log('Launched dialer!', res))
.catch(err => console.log('Error launching dialer', err));
}
onContactSubmit(form: NgForm) {
this.submitted = true;
console.log(form.value);
if (form.valid && form.value.message !== '') {
this.service.get('orderId').then((orderId) => {
const newOrder = orderId;
// const contData = { ...this.contactData, from: this.userData.emailId, orderId: newOrder };
// this.contactService.contactCreate(contData);
});
} else {
console.log('form not valid');
this.submitted = false;
this.service.showToast('Invalid request!', 'top', 'my-error', 1000);
}
}
goBack() {
this.location.back();
}
}
// +61 411 622 880
......@@ -113,11 +113,7 @@
<div class="terms_wrapper" *ngIf="menuShow" [@slideInOut]>
<div class="terms_inner">
<h5>Terms & Conditions</h5>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p [innerHTML]="register.terms"></p>
<button class="accept" (click)="menuToggle()">I Accept</button>
</div>
</div>
\ No newline at end of file
......@@ -50,6 +50,7 @@ export class SignupPage implements OnInit {
day = this.currDate.getDate() < 10 ? '0' + this.currDate.getDate() : this.currDate.getDate(),
year = this.currDate.getFullYear();
this.minDate = [year, month, day].join('-');
this.register.termsFun();
}
ngOnInit() { }
......
......@@ -24,6 +24,7 @@ export class AuthService {
type: number;
userPostData: any;
loggedUser: any;
terms: string;
constructor(
public afs: AngularFirestore,
public afAuth: AngularFireAuth,
......@@ -46,13 +47,23 @@ export class AuthService {
this.service.set('user', JSON.stringify(this.userData));
this.SetUserData(user);
this.loader = false;
if (this.type === 1) {
this.regState = true;
this.router.navigateByUrl('home', { replaceUrl: true });
} else {
this.regState = false;
this.router.navigateByUrl('verification', { replaceUrl: true });
}
// tslint:disable-next-line:max-line-length
const userRef: AngularFirestoreCollection<any> = this.afs.collection('customers', ref => ref.where('status', '==', true).where('uid', '==', user.uid));
userRef.valueChanges().subscribe(value => {
console.log(value.length);
if (value.length === 0) {
this.SignOut();
this.service.showToast('Invalid credentials', 'bottom', 'my-error', 1000);
} else {
if (this.type === 1) {
this.regState = true;
this.router.navigateByUrl('home', { replaceUrl: true });
} else {
this.regState = false;
this.router.navigateByUrl('verification', { replaceUrl: true });
}
}
});
} else {
console.log('here too');
this.loader = false;
......@@ -187,25 +198,30 @@ export class AuthService {
`customers/${user.uid}`
);
userRef.valueChanges().subscribe(value => {
if (value === undefined) {
this.SignOut();
this.service.showToast('Invalid credentials', 'bottom', 'my-error', 1000);
} else {
const userData: User = {
uid: value.uid,
emailId: value.emailId,
name: value.name,
dob: value.dob,
profilePhoto: value.profilePhoto,
emailVerified: value.emailVerified,
phone: value.phone,
phoneVerified: value.phoneVerified,
status: value.status,
currency: value.currency,
otp: value.otp,
loginType: value.loginType
};
this.loggedUser = userData;
this.service.set('userData', JSON.stringify(this.loggedUser));
this.subjectService.sendUserData(JSON.stringify(this.loggedUser));
console.log(this.loggedUser);
}
console.log(value);
const userData: User = {
uid: value.uid,
emailId: value.emailId,
name: value.name,
dob: value.dob,
profilePhoto: value.profilePhoto,
emailVerified: value.emailVerified,
phone: value.phone,
phoneVerified: value.phoneVerified,
status: value.status,
currency: value.currency,
otp: value.otp,
loginType: value.loginType
};
this.loggedUser = userData;
this.service.set('userData', JSON.stringify(this.loggedUser));
this.subjectService.sendUserData(JSON.stringify(this.loggedUser));
console.log(this.loggedUser);
});
}
......@@ -355,25 +371,51 @@ export class AuthService {
resetPassword(email: string) {
this.loader = true;
this.afAuth.auth
.sendPasswordResetEmail(email)
.then(() => {
this.service.showToast(
'Password reset mail has been sent your mail Id',
'top',
'my-toast',
2000
);
this.loader = false;
this.router.navigateByUrl('login', { replaceUrl: true });
})
.catch(error => {
this.service.showToast(error, 'top', 'my-error', 1000);
this.loader = false;
const state = true;
const custRef: AngularFirestoreCollection<any> = this.afs.collection(
'customers',
ref => ref.where('status', '==', state).where('emailId', '==', email)
);
custRef
.valueChanges()
.pipe(take(1))
.subscribe((value: User[]) => {
if (value.length > 0) {
this.afAuth.auth.sendPasswordResetEmail(email).then(() => {
this.service.showToast(
'Password reset mail has been sent your mail Id',
'top',
'my-toast',
2000
);
this.loader = false;
this.router.navigateByUrl('login', { replaceUrl: true });
})
.catch(error => {
this.service.showToast(error, 'top', 'my-error', 1000);
this.loader = false;
});
} else {
this.service.showToast(
'Invalid customer email Id',
'top',
'my-error',
1000
);
this.loader = false;
}
});
}
resend() {
this.service.showToast('OTP sent successfully', 'top', 'my-toast', 1000);
}
termsFun() {
const userRef: AngularFirestoreDocument<any> = this.afs.doc(`setting/cms`);
userRef.valueChanges().subscribe(value => {
this.terms = value.content;
console.log(this.terms);
});
}
}
......@@ -26,6 +26,7 @@ export class CartsService {
user: User;
carts: CartItem[] = [];
cartTotal: number;
totalGst: number;
cartCenter: any;
constructor(
......@@ -47,6 +48,7 @@ export class CartsService {
}
public async buyNow(product: Products) {
console.log(product);
const promise = new Promise(resolve => {
this.prodId = product.prodId;
const prodRef = firebase
......@@ -75,7 +77,6 @@ export class CartsService {
.valueChanges()
.pipe(take(1))
.subscribe(value => {
// console.log(value);
if (value.length === 0) {
product.image =
......@@ -93,10 +94,12 @@ export class CartsService {
prodName: product.prodName,
shopper: product.shopper,
centerId: product.centerId,
skuCode: product.skuCode,
qty: 1,
size: this.size
size: this.size,
gst: product.gst
};
// console.log(cart);
console.log(cart);
this.afs
.collection('carts')
.add(cart)
......@@ -152,6 +155,7 @@ export class CartsService {
this.carts = [];
const res = value;
this.cartTotal = 0;
this.totalGst = 0;
if (res.length > 0) {
// if (this.cartCenter === '') {
this.cartCenter = res[0].centerId;
......@@ -169,11 +173,14 @@ export class CartsService {
prodName: item.prodName,
image: item.image,
qty: item.qty,
size: item.size
size: item.size,
skuCode: item.skuCode,
gst: item.gst
};
// console.log(item.price, item.qty);
if (item.price) {
this.cartTotal += item.price * item.qty;
this.totalGst += ((item.price * item.gst) / 100) * item.qty;
}
/*const prodItem = item.product.get().then((property) => {
const response = property.data();
......
......@@ -9,6 +9,7 @@ import { ServiceService } from './../config/service.service';
import * as firebase from 'firebase';
import { take } from 'rxjs/operators';
import { Observable, of } from 'rxjs';
import { resolve } from 'url';
@Injectable({
providedIn: 'root'
......@@ -18,6 +19,9 @@ export class MyordersService {
custId: string;
orders: Myorder[];
selItem: Myorder;
timeinterval: any;
cancelDelivery: number;
deliveryTime: string;
constructor(public afs: AngularFirestore, public service: ServiceService) {
const users = this.service.get('user').then(data => {
......@@ -34,58 +38,14 @@ export class MyordersService {
});
}
/*public async orgorderList(custId) {
// console.log('called');
// console.log(custId);
const This = this;
const orderRef: AngularFirestoreCollection<any> = this.afs.collection('orders', ref => ref.where('custId', '==', custId)
.orderBy('bookDate', 'desc'));
orderRef.stateChanges().subscribe((value) => {
// console.log(value[0].payload.doc.data());
});
orderRef.valueChanges().pipe(take(1)).subscribe((value) => {
// console.log(value);
this.orders = [];
const res = value;
if (res.length > 0) {
res.forEach((item) => {
// console.log(item);
const order: Myorder = {
prodName: item.prodName,
color: item.color,
image: item.image,
amount: item.amount,
qty: item.qty,
status: item.status,
orderStatus: item.orderStatus,
bookDate: item.bookDate,
deliveryLocation: item.deliveryLocation,
pickupLocation: item.pickupLocation,
riderName: 'John',
orderId: item.orderId,
size: item.size,
orderCode: item.orderCode,
product: this.service.key2Array(item.product),
time: '60'
};
this.orders.push(order);
});
// console.log(this.orders);
} else {
alert('No Orders Found');
}
this.orderState();
});
}*/
public async cancelOrder(orderId) {
// tslint:disable-next-line:no-shadowed-variable
const promise = new Promise(resolve => {
this.afs
.collection('orders')
.doc(orderId)
.update({
orderStatus: 0,
orderStatus: 4,
cancelTime: firebase.firestore.FieldValue.serverTimestamp()
});
resolve(true);
......@@ -103,29 +63,45 @@ export class MyordersService {
ref => ref.where('custId', '==', custId).orderBy('orderDate', 'desc')
);
orderRef.stateChanges().subscribe(value => {
console.log(value);
const res = value;
// console.log(res);
if (res.length > 0) {
res.forEach(items => {
const item = items.payload.doc.data();
// console.log(item);
console.log(item);
const orderId = item.orderId;
const order: Myorder = {
amount: item.amount,
status: item.status,
center: item.center,
contactLess: item.contactLess,
contactNo: item.contactNo,
custExp: item.custExp,
deliveredTime: item.deliveredTime,
deliveryAddress: item.deliveryAddress,
deliveryCharge: item.deliveryCharge,
deliveryLocation: item.deliveryLocation,
discount: item.discount,
orderCode: item.orderCode,
orderDate: item.orderDate,
orderId: item.orderId,
orderStatus: item.orderStatus,
bookDate: item.bookDate,
deliveryLocation: item.deliveryLocation,
paymentMethod: item.paymentMethod,
pickupAddress: item.pickupAddress,
pickupLocation: item.pickupLocation,
deliveryAddress: item.deliveryAddress,
paymentMode: item.paymentMethod,
riderName: 'John',
orderId: item.orderId,
orderCode: item.orderCode,
product: this.service.key2Array(item.product),
time: item.timeRemain
promoApplied: item.promoApplied,
promoCode: item.promoCode,
riderExp: item.riderExp,
riderId: item.riderId,
riderName: item.riderName,
riderStatus: item.riderStatus,
shopper: this.prodConfig(item.shopper),
shoppers: item.shoppers,
tax: item.tax,
timeRemain: item.timeRemain,
timeTaken: item.timeTaken,
totalItem: item.totalItem,
transId: item.transId,
transaction: item.transaction
};
// console.log(order);
if (items.type === 'added') {
......@@ -139,11 +115,122 @@ export class MyordersService {
}
});
this.orders.sort((a, b) => Number(b.orderDate) - Number(a.orderDate));
// console.log(this.orders);
console.log(this.orders);
}
});
}
public async getOrder(orderDta) {
// tslint:disable-next-line:no-shadowed-variable
const promise = new Promise((resolve) => {
const orderRef: AngularFirestoreDocument<any> = this.afs.collection('orders').doc(orderDta.orderId);
orderRef.valueChanges().subscribe(item => {
console.log(item);
const order: Myorder = {
amount: item.amount,
center: item.center,
contactLess: item.contactLess,
contactNo: item.contactNo,
custExp: item.custExp,
deliveredTime: item.deliveredTime,
deliveryAddress: item.deliveryAddress,
deliveryCharge: item.deliveryCharge,
deliveryLocation: item.deliveryLocation,
discount: item.discount,
orderCode: item.orderCode,
orderDate: item.orderDate,
orderId: item.orderId,
orderStatus: item.orderStatus,
paymentMethod: item.paymentMethod,
pickupAddress: item.pickupAddress,
pickupLocation: item.pickupLocation,
promoApplied: item.promoApplied,
promoCode: item.promoCode,
riderExp: item.riderExp,
riderId: item.riderId,
riderName: item.riderName,
riderStatus: item.riderStatus,
shopper: this.prodConfigShopper(item.shopper, orderDta.shopperId),
shoppers: item.shoppers,
tax: item.tax,
timeRemain: item.timeRemain,
timeTaken: item.timeTaken,
totalItem: item.totalItem,
transId: item.transId,
transaction: item.transaction
};
this.selItem = order;
const This = this;
this.timeinterval = setInterval(() => {
This.getDeliveryTime(this.selItem.orderDate.seconds, this.selItem.timeRemain);
}, 1000);
resolve(true);
});
});
return promise;
}
getDeliveryTime(timeStamp, minute) {
let endDate = new Date(timeStamp * 1000);
endDate = new Date(endDate.getTime() + minute * 60000);
if (Math.round(Date.now() / 1000) < Math.round(endDate.getTime() / 1000)) {
// console.log(endDate);
const t = this.getTimeRemaining(endDate, new Date());
const minutes = t.minutes < 10 ? '0' + t.minutes : t.minutes;
const seconds = t.seconds < 10 ? '0' + t.seconds : t.seconds;
const hours = t.hours < 10 ? '0' + t.hours : t.hours;
this.deliveryTime = t.hours + ' : ' + minutes + ' : ' + seconds;
if (t.t <= 0) {
clearInterval(this.timeinterval);
}
}
}
getTimeRemaining(endtime, currDate) {
const t = Date.parse(endtime) - Date.parse(currDate);
this.cancelDelivery = t;
const hours = Math.floor((((t / 1000) / 60) / 60) % 60);
const seconds = Math.floor((t / 1000) % 60);
const minutes = Math.floor((t / 1000 / 60) % 60);
return {
t,
hours,
minutes,
seconds
};
}
prodConfig(ShoppItems) {
const shopperData = [];
// tslint:disable-next-line:forin
for (const i in ShoppItems) {
const shopData = ShoppItems[i];
const product = [];
// tslint:disable-next-line: forin
for (const j in shopData.product) {
const prodData = shopData.product[j];
product.push(prodData);
}
shopData.product = product;
shopperData.push(shopData);
}
return shopperData;
}
prodConfigShopper(ShoppItems, shopperId) {
const shopData = ShoppItems[shopperId];
const product = [];
// tslint:disable-next-line: forin
for (const j in shopData.product) {
const prodData = shopData.product[j];
product.push(prodData);
}
shopData.product = product;
return shopData;
}
/* public orderState(): Observable<Myorder[]> {
// console.log('called');
const custId = 'WwHnLICVY2dvZGUHuKqasiTB91a2';
......
......@@ -5,7 +5,7 @@ import {
AngularFirestoreCollection
} from '@angular/fire/firestore';
import { Router, ActivatedRoute } from '@angular/router';
import { Order, CartProd } from './services/order';
import { Order, OrderData, Product, Shopper } from './services/order';
import { Products } from './services/product';
import { ServiceService } from './service.service';
import { SubjectService } from './subject.service';
......@@ -27,6 +27,7 @@ export class OrdersService {
cartCount: any;
email: any;
displayName: string;
phone: any;
constructor(
public afs: AngularFirestore,
......@@ -45,6 +46,7 @@ export class OrdersService {
this.custId = data.uid;
this.email = data.emailId;
this.displayName = data.name;
this.phone = data.phone;
// console.log(this.custId);
} else {
this.custId = 'WwHnLICVY2dvZGUHuKqasiTB91a2';
......@@ -115,10 +117,8 @@ export class OrdersService {
}*/
public async checkOut(cart: CartItem[], otherCharge, centerLoc: any) {
// console.log(cart);
// console.log(this.users);
console.log(cart, otherCharge, centerLoc);
const cartGroup = [];
// const distinctShops = [...new Set(cart.map(obj => obj.shopperId))];
const distinctShops = [];
const map = new Map();
for (const item of cart) {
......@@ -127,93 +127,120 @@ export class OrdersService {
distinctShops.push(item.shopperId);
}
}
cart.forEach(items => {
cartGroup[items.shopperId] =
cartGroup[items.shopperId] === undefined
? []
: cartGroup[items.shopperId];
cartGroup[items.shopperId] = cartGroup[items.shopperId] === undefined ? [] : cartGroup[items.shopperId];
cartGroup[items.shopperId].push(items);
});
this.cartCount = distinctShops.length;
const timer = ((this.cartCount - 1) * 20) + 60;
// console.log(cartGroup);
// console.log(cartCount);
const promise = new Promise(resolve => {
distinctShops.forEach(item => {
const pickup = new firebase.firestore.GeoPoint(centerLoc.latLng.latitude, centerLoc.latLng.longitude);
const products = {};
const cartItem = cartGroup[item];
let prodPrice = 0;
cartItem.forEach(prodItem => {
prodPrice += prodItem.price;
products[prodItem.prodId] = {
const pickup = new firebase.firestore.GeoPoint(centerLoc.latLng.latitude, centerLoc.latLng.longitude);
const promise = new Promise(async resolve => {
const shopRef = await this.afs.collection(`shoppers`,
ref =>
ref
.where('uid', 'in', distinctShops)
);
shopRef.valueChanges().subscribe((value: any) => {
console.log(value);
const shoppersData = value;
console.log(shoppersData);
const shoppers = {};
distinctShops.forEach(item => {
const shopperInfo = shoppersData.find((ret) => ret.uid === item);
console.log(shopperInfo);
const cartItem = cartGroup[item];
shoppers[item] = {};
const shopper: Shopper = {
amount: 0,
getmiCharge: 0,
product: {},
shopperEarn: 0,
shopperId: shopperInfo.uid,
shopperName: shopperInfo.shopName,
shopperOrderNo: this.orderCode(),
shopperRef: firebase.firestore().doc('/shoppers/' + shopperInfo.uid),
shopperStatus: 0
};
const products = {};
cartItem.forEach(prodItem => {
shopper.amount += prodItem.price;
const prod: Product = {
prodId: prodItem.prodId,
skuCode: prodItem.skuCode,
prodName: prodItem.prodName,
image: prodItem.image,
price: prodItem.price,
gst: prodItem.gst,
color: prodItem.color,
size: prodItem.size,
qty: prodItem.qty,
discount: ''
itemId: `${shopperInfo.uid}-${prodItem.skuCode}-${this.pad(Math.round(Math.random() * 1000), 3, null)}`,
discount: 0
};
products[prodItem.prodId] = prod;
this.afs.doc(`carts/${prodItem.cartId}`).delete();
});
// console.log(cartItem);
// console.log(products);
const product = cartItem[0];
this.custId = this.custId.trim();
const orderItem: Order = {
amount: 'A$ ' + otherCharge.totalAmt.toFixed(2),
customer: firebase.firestore().doc('/customer/' + this.custId),
shopper: product.shopper,
shopper.product = products;
shoppers[item] = shopper;
});
const orderItem: OrderData = {
amount: otherCharge.totalAmt.toFixed(2),
orderDate: firebase.firestore.FieldValue.serverTimestamp(),
center: centerLoc,
custId: this.custId.trim(),
custName: this.displayName,
deliveryAddress: otherCharge.custAddress,
deliveryCharge: 'A$ ' + otherCharge.deliveryCharge.toFixed(2),
deliveryCharge: otherCharge.deliveryCharge.toFixed(2),
deliveryLocation: otherCharge.custAddress.latLng,
bookDate: firebase.firestore.FieldValue.serverTimestamp(),
orderDate: Math.floor(Date.now() / 1000),
orderCode: this.orderCode(),
discount: otherCharge.discount.toFixed(2),
email: this.email,
orderCode: this.gmCode(),
contactLess: otherCharge.contactLess,
contactNo: this.phone,
custExp: {
rating: 0,
feedback: ''
},
customer: firebase.firestore().doc('/customer/' + this.custId.trim()),
deliveredTime: '',
orderId: '',
orderStatus: 1,
paymentMethod: otherCharge.paymentMethod,
pickupAddress: centerLoc.location,
pickupLocation: pickup,
center: firebase
.firestore()
.doc('/riders/qbTKza18mWVzYG9NLIbmjMbrYjG2'),
promoId: null,
rider: firebase
.firestore()
.doc('/centers/' + centerLoc.cId),
status: 1,
custId: this.custId,
riderId: 'qbTKza18mWVzYG9NLIbmjMbrYjG2',
shopperId: product.shopperId,
email: this.email,
custName: this.displayName,
riderName: 'John',
shopperState: 0,
paymentMethod: otherCharge.paymentMethod,
shopperName: '',
product: products,
timeRemain: timer,
discount: 'A$ ' + otherCharge.discount.toFixed(2),
promoApplied: otherCharge.discountApplied,
tax: 'A$ ' + otherCharge.taxAmount.toFixed(2)
promoCode: otherCharge.promoCode ? otherCharge.promoCode : '',
promoId: otherCharge.promoId ? otherCharge.promoId : '',
rider: '',
riderExp: {
rating: 0,
feedback: ''
},
riderId: '',
riderName: '',
riderStatus: 0,
shopper: shoppers,
shoppers: distinctShops,
tax: otherCharge.taxAmount.toFixed(2),
timeRemain: timer,
timeTaken: 0,
totalItem: cart.length,
transId: otherCharge.transId,
transaction: otherCharge.transaction
};
// console.log(orderItem);
this.afs
.collection('orders')
this.afs.collection('orders')
.add(orderItem)
.then(docRef => {
const neworderId = docRef.id;
console.log(neworderId);
this.afs
.collection('orders')
.doc(neworderId)
.update({ orderId: neworderId })
.then(() => {
// console.log('Booking Successfully');
// this.router.navigateByUrl('cart');
resolve('Cart to Order Successfully');
document.body.scrollTop = document.documentElement.scrollTop = 0;
});
......@@ -222,7 +249,6 @@ export class OrdersService {
});
});
});
// promise.then(value => console.log(value));
}
public async changeOrder(orderId, status) {
......@@ -243,6 +269,12 @@ export class OrdersService {
return orderCode;
}
gmCode() {
const newpin = Math.round(Math.random() * 1000000);
const orderCode = 'OD' + this.pad(newpin, 5, null) + new Date().valueOf();
return orderCode;
}
pad(n, width, z) {
z = z || '0';
n = n + '';
......
......@@ -108,7 +108,8 @@ export class ProductsService {
centerRef: item.center,
size: this.service.splitSep(item.size),
subCate: item.subCate,
tag: this.service.splitSep(item.tag)
tag: this.service.splitSep(item.tag),
gst: item.gst
};
this.product.push(prod);
});
......@@ -183,7 +184,8 @@ export class ProductsService {
status: item.status,
size: this.service.splitSep(item.size),
subCate: item.subCate,
tag: this.service.splitSep(item.tag)
tag: this.service.splitSep(item.tag),
gst: item.gst
};
this.product.push(prod);
});
......@@ -238,7 +240,8 @@ export class ProductsService {
status: item.status,
size: this.service.splitSep(item.size),
subCate: item.subCate,
tag: this.service.splitSep(item.tag)
tag: this.service.splitSep(item.tag),
gst: item.gst
};
this.similar.push(prod);
});
......
import { Injectable } from '@angular/core';
import {
AngularFirestore,
AngularFirestoreCollection
} from '@angular/fire/firestore';
import { take } from 'rxjs/operators';
import { Return } from './services/return';
import { ServiceService } from './service.service';
import { Router, ActivatedRoute } from '@angular/router';
@Injectable({
providedIn: 'root'
})
export class ReturnService {
loader: boolean;
constructor(
public afs: AngularFirestore,
private router: Router,
private service: ServiceService
) {
this.loader = false;
}
returnCreate(data) {
this.loader = true;
this.afs
.collection('orderReturn')
.add(data)
.then(docRef => {
data.contactId = docRef.id;
this.afs
.collection('orderReturn')
.doc(data.contactId)
.update({ contactId: data.contactId })
.then(() => {
this.service
.showToast('Thank you for your feedback!', 'top', 'my-toast', 500)
.then(() => {
this.loader = false;
console.log('redirected');
setTimeout(() => {
this.router.navigateByUrl('home');
}, 500);
})
.catch(err => {
this.loader = false;
});
});
});
}
}
......@@ -11,6 +11,8 @@ export interface Cart {
qty: number;
price: number;
centerId: string;
skuCode: string;
gst: number;
}
export interface CartItem {
......@@ -24,5 +26,7 @@ export interface CartItem {
color: string;
qty: number;
price: number;
skuCode: string;
gst: number;
}
export interface Myorder {
amount: string;
bookDate: any;
amount: number;
orderDate: any;
pickupLocation: any;
center: object;
deliveryAddress: string;
deliveryCharge: number;
deliveryLocation: any;
deliveryAddress: any;
status: number;
discount: number;
orderCode: string;
contactLess: boolean;
contactNo: string;
custExp: {
rating: number,
feedback: string,
};
deliveredTime: any;
orderId: string;
orderStatus: number;
paymentMethod: string;
pickupAddress: string;
pickupLocation: any;
promoApplied: boolean;
promoCode: string;
riderExp: {
rating: number;
feedback: string
};
riderId: string;
riderName: string;
orderId: string;
time: number;
product: any;
orderCode: string;
paymentMode: string;
riderStatus: number;
shopper: any;
shoppers: any;
tax: number;
timeRemain: number;
timeTaken: number;
totalItem: number;
transId: string;
transaction: string;
}
/*export interface Order {
amount: string;
customer: any;
deliveryAddress: string;
deliveryCharge: string;
deliveryLocation: object;
discount: string;
orderCode: string;
orderId: string;
orderStatus: number;
pickupAddress: string;
pickupLocation: object;
price: string;
bookDate: any;
prodId: string;
custId: string;
prodName: any;
image: string;
size: string;
color: string;
promoId: any;
qty: number;
rider: any;
riderId: string;
shopper: any;
shopperId: string;
status: number;
tax: string;
}*/
export interface CartProd {
prodName: any;
prodId: string;
......@@ -40,6 +10,33 @@ export interface CartProd {
productDoc: any;
}
export interface Product {
skuCode: string;
prodName: string;
color: string;
discount: number;
prodId: string;
image: string;
price: number;
size: any;
qty: number;
itemId: string;
gst: number;
}
export interface Shopper {
shopperStatus: number;
shopperOrderNo: string;
shopperName: string;
shopperId: string;
shopperRef: any;
amount: number;
getmiCharge: number;
shopperEarn: number;
product: any;
}
export interface Order {
amount: string;
customer: any;
......@@ -73,3 +70,50 @@ export interface Order {
timeRemain: number;
center: any;
}
export interface OrderData {
amount: number;
pickupAddress: string;
orderStatus: number;
rider: any;
tax: number;
email: string;
deliveryCharge: number;
deliveryAddress: any;
orderCode: string;
custId: string;
paymentMethod: string;
transaction: string;
transId: string;
deliveryLocation: object;
orderId: string;
center: any;
riderName: string;
timeRemain: number;
timeTaken: number;
deliveredTime: any;
discount: number;
orderDate: any;
contactLess: boolean;
promoId: string;
promoCode: string;
riderStatus: number;
promoApplied: boolean;
pickupLocation: any;
riderId: string;
customer: any;
shoppers: any;
totalItem: number;
shopper: any;
custName: string;
contactNo: string;
riderExp: {
rating: number;
feedback: string
};
custExp: {
rating: number;
feedback: string
};
}
......@@ -13,6 +13,7 @@ export interface Products {
prodStatus: boolean;
shopperId: string;
qty: number;
gst: number;
shopper: string;
centerId: string;
centerRef: any;
......
export interface Return {
orderId: string;
shopperId: string;
shopperName: string;
shopperRef: any;
orderInfo: {
shopOrder: string;
productId: string;
prodName: string;
qty: number;
size: string;
color: string;
price: number;
discount: number;
};
description: string;
comment: string;
status: number;
refundAmount: number;
customerId: string;
customerName: string;
custRef: any;
}
......@@ -76,7 +76,8 @@ export class WishService {
status: item.status,
subCate: item.subCate,
tag: this.service.splitSep(item.tag),
size: this.service.splitSep(item.size)
size: this.service.splitSep(item.size),
gst: item.gst
};
const found = this.whishItem.some(
el => el.prodId === item.prodId
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment