Skip to content

Commit

Permalink
Merge pull request #84 from Som-Energia/IMP_form_generationkwh
Browse files Browse the repository at this point in the history
♻️ Improve the contribution to make it more understandable
  • Loading branch information
dukenuken09 authored Nov 23, 2023
2 parents 2fc4a02 + 2dee97a commit c163c25
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import { makeStyles } from '@material-ui/core/styles'

import StepHeader from '../../../components/StepHeader'
import IBANField from '../../../components/IBANField'
import AlertBox from 'components/AlertBox'

import AddIcon from '@material-ui/icons/AddBox'
import RemoveIcon from '@material-ui/icons/IndeterminateCheckBox'
Expand Down Expand Up @@ -98,29 +98,33 @@ const GenerationContributionForm = (props) => {
isNaN(values.percent_over_annual_use) ||
!isFinite(values.percent_over_annual_use)
) {
percentProd = 'n/s %'
percentProd = undefined
}

return (
<Box id="box_percent_use">
<Grid
container
style={{
border: '0.5px lightgrey solid'
}}>
{percentProd ? (
<Grid
item
container
style={{
padding: '10px 2px 10px 2px',
width: percentProd,
height: '100%',
backgroundColor: '#96b633'
border: '0.5px lightgrey solid'
}}>
<Typography id="percent_value" style={{ margin: '0px 10px' }}>
{percentProd}
</Typography>
<Grid
item
style={{
padding: '10px 2px 10px 2px',
width: percentProd,
height: '100%',
backgroundColor: '#96b633'
}}>
<Typography id="percent_value" style={{ margin: '0px 10px' }}>
{percentProd}
</Typography>
</Grid>
</Grid>
</Grid>
) : (
<AlertBox id='percent_value_error' description={t('GENERATION_PERCENT_ERROR_DESC')} severity={'warning'} variant={'body2'}/>
)}
</Box>
)
}, [values.percent_over_annual_use])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,6 @@ describe('Generation Form Contribution', () => {
expect(mockSetFieldValue).toHaveBeenCalledWith('payment.iban', IBAN, false)
})

test('Should show error when percent use has erroneous value', () => {
const mockPercentValues = JSON.parse(JSON.stringify(mockValues))
mockPercentValues.percent_over_annual_use = Infinity

const dom = render(
<GenerationContributionForm
values={mockPercentValues}
errors={errors}
setFieldValue={mockSetFieldValue}
/>
)

const percentValue = getById(dom.container, 'percent_value')
expect(getByText(percentValue, 'n/s %')).toBeInTheDocument()
})

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

const dom = render(
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Generation/GenerationForm/GenerationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const GenerationContribution = (props) => {
sepa_accepted: true
},
number_of_actions: 0,
annual_use: 0,
annual_use: 5000,
privacy_policy_accepted: false,
privacy_policy_accepted_responsible_declaration: false,
percent_over_annual_use: 0,
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locale-ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@
"GENERATION_FORM_PERSONAL_DATA_TITLE":"Formulari per fer-se soci/sòcia",
"GENERATION_FORM_ANNUAL_CONSUMPTION_URL":"https://ca.support.somenergia.coop/article/945-com-puc-saber-el-meu-us-anual-delectricitat",
"GENERATION_FORM_POSTAL_CODE":"Introdueix el codi postal",
"GENERATION_PERCENT_ERROR_DESC":"Per poder veure aquest percentatge, has d'emplenar el camp d'ús anual",
"TAR_20TD_SOM": "2.0TD Períodes Península",
"TAR_20TD_SOM_INSULAR": "2.0TD Períodes Insular",
"TAR_30TD_SOM": "3.0TD Períodes Península",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locale-es.json
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@
"GENERATION_FORM_PERSONAL_DATA_TITLE":"Formulario para hacerse socio/socia",
"GENERATION_FORM_ANNUAL_CONSUMPTION_URL":"https://es.support.somenergia.coop/article/946-como-puedo-saber-mi-uso-anual-de-electricidad?utm_source=linkidiomes&utm_medium=cda&utm_campaign=castellano",
"GENERATION_FORM_POSTAL_CODE":"Introduce el código postal",
"GENERATION_PERCENT_ERROR_DESC":"Para poder ver este porcentaje, debes rellenar el campo de uso anual",
"TAR_20TD_SOM": "2.0TD Periodos Península",
"TAR_20TD_SOM_INSULAR": "2.0TD Periodos Insular",
"TAR_30TD_SOM": "3.0TD Periodos Península",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locale-eu.json
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@
"GENERATION_FORM_IN_PROCESS":"Eskaera prozesatzen ari da...",
"GENERATION_FORM_PERSONAL_DATA_TITLE":"Bazkide izateko formularioa",
"GENERATION_FORM_ANNUAL_CONSUMPTION_URL":"https://eu.support.somenergia.coop/article/947-nola-jakin-dezaket-urtean-zenbat-elektrizitate-erabiltzen-dudan?utm_source=linkidiomes&utm_medium=cda&utm_campaign=euskara",
"GENERATION_PERCENT_ERROR_DESC":"Ehuneko hori ikusteko, urteko erabilera eremua bete behar duzu",
"TAR_20TD_SOM": "2.0TD Periodos Península",
"TAR_20TD_SOM_INSULAR": "2.0TD Periodos Insular",
"TAR_30TD_SOM": "3.0TD Periodos Península",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locale-gl.json
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@
"GENERATION_FORM_IN_PROCESS":"A solicitude estase a procesar...",
"GENERATION_FORM_PERSONAL_DATA_TITLE":"Formulario para facerte socio/socia",
"GENERATION_FORM_ANNUAL_CONSUMPTION_URL":"https://gl.support.somenergia.coop/article/948-como-podo-saber-o-meu-uso-anual-de-electricidade?utm_source=linkidiomes&utm_medium=cda&utm_campaign=galego",
"GENERATION_PERCENT_ERROR_DESC":"Para ver esta porcentaxe, debes cubrir o campo de uso anual",
"TAR_20TD_SOM": "2.0TD Periodos Península",
"TAR_20TD_SOM_INSULAR": "2.0TD Periodos Insular",
"TAR_30TD_SOM": "3.0TD Periodos Península",
Expand Down

1 comment on commit c163c25

@vercel
Copy link

@vercel vercel bot commented on c163c25 Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

webforms-ui – ./

webforms-ui-somenergia.vercel.app
webforms-ui-git-master-somenergia.vercel.app
webforms-ui.vercel.app

Please sign in to comment.