import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';

/**************************  
 Created by Ajith A Pradeep
 Created on 02/04/2022
 **************************/

@Injectable({
  providedIn: 'root'
})
export class MenuService {

  menuData: any;

  favouriteMenuData: any;

  public isShowSidebar: boolean;

  constructor(
    private httpClient: HttpClient
  ) { }

  async getJsonData(name: string): Promise<any> {
    if (!name || name.trim() == "") return {};
    return await this.httpClient.get(`assets/i18n/json/${name}.json`).toPromise();
  }

  async getMenuData(apiUrl, filter?): Promise<any> {
    if (!filter)
      filter = ''
    return await this.httpClient.get(`${environment.apiUrl}/${apiUrl}${filter}`).toPromise();
  }
}
