-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(transfer-of-machine-ownership): seller cant be buyer (#16130)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1ea2e20
commit 23d2dbd
Showing
6 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
...templates/aosh/transfer-of-machine-ownership/src/fields/StopBuyerIfSameAsSeller/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,18 @@ | ||
import { FieldBaseProps } from '@island.is/application/types' | ||
import { FC } from 'react' | ||
import { doSellerAndBuyerHaveSameNationalId } from '../../utils' | ||
|
||
export const StopBuyerIfSameAsSeller: FC< | ||
React.PropsWithChildren<FieldBaseProps> | ||
> = (props) => { | ||
const { application, setBeforeSubmitCallback } = props | ||
|
||
setBeforeSubmitCallback?.(async () => { | ||
if (doSellerAndBuyerHaveSameNationalId(application.answers)) { | ||
return [false, ''] | ||
} | ||
return [true, null] | ||
}) | ||
|
||
return <></> | ||
} |
1 change: 1 addition & 0 deletions
1
libs/application/templates/aosh/transfer-of-machine-ownership/src/fields/index.ts
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { ApplicationStatus } from './ApplicationStatus' | ||
export { MachinesField } from './MachinesField' | ||
export { Review } from './Review' | ||
export { StopBuyerIfSameAsSeller } from './StopBuyerIfSameAsSeller' |
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
17 changes: 17 additions & 0 deletions
17
...plates/aosh/transfer-of-machine-ownership/src/utils/doSellerAndBuyerHaveSameNationalId.ts
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,17 @@ | ||
import { getValueViaPath } from '@island.is/application/core' | ||
import { FormValue } from '@island.is/application/types' | ||
|
||
export const doSellerAndBuyerHaveSameNationalId = (answers: FormValue) => { | ||
const buyerNationalId = getValueViaPath( | ||
answers, | ||
'buyer.nationalId', | ||
'', | ||
) as string | ||
const sellerNationalId = getValueViaPath( | ||
answers, | ||
'seller.nationalId', | ||
'', | ||
) as string | ||
|
||
return buyerNationalId === sellerNationalId | ||
} |
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