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

psp-8154 show warning when adding lease take type. #3959

Merged
merged 1 commit into from
Apr 17, 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
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const TakeSubForm: React.FunctionComponent<ITakeSubFormProps> = ({
}
}, [currentTake.completionDt, currentTake.takeStatusTypeCode, nameSpace, setFieldValue]);

const getModalWarning = (onOk: () => void) => {
const getModalWarning = (onOk: () => void, isLeasePayable = false) => {
return (e: React.ChangeEvent<any>) => {
if (e.target.value === 'false') {
setModalContent({
Expand All @@ -79,6 +79,20 @@ const TakeSubForm: React.FunctionComponent<ITakeSubFormProps> = ({
},
});
setDisplayModal(true);
} else if (isLeasePayable) {
setModalContent({
variant: 'info',
title: 'Follow-up required',
message:
'You have created a Lease (Payable) Take. You also need to create a Lease/License File.',
okButtonText: 'Close',
cancelButtonText: null,
handleOk: () => {
handleChange(e);
setDisplayModal(false);
},
});
setDisplayModal(true);
} else {
handleChange(e);
}
Expand Down Expand Up @@ -375,7 +389,7 @@ const TakeSubForm: React.FunctionComponent<ITakeSubFormProps> = ({
setFieldValue(withNameSpace(nameSpace, 'isLeasePayable'), 'false');
setFieldValue(withNameSpace(nameSpace, 'leasePayableArea'), 0);
setFieldValue(withNameSpace(nameSpace, 'leasePayableEndDt'), '');
})}
}, true)}
/>
</SectionField>
{isLeasePayable === 'true' && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ describe('TakesUpdateForm component', () => {
expect(confirmModal).toBeVisible();
});

it('displays a warning if lease payable radio button toggled from no to yes', async () => {
const { getByTestId } = setup({});
const noButton = getByTestId('radio-takes.0.isleasepayable-no');
const yesButton = getByTestId('radio-takes.0.isleasepayable-yes');

await act(async () => userEvent.click(noButton));

const confirmModal = await screen.findByText('Confirm');
await act(async () => userEvent.click(confirmModal));

await act(async () => userEvent.click(yesButton));

const closeModal = await screen.findByText('Close');
expect(closeModal).toBeVisible();
});

it('resets is new isNewHighwayDedication values if radio button toggled from yes to no', async () => {
const { getByTestId, queryByDisplayValue } = setup({});
const noButton = getByTestId('radio-takes.0.isnewhighwaydedication-no');
Expand Down Expand Up @@ -200,7 +216,6 @@ describe('TakesUpdateForm component', () => {
const noButton = getByTestId('radio-takes.0.isleasepayable-no');
await act(async () => userEvent.click(noButton));

console.log(prettyDOM(undefined, 999999));
expect(queryByDisplayValue('20231.28')).not.toBeNull();
const confirmButton = await screen.findByText('Confirm');
await act(async () => userEvent.click(confirmButton));
Expand Down
Loading