diff --git a/src/app/malls/malls.page.ts b/src/app/malls/malls.page.ts
index 71f570f..9885318 100644
--- a/src/app/malls/malls.page.ts
+++ b/src/app/malls/malls.page.ts
@@ -25,12 +25,14 @@ export class MallsPage implements OnInit {
) { }
ngOnInit() {
- if (localStorage.allMalls) {
- this.allMalls = JSON.parse(localStorage.allMalls);
- this.tempMalls = JSON.parse(localStorage.allMalls);
- } else {
- this.getMallsByLocation()
- }
+ this.getMallsByLocation();
+ }
+
+ toggleMallBookmark(index: number) {
+ this.tempMalls[index].mall.is_bookmarked = !this.tempMalls[index].mall.is_bookmarked;
+ this.allMalls[index].mall.is_bookmarked = !this.allMalls[index].mall.is_bookmarked;
+ localStorage.allMalls = JSON.stringify(this.allMalls);
+ this.mallService.updateMallData(this.tempMalls[index]);
}
doRefresh(e: any) {
diff --git a/src/app/services/mall.service.ts b/src/app/services/mall.service.ts
index 122dedd..e3f7114 100644
--- a/src/app/services/mall.service.ts
+++ b/src/app/services/mall.service.ts
@@ -35,4 +35,17 @@ export class MallService {
return await this.http.get(URL + '/api/maioraservice/mall/getallmalls/', httpOptions).toPromise();
}
+
+
+ async updateMallData(mallData: any) {
+ const httpOptions = {
+ headers: new HttpHeaders({
+ 'Access-Control-Allow-Origin': '*',
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Bearer ' + localStorage.access_Token
+ })
+ };
+
+ return await this.http.put(URL + '/api/maioraservice/mall/v1/update/', mallData.mall , httpOptions).toPromise();
+ }
}