diff --git a/libs/common/src/vault/models/view/identity.view.ts b/libs/common/src/vault/models/view/identity.view.ts index dca54fa04e8..fadfafb8777 100644 --- a/libs/common/src/vault/models/view/identity.view.ts +++ b/libs/common/src/vault/models/view/identity.view.ts @@ -94,16 +94,16 @@ export class IdentityView extends ItemView implements SdkIdentityView { this.lastName != null ) { let name = ""; - if (this.title != null) { + if (!Utils.isNullOrWhitespace(this.title)) { name += this.title + " "; } - if (this.firstName != null) { + if (!Utils.isNullOrWhitespace(this.firstName)) { name += this.firstName + " "; } - if (this.middleName != null) { + if (!Utils.isNullOrWhitespace(this.middleName)) { name += this.middleName + " "; } - if (this.lastName != null) { + if (!Utils.isNullOrWhitespace(this.lastName)) { name += this.lastName; } return name.trim(); @@ -130,14 +130,20 @@ export class IdentityView extends ItemView implements SdkIdentityView { } get fullAddressPart2(): string | undefined { - if (this.city == null && this.state == null && this.postalCode == null) { + const hasCity = !Utils.isNullOrWhitespace(this.city); + const hasState = !Utils.isNullOrWhitespace(this.state); + const hasPostalCode = !Utils.isNullOrWhitespace(this.postalCode); + + if (!hasCity && !hasState && !hasPostalCode) { return undefined; } - const city = this.city || "-"; + + const city = hasCity ? this.city : "-"; const state = this.state; - const postalCode = this.postalCode || "-"; + const postalCode = hasPostalCode ? this.postalCode : "-"; + let addressPart2 = city; - if (!Utils.isNullOrWhitespace(state)) { + if (hasState) { addressPart2 += ", " + state; } addressPart2 += ", " + postalCode;