20 lines
552 B
TypeScript
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;
|
|
}
|
|
}
|