Skip to content

Commit

Permalink
UI - hosts submit, tweaks (#362)
Browse files Browse the repository at this point in the history
Signed-off-by: Kial Jinnah <kialj876@gmail.com>
  • Loading branch information
kialj876 authored Dec 9, 2024
1 parent 920ffc2 commit 26a73bd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
25 changes: 14 additions & 11 deletions strr-host-pm-web/app/interfaces/host-api.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,55 @@
export interface ApiHostParty extends ApiParty {
preferredName: string
preferredName?: string
}

export interface ApiHostPartyWithAddress extends ApiHostParty {
mailingAddress: ApiAddress
}

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
}

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
Expand Down
24 changes: 12 additions & 12 deletions strr-host-pm-web/app/utils/host-formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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 } : {})
}
}
}
Expand All @@ -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 || '',
Expand All @@ -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,
Expand All @@ -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 } : {})
}
}

Expand Down

0 comments on commit 26a73bd

Please sign in to comment.