Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
getme
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
amal
getme
Commits
cee55fe8
Commit
cee55fe8
authored
Sep 27, 2019
by
amalk
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into amal
parents
aa18aaad
d0cd2a4f
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
399 additions
and
41 deletions
+399
-41
app.component.html
src/app/app.component.html
+2
-2
app.component.ts
src/app/app.component.ts
+3
-1
cart.page.html
src/app/cart/cart.page.html
+5
-5
cart.page.ts
src/app/cart/cart.page.ts
+8
-2
home.page.ts
src/app/home/home.page.ts
+10
-3
landing.page.ts
src/app/landing/landing.page.ts
+1
-0
login.page.ts
src/app/login/login.page.ts
+7
-1
myorder.page.html
src/app/myorder/myorder.page.html
+29
-5
myorder.page.scss
src/app/myorder/myorder.page.scss
+16
-0
myorder.page.ts
src/app/myorder/myorder.page.ts
+7
-0
productdetail.page.html
src/app/productdetail/productdetail.page.html
+4
-3
productdetail.page.ts
src/app/productdetail/productdetail.page.ts
+11
-0
trackorder.module.ts
src/app/trackorder/trackorder.module.ts
+1
-1
auth.service.ts
src/config/auth.service.ts
+2
-1
cart.service.ts
src/config/cart.service.ts
+3
-2
myorder.service.ts
src/config/myorder.service.ts
+141
-2
order.service.ts
src/config/order.service.ts
+102
-3
products.service.ts
src/config/products.service.ts
+1
-0
cart.ts
src/config/services/cart.ts
+2
-0
myorder.ts
src/config/services/myorder.ts
+2
-5
order.ts
src/config/services/order.ts
+41
-5
product.ts
src/config/services/product.ts
+1
-0
No files found.
src/app/app.component.html
View file @
cee55fe8
...
...
@@ -33,8 +33,8 @@
</div>
<li>
Complaints
&
Feedback
</li>
<li>
<span
class=
"floatLeft"
>
Logout
</span>
<span
class=
"floatRight version"
>
Version
1.2.0.3
</span>
<span
class=
"floatLeft"
(
click
)="
authService
.
SignOut
()"
>
Logout
</span>
<span
class=
"floatRight version"
>
Version
0.1.0.2
</span>
<div
class=
"clear"
></div>
</li>
</ul>
...
...
src/app/app.component.ts
View file @
cee55fe8
...
...
@@ -7,6 +7,7 @@ import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection
import
*
as
firebase
from
'firebase'
;
import
{
ModalController
}
from
'@ionic/angular'
;
import
{
DeliverypopPage
}
from
'./deliverypop/deliverypop.page'
;
import
{
AuthService
}
from
'./../config/auth.service'
;
@
Component
({
...
...
@@ -21,7 +22,8 @@ export class AppComponent {
private
statusBar
:
StatusBar
,
private
router
:
Router
,
public
afs
:
AngularFirestore
,
public
modalController
:
ModalController
public
modalController
:
ModalController
,
public
authService
:
AuthService
)
{
this
.
initializeApp
();
this
.
orderState
();
...
...
src/app/cart/cart.page.html
View file @
cee55fe8
...
...
@@ -179,13 +179,13 @@
<div
class=
"footer_btn"
*
ngIf=
"cartService.carts && cartService.carts.length > 0"
[
hidden
]="
currentIndex
!=
1
"
(
click
)="
next
(
2
);"
>
PAY
</div>
<div
class=
"footer_btn"
[
hidden
]="
currentIndex
!=
2
"
(
click
)="
finishpop
()"
>
<
!-- <
div class="footer_btn" [hidden]="currentIndex != 2" (click)="finishpop()">
FINISH
</div>
</div>
-->
</ion-footer>
<
!-- <div class
="loader">
<
div
class=
"loader"
*
ngIf
=
"loader"
>
<div
class=
"lds-ripple"
>
<div></div>
<div></div>
</div>
</div> -->
\ No newline at end of file
</div>
\ No newline at end of file
src/app/cart/cart.page.ts
View file @
cee55fe8
...
...
@@ -19,6 +19,7 @@ export class CartPage implements OnInit {
currentIndex
:
any
;
count
:
any
;
gateway
:
any
;
loader
=
false
;
cartwizard
=
{
initialSlide
:
0
,
speed
:
1000
,
...
...
@@ -47,11 +48,11 @@ export class CartPage implements OnInit {
this
.
gateway
=
1
;
}
getwayafterpay
(){
getwayafterpay
()
{
this
.
gateway
=
2
;
}
getwaypayk
(){
getwaypayk
()
{
this
.
gateway
=
3
;
}
...
...
@@ -76,6 +77,11 @@ export class CartPage implements OnInit {
next
(
index
:
number
=
null
)
{
this
.
loader
=
true
;
const
This
=
this
;
setTimeout
(()
=>
{
This
.
loader
=
false
;
},
500
);
console
.
log
(
index
);
if
(
index
===
2
)
{
const
state
=
this
.
orderService
.
checkOut
(
this
.
cartService
.
carts
).
then
((
data
)
=>
{
...
...
src/app/home/home.page.ts
View file @
cee55fe8
...
...
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import
{
Location
}
from
'@angular/common'
;
import
{
trigger
,
transition
,
animate
,
style
}
from
'@angular/animations'
;
import
{
Router
,
ActivatedRoute
}
from
'@angular/router'
;
import
{
MenuController
}
from
'@ionic/angular'
;
@
Component
({
selector
:
'app-home'
,
templateUrl
:
'./home.page.html'
,
...
...
@@ -21,8 +22,8 @@ import { Router, ActivatedRoute } from '@angular/router';
export
class
HomePage
implements
OnInit
{
isShow
=
false
;
public
lat
:
number
=
51.678418
;
public
lng
:
number
=
7.809007
;
public
lat
=
51.678418
;
public
lng
=
7.809007
;
slideOpts
=
{
slidesPerView
:
1.5
...
...
@@ -31,10 +32,16 @@ export class HomePage implements OnInit {
constructor
(
private
router
:
Router
,
private
route
:
ActivatedRoute
,
private
location
:
Location
private
location
:
Location
,
public
menuCtrl
:
MenuController
)
{
}
ngOnInit
()
{
this
.
menuCtrl
.
enable
(
true
);
}
ionViewWillEnter
()
{
this
.
menuCtrl
.
enable
(
true
);
}
goToPage
(
path
,
data
=
null
)
{
...
...
src/app/landing/landing.page.ts
View file @
cee55fe8
...
...
@@ -26,6 +26,7 @@ export class LandingPage implements OnInit {
this
.
service
.
get
(
'landing'
).
then
((
data
)
=>
{
if
(
data
===
true
)
{
const
user
=
JSON
.
parse
(
localStorage
.
getItem
(
'user'
));
console
.
log
(
user
);
if
(
user
)
{
this
.
goToPage
(
'home'
);
}
else
{
...
...
src/app/login/login.page.ts
View file @
cee55fe8
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
Router
,
ActivatedRoute
}
from
'@angular/router'
;
import
{
AuthService
}
from
'./../../config/auth.service'
;
import
{
MenuController
}
from
'@ionic/angular'
;
import
{
async
}
from
'q'
;
...
...
@@ -14,12 +15,17 @@ export class LoginPage implements OnInit {
constructor
(
private
router
:
Router
,
private
route
:
ActivatedRoute
,
public
authService
:
AuthService
public
authService
:
AuthService
,
public
menuCtrl
:
MenuController
)
{
}
ngOnInit
()
{
}
ionViewWillEnter
()
{
this
.
menuCtrl
.
enable
(
false
);
}
goToPage
(
path
,
data
=
null
)
{
this
.
router
.
navigateByUrl
(
path
,
{
queryParams
:
data
});
document
.
body
.
scrollTop
=
document
.
documentElement
.
scrollTop
=
0
;
...
...
src/app/myorder/myorder.page.html
View file @
cee55fe8
...
...
@@ -10,24 +10,41 @@
<div
class=
"myorder_wrapper"
*
ngIf=
"myorder.orders"
>
<ul
*
ngIf=
"myorder.orders.length > 0"
>
<li
*
ngFor=
"let order of myorder.orders; let i = index"
>
<div
class=
"order_image"
><img
[
src
]="
order
.
image
"
onerror=
""
/></div>
<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
)"
>
Track Order
</button>
<div
class=
"clear"
></div>
</div>
<div
*
ngFor=
"let product of order.product"
>
<div
class=
"order_image"
><img
[
src
]="
product
.
image
"
onerror=
""
/></div>
<div
class=
"order_detail"
>
<h5
class=
"floatLeft"
>
{{order
.prodName}}
</h5>
<h5
class=
"floatLeft"
>
{{product
.prodName}}
</h5>
<div
class=
"clear"
></div>
<h5>
{{order.color}}, {{order.size}}
<span>
{{order
.qty}}
</span></h5>
<h5>
{{product.color}}, {{product.size}}
<span>
{{product
.qty}}
</span></h5>
<p>
{{order.amount
}}
</p>
<p>
A$ {{product.price
}}
</p>
</div>
<div
class=
"order_other"
>
<h6
class=
"floatRight"
>
{{ 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>
<!-- <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>
<hr>
</div>
<div
class=
"order_info"
>
<h5
class=
"floatRight"
>
TOTAL PRICE : {{order.amount}}
</h5>
<div
class=
"clear"
></div>
</div>
</li>
<!-- <li>
<div class="order_image"></div>
<div class="order_detail">
...
...
@@ -77,3 +94,9 @@
</ul>
</div>
</ion-content>
<div
class=
"loader"
*
ngIf=
"loader"
>
<div
class=
"lds-ripple"
>
<div></div>
<div></div>
</div>
</div>
\ No newline at end of file
src/app/myorder/myorder.page.scss
View file @
cee55fe8
...
...
@@ -6,6 +6,22 @@
list-style
:
none
;
padding
:
10px
;
padding-bottom
:
15px
;
.order_info
{
padding-top
:
10px
;
padding-bottom
:
10px
;
h5
{
margin
:
0px
;
padding
:
0px
;
}
.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
;
...
...
src/app/myorder/myorder.page.ts
View file @
cee55fe8
...
...
@@ -11,6 +11,7 @@ import { DeliverypopPage } from '../deliverypop/deliverypop.page';
styleUrls
:
[
'./myorder.page.scss'
],
})
export
class
MyorderPage
implements
OnInit
{
loader
=
false
;
constructor
(
private
router
:
Router
,
...
...
@@ -21,6 +22,12 @@ export class MyorderPage implements OnInit {
)
{
}
ngOnInit
()
{
const
This
=
this
;
this
.
loader
=
true
;
setTimeout
(()
=>
{
This
.
loader
=
false
;
},
500
);
// this.myorder.orderList('WwHnLICVY2dvZGUHuKqasiTB91a2');
}
async
finishpop
(
data
:
any
)
{
...
...
src/app/productdetail/productdetail.page.html
View file @
cee55fe8
...
...
@@ -4,7 +4,7 @@
</button>
<div
class=
"nav_title floatLeft"
>
</div>
<button
class=
"nav_btn nav_cart floatRight"
>
<button
class=
"nav_btn nav_cart floatRight"
(
click
)="
goToPage
('
cart
')"
>
</button>
<div
class=
"clear"
></div>
</div>
...
...
@@ -177,8 +177,8 @@
<div
class=
"footer_options"
>
<button
class=
"share"
></button>
<button
class=
"fav"
></button>
<button
class=
"cart"
(
click
)="
goToPage
('
cart
'
)"
></button>
<button
class=
"cart"
(
click
)="
buyNow
(
product
,
0
)"
></button>
</div>
<div
class=
"footer_btn"
(
click
)="
cartService
.
buyNow
(
product
)"
>
BUY NOW
</div>
<div
class=
"footer_btn"
(
click
)="
buyNow
(
product
,
1
)"
>
BUY NOW
</div>
</div>
</ion-footer>
\ No newline at end of file
src/app/productdetail/productdetail.page.ts
View file @
cee55fe8
...
...
@@ -45,6 +45,7 @@ export class ProductdetailPage implements OnInit {
prodStatus
:
params
.
prodStatus
,
brand
:
params
.
brand
,
category
:
params
.
category
,
shopperId
:
params
.
shopperId
,
color
:
params
.
color
,
discount
:
params
.
discount
,
featured
:
params
.
featured
,
...
...
@@ -81,4 +82,14 @@ export class ProductdetailPage implements OnInit {
this
.
location
.
back
();
}
buyNow
(
product
:
any
,
type
:
number
)
{
this
.
cartService
.
buyNow
(
product
).
then
(()
=>
{
if
(
type
===
1
)
{
this
.
router
.
navigateByUrl
(
'cart'
);
}
else
{
alert
(
'Product added to cart'
);
}
});
}
}
src/app/trackorder/trackorder.module.ts
View file @
cee55fe8
...
...
@@ -23,7 +23,7 @@ const routes: Routes = [
IonicModule
,
AgmDirectionModule
,
AgmCoreModule
.
forRoot
({
apiKey
:
'AIzaSy
AK3Av2e2dunqInYEaAVJPmzK5HTi0gubw
'
apiKey
:
'AIzaSy
Bn6hOlr6YHcZAmbptlsmbhvH5iQllWflE
'
}),
RouterModule
.
forChild
(
routes
)
],
...
...
src/config/auth.service.ts
View file @
cee55fe8
...
...
@@ -23,9 +23,11 @@ export class AuthService {
if
(
user
)
{
this
.
userData
=
user
;
this
.
service
.
set
(
'user'
,
JSON
.
stringify
(
this
.
userData
));
this
.
router
.
navigateByUrl
(
'home'
);
}
else
{
this
.
service
.
set
(
'user'
,
null
);
JSON
.
parse
(
localStorage
.
getItem
(
'user'
));
this
.
router
.
navigateByUrl
(
'login'
);
}
});
}
...
...
@@ -33,7 +35,6 @@ export class AuthService {
public
async
SignIn
(
email
:
string
,
password
:
string
)
{
return
this
.
afAuth
.
auth
.
signInWithEmailAndPassword
(
email
,
password
).
then
((
result
)
=>
{
console
.
log
(
'success'
);
this
.
router
.
navigateByUrl
(
'home'
);
document
.
body
.
scrollTop
=
document
.
documentElement
.
scrollTop
=
0
;
this
.
SetUserData
(
result
.
user
);
}).
catch
((
error
)
=>
{
...
...
src/config/cart.service.ts
View file @
cee55fe8
...
...
@@ -56,6 +56,7 @@ export class CartsService {
const
cart
:
Cart
=
{
color
:
this
.
color
,
custId
:
this
.
custId
,
shopperId
:
product
.
shopperId
,
product
:
firebase
.
firestore
().
doc
(
`products/
${
this
.
prodId
}
`
),
image
:
product
.
image
,
prodId
:
product
.
prodId
,
...
...
@@ -69,7 +70,6 @@ export class CartsService {
const
neworderId
=
docRef
.
id
;
this
.
afs
.
collection
(
'carts'
).
doc
(
neworderId
).
update
({
cartId
:
docRef
.
id
}).
then
(()
=>
{
console
.
log
(
'Booking Successfully'
);
this
.
router
.
navigateByUrl
(
'cart'
);
document
.
body
.
scrollTop
=
document
.
documentElement
.
scrollTop
=
0
;
});
}).
catch
((
error
)
=>
{
...
...
@@ -92,7 +92,8 @@ export class CartsService {
const
cartItem
:
CartItem
=
{
cartId
:
item
.
cartId
,
color
:
item
.
color
,
shopperId
:
item
.
shopper
,
shopperId
:
item
.
shopperId
,
shopper
:
item
.
shopper
,
prodId
:
item
.
prodId
,
price
:
item
.
price
,
prodName
:
item
.
prodName
,
...
...
src/config/myorder.service.ts
View file @
cee55fe8
...
...
@@ -3,6 +3,8 @@ import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection
import
{
Myorder
}
from
'./services/myorder'
;
import
{
ServiceService
}
from
'./../config/service.service'
;
import
*
as
firebase
from
'firebase'
;
import
{
take
}
from
'rxjs/operators'
;
import
{
Observable
,
of
}
from
'rxjs'
;
@
Injectable
({
providedIn
:
'root'
...
...
@@ -23,6 +25,7 @@ export class MyordersService {
this
.
custId
=
data
.
uid
;
if
(
this
.
custId
!==
undefined
)
{
this
.
orderList
(
this
.
custId
);
// this.orderState();
}
}
else
{
this
.
custId
=
'WwHnLICVY2dvZGUHuKqasiTB91a2'
;
...
...
@@ -30,13 +33,17 @@ export class MyordersService {
});
}
public
async
orderList
(
custId
)
{
/*public async org
orderList(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
.
valueChanges
().
subscribe
((
value
)
=>
{
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;
...
...
@@ -57,6 +64,8 @@ export class MyordersService {
riderName: 'John',
orderId: item.orderId,
size: item.size,
orderCode: item.orderCode,
product: this.service.key2Array(item.product),
time: '60'
};
this.orders.push(order);
...
...
@@ -65,9 +74,139 @@ export class MyordersService {
} else {
alert('No Orders Found');
}
this.orderState();
});
}*/
public
async
orderList
(
custId
)
{
console
.
log
(
'called'
);
console
.
log
(
custId
);
const
This
=
this
;
this
.
orders
=
[];
const
orderRef
:
AngularFirestoreCollection
<
any
>
=
this
.
afs
.
collection
(
'orders'
,
ref
=>
ref
.
where
(
'custId'
,
'=='
,
custId
)
.
orderBy
(
'bookDate'
,
'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
);
const
orderId
=
item
.
orderId
;
const
order
:
Myorder
=
{
amount
:
item
.
amount
,
status
:
item
.
status
,
orderStatus
:
item
.
orderStatus
,
bookDate
:
item
.
bookDate
,
deliveryLocation
:
item
.
deliveryLocation
,
pickupLocation
:
item
.
pickupLocation
,
riderName
:
'John'
,
orderId
:
item
.
orderId
,
orderCode
:
item
.
orderCode
,
product
:
this
.
service
.
key2Array
(
item
.
product
),
time
:
'60'
};
console
.
log
(
order
);
if
(
items
.
type
===
'added'
)
{
this
.
orders
.
push
(
order
);
}
else
{
console
.
log
(
orderId
);
const
index
=
this
.
orders
.
findIndex
(
obj
=>
obj
.
orderId
===
orderId
);
if
(
index
>=
0
)
{
this
.
orders
[
index
]
=
order
;
}
}
});
console
.
log
(
this
.
orders
);
}
});
}
/* public orderState(): Observable<Myorder[]> {
console.log('called');
const custId = 'WwHnLICVY2dvZGUHuKqasiTB91a2';
this.orders = [];
firebase.firestore().collection('orders').where('custId', '==', custId)
.onSnapshot((snapData) => {
snapData.docChanges().forEach((change) => {
console.log(change.type);
if (change.type === 'modified') {
const item = change.doc.data();
console.log(item);
const orderId = item.orderId;
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,
time: '60'
};
const count = this.orders.length;
for (let index = 0; index < count; index++) {
if (this.orders[index].orderId === orderId) {
console.log(index);
this.orders[index] = order;
console.log(this.orders);
break;
}
}
} else if (change.type === 'added') {
const item = change.doc.data();
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,
time: '60'
};
this.orders.push(order);
} else {
//
}
});
});
/*
.onSnapshot(function(snapshot) {
snapshot.docChanges().forEach(function(change) {
if (change.type === "added") {
console.log("New city: ", change.doc.data());
}
if (change.type === "modified") {
console.log("Modified city: ", change.doc.data());
}
if (change.type === "removed") {
console.log("Removed city: ", change.doc.data());
}
});
});
return of(this.orders);
}
*/
public
async
trackOrder
(
order
)
{
this
.
selItem
=
order
;
}
...
...
src/config/order.service.ts
View file @
cee55fe8
import
{
Injectable
}
from
'@angular/core'
;
import
{
AngularFirestore
,
AngularFirestoreDocument
,
AngularFirestoreCollection
}
from
'@angular/fire/firestore'
;
import
{
Router
,
ActivatedRoute
}
from
'@angular/router'
;
import
{
Order
}
from
'./services/order'
;
import
{
Order
,
CartProd
}
from
'./services/order'
;
import
{
Products
}
from
'./services/product'
;
import
{
ServiceService
}
from
'./service.service'
;
import
*
as
firebase
from
'firebase'
;
...
...
@@ -19,6 +19,7 @@ export class OrdersService {
custId
:
string
;
shopperId
:
any
;
checkout
=
new
BehaviorSubject
(
false
);
users
:
any
;
constructor
(
public
afs
:
AngularFirestore
,
...
...
@@ -28,9 +29,10 @@ export class OrdersService {
this
.
size
=
'small'
;
this
.
color
=
'Blue'
;
this
.
custId
=
''
;
const
users
=
this
.
service
.
get
(
'user'
).
then
((
data
)
=>
{
this
.
service
.
get
(
'user'
).
then
((
data
)
=>
{
if
(
data
)
{
data
=
JSON
.
parse
(
data
);
this
.
users
=
data
;
this
.
custId
=
data
.
uid
;
console
.
log
(
this
.
custId
);
}
else
{
...
...
@@ -39,8 +41,10 @@ export class OrdersService {
});
}
public
async
checkOut
(
cart
:
CartItem
[])
{
/*public async org
checkOut(cart: CartItem[]) {
console.log(cart);
console.log(this.users);
return;
let currProcess = 0;
const cartCount = cart.length;
cart.forEach((product) => {
...
...
@@ -97,6 +101,101 @@ export class OrdersService {
});
});
}*/
public
async
checkOut
(
cart
:
CartItem
[])
{
console
.
log
(
cart
);
console
.
log
(
this
.
users
);
const
cartGroup
=
[];
// const distinctShops = [...new Set(cart.map(obj => obj.shopperId))];
const
distinctShops
=
[];
const
map
=
new
Map
();
for
(
const
item
of
cart
)
{
if
(
!
map
.
has
(
item
.
shopperId
)){
map
.
set
(
item
.
shopperId
,
true
);
// set any value to Map
distinctShops
.
push
(
item
.
shopperId
);
}
}
cart
.
forEach
((
items
)
=>
{
cartGroup
[
items
.
shopperId
]
=
cartGroup
[
items
.
shopperId
]
===
undefined
?
[]
:
cartGroup
[
items
.
shopperId
];
cartGroup
[
items
.
shopperId
].
push
(
items
);
});
const
cartCount
=
distinctShops
.
length
;
console
.
log
(
cartGroup
);
console
.
log
(
cartCount
);
const
promise
=
new
Promise
(
resolve
=>
{
distinctShops
.
forEach
((
item
)
=>
{
console
.
log
(
item
);
this
.
afs
.
collection
(
'orders'
).
add
({
bookDate
:
firebase
.
firestore
.
FieldValue
.
serverTimestamp
()
}).
then
((
docRef
)
=>
{
const
neworderId
=
docRef
.
id
;
const
delivery
=
new
firebase
.
firestore
.
GeoPoint
(
10.0237
,
76.3116
);
const
pickup
=
new
firebase
.
firestore
.
GeoPoint
(
10.7231
,
76.1234
);
const
products
=
{};
const
cartItem
=
cartGroup
[
item
];
let
prodPrice
=
0
;
cartItem
.
forEach
((
prodItem
)
=>
{
prodPrice
+=
prodItem
.
price
;
products
[
prodItem
.
prodId
]
=
{
prodId
:
prodItem
.
prodId
,
prodName
:
prodItem
.
prodName
,
image
:
prodItem
.
image
,
price
:
prodItem
.
price
,
color
:
prodItem
.
color
,
size
:
prodItem
.
size
,
qty
:
prodItem
.
qty
,
discount
:
''
};
this
.
afs
.
doc
(
`carts/
${
prodItem
.
cartId
}
`
).
delete
();
});
console
.
log
(
cartItem
);
console
.
log
(
products
);
const
product
=
cartItem
[
0
];
const
orderItem
:
Order
=
{
amount
:
'A$ '
+
prodPrice
,
customer
:
firebase
.
firestore
().
doc
(
'/customer/'
+
this
.
custId
),
shopper
:
product
.
shopper
,
deliveryAddress
:
'Techware Software solution, Carnival Infopark, Kochi'
,
deliveryCharge
:
'A$ 0.5'
,
deliveryLocation
:
delivery
,
bookDate
:
firebase
.
firestore
.
FieldValue
.
serverTimestamp
(),
orderCode
:
this
.
orderCode
(),
orderId
:
neworderId
,
orderStatus
:
1
,
pickupAddress
:
'GetMi, Canberra, AUS'
,
pickupLocation
:
pickup
,
promoId
:
null
,
rider
:
firebase
.
firestore
().
doc
(
'/riders/qbTKza18mWVzYG9NLIbmjMbrYjG2'
),
status
:
1
,
custId
:
this
.
custId
,
riderId
:
'qbTKza18mWVzYG9NLIbmjMbrYjG2'
,
shopperId
:
product
.
shopperId
,
custName
:
'Jone Doe'
,
riderName
:
'John'
,
shopperState
:
0
,
shopperName
:
'Witchery'
,
product
:
products
};
console
.
log
(
orderItem
);
this
.
afs
.
collection
(
'orders'
).
doc
(
neworderId
).
set
(
orderItem
).
then
(()
=>
{
console
.
log
(
'Booking Successfully'
);
// this.router.navigateByUrl('cart');
resolve
(
'Cart to Order Successfully'
);
document
.
body
.
scrollTop
=
document
.
documentElement
.
scrollTop
=
0
;
});
}).
catch
((
error
)
=>
{
console
.
error
(
'Error adding document: '
,
error
);
});
});
});
promise
.
then
(
value
=>
console
.
log
(
value
));
}
public
async
changeOrder
(
orderId
,
status
)
{
...
...
src/config/products.service.ts
View file @
cee55fe8
...
...
@@ -32,6 +32,7 @@ export class ProductsService {
prodStatus
:
item
.
prodStatus
,
brand
:
item
.
brand
.
brandName
,
category
:
item
.
category
.
catName
,
shopperId
:
item
.
shopperId
,
color
:
item
.
color
,
discount
:
item
.
discount
,
featured
:
item
.
featured
,
...
...
src/config/services/cart.ts
View file @
cee55fe8
...
...
@@ -4,6 +4,7 @@ export interface Cart {
product
:
any
;
prodName
:
any
;
prodId
:
string
;
shopperId
:
string
;
image
:
string
;
size
:
string
;
color
:
string
;
...
...
@@ -15,6 +16,7 @@ export interface CartItem {
cartId
:
string
;
prodId
:
string
;
shopperId
:
any
;
shopper
:
any
;
prodName
:
any
;
image
:
string
;
size
:
string
;
...
...
src/config/services/myorder.ts
View file @
cee55fe8
export
interface
Myorder
{
amount
:
string
;
prodName
:
any
;
image
:
string
;
size
:
string
;
color
:
string
;
qty
:
number
;
bookDate
:
any
;
pickupLocation
:
any
;
deliveryLocation
:
any
;
...
...
@@ -13,5 +8,7 @@ export interface Myorder {
riderName
:
string
;
orderId
:
string
;
time
:
string
;
product
:
any
;
orderCode
:
string
;
}
src/config/services/order.ts
View file @
cee55fe8
import
{
AngularFirestoreDocument
}
from
'@angular/fire/firestore'
;
import
{
GeoJsonOptions
}
from
'@agm/core/services/google-maps-types'
;
export
interface
Order
{
/*export interface Order {
amount: string;
customer: any;
deliveryAddress: string;
...
...
@@ -17,7 +14,6 @@ export interface Order {
bookDate: any;
prodId: string;
custId: string;
product
:
any
;
prodName: any;
image: string;
size: string;
...
...
@@ -30,5 +26,45 @@ export interface Order {
shopperId: string;
status: number;
tax: string;
}*/
export
interface
CartProd
{
prodName
:
any
;
prodId
:
string
;
image
:
string
;
size
:
string
;
color
:
string
;
qty
:
number
;
discount
:
string
;
price
:
string
;
productDoc
:
any
;
}
export
interface
Order
{
amount
:
string
;
customer
:
any
;
custName
:
string
;
deliveryAddress
:
string
;
deliveryCharge
:
string
;
deliveryLocation
:
object
;
orderCode
:
string
;
orderId
:
string
;
orderStatus
:
number
;
pickupAddress
:
string
;
pickupLocation
:
object
;
bookDate
:
any
;
custId
:
string
;
promoId
:
any
;
rider
:
any
;
riderName
:
string
;
riderId
:
string
;
shopper
:
any
;
shopperName
:
string
;
shopperId
:
string
;
status
:
number
;
shopperState
:
number
;
product
:
any
;
}
src/config/services/product.ts
View file @
cee55fe8
...
...
@@ -11,6 +11,7 @@ export interface Products {
prodId
:
string
;
prodName
:
string
;
prodStatus
:
boolean
;
shopperId
:
string
;
qty
:
number
;
shopper
:
string
;
size
:
Size
[];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment