-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(inheritance-report): make sure total assets get into answers (#15903
) * fix(inheritance-report): mappers fix * fix set total assets --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
0815408
commit 5c1b2c2
Showing
4 changed files
with
27 additions
and
38 deletions.
There are no files selected for viewing
37 changes: 0 additions & 37 deletions
37
...emplates/inheritance-report/src/fields/CalculationsOfTotal/CalculateTotalAssets/index.tsx
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
...tion/templates/inheritance-report/src/fields/CalculationsOfTotal/SetTotalAssets/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters