1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-18 02:41:15 +02:00

Add UserNamePipe (#429)

This commit is contained in:
Oscar Hinton 2021-07-16 15:24:14 +02:00 committed by GitHub
parent 9f0ca7e4d2
commit 48d2ffc8d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,22 @@
import {
Pipe,
PipeTransform,
} from '@angular/core';
interface User {
name?: string;
email: string;
}
@Pipe({
name: 'userName',
})
export class UserNamePipe implements PipeTransform {
transform(user?: User): string {
if (user == null) {
return null;
}
return user.name == null || user.name.trim() === '' ? user.email : user.name;
}
}