Skip to content

Commit

Permalink
I added a conditional to the page
Browse files Browse the repository at this point in the history
  • Loading branch information
aline-borges committed Oct 28, 2020
1 parent 4744f72 commit 63f9c07
Show file tree
Hide file tree
Showing 5 changed files with 233 additions and 118 deletions.
86 changes: 60 additions & 26 deletions src/app/components/form/form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class FormComponent implements OnInit {
pagination: this.pagination,
quantity: this.quantity,
place: this.place,
location: this.location
location: this.location,
}
});
}
Expand Down Expand Up @@ -105,42 +105,76 @@ export class FormComponent implements OnInit {

if(this.typeSearchOption === 'offer') {
this.packages = data.results;
this.pagination = data.pagination;
this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
this.currentPage = page;

if(this.packages !== null) {

if(data?.pagination !== undefined){
this.pagination = data.pagination;
}

this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;

if(data?.filters?.priceInterval?.min !== undefined) {
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
}

this.currentPage = page;
}

this.titleService.setTitle(`Hotéis e Pacotes Para ${this.location} | Agência de Viagens - Hurb`);
this.goToPackages(this.packages, this.currentPage, this.pagination, this.quantity, this.place, this.location)
}
else if(this.typeSearchOption === 'ticket') {
this.tickets = data.results;
this.pagination = data.pagination;
this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
this.currentPage = page;

if(this.tickets !== null) {

if(data?.pagination !== undefined){
this.pagination = data.pagination;
}

this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;

if(data?.filters?.priceInterval?.min !== undefined) {
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
}

this.currentPage = page;
}

this.titleService.setTitle(`Hotéis e Pacotes Para ${this.location} | Agência de Viagens - Hurb`);
this.goToTickets(this.tickets, this.currentPage, this.pagination, this.quantity, this.place, this.location)
this.goToTickets(this.tickets, this.currentPage, this.pagination, this.quantity, this.place,
this.location)
}
else {
this.hotels = data.results;
this.pagination = data.pagination;
this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
this.currentPage = page;

if(this.hotels !== null) {

if(data?.pagination !== undefined){
this.pagination = data.pagination;
}

this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;

if(data?.filters?.priceInterval?.min !== undefined) {
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
}

this.currentPage = page;
}

this.titleService.setTitle(`Hotéis e Pacotes Para ${this.location} | Agência de Viagens - Hurb`);
this.goToHotels(this.hotels, this.currentPage, this.pagination, this.quantity, this.place, this.location)
Expand Down
90 changes: 57 additions & 33 deletions src/app/components/hotel/hotel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,54 +107,78 @@ export class HotelComponent implements OnInit {
getAPI(page = 1, typeSearchOption, order: string, limited: string, quantityStars: Array<any>) {
this.hurbService.getData(this.location, this.typeSearchOption, page, order, limited, quantityStars).subscribe((data) => {

if(data.length < 1) {
console.log('Sem resultados')
}

if(this.typeSearchOption === 'offer') {
this.packages = data.results;
this.pagination = data.pagination;
this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
this.currentPage = page;

if(this.packages !== null) {
if(data?.pagination !== undefined){
this.pagination = data.pagination;
}

this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;

if(data?.filters?.priceInterval?.min !== undefined) {
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
}

this.currentPage = page;
}

this.titleService.setTitle(`Hotéis e Pacotes Para ${this.location} | Agência de Viagens - Hurb`);
this.goToPackages(this.packages, this.currentPage, this.pagination, this.quantity, this.place,
this.location)
this.goToPackages(this.packages, this.currentPage, this.pagination, this.quantity, this.place, this.location)
}
else if(this.typeSearchOption === 'ticket') {
this.tickets = data.results;
this.pagination = data.pagination;
this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
this.currentPage = page;

if(this.tickets !== null) {
if(data?.pagination !== undefined){
this.pagination = data.pagination;
}

this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;

if(data?.filters?.priceInterval?.min !== undefined) {
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
}

this.currentPage = page;
}


this.titleService.setTitle(`Hotéis e Pacotes Para ${this.location} | Agência de Viagens - Hurb`);
this.goToTickets(this.tickets, this.currentPage, this.pagination, this.quantity, this.place,
this.goToTickets(this.tickets, this.currentPage, this.pagination, this.quantity, this.place,
this.location)
}
else {
this.hotels = data.results;
this.pagination = data.pagination;
this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
this.currentPage = page;

if(this.hotels !== null) {
if(data?.pagination !== undefined){
this.pagination = data.pagination;
}
this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;

if(data?.filters?.priceInterval?.min !== undefined) {
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
}

this.currentPage = page;
}

this.titleService.setTitle(`Hotéis e Pacotes Para ${this.location} | Agência de Viagens - Hurb`);
this.goToHotels(this.hotels, this.currentPage, this.pagination, this.quantity, this.place,
this.location)
this.goToHotels(this.hotels, this.currentPage, this.pagination, this.quantity, this.place, this.location)
}
})

Expand Down
86 changes: 56 additions & 30 deletions src/app/components/package/package.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,51 +108,77 @@ export class PackageComponent implements OnInit {

getAPI(page = 1, typeSearchOption, order: string, limited: string, quantityStars: Array<any>) {
this.hurbService.getData(this.location, this.typeSearchOption, page, order, limited, quantityStars).subscribe((data) => {

if(this.typeSearchOption === 'offer') {
this.packages = data.results;
this.pagination = data.pagination;
this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
this.currentPage = page;

if(this.packages !== null) {
if(data?.pagination !== undefined){
this.pagination = data.pagination;
}
this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;

if(data?.filters?.priceInterval?.min !== undefined) {
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
}

this.currentPage = page;
}

this.titleService.setTitle(`Hotéis e Pacotes Para ${this.location} | Agência de Viagens - Hurb`);
this.goToPackages(this.packages, this.currentPage, this.pagination, this.quantity, this.place,
this.location)
this.goToPackages(this.packages, this.currentPage, this.pagination, this.quantity, this.place, this.location)
}
else if(this.typeSearchOption === 'ticket') {
this.tickets = data.results;
this.pagination = data.pagination;
this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
this.currentPage = page;

if(this.tickets !== null) {
if(data?.pagination !== undefined){
this.pagination = data.pagination;
}
this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;

if(data?.filters?.priceInterval?.min !== undefined) {
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
}

this.currentPage = page;
}


this.titleService.setTitle(`Hotéis e Pacotes Para ${this.location} | Agência de Viagens - Hurb`);
this.goToTickets(this.tickets, this.currentPage, this.pagination, this.quantity, this.place,
this.goToTickets(this.tickets, this.currentPage, this.pagination, this.quantity, this.place,
this.location)
}
else {
this.hotels = data.results;
this.pagination = data.pagination;
this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
this.currentPage = page;

if(this.hotels !== null) {
if(data?.pagination !== undefined){
this.pagination = data.pagination;
}
this.quantity = data.meta.count;
this.place = data.meta.query;
this.price = data.results.price;
this.stars = data.results.stars;

if(data?.filters?.priceInterval?.min !== undefined) {
this.minPrice = ((data.filters.priceInterval.min)/100).toFixed(0);
this.maxPrice = ((data.filters.priceInterval.max)/100).toFixed(0);
}

this.currentPage = page;
}

this.titleService.setTitle(`Hotéis e Pacotes Para ${this.location} | Agência de Viagens - Hurb`);
this.goToHotels(this.hotels, this.currentPage, this.pagination, this.quantity, this.place,
this.location)
this.goToHotels(this.hotels, this.currentPage, this.pagination, this.quantity, this.place, this.location)
}
})

Expand Down
Loading

0 comments on commit 63f9c07

Please sign in to comment.