-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Export Win - Win details (step 4 of 6) (#6455)
- Loading branch information
Showing
7 changed files
with
867 additions
and
34 deletions.
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
8 changes: 7 additions & 1 deletion
8
...ules/ExportWins/Form/SupportGivenStep.jsx → ...s/ExportWins/Form/SupportProvidedStep.jsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react' | ||
import Label from '@govuk-react/label' | ||
import pluralize from 'pluralize' | ||
import styled from 'styled-components' | ||
|
||
import { LIGHT_GREY } from '../../../../client/utils/colours' | ||
import { FieldCurrency } from '../../../components' | ||
import { StyledHintParagraph } from './styled' | ||
import { | ||
formatValue, | ||
getYearFromWinType, | ||
sumWinTypeYearlyValues, | ||
} from './utils' | ||
|
||
const WinTypeContainer = styled('div')({ | ||
marginLeft: 56, | ||
}) | ||
|
||
const FieldCurrencyContainer = styled('div')({ | ||
display: 'flex', | ||
gap: 5, | ||
}) | ||
|
||
const StyledLabel = styled(Label)({ | ||
fontWeight: 'bold', | ||
}) | ||
|
||
const StyledParagraph = styled('p')({ | ||
padding: 10, | ||
fontWeight: 'bold', | ||
backgroundColor: LIGHT_GREY, | ||
}) | ||
|
||
export const WinTypeValues = ({ label, name, years = 5, values }) => { | ||
const year = getYearFromWinType(name, values) | ||
return ( | ||
<WinTypeContainer data-test={`win-type-values-${name}`}> | ||
<StyledLabel data-test="label">{label}</StyledLabel> | ||
<StyledHintParagraph data-test="hint"> | ||
(round to nearest £) | ||
</StyledHintParagraph> | ||
<FieldCurrencyContainer> | ||
{[...Array(years).keys()].map((index) => ( | ||
<FieldCurrency | ||
type="text" | ||
name={`${name}_${index}`} | ||
key={`${name}_${index}`} | ||
label={`Year ${index + 1}`} | ||
boldLabel={true} | ||
/> | ||
))} | ||
</FieldCurrencyContainer> | ||
<StyledParagraph data-test="total"> | ||
Totalling over {year} {pluralize('year', year)}:{' '} | ||
{formatValue(sumWinTypeYearlyValues(name, values))} | ||
</StyledParagraph> | ||
</WinTypeContainer> | ||
) | ||
} |
Oops, something went wrong.