Skip to content

Commit

Permalink
yaaaaaaaas itest it , wait sec it't work bi**c hhh
Browse files Browse the repository at this point in the history
  • Loading branch information
Tayeb-Ali authored and Tayeb-Ali committed Apr 1, 2020
1 parent c9caa2a commit 191da80
Show file tree
Hide file tree
Showing 13 changed files with 401 additions and 132 deletions.
5 changes: 5 additions & 0 deletions src/app/Pages/Dashboard/home/home.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,9 @@
</ion-row>

</ion-grid>

<div *ngIf="response?.user.status == 2">
<p class="ion-text-center">Please complete the profile and upload the <strong>CV</strong></p>
<ion-button (click)="openCvUpdate()" color="danger" expand="block">upload cv</ion-button>
</div>
</ion-content>
79 changes: 65 additions & 14 deletions src/app/Pages/Dashboard/home/home.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Storage} from '@ionic/storage';
import {InAppBrowser} from '@ionic-native/in-app-browser/ngx';
import {ActionSheetController} from '@ionic/angular';
import {Router} from '@angular/router';
import {AuthService} from '../../../Service/auth.service';

@Component({
selector: 'app-home',
Expand All @@ -11,14 +12,16 @@ import {Router} from '@angular/router';
})
export class HomePage implements OnInit {
userInfo: any;
response: any;

constructor(
private storage: Storage,
public router: Router,
private iab: InAppBrowser,
private userServ: AuthService,
public actionSheetController: ActionSheetController
) {
// this.userInfo = JSON.parse(localStorage.getItem('userInfo'));
this.getDashboardData();
}

ngOnInit(): void {
Expand All @@ -29,16 +32,18 @@ export class HomePage implements OnInit {
.catch(err => {
console.log(err);
});
// this.updateFcmToken();
}

openBrow() {
const browser = this.iab.create('https://medical.detatech.xyz/profile/' + this.userInfo.id);
// browser.executeScript('...');
// browser.insertCSS(...);
// browser.on('loadstop').subscribe(event => {
// browser.insertCSS({code: 'body{color: red;'});
// });

ionViewDidEnter() {
if (localStorage.getItem('fcm_registration_in')) {
this.updateFcmToken();
}
}

openCvUpdate() {
const browser = this.iab.create('https://medical.detatech.xyz/profile/' + this.userInfo.id);
browser.on('loadstop').subscribe(event => {
console.log('sus: ', event);
},
Expand All @@ -48,6 +53,37 @@ export class HomePage implements OnInit {
}


getDashboardData() {
this.userServ.checkUserService()
.subscribe(response => {
this.response = response;
if (this.response.status === true) {
console.log('check: ', this.response);
} else {
alert('filed');
}
}, error => {
console.log('server: ', error);
});
}

updateFcmToken() {
const data = {
fcm_registration_in: localStorage.getItem('fcm_registration_in')
};
this.userServ.updateFcmToken(data)
.subscribe(response => {
console.log('res: ', response);
// if (this.response.status === true) {
// } else {
// alert('filed');
// }
}, error => {
console.log('server: ', error);
});
}


async ambulanceActionSheet() {
const actionSheet = await this.actionSheetController.create({
header: 'Ambulances Services',
Expand Down Expand Up @@ -140,19 +176,34 @@ export class HomePage implements OnInit {
this.router.navigate(['/find-pharmacy']);
}
}, {
text: 'Request history',
text: 'Last Request',
icon: 'list-circle-outline',
handler: () => {
this.router.navigate(['/pharmacy']);
}
}, {
text: 'Cancel',
icon: 'close',
role: 'cancel',
text: 'Your Request history',
icon: 'list-circle-outline',
handler: () => {
console.log('Cancel clicked');
// this.router.navigate(['/pharmacy']);
alert('soon');
}
}]
},
{
text: 'Your Accept history',
icon: 'list-circle-outline',
handler: () => {
// this.router.navigate(['/pharmacy']);
alert('soon');
}
}, {
text: 'Cancel',
icon: 'close',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
}]
});
await actionSheet.present();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {EmergencyService} from '../../../Service/emergency.service';
export class EmergencyDetailsPage implements OnInit {

result: any;
params: any;
requestId: number;
emergency: any;
emergencyData: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<ion-label position="floating">You are looking for:</ion-label>
<ion-input [(ngModel)]="medicine.name"></ion-input>
</ion-item>
<ion-item>
<ion-label position="floating">Your address:</ion-label>
<ion-input [(ngModel)]="medicine.address"></ion-input>
</ion-item>
<!-- <ion-item>-->
<!-- <ion-label position="floating">Your address:</ion-label>-->
<!-- <ion-input [(ngModel)]="medicine.address"></ion-input>-->
<!-- </ion-item>-->
<ion-item>
<ion-label position="floating">Dose:</ion-label>
<ion-input [(ngModel)]="medicine.dose"></ion-input>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,90 @@
<ion-header>
<ion-toolbar>
<ion-title>pharmacy-details</ion-title>
</ion-toolbar>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button color="light">
</ion-back-button>
</ion-buttons>
<ion-title class="ion-text-center">details</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>

<ion-content *ngIf="!pharmacy">
<div class="ion-padding ion-color-success">
<ion-skeleton-text animated class="ion-color-success" style="width: 60%"></ion-skeleton-text>
<ion-skeleton-text animated class="ion-color-success"></ion-skeleton-text>
<ion-skeleton-text animated class="ion-color-success" style="width: 88%"></ion-skeleton-text>
<ion-skeleton-text animated style="width: 70%"></ion-skeleton-text>
<ion-skeleton-text animated style="width: 60%"></ion-skeleton-text>
</div>
<div class="ion-padding ion-color-success">
<ion-skeleton-text animated class="ion-color-success" style="width: 80%"></ion-skeleton-text>
<ion-skeleton-text animated class="ion-color-success"></ion-skeleton-text>
<ion-skeleton-text animated class="ion-color-success" style="width: 50%"></ion-skeleton-text>
<ion-skeleton-text animated style="width: 40%"></ion-skeleton-text>
<ion-skeleton-text animated style="width: 100%"></ion-skeleton-text>
</div>
</ion-content>

<ion-content *ngIf="pharmacy" class="ion-no-padding">
<ion-card>
<ion-item>
<ion-avatar slot="start">
<img src="{{pharmacy?.user?.image}}"/>
</ion-avatar>
<ion-label>
<h3>Create by: DR. {{pharmacy?.user?.name}}</h3>
</ion-label>
</ion-item>

<ion-card-content>
<ion-label>
<p>#: {{pharmacy?.id}}</p>
<h2>Name: {{pharmacy?.name}}</h2>
<h3>Type: {{pharmacy?.type}}</h3>
<h3>dose: {{pharmacy?.dose}} m/g</h3>
<p>Location: {{pharmacy?.address}}</p>
<p>Type: {{pharmacy?.type}}</p>
<p>Created at: {{pharmacy?.created_at|date: 'yyyy-MMMM-dd '}}</p>
</ion-label>
</ion-card-content>
<ion-row>
<ion-col class="ion-no-padding" size="6">
<ion-button color="primary" fill="outline" size="small">
Order #:{{pharmacy?.id}}
</ion-button>
</ion-col>
<ion-col class="ion-no-padding" size="6">
<ion-button fill="outline" size="small">
Available: {{pharmacy?.available}}
</ion-button>
</ion-col>
</ion-row>
</ion-card>
<ion-card>
<div *ngIf="!formCard" class="ion-text-center ion-align-items-center">
<ion-button (click)="pharmacyConfirm()" disabled="{{formCard}}" expand="block">
<ion-icon name="thumbs-up"></ion-icon>
<div>Accept</div>
</ion-button>
</div>
<!-- <div *ngIf="pharmacy.status == 2">-->
<ion-button (click)="requestCancel()" color="danger" disabled="" expand="block">
<div>Cancel</div>
</ion-button>
<!-- </div>-->

</ion-card>

<ion-list *ngIf="formCard">
<ion-item>
<ion-label>Price:</ion-label>
<ion-input [(ngModel)]="formData.price" type="number"></ion-input>
</ion-item>
<ion-item>
<ion-label>Location:</ion-label>
<ion-input [(ngModel)]="formData.address" type="text"></ion-input>
</ion-item>
<ion-button (click)="emergencyConfirm(formData)" shape="round" type="full">Send</ion-button>
</ion-list>
</ion-content>
117 changes: 115 additions & 2 deletions src/app/Pages/pharmacy-pages/pharmacy-details/pharmacy-details.page.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,128 @@
import { Component, OnInit } from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {AlertController, LoadingController, ToastController} from '@ionic/angular';
import {EmergencyService} from '../../../Service/emergency.service';

@Component({
selector: 'app-pharmacy-details',
templateUrl: './pharmacy-details.page.html',
styleUrls: ['./pharmacy-details.page.scss'],
})
export class PharmacyDetailsPage implements OnInit {
requestId: number;
result: any;
pharmacy: any;
acceptRes: any;
pharmacyData: any;
formCard = false;
formData = {price: null, address: ''};

constructor() { }
constructor(
public tostMessage: ToastController,
private activeRoute: ActivatedRoute,
private presentAlertConfirm: AlertController,
private loadingController: LoadingController,
public router: Router,
private pharmacyServe: EmergencyService
) {
this.activeRoute.params.subscribe(
params => {
this.requestId = params.id;
}
);
}

ngOnInit() {
this.requestData();
}


async requestData() {
const loading = await this.loadingController.create({
message: 'Loading...'
});
await loading.present();
await this.pharmacyServe.getPharmcyRequestbyID(this.requestId)
.subscribe(result => {
this.result = result;
this.pharmacy = this.result.data;
loading.dismiss();
}, err => {
console.log(err);
loading.dismiss();
});
}

acceptRequest(data) {
this.pharmacyServe.updatePharmcyRequest(this.requestId, data)
.subscribe(response => {
console.log(this.acceptRes = response);
if (this.acceptRes.success) {
this.succseMessage(this.acceptRes.message)
this.router.navigateByUrl('/');
} else {
this.faildMessage();
}

},
error => {
this.acceptRes = error;
alert('try later');
console.log(this.acceptRes);
}
);
}

async emergencyConfirm(data) {
const alert = await this.presentAlertConfirm.create({
header: 'Confirm!',
message: 'Message <strong>Do you want to follow up and agree to the request?</strong>!!!',
buttons: [
{
text: 'Cancel',
role: 'cancel',
cssClass: 'secondary',
handler: (blah) => {
}
}, {
text: 'Okay',
handler: () => {
console.log('Confirm Okay');
this.acceptRequest(data);
}
}
]
});

await alert.present();
}

pharmacyConfirm() {
this.formCard = true;
}

requestCancel() {
this.formCard = false;

}

async succseMessage(messge) {
const toast = await this.tostMessage.create({
message: messge,
duration: 3000,
color: 'primary',
position: 'middle'
});
toast.present();
}

async faildMessage() {
const toast = await this.tostMessage.create({
message: 'try again with veiled data',
duration: 3000,
color: 'danger',
position: 'middle'
});
toast.present();
}
}

0 comments on commit 191da80

Please sign in to comment.