common-ui/src/lib/tenants/tenant.pipe.ts
2023-05-18 12:19:53 +03:00

20 lines
552 B
TypeScript

import { inject, Pipe, PipeTransform } from '@angular/core';
import { TenantsService } from './services';
@Pipe({
name: 'tenant',
pure: true,
standalone: true,
})
export class TenantPipe implements PipeTransform {
readonly #tenantsService = inject(TenantsService);
transform(value: string | string[]): string | undefined {
if (!value) {
return undefined;
}
const _value = Array.isArray(value) ? value.join('/') : value;
return '/' + this.#tenantsService.currentTenant + _value;
}
}