Skip to content

Commit

Permalink
♻️ Remove the restriction of percentage and fix the test
Browse files Browse the repository at this point in the history
  • Loading branch information
dukenuken09 committed Aug 9, 2023
1 parent ff628d3 commit 054212d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ const useStyles = makeStyles((theme) => ({
color: 'rgba(0, 0, 0, 0.54)'
}
},
helperText: {
marginLeft: '14px',
color: '#f44336',
fontSize: '0.75rem',
marginTop: '3px',
textAlign: 'left',
fontWeight: '400',
lineHeight: '1.66',
letterSpacing: '0.03333em'
},
noHover: {
backgroundColor: 'white',
padding: 0,
Expand Down Expand Up @@ -106,35 +96,24 @@ const GenerationContributionForm = (props) => {
<Grid
container
style={{
border: errors.percent_over_annual_use
? '1.5px #f44336 solid'
: '0.5px lightgrey solid'
border: '0.5px lightgrey solid'
}}>
<Grid
item
style={{
padding: '10px 2px 10px 2px',
width: percentProd,
height: '100%',
backgroundColor: errors.percent_over_annual_use
? '#ff00001c'
: '#96b633'
backgroundColor: '#96b633'
}}>
<Typography id="percent_value" style={{ margin: '0px 10px' }}>
{percentProd}
</Typography>
</Grid>
</Grid>
<Typography variant="body1" className={classes.helperText}>
{errors.percent_over_annual_use ? errors.percent_over_annual_use : ''}
</Typography>
</Box>
)
}, [
values.percent_over_annual_use,
classes.helperText,
errors.percent_over_annual_use
])
}, [values.percent_over_annual_use])

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,23 +254,6 @@ describe('Generation Form Contribution', () => {
expect(getByText(ibanTextField, mockErrMsg)).toBeInTheDocument()
})

test('Should show percent use error text, when has an error', () => {
const mockErrMsg = "percent use is not valid"
const mockErrors = JSON.parse(JSON.stringify(errors))
mockErrors.percent_over_annual_use = mockErrMsg
const dom = render(
<GenerationContributionForm
values={mockValues}
errors={mockErrors}
touched={{payment:{iban:true}}}
setFieldValue={mockSetFieldValue}
/>
)

const ibanTextField = getById(dom.container, 'box_percent_use')
expect(getByText(ibanTextField, mockErrMsg)).toBeInTheDocument()
})

test('Should show annual use helper text', () => {

const dom = render(
Expand Down
12 changes: 1 addition & 11 deletions src/containers/Generation/GenerationForm/GenerationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,7 @@ const GenerationContribution = (props) => {
iban_valid: Yup.bool()
.required(t('IBAN_ERROR'))
.oneOf([true], t('IBAN_ERROR'))
}),
percent_over_annual_use: Yup.number()
.max(
contributionParams?.maxPercentOverAnnualUse,
t('No et passis de percentatge nano!!', {
amount: new Intl.NumberFormat('ca').format(
contributionParams?.maxPercentOverAnnualUse
)
})
)
.typeError('El percentatge resultant no és vàlid!')
})
}),
Yup.object().shape({
privacy_policy_accepted: Yup.bool()
Expand Down

0 comments on commit 054212d

Please sign in to comment.