-
Notifications
You must be signed in to change notification settings - Fork 0
/
made-travels.page.ts
73 lines (60 loc) · 1.82 KB
/
made-travels.page.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { Component, OnInit } from '@angular/core';
import { NavController, ModalController } from '@ionic/angular';
import { PopoverComponentPage } from '../popover-component/popover-component.page';
import { Storage } from '@ionic/storage';
@Component({
selector: 'app-made-travels',
templateUrl: './made-travels.page.html',
styleUrls: ['./made-travels.page.scss'],
})
export class MadeTravelsPage implements OnInit {
slideOpts = {
initialSlide: 1,
speed: 400
};
noItem: boolean;
mta = [];
constructor(public navCtrl: NavController,
public modalCtrl: ModalController,
private storage: Storage) {
this.load();
}
ngOnInit() {
}
load() {
this.storage.get('travels').then( (array: any[]) => {
if (!(array === null || array.length === 0)) {
this.sortTravelsByDate(array);
} else {
this.noItem = true;
}
});
}
sortTravelsByDate(array: any[]) {
array.forEach((elm: any, index) => {
const elmDate: string = elm.Date;
const date = new Date();
if ((date.getFullYear() > Number(elmDate.split('-')[0]))) {
this.mta.push(elm);
} else if (date.getFullYear() === Number(elmDate.split('-')[0])) {
if ((date.getMonth() > Number(elmDate.split('-')[1]) - 1)) {
this.mta.push(elm);
} else if ((date.getMonth() === Number(elmDate.split('-')[1]) - 1)) {
if (date.getDate() > Number(elmDate.split('-')[2])) {
this.mta.push(elm);
}
}
}
});
}
goBack() {
this.navCtrl.back();
}
async presentPartners() {
const modal = await this.modalCtrl.create({
component: PopoverComponentPage,
// componentProps: { value: 123 }
});
return await modal.present();
}
}