Skip to content

Commit

Permalink
fix(inheritance-report): make sure total assets get into answers (#15903
Browse files Browse the repository at this point in the history
)

* fix(inheritance-report): mappers fix

* fix set total assets

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
albinagu and kodiakhq[bot] authored Sep 5, 2024
1 parent 0815408 commit 5c1b2c2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 38 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { FieldBaseProps } from '@island.is/application/types'
import { FC, useEffect } from 'react'
import { useFormContext } from 'react-hook-form'
import { calculateTotalAssets } from '../../../lib/utils/calculateTotalAssets'

export const SetTotalAssets: FC<React.PropsWithChildren<FieldBaseProps>> = ({
application,
}) => {
const { answers } = application
const { setValue } = useFormContext()

const total = calculateTotalAssets(answers)

useEffect(() => {
setValue('assets.assetsTotal', total)
}, [total, setValue])

return null
}

export default SetTotalAssets
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export { OverviewHeirs } from './Overview/OverviewHeirs'
export { FuneralCost } from './FuneralCost'
export { OtherAssetsRepeater } from './OtherAssetsRepeater'
export { DeceasedShareField } from './DeceasedShareField'
export { CalculateTotalAssets } from './CalculationsOfTotal/CalculateTotalAssets'
export { SetTotalAssets } from './CalculationsOfTotal/SetTotalAssets'
export { CalculateTotalDebts } from './CalculationsOfTotal/CalculateTotalDebts'
export { CalculateTotalBusiness } from './CalculationsOfTotal/CalculateTotalBusiness'
export { CalculateFuneralCost } from './CalculationsOfTotal/CalculateFuneralCost'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,11 @@ export const assets = buildSection({
doesNotRequireAnswer: true,
component: 'OverviewAssets',
}),
buildCustomField({
title: '',
id: 'assets.assetsTotal',
component: 'SetTotalAssets',
}),
buildDescriptionField({
id: 'space',
title: '',
Expand Down

0 comments on commit 5c1b2c2

Please sign in to comment.