diff --git a/strr-host-pm-web/app/interfaces/host-api.ts b/strr-host-pm-web/app/interfaces/host-api.ts index f30c27ec..15359a91 100644 --- a/strr-host-pm-web/app/interfaces/host-api.ts +++ b/strr-host-pm-web/app/interfaces/host-api.ts @@ -1,5 +1,5 @@ export interface ApiHostParty extends ApiParty { - preferredName: string + preferredName?: string } export interface ApiHostPartyWithAddress extends ApiHostParty { @@ -7,22 +7,25 @@ export interface ApiHostPartyWithAddress extends ApiHostParty { } export interface ApiHostContactDetails extends ApiPhone { - preferredName: string + preferredName?: string faxNumber: string emailAddress: string } -export interface ApiHostContactBusiness extends ApiHostBusinessDetails { - contactType: OwnerType, +export interface ApiHostBaseBusiness { name: { firstName: string - middleName: string + middleName?: string lastName: string } details: ApiHostContactDetails mailingAddress: ApiAddress } +export interface ApiHostContactBusiness extends ApiHostBaseBusiness { + contactType: OwnerType +} + export interface ApiHostContactPerson extends ApiHostContactBusiness { dateOfBirth?: string socialInsuranceNumber?: string @@ -30,23 +33,23 @@ export interface ApiHostContactPerson extends ApiHostContactBusiness { export interface ApiPropertyManagerBusiness { legalName: string - businessNumber: string + businessNumber?: string mailingAddress: ApiAddress primaryContact: ApiHostParty secondaryContact?: ApiHostParty } -export interface ApiPropertyManager extends ApiHostBusinessDetails { +export interface ApiPropertyManager { initiatedByPropertyManager: boolean - type: OwnerType + propertyManagerType: OwnerType business?: ApiPropertyManagerBusiness // required if OwnerType.BUSINESS contact?: ApiHostPartyWithAddress // required if OwnerType.INDIVIDUAL } export interface ApiUnitDetails { - parcelIdentifier: string - businessLicense: string - businessLicenseExpiryDate: string + parcelIdentifier?: string + businessLicense?: string + businessLicenseExpiryDate?: string propertyType: PropertyType | undefined ownershipType: OwnershipType | undefined rentalUnitSpaceType: RentalUnitType | undefined diff --git a/strr-host-pm-web/app/utils/host-formatting.ts b/strr-host-pm-web/app/utils/host-formatting.ts index 877d2def..d7b6c3db 100644 --- a/strr-host-pm-web/app/utils/host-formatting.ts +++ b/strr-host-pm-web/app/utils/host-formatting.ts @@ -3,19 +3,19 @@ export function formatOwnerHostAPI (owner: HostOwner): ApiHostContactPerson { contactType: owner.ownerType, name: { firstName: owner.firstName || '', - middleName: owner.middleName || '', + ...(owner.middleName ? { middleName: owner.middleName } : {}), lastName: owner.lastName || '' }, details: { - preferredName: owner.preferredName || '', + ...(owner.preferredName ? { preferredName: owner.preferredName } : {}), emailAddress: owner.emailAddress || '', phoneCountryCode: owner.phone.countryCode || '', phoneNumber: owner.phone.number || '', extension: owner.phone.extension || '', faxNumber: owner.faxNumber || '' }, - dateOfBirth: owner.dateOfBirth || '', - socialInsuranceNumber: owner.taxNumber || '', + ...(owner.dateOfBirth ? { dateOfBirth: owner.dateOfBirth } : {}), + ...(owner.taxNumber ? { socialInsuranceNumber: owner.taxNumber } : {}), mailingAddress: formatAddress(owner.mailingAddress) } } @@ -47,23 +47,23 @@ export function formatOwnerHostUI ( export function formatOwnerPropertyManagerAPI (owner: HostOwner): ApiPropertyManager { return { initiatedByPropertyManager: owner.isCompParty, - type: owner.ownerType, + propertyManagerType: owner.ownerType, ...(owner.ownerType === OwnerType.INDIVIDUAL ? { contact: { ...formatParty(owner), - preferredName: owner.preferredName || '', + ...(owner.preferredName ? { preferredName: owner.preferredName } : {}), mailingAddress: formatAddress(owner.mailingAddress) } } : { business: { legalName: owner.businessLegalName, - businessNumber: owner.businessNumber, + ...(owner.businessNumber ? { businessNumber: owner.businessNumber } : {}), mailingAddress: formatAddress(owner.mailingAddress), primaryContact: { ...formatParty(owner), - preferredName: owner.preferredName || '' + ...(owner.preferredName ? { preferredName: owner.preferredName } : {}) } } } @@ -73,7 +73,7 @@ export function formatOwnerPropertyManagerAPI (owner: HostOwner): ApiPropertyMan export function formatOwnerPropertyManagerUI (owner: ApiPropertyManager): HostOwner { return { - ownerType: owner.type, + ownerType: owner.propertyManagerType, firstName: owner.contact?.firstName || owner.business?.primaryContact?.firstName || '', middleName: owner.contact?.middleName || owner.business?.primaryContact?.middleName || '', lastName: owner.contact?.lastName || owner.business?.primaryContact?.lastName || '', @@ -93,7 +93,6 @@ export function formatOwnerPropertyManagerUI (owner: ApiPropertyManager): HostOw export function formatHostUnitDetailsAPI (unitDetails: UiUnitDetails, blInfo: UiBlInfo): ApiUnitDetails { return { - parcelIdentifier: unitDetails.parcelIdentifier || '', propertyType: unitDetails.propertyType, ownershipType: unitDetails.ownershipType, numberOfRoomsForRent: unitDetails.numberOfRoomsForRent, @@ -102,8 +101,9 @@ export function formatHostUnitDetailsAPI (unitDetails: UiUnitDetails, blInfo: Ui ? ResidenceType.SAME_UNIT : ResidenceType.ANOTHER_UNIT, rentalUnitSpaceType: unitDetails.typeOfSpace, - businessLicense: blInfo.businessLicense || '', - businessLicenseExpiryDate: blInfo.businessLicenseExpiryDate || '' + ...(unitDetails.parcelIdentifier ? { parcelIdentifier: unitDetails.parcelIdentifier } : {}), + ...(blInfo.businessLicense ? { businessLicense: blInfo.businessLicense } : {}), + ...(blInfo.businessLicenseExpiryDate ? { businessLicenseExpiryDate: blInfo.businessLicenseExpiryDate } : {}) } }