Dear All,
I am looking for a way to get list of customers whom I have sent invitation through the Alert trigger. Following is the code for invitation alert:
inviteCustomer(): void {
let prompt = this.alertCtrl.create({
title: 'Invite a customer',
message: "Customer will be invited to join app.",
inputs: [
{
name: 'name',
placeholder: "Your customer's name",
type: 'text'
},
{
name: 'mobile',
placeholder: "Your customer's mobile number",
type: 'mobile'
},
{
name: 'email',
placeholder: "Your customer's email",
type: 'email'
},
],
buttons: [
{
text: 'Cancel',
handler: data => {
console.log('Cancel clicked');
}
},
{
text: 'Save',
handler: data => {
this.customerProvider.inviteCustomer(data.name, data.mobile, data.email,this.retailerProfile.retailerId,
this.retailerProfile.retailerName).then( () => {
let loading = this.loadingCtrl.create();
loading.dismiss().then(()=> {
this.customerProvider.getPendingInvitationList();
});
}
)}
}
]
} );
prompt.present();
}
This saves the data correctly but the problem starts when I want to retrieve and conduct search for that invitation:
getInvitation(): void {
const loading = this.loadingCtrl.create();
if (!this.getInvitationForm.valid){
console.log(this.getInvitationForm.value);
} else {
this.authProvider.getRetailerInvite(this.getInvitationForm.value.email)
.subscribe(inviteSnapshot => {
if (inviteSnapshot){
this.invitation = inviteSnapshot[0];
} else {
console.log("No email found...");
}
loading.dismiss().then( () => {
this.nextSlide();
});
});
}
loading.present();
}
The authProvider TS:
getRetailerInvite(email: string): FirebaseListObservable<any> {
return this.afDatabase.list('/invite', {
query: {
orderByChild: 'email',
equalTo: email,
limitToFirst: 1
}
})
}
Everytime the request returns ‘not found’ … I wanted to understand wht I am missing? The database reference or logic?