-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(page): add merchant and category segment to browse page
- Loading branch information
bravemaster619
committed
May 2, 2020
1 parent
ab97acb
commit f80398d
Showing
13 changed files
with
159 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +0,0 @@ | ||
.wrapper-merchant-img { | ||
margin-top: -20px; | ||
margin-left: -20px; | ||
margin-right: -20px; | ||
margin-bottom: 10px; | ||
} | ||
.label-merchant-name h3 { | ||
font-weight: 600; | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/app/pages/browse/category-list/category-list.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<ion-row class="ion-padding"> | ||
<ion-list> | ||
<ion-item *ngFor="let category of categories"> | ||
<h4 localValue [data]="category" key="name"></h4> | ||
</ion-item> | ||
</ion-list> | ||
</ion-row> |
Empty file.
28 changes: 28 additions & 0 deletions
28
src/app/pages/browse/category-list/category-list.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Component, OnInit } from "@angular/core"; | ||
import { ApiService } from "src/app/services/api/api.service"; | ||
import { CategoryInterface } from "src/app/models/category.model"; | ||
|
||
@Component({ | ||
selector: "category-list", | ||
templateUrl: "./category-list.component.html", | ||
styleUrls: ["./category-list.component.scss"] | ||
}) | ||
export class CategoryListComponent implements OnInit { | ||
loading: boolean; | ||
categories: Array<CategoryInterface>; | ||
constructor(private api: ApiService) { | ||
this.loading = true; | ||
this.categories = []; | ||
} | ||
|
||
ngOnInit() { | ||
this.api.get("Categories/G").then((observable) => { | ||
observable.subscribe((resp: { code: string; data: Array<any> }) => { | ||
if (resp.code === "success") { | ||
this.categories = resp.data; | ||
} | ||
this.loading = false; | ||
}); | ||
}); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/app/pages/browse/merchant-list/merchant-list.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<ion-row class="ion-padding"> | ||
<ion-col size="6" *ngFor="let merchant of merchants"> | ||
<ion-card | ||
class="card-merchant ion-no-margin" | ||
[routerLink]="['/tabs/browse/merchants', merchant._id]" | ||
> | ||
<ion-card-content class="card-content-merchant ion-margin-bottom"> | ||
<div class="wrapper-merchant-img"> | ||
<app-ion-image | ||
[src]="getPictureUrl(merchant)" | ||
[alt]="merchant.name" | ||
style="height: 180px; object-fit: cover;" | ||
></app-ion-image> | ||
</div> | ||
<ion-label class="label-merchant-name"> | ||
<h3 localValue [data]="merchant" key="name"></h3> | ||
</ion-label> | ||
</ion-card-content> | ||
</ion-card> | ||
</ion-col> | ||
</ion-row> |
9 changes: 9 additions & 0 deletions
9
src/app/pages/browse/merchant-list/merchant-list.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.wrapper-merchant-img { | ||
margin-top: -20px; | ||
margin-left: -20px; | ||
margin-right: -20px; | ||
margin-bottom: 10px; | ||
} | ||
.label-merchant-name h3 { | ||
font-weight: 600; | ||
} |
62 changes: 62 additions & 0 deletions
62
src/app/pages/browse/merchant-list/merchant-list.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Component, OnInit } from "@angular/core"; | ||
import { ApiService } from "src/app/services/api/api.service"; | ||
import { LocationInterface } from "src/app/models/location.model"; | ||
import { MerchantInterface } from "src/app/models/merchant.model"; | ||
import { getPictureUrl } from "src/app/models/merchant.model"; | ||
import { LocationService } from "src/app/services/location/location.service"; | ||
|
||
@Component({ | ||
selector: "merchant-list", | ||
templateUrl: "./merchant-list.component.html", | ||
styleUrls: ["./merchant-list.component.scss"] | ||
}) | ||
export class MerchantListComponent implements OnInit { | ||
merchants: Array<MerchantInterface>; | ||
location: LocationInterface; | ||
constructor(private locSvc: LocationService, private api: ApiService) {} | ||
|
||
ngOnInit() { | ||
this.locSvc.getLocation().subscribe((location: LocationInterface) => { | ||
if (location) { | ||
this.api | ||
.get("/Areas/G/my", { lat: location.lat, lng: location.lng }) | ||
.then((observable) => { | ||
observable.subscribe((resp: { code: string; data: any }) => { | ||
if (resp.code === "success") { | ||
this.loadMerchants(resp.data._id); | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
loadMerchants(areaId: string) { | ||
this.api.get("Merchants/G", { status: "A" }).then((observable) => { | ||
observable.subscribe((resp: any) => { | ||
const data = resp.data; | ||
const merchants: Array<any> = data; | ||
if (areaId) { | ||
this.api | ||
.geth("MerchantSchedules/availableMerchants", { areaId }) | ||
.then((merchantIds: Array<string>) => { | ||
if (merchantIds && merchantIds.length > 0) { | ||
const availables = merchants.filter((merchant) => | ||
merchantIds.includes(merchant._id) | ||
); | ||
this.merchants = availables; | ||
} else { | ||
this.merchants = []; | ||
} | ||
}); | ||
} else { | ||
this.merchants = merchants; | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
getPictureUrl(merchant: MerchantInterface) { | ||
return getPictureUrl(merchant); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters