import { Pipe, PipeTransform } from '@angular/core';
import {ADMIN_INFO_OBJECT} from '../../services/local-storage.namespace';
import {BrowserStorageService} from "../../utils/localStorage.service";
@Pipe({
  name: 'button',
  standalone: true
})
export class ButtonPipe implements PipeTransform {

  constructor(
      private store: BrowserStorageService, // 数据请求
  ) { }

  transform(button: string): boolean {
    const buttonArray = new Set<string>();
    buttonArray.add(button);
    return this.store.get(ADMIN_INFO_OBJECT)['buttonList'].filter(i => buttonArray.has(i.permissionCode)).length > 0;
  }
}
