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

feat(rental-agreement): Summary updates #17066

Merged
merged 23 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
02a13cb
Add logo. Add summary section and init custom component to form.
hebaulf Oct 31, 2024
0f5dcc2
Merge branch 'rental-agreement-application' of github.com:island-is/i…
hebaulf Oct 31, 2024
039c35c
Update summary custom component
hebaulf Nov 1, 2024
f4652bf
Merge branch 'rental-agreement-application' of github.com:island-is/i…
hebaulf Nov 1, 2024
f56f855
Summary updates
hebaulf Nov 5, 2024
27af684
Merge branch 'rental-agreement-application' of github.com:island-is/i…
hebaulf Nov 6, 2024
510c48c
Merge from rental-agreement-application and fix conflicts
hebaulf Nov 12, 2024
4b12a0d
Add all viable data from fields to summary
hebaulf Nov 17, 2024
5004619
Merge from rental-agreement-application and fix conflicts
hebaulf Nov 17, 2024
7dd138a
Merge branch 'rental-agreement-application' of github.com:island-is/i…
hebaulf Nov 17, 2024
b5870ce
Fix conflict from merge
hebaulf Nov 17, 2024
e51b38d
Fix lint error for relative import
hebaulf Nov 17, 2024
7d552e5
Update summary styling
hebaulf Nov 18, 2024
15f764b
Merge branch 'rental-agreement-application' of github.com:island-is/i…
hebaulf Nov 18, 2024
aa4df87
Update summary component structure
hebaulf Nov 19, 2024
e0597cd
Merge branch 'rental-agreement-application' of github.com:island-is/i…
hebaulf Nov 19, 2024
3583d95
Update summary. Add Security deposit amount. Add phone fileds with co…
hebaulf Nov 20, 2024
328035f
Fix lint errors
hebaulf Nov 20, 2024
d8164f1
Add special groups to summary.
hebaulf Nov 25, 2024
e30c184
Merge from rental-agreement-application and fix conflicts
hebaulf Nov 25, 2024
b9d3f92
Merge branch 'rental-agreement-application' of github.com:island-is/i…
hebaulf Nov 26, 2024
d3b7c60
Update summary
hebaulf Nov 26, 2024
6b02072
Updates from PR comments
hebaulf Nov 28, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export const ApplicantsRepresentativesSummary = ({ answers }: Props) => {
<SummarySection
sectionLabel={formatMessage(summary.landlordsRepresentativeLabel)}
>
{landlordRepresentatives.map((landlordRep) => {
{landlordRepresentatives.map((landlordRep, index) => {
return (
<Fragment key={crypto.randomUUID()}>
<Fragment key={`${index}_${landlordRep.nationalId}`}>
<GridRow className={gridRow}>
<GridColumn span={['12/12']}>
<KeyValue
Expand Down Expand Up @@ -81,9 +81,9 @@ export const ApplicantsRepresentativesSummary = ({ answers }: Props) => {
<SummarySection
sectionLabel={formatMessage(summary.tenantsRepresentativeLabel)}
>
{tenantRepresentatives.map((tenantRep) => {
{tenantRepresentatives.map((tenantRep, index) => {
return (
<Fragment key={crypto.randomUUID()}>
<Fragment key={`${index}_${tenantRep.nationalId}`}>
<GridRow className={gridRow}>
<GridColumn span={['12/12']}>
<KeyValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export const ApplicantsSummary = ({ answers }: Props) => {
: formatMessage(summary.landlordsHeader)
}
>
{landlordListWithoutRepresentatives.map((landlord) => {
{landlordListWithoutRepresentatives.map((landlord, index) => {
return (
<Fragment key={crypto.randomUUID()}>
<Fragment key={`${index}_${landlord.nationalId}`}>
<GridRow className={gridRow}>
<GridColumn span={['12/12']}>
<KeyValue
Expand Down Expand Up @@ -77,9 +77,9 @@ export const ApplicantsSummary = ({ answers }: Props) => {
: formatMessage(summary.tenantsHeader)
}
>
{tenantListWithoutRepresentatives.map((tenant) => {
{tenantListWithoutRepresentatives.map((tenant, index) => {
return (
<Fragment key={crypto.randomUUID()}>
<Fragment key={`${index}_${tenant.nationalId}`}>
<GridRow className={gridRow}>
<GridColumn span={['12/12']}>
<KeyValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export const LandlordInfoSummary = ({ answers }: Props) => {
/>
</GridColumn>
<GridColumn span={['12/12', '6/12']}>
<KeyValue label={summary.emailLabel} value={landlord.email} />
<KeyValue
label={summary.emailLabel}
value={landlord.email || '-'}
/>
</GridColumn>
<GridColumn span={['12/12', '6/12']}>
<KeyValue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { GridColumn, GridRow } from '@island.is/island-ui/core'
import { useLocale } from '@island.is/localization'
import { RentalAgreement } from '../../lib/dataSchema'
import { RentalHousingConditionInspector } from '../../lib/constants'
import {
getPropertyCategoryClassOptions,
getPropertyCategoryTypeOptions,
RentalHousingCategoryClass,
RentalHousingConditionInspector,
} from '../../lib/constants'
import {
getPropertyTypeOptions,
getPropertyClassOptions,
getPropertyClassGroupOptions,
} from '../../lib/utils'
import { summary } from '../../lib/messages'
import { KeyValue } from './KeyValue'
Expand All @@ -20,13 +24,19 @@ export const PropertyInfoSummary = ({ answers }: Props) => {
const { formatMessage } = useLocale()

const propertyType = (answer: string) => {
const options = getPropertyCategoryTypeOptions()
const options = getPropertyTypeOptions()
const matchingOption = options.find((option) => option.value === answer)
return matchingOption ? matchingOption.label : '-'
}

const propertyClass = (answer: string) => {
const options = getPropertyClassOptions()
const matchingOption = options.find((option) => option.value === answer)
return matchingOption ? matchingOption.label : '-'
}

const propertyCategory = (answer: string) => {
const options = getPropertyCategoryClassOptions()
const propertyClassGroup = (answer: string) => {
const options = getPropertyClassGroupOptions()
const matchingOption = options.find((option) => option.value === answer)
return matchingOption ? matchingOption.label : '-'
}
Expand Down Expand Up @@ -60,16 +70,29 @@ export const PropertyInfoSummary = ({ answers }: Props) => {
<Divider />

<GridRow className={gridRow}>
<GridColumn span={['12/12']}>
<GridColumn span={['12/12', '4/12']}>
<KeyValue
label={summary.propertyCategoryLabel}
label={summary.propertyClassLabel}
value={
propertyCategory(
answers.registerProperty.categoryClass as string,
) || '-'
propertyClass(answers.registerProperty.categoryClass as string) ||
'-'
}
/>
</GridColumn>
{answers.registerProperty.categoryClass ===
RentalHousingCategoryClass.SPECIAL_GROUPS &&
answers.registerProperty.categoryClassGroup && (
<GridColumn span={['12/12', '4/12']}>
<KeyValue
label={summary.propertyClassGroupLabel}
value={
propertyClassGroup(
answers.registerProperty.categoryClassGroup as string,
) || '-'
}
/>
</GridColumn>
)}
</GridRow>

<Divider />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,23 +179,6 @@ export const RentalInfoSummary = ({ answers }: Props) => {
</>
)}
</GridRow>

{/* <Divider />

<GridRow className={gridRow}>
<GridColumn span={['12/12', '4/12']}>
<KeyValue
label={summary.paymentTransactionTypeLabel}
value={'---'}
/>
</GridColumn>
<GridColumn span={['12/12', '4/12']}>
<KeyValue
label={summary.paymentTransactionAccountLabel}
value={'---'}
/>
</GridColumn>
</GridRow> */}
</SummarySection>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export const TenantInfoSummary = ({ answers }: Props) => {
/>
</GridColumn>
<GridColumn span={['12/12', '6/12']}>
<KeyValue label={summary.emailLabel} value={tenant.email} />
<KeyValue
label={summary.emailLabel}
value={tenant.email || '-'}
/>
</GridColumn>
<GridColumn span={['12/12', '6/12']}>
<KeyValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import {
} from '../../lib/constants'
import {
getApplicationAnswers,
getPropertyCategoryClassGroupOptions,
getPropertyCategoryClassOptions,
getPropertyCategoryTypeOptions,
getPropertyTypeOptions,
getPropertyClassOptions,
getPropertyClassGroupOptions,
} from '../../lib/utils'
import { registerProperty } from '../../lib/messages'

Expand Down Expand Up @@ -127,13 +127,13 @@ export const RentalHousingPropertyInfo: SubSection = buildSubSection({
)
return [
[
propertyId ? `F${propertyId}` : '-',
propertyId ? `F${propertyId}` : '--',
address
? `${address}${municipality ? `, ${municipality}` : ''}`
: '-',
unitId ? unitId : '-',
size ? `${size} m²` : '-',
numOfRooms ? numOfRooms : '-',
: '--',
unitId ? unitId : '--',
size ? `${size} m²` : '--',
numOfRooms ? numOfRooms : '--',
],
]
},
Expand All @@ -154,15 +154,15 @@ export const RentalHousingPropertyInfo: SubSection = buildSubSection({
id: 'registerProperty.categoryType',
title: messagesCategory.typeTitle,
description: messagesCategory.typeDescription,
options: getPropertyCategoryTypeOptions(),
options: getPropertyTypeOptions(),
defaultValue: RentalHousingCategoryTypes.ENTIRE_HOME,
required: true,
}),
buildRadioField({
id: 'registerProperty.categoryClass',
title: messagesCategory.classTitle,
description: messagesCategory.classDescription,
options: getPropertyCategoryClassOptions(),
options: getPropertyClassOptions(),
defaultValue: RentalHousingCategoryClass.GENERAL_MARKET,
required: true,
width: 'half',
Expand All @@ -173,14 +173,12 @@ export const RentalHousingPropertyInfo: SubSection = buildSubSection({
title: messagesCategory.classGroupLabel,
placeholder: messagesCategory.classGroupPlaceholder,
condition: (answers) => {
const { propertyCategoryClassOptions } =
getApplicationAnswers(answers)
const { propertyClassOptions } = getApplicationAnswers(answers)
return (
propertyCategoryClassOptions ===
RentalHousingCategoryClass.SPECIAL_GROUPS
propertyClassOptions === RentalHousingCategoryClass.SPECIAL_GROUPS
)
},
options: getPropertyCategoryClassGroupOptions(),
options: getPropertyClassGroupOptions(),
}),
],
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const rentalPeriodIsDefinite = (answers: FormValue) => {
return rentalPeriodDefinite && rentalPeriodDefinite.includes(TRUE)
}

console.log('RentalPeriodIsDefinite: ', rentalPeriodIsDefinite)

export const RentalPeriodDetails = buildSubSection({
id: 'rentalPeriod',
title: rentalPeriod.subSectionName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,15 @@ export const summary = defineMessages({
defaultMessage: 'Fermetrar',
description: 'Property size label',
},
propertyCategoryLabel: {
id: 'ra.application:summary.propertyCategoryLabel',
propertyClassLabel: {
id: 'ra.application:summary.propertyClassLabel',
defaultMessage: 'Flokkun húsnæðis',
description: 'Property category label',
description: 'Property classification label',
},
propertyClassGroupLabel: {
id: 'ra.application:summary.propertyClassGroupLabel',
defaultMessage: 'Hópur',
description: 'Property classification group label',
},
propertyDescriptionLabel: {
id: 'ra.application:summary.propertyDescriptionLabel',
Expand Down
28 changes: 13 additions & 15 deletions libs/application/templates/rental-agreement/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ export const formatCurrency = (answer: string) =>
answer.replace(/\B(?=(\d{3})+(?!\d))/g, '.') + ' ISK'

export const getApplicationAnswers = (answers: Application['answers']) => {
const propertyCategoryTypeOptions =
getValueViaPath<RentalHousingCategoryTypes>(
answers,
'registerProperty.categoryType',
)
const propertyTypeOptions = getValueViaPath<RentalHousingCategoryTypes>(
answers,
'registerProperty.categoryType',
)

const propertyCategoryClassOptions =
getValueViaPath<RentalHousingCategoryClass>(
answers,
'registerProperty.categoryClass',
)
const propertyClassOptions = getValueViaPath<RentalHousingCategoryClass>(
answers,
'registerProperty.categoryClass',
)

const inspectorOptions = getValueViaPath<RentalHousingConditionInspector>(
answers,
Expand Down Expand Up @@ -77,8 +75,8 @@ export const getApplicationAnswers = (answers: Application['answers']) => {
)

return {
propertyCategoryTypeOptions,
propertyCategoryClassOptions,
propertyTypeOptions,
propertyClassOptions,
inspectorOptions,
rentalAmountIndexTypesOptions,
rentalAmountPaymentDateOptions,
Expand All @@ -88,7 +86,7 @@ export const getApplicationAnswers = (answers: Application['answers']) => {
}
}

export const getPropertyCategoryTypeOptions = () => [
export const getPropertyTypeOptions = () => [
{
value: RentalHousingCategoryTypes.ENTIRE_HOME,
label: m.registerProperty.category.typeSelectLabelEntireHome,
Expand All @@ -103,7 +101,7 @@ export const getPropertyCategoryTypeOptions = () => [
},
]

export const getPropertyCategoryClassOptions = () => [
export const getPropertyClassOptions = () => [
{
value: RentalHousingCategoryClass.GENERAL_MARKET,
label: m.registerProperty.category.classSelectLabelGeneralMarket,
Expand All @@ -114,7 +112,7 @@ export const getPropertyCategoryClassOptions = () => [
},
]

export const getPropertyCategoryClassGroupOptions = () => [
export const getPropertyClassGroupOptions = () => [
{
value: RentalHousingCategoryClassGroup.STUDENT_HOUSING,
label: m.registerProperty.category.classGroupSelectLabelStudentHousing,
Expand Down