File: /var/www/vhost/disk-apps/pwa.sports-crowd.com/src/app/services/section.service.ts
import { Injectable } from '@angular/core';
import { ApiService } from './api.service';
import { UtilsService } from './utils.service';
@Injectable({
providedIn: 'root'
})
export class SectionService {
sections = [];
sectionName: string = '';
constructor(public api: ApiService, private utilsService: UtilsService) { }
//-------------------------------------------api_functions------------------------------------------------------------
async getSections() {
return new Promise(async (resolve, reject) => {
let seq = this.api.get("section/get", await this.utilsService.getAccessToken());
(await seq).subscribe({
next: (resp: any) => {
this.sections = resp.data;
resolve(resp);
},
error: (error) => {
reject(error);
}
})
});
}
//-----------------------------------------END_api_functions----------------------------------------------------------
//--------------------------------------functional_functions----------------------------------------------------------
validateSection(sectionName: string) {
let data = this.getSection(sectionName);
return data ?? false;
}
getSection(name: String) {
return this.sections.filter((x: any) => x.name === name)[0];
}
//------------------------------------END_functional_functions--------------------------------------------------------
}