-
Notifications
You must be signed in to change notification settings - Fork 24
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-8317: Lease and Licence Edit/View Fee Denomination forms #4187
Merged
Merged
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
258395c
Merge branch 'dev' of https://github.com/stairaku/PSP into dev
stairaku 42163d5
Merge branch 'dev' of https://github.com/stairaku/PSP into dev
stairaku 21b5b4d
Merge branch 'bcgov:dev' into dev
stairaku 5820cb4
First commit
stairaku 45d04da
#
stairaku 86581a0
Merge branch 'bcgov:dev' into PSP-8317
stairaku c7f2295
Fee Determination Edit and view forms completed
stairaku 006aa3a
fix conflicts
stairaku b6132c3
Unit test completed
stairaku c758325
Merge branch 'bcgov:dev' into PSP-8317
stairaku 789258d
Adding unit test files
stairaku 8c27833
Merge branch 'PSP-8317' of https://github.com/stairaku/PSP into PSP-8317
stairaku d52522d
fixing error on backend model
stairaku 8ca67ba
Merge branch 'bcgov:dev' into PSP-8317
stairaku 75a91d6
Fixing observations
stairaku 4c7f370
Merge branch 'PSP-8317' of https://github.com/stairaku/PSP into PSP-8317
stairaku File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
61 changes: 61 additions & 0 deletions
61
source/frontend/src/features/leases/add/FeeDeterminationSubForm.test.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,61 @@ | ||
import { act, getByText, render, RenderOptions } from '@testing-library/react'; | ||
import { getDefaultFormLease, LeaseFormModel } from '../models'; | ||
import { AddLeaseYupSchema } from './AddLeaseYupSchema'; | ||
import { createMemoryHistory } from 'history'; | ||
import FeeDeterminationSubForm, { IFeeDeterminationSubFormProps } from './FeeDeterminationSubForm'; | ||
import { Formik, FormikProps } from 'formik'; | ||
import React from 'react'; | ||
import { noop } from 'lodash'; | ||
import { fillInput, renderAsync } from '@/utils/test-utils'; | ||
import { lookupCodesSlice } from '@/store/slices/lookupCodes'; | ||
import { mockLookups } from '@/mocks/lookups.mock'; | ||
import { Simulate } from 'react-dom/test-utils'; | ||
|
||
const history = createMemoryHistory(); | ||
const storeState = { | ||
[lookupCodesSlice.name]: { lookupCodes: mockLookups }, | ||
}; | ||
|
||
describe('LeaseFeeDeterminationSubForm component', () => { | ||
const setup = async ( | ||
renderOptions: RenderOptions & Partial<IFeeDeterminationSubFormProps> = {}, | ||
) => { | ||
// render component under test | ||
const component = await renderAsync( | ||
<Formik onSubmit={noop} initialValues={getDefaultFormLease()}> | ||
{formikProps => <FeeDeterminationSubForm formikProps={formikProps} />} | ||
</Formik>, | ||
{ | ||
...renderOptions, | ||
claims: [], | ||
store: storeState, | ||
history, | ||
}, | ||
); | ||
|
||
return { | ||
component, | ||
}; | ||
}; | ||
it('renders as expected', async () => { | ||
const { component } = await setup({}); | ||
expect(component.asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
it('displays expected suggested fee', async () => { | ||
const { | ||
component: { container, getByText }, | ||
} = await setup({}); | ||
|
||
let suggestedFeeField = await container.querySelector("span[data-testid='suggestedFee']"); | ||
|
||
expect(suggestedFeeField).toHaveTextContent('Unknown'); | ||
|
||
await act(async () => { | ||
await fillInput(container, 'isPublicBenefit', 'true', 'select'); | ||
await fillInput(container, 'isFinancialGain', 'true', 'select'); | ||
}); | ||
|
||
expect(suggestedFeeField).toHaveTextContent('Licence Administration Fee (LAF) *'); | ||
}); | ||
}); |
69 changes: 69 additions & 0 deletions
69
source/frontend/src/features/leases/add/FeeDeterminationSubForm.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,69 @@ | ||
import { FormikProps, getIn } from 'formik'; | ||
import { useEffect, useState } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
import { TextArea } from '@/components/common/form'; | ||
import { InlineYesNoSelect } from '@/components/common/form/styles'; | ||
import { Section } from '@/components/common/Section/Section'; | ||
import { SectionField } from '@/components/common/Section/SectionField'; | ||
|
||
import { getSuggestedFee } from '../leaseUtils'; | ||
import { LeaseFormModel } from '../models'; | ||
|
||
export interface IFeeDeterminationSubFormProps { | ||
formikProps: FormikProps<LeaseFormModel>; | ||
} | ||
|
||
const FeeDeterminationSubForm: React.FunctionComponent<IFeeDeterminationSubFormProps> = ({ | ||
formikProps, | ||
}) => { | ||
const { values } = formikProps; | ||
const isPublicBenefit = getIn(values, 'isPublicBenefit'); | ||
const financialGain = getIn(values, 'isFinancialGain'); | ||
|
||
const [fee, setFee] = useState(''); | ||
|
||
useEffect(() => { | ||
setFee(getSuggestedFee(isPublicBenefit, financialGain)); | ||
}, [isPublicBenefit, financialGain]); | ||
|
||
return ( | ||
<Section header="Fee Determination"> | ||
<SectionField label="Public benefit" labelWidth="2" contentWidth="8"> | ||
<InlineYesNoSelect field="isPublicBenefit" /> | ||
</SectionField> | ||
|
||
<SectionField label="Financial gain" labelWidth="2" contentWidth="8"> | ||
<InlineYesNoSelect field="isFinancialGain" /> | ||
</SectionField> | ||
|
||
<SectionField | ||
label="Sugested fee" | ||
tooltip="If the financial gain far outweighs the public benefit, Fair Market Value should be considered over Licence Administration Fee." | ||
labelWidth="2" | ||
contentWidth="8" | ||
> | ||
<span data-testid="suggestedFee">{fee}</span> | ||
</SectionField> | ||
|
||
<SectionField | ||
label="Notes" | ||
tooltip="Deviations from standard fees should be explained here" | ||
labelWidth="2" | ||
contentWidth="8" | ||
> | ||
<MediumTextArea field="feeDeterminationNote" /> | ||
</SectionField> | ||
</Section> | ||
); | ||
}; | ||
|
||
export default FeeDeterminationSubForm; | ||
|
||
const MediumTextArea = styled(TextArea)` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this necessary? I'm surprised that you needed to manually specify the height here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed this since height is not needed |
||
textarea.form-control { | ||
min-width: 100%; | ||
height: 7rem; | ||
resize: none; | ||
} | ||
`; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, these are defined as booleans in the frontend model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken out the nullable validation on the yup schema since is not needed.