Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI - hosts submit, tweaks #362

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading