diff --git a/src/components/Analysis/AnalysisConsumption.tsx b/src/components/Analysis/AnalysisConsumption.tsx index a5bb72b6d7fc719edc3bca5859690c43d10d5d3e..d2b298c9a1cb5dc267ee958c153802279420392a 100644 --- a/src/components/Analysis/AnalysisConsumption.tsx +++ b/src/components/Analysis/AnalysisConsumption.tsx @@ -50,11 +50,13 @@ const AnalysisConsumption: React.FC<AnalysisConsumptionProps> = ({ ].filter(fluidType => !fluidTypes.includes(fluidType)) const emptyFluidTypes: FluidType[] = [] + for (let i = 0; i < performanceIndicators.length; i++) { - if (!performanceIndicators[i].value) { + if (performanceIndicators[i] && !performanceIndicators[i].value) { emptyFluidTypes.push(fluidTypes[i]) } } + const getTotalValueWithConnectedFluids = useCallback( (monthlyForecast: MonthlyForecast) => { if (fluidTypes.length === 3) { @@ -62,7 +64,8 @@ const AnalysisConsumption: React.FC<AnalysisConsumptionProps> = ({ } else { let totalPrice = 0 fluidTypes.forEach(fluid => { - totalPrice += monthlyForecast.fluidForecast[fluid].value + if (monthlyForecast.fluidForecast[fluid].value) + totalPrice += monthlyForecast.fluidForecast[fluid].value }) setHomePriceConsumption(totalPrice) } @@ -176,6 +179,7 @@ const AnalysisConsumption: React.FC<AnalysisConsumptionProps> = ({ </div> {fluidTypes.map((fluid, index) => { return ( + performanceIndicators[fluid] && performanceIndicators[fluid].value && ( <AnalysisConsumptionRow key={index} diff --git a/src/components/Analysis/MonthlyAnalysis.tsx b/src/components/Analysis/MonthlyAnalysis.tsx index 78cbd3c939cd2682d0999518ec15ee754e98a761..d8725f87f92aa29506a9ffa0577e940378014150 100644 --- a/src/components/Analysis/MonthlyAnalysis.tsx +++ b/src/components/Analysis/MonthlyAnalysis.tsx @@ -92,7 +92,10 @@ const MonthlyAnalysis: React.FC<MonthlyAnalysisProps> = ({ setPerformanceIndicators(fetchedPerformanceIndicators) setLoadAnalysis(false) for (let i = 0; i < fetchedPerformanceIndicators.length; i++) { - if (fetchedPerformanceIndicators[i].value) { + if ( + fetchedPerformanceIndicators[i] && + fetchedPerformanceIndicators[i].value + ) { setLoadAnalysis(true) } } diff --git a/src/components/Ecogesture/EcogestureEmptyList.spec.tsx b/src/components/Ecogesture/EcogestureEmptyList.spec.tsx index f629d559a8c9ae94bf777e1343d440300bbf89b8..1093a09a8df46b210f413ec0e7e223b13c53ada5 100644 --- a/src/components/Ecogesture/EcogestureEmptyList.spec.tsx +++ b/src/components/Ecogesture/EcogestureEmptyList.spec.tsx @@ -36,7 +36,11 @@ describe('EcogestureEmptyList component', () => { }) const wrapper = mount( <Provider store={store}> - <EcogestureEmptyList setTab={mockChangeTab} isObjective={true} /> + <EcogestureEmptyList + setTab={mockChangeTab} + isObjective={true} + isSelectionDone={false} + /> </Provider> ) expect(toJson(wrapper)).toMatchSnapshot() @@ -50,7 +54,11 @@ describe('EcogestureEmptyList component', () => { }) const wrapper = mount( <Provider store={store}> - <EcogestureEmptyList setTab={mockChangeTab} isObjective={false} /> + <EcogestureEmptyList + setTab={mockChangeTab} + isObjective={false} + isSelectionDone={true} + /> </Provider> ) wrapper @@ -68,7 +76,11 @@ describe('EcogestureEmptyList component', () => { }) const wrapper = mount( <Provider store={store}> - <EcogestureEmptyList setTab={mockChangeTab} isObjective={false} /> + <EcogestureEmptyList + setTab={mockChangeTab} + isObjective={false} + isSelectionDone={false} + /> </Provider> ) wrapper @@ -77,4 +89,52 @@ describe('EcogestureEmptyList component', () => { .simulate('click') expect(mockHistoryPush).toHaveBeenCalledWith('/ecogesture-form') }) + it('should render doing text with empty list on completed selection', () => { + const store = mockStore({ + ecolyo: { + profile: profileData, + global: globalStateData, + }, + }) + const wrapper = mount( + <Provider store={store}> + <EcogestureEmptyList + setTab={mockChangeTab} + isObjective={false} + isSelectionDone={true} + /> + </Provider> + ) + + expect( + wrapper + .find('.text') + .first() + .text() + ).toBe('ecogesture.emptyList.doing1_done') + }) + it('should render objective text with empty list on completed selection', () => { + const store = mockStore({ + ecolyo: { + profile: profileData, + global: globalStateData, + }, + }) + const wrapper = mount( + <Provider store={store}> + <EcogestureEmptyList + setTab={mockChangeTab} + isObjective={true} + isSelectionDone={true} + /> + </Provider> + ) + + expect( + wrapper + .find('.text') + .first() + .text() + ).toBe('ecogesture.emptyList.obj1_done') + }) }) diff --git a/src/components/Ecogesture/EcogestureEmptyList.tsx b/src/components/Ecogesture/EcogestureEmptyList.tsx index 11140d735e5f0a2b162ba4597e0f1fca6074cf20..d83cdec613cb77fdfb8df8a14d6fa632760a977a 100644 --- a/src/components/Ecogesture/EcogestureEmptyList.tsx +++ b/src/components/Ecogesture/EcogestureEmptyList.tsx @@ -11,10 +11,12 @@ import { useHistory } from 'react-router-dom' interface EcogestureEmptyListProps { setTab: React.Dispatch<React.SetStateAction<number>> isObjective: boolean + isSelectionDone: boolean } const EcogestureEmptyList: React.FC<EcogestureEmptyListProps> = ({ setTab, isObjective, + isSelectionDone, }: EcogestureEmptyListProps) => { const { t } = useI18n() const history = useHistory() @@ -28,12 +30,20 @@ const EcogestureEmptyList: React.FC<EcogestureEmptyListProps> = ({ /> <div className="text-16-normal text"> {isObjective - ? t('ecogesture.emptyList.obj1') + ? isSelectionDone + ? t('ecogesture.emptyList.obj1_done') + : t('ecogesture.emptyList.obj1') + : isSelectionDone + ? t('ecogesture.emptyList.doing1_done') : t('ecogesture.emptyList.doing1')} </div> <div className="text-16-normal text"> {isObjective - ? t('ecogesture.emptyList.obj2') + ? isSelectionDone + ? t('ecogesture.emptyList.obj2_done') + : t('ecogesture.emptyList.obj2') + : isSelectionDone + ? t('ecogesture.emptyList.doing2_done') : t('ecogesture.emptyList.doing2')} </div> <div className="btn-container"> @@ -47,18 +57,20 @@ const EcogestureEmptyList: React.FC<EcogestureEmptyListProps> = ({ > {t('ecogesture.emptyList.btn1')} </Button> - <Button - aria-label={t('ecogesture.emptyList.btn2')} - onClick={() => { - history.push('/ecogesture-form') - }} - classes={{ - root: 'btn-highlight', - label: 'text-16-bold', - }} - > - {t('ecogesture.emptyList.btn2')} - </Button> + {!isSelectionDone && ( + <Button + aria-label={t('ecogesture.emptyList.btn2')} + onClick={() => { + history.push('/ecogesture-form') + }} + classes={{ + root: 'btn-highlight btn2', + label: 'text-16-bold', + }} + > + {t('ecogesture.emptyList.btn2')} + </Button> + )} </div> </div> </div> diff --git a/src/components/Ecogesture/EcogestureList.tsx b/src/components/Ecogesture/EcogestureList.tsx index 578a45adb2d1a258e1d495816392637dc05157e9..029e36748d843c2b69784bb22bf0fb7a1ebe798a 100644 --- a/src/components/Ecogesture/EcogestureList.tsx +++ b/src/components/Ecogesture/EcogestureList.tsx @@ -169,7 +169,7 @@ const EcogestureList: React.FC<EcogestureListProps> = ({ )) ) : list.length > 0 && activeFilter !== Usage[Usage.ALL] ? ( filterEcogesture(list) - ) : ( + ) : !displaySelection ? ( <div className="ec-filter-error"> <div className="text-20-normal"> {t('ecogesture.no_ecogesture_filter.text1')} @@ -178,6 +178,8 @@ const EcogestureList: React.FC<EcogestureListProps> = ({ {t('ecogesture.no_ecogesture_filter.text2')} </div> </div> + ) : ( + '' )} </div> </div> diff --git a/src/components/Ecogesture/EcogestureView.tsx b/src/components/Ecogesture/EcogestureView.tsx index 582af599b6919104861d68895d0f60a3202df8ad..3a4110cca29bb1bcf55966cfeb2968e9cf2150df 100644 --- a/src/components/Ecogesture/EcogestureView.tsx +++ b/src/components/Ecogesture/EcogestureView.tsx @@ -209,27 +209,53 @@ const EcogestureView: React.FC = () => { <Content height={headerHeight}> <TabPanel value={tabValue} index={EcogestureStatus.OBJECTIVE}> {isProfileEcogestureCompleted === true ? ( - <EcogestureList - list={objectiveEcogestureList} - displaySelection={totalAvailable !== totalViewed} - selectionTotal={totalAvailable} - selectionViewed={totalViewed} - /> + totalAvailable === totalViewed && + objectiveEcogestureList.length === 0 ? ( + <EcogestureEmptyList + setTab={setTabValue} + isObjective={true} + isSelectionDone={true} + /> + ) : ( + <EcogestureList + list={objectiveEcogestureList} + displaySelection={totalAvailable !== totalViewed} + selectionTotal={totalAvailable} + selectionViewed={totalViewed} + /> + ) ) : ( - <EcogestureEmptyList setTab={setTabValue} isObjective={true} /> + <EcogestureEmptyList + setTab={setTabValue} + isObjective={true} + isSelectionDone={false} + /> )} </TabPanel> <TabPanel value={tabValue} index={EcogestureStatus.DOING}> {isProfileEcogestureCompleted === true ? ( - <EcogestureList - list={doingEcogestureList} - displaySelection={totalAvailable !== totalViewed} - selectionTotal={totalAvailable} - selectionViewed={totalViewed} - /> + totalAvailable === totalViewed && + doingEcogestureList.length === 0 ? ( + <EcogestureEmptyList + setTab={setTabValue} + isObjective={false} + isSelectionDone={true} + /> + ) : ( + <EcogestureList + list={doingEcogestureList} + displaySelection={totalAvailable !== totalViewed} + selectionTotal={totalAvailable} + selectionViewed={totalViewed} + /> + ) ) : ( - <EcogestureEmptyList setTab={setTabValue} isObjective={false} /> + <EcogestureEmptyList + setTab={setTabValue} + isObjective={false} + isSelectionDone={false} + /> )} </TabPanel> <TabPanel value={tabValue} index={EcogestureStatus.ALL}> diff --git a/src/components/Ecogesture/__snapshots__/EcogestureEmptyList.spec.tsx.snap b/src/components/Ecogesture/__snapshots__/EcogestureEmptyList.spec.tsx.snap index dd45ee676b600e22e47fcbbc3852162321378196..db551a11f78ecb9ab71eb9e9a261063f0a689022 100644 --- a/src/components/Ecogesture/__snapshots__/EcogestureEmptyList.spec.tsx.snap +++ b/src/components/Ecogesture/__snapshots__/EcogestureEmptyList.spec.tsx.snap @@ -15,6 +15,7 @@ exports[`EcogestureEmptyList component should be rendered correctly 1`] = ` > <EcogestureEmptyList isObjective={true} + isSelectionDone={false} setTab={[MockFunction]} > <div @@ -207,7 +208,7 @@ exports[`EcogestureEmptyList component should be rendered correctly 1`] = ` classes={ Object { "label": "text-16-bold", - "root": "btn-highlight", + "root": "btn-highlight btn2", } } onClick={[Function]} @@ -236,7 +237,7 @@ exports[`EcogestureEmptyList component should be rendered correctly 1`] = ` "outlinedSecondary": "MuiButton-outlinedSecondary", "outlinedSizeLarge": "MuiButton-outlinedSizeLarge", "outlinedSizeSmall": "MuiButton-outlinedSizeSmall", - "root": "MuiButton-root btn-highlight", + "root": "MuiButton-root btn-highlight btn2", "sizeLarge": "MuiButton-sizeLarge", "sizeSmall": "MuiButton-sizeSmall", "startIcon": "MuiButton-startIcon", @@ -251,7 +252,7 @@ exports[`EcogestureEmptyList component should be rendered correctly 1`] = ` > <WithStyles(ForwardRef(ButtonBase)) aria-label="ecogesture.emptyList.btn2" - className="MuiButton-root btn-highlight MuiButton-text" + className="MuiButton-root btn-highlight btn2 MuiButton-text" component="button" disabled={false} focusRipple={true} @@ -261,7 +262,7 @@ exports[`EcogestureEmptyList component should be rendered correctly 1`] = ` > <ForwardRef(ButtonBase) aria-label="ecogesture.emptyList.btn2" - className="MuiButton-root btn-highlight MuiButton-text" + className="MuiButton-root btn-highlight btn2 MuiButton-text" classes={ Object { "disabled": "Mui-disabled", @@ -278,7 +279,7 @@ exports[`EcogestureEmptyList component should be rendered correctly 1`] = ` > <button aria-label="ecogesture.emptyList.btn2" - className="MuiButtonBase-root MuiButton-root btn-highlight MuiButton-text" + className="MuiButtonBase-root MuiButton-root btn-highlight btn2 MuiButton-text" disabled={false} onBlur={[Function]} onClick={[Function]} diff --git a/src/components/Ecogesture/__snapshots__/EcogestureView.spec.tsx.snap b/src/components/Ecogesture/__snapshots__/EcogestureView.spec.tsx.snap index 6389b50f17cb2b13d2f50cf51ecd964dbc9311af..a438baf66a1755b3470bab2b62e3fb1b59f1502a 100644 --- a/src/components/Ecogesture/__snapshots__/EcogestureView.spec.tsx.snap +++ b/src/components/Ecogesture/__snapshots__/EcogestureView.spec.tsx.snap @@ -566,6 +566,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` > <EcogestureEmptyList isObjective={true} + isSelectionDone={false} setTab={[Function]} > <div @@ -758,7 +759,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` classes={ Object { "label": "text-16-bold", - "root": "btn-highlight", + "root": "btn-highlight btn2", } } onClick={[Function]} @@ -787,7 +788,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` "outlinedSecondary": "MuiButton-outlinedSecondary", "outlinedSizeLarge": "MuiButton-outlinedSizeLarge", "outlinedSizeSmall": "MuiButton-outlinedSizeSmall", - "root": "MuiButton-root btn-highlight", + "root": "MuiButton-root btn-highlight btn2", "sizeLarge": "MuiButton-sizeLarge", "sizeSmall": "MuiButton-sizeSmall", "startIcon": "MuiButton-startIcon", @@ -802,7 +803,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` > <WithStyles(ForwardRef(ButtonBase)) aria-label="ecogesture.emptyList.btn2" - className="MuiButton-root btn-highlight MuiButton-text" + className="MuiButton-root btn-highlight btn2 MuiButton-text" component="button" disabled={false} focusRipple={true} @@ -812,7 +813,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` > <ForwardRef(ButtonBase) aria-label="ecogesture.emptyList.btn2" - className="MuiButton-root btn-highlight MuiButton-text" + className="MuiButton-root btn-highlight btn2 MuiButton-text" classes={ Object { "disabled": "Mui-disabled", @@ -829,7 +830,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` > <button aria-label="ecogesture.emptyList.btn2" - className="MuiButtonBase-root MuiButton-root btn-highlight MuiButton-text" + className="MuiButtonBase-root MuiButton-root btn-highlight btn2 MuiButton-text" disabled={false} onBlur={[Function]} onClick={[Function]} @@ -904,6 +905,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` > <EcogestureEmptyList isObjective={false} + isSelectionDone={false} setTab={[Function]} > <div @@ -1096,7 +1098,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` classes={ Object { "label": "text-16-bold", - "root": "btn-highlight", + "root": "btn-highlight btn2", } } onClick={[Function]} @@ -1125,7 +1127,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` "outlinedSecondary": "MuiButton-outlinedSecondary", "outlinedSizeLarge": "MuiButton-outlinedSizeLarge", "outlinedSizeSmall": "MuiButton-outlinedSizeSmall", - "root": "MuiButton-root btn-highlight", + "root": "MuiButton-root btn-highlight btn2", "sizeLarge": "MuiButton-sizeLarge", "sizeSmall": "MuiButton-sizeSmall", "startIcon": "MuiButton-startIcon", @@ -1140,7 +1142,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` > <WithStyles(ForwardRef(ButtonBase)) aria-label="ecogesture.emptyList.btn2" - className="MuiButton-root btn-highlight MuiButton-text" + className="MuiButton-root btn-highlight btn2 MuiButton-text" component="button" disabled={false} focusRipple={true} @@ -1150,7 +1152,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` > <ForwardRef(ButtonBase) aria-label="ecogesture.emptyList.btn2" - className="MuiButton-root btn-highlight MuiButton-text" + className="MuiButton-root btn-highlight btn2 MuiButton-text" classes={ Object { "disabled": "Mui-disabled", @@ -1167,7 +1169,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` > <button aria-label="ecogesture.emptyList.btn2" - className="MuiButtonBase-root MuiButton-root btn-highlight MuiButton-text" + className="MuiButtonBase-root MuiButton-root btn-highlight btn2 MuiButton-text" disabled={false} onBlur={[Function]} onClick={[Function]} diff --git a/src/components/Ecogesture/ecogestureEmptyList.scss b/src/components/Ecogesture/ecogestureEmptyList.scss index 1326c2218c7732de283dd89296326555b3de8ee0..56ec9b82958fa9e5272625c59018612b5393ac4d 100644 --- a/src/components/Ecogesture/ecogestureEmptyList.scss +++ b/src/components/Ecogesture/ecogestureEmptyList.scss @@ -21,8 +21,8 @@ } .btn-container { display: flex; - button.btn1 { - margin-right: 1rem; + button.btn2 { + margin-left: 1rem; } } } diff --git a/src/components/EcogestureSelection/ecogestureSelectionDetail.scss b/src/components/EcogestureSelection/ecogestureSelectionDetail.scss index c186102dd259af0b740bb8692cd56b5cb938bae9..db61bfa253cdd25701e539fd2863ae849e296265 100644 --- a/src/components/EcogestureSelection/ecogestureSelectionDetail.scss +++ b/src/components/EcogestureSelection/ecogestureSelectionDetail.scss @@ -47,8 +47,12 @@ height: 7.375rem; width: 6.5rem; border-radius: 0.25rem; + &:focus { + background: transparent; + } span { flex-direction: column; + color: $grey-bright; } } } diff --git a/src/locales/fr.json b/src/locales/fr.json index 42d6dad1ca5a283253dc088ee4630d9da57b8618..df2803bb5a2366380b4cbff7adaa676df1b25dde 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -390,9 +390,13 @@ "objective": "Objectif", "emptyList": { "obj1": "Les écogestes sont des actions qui vous permettent de réduire vos consommations et donc vos factures.", + "obj1_done": "Aucun écogeste n’est indiqué comme objectif actuellement.", "obj2": "Vous pouvez sélectionner ceux à mettre en objectifs et ceux que vous appliquez déjà.", + "obj2_done": "Vous pouvez consulter tous les écogestes et ajouter les gestes que vous souhaitez garder en objectif dans cette section.", "doing1": "Aucun écogeste n’est indiqué comme déjà appliqué actuellement.", + "doing1_done": "Aucun écogeste n’est indiqué comme déjà appliqué actuellement.", "doing2": "Vous pouvez consulter tous les écogestes et ajouter les gestes que vous mettez déjà en pratique dans cette section.", + "doing2_done": "Vous pouvez consulter tous les écogestes et ajouter les gestes que vous mettez déjà en pratique dans cette section.", "btn1": "Voir tous les écogestes", "btn2": "Sélectionner" }, @@ -464,7 +468,7 @@ "cooking_plates": "Plaques électriques", "garden": "Jardin", "dryer": "Sèche-linge", - "refregirator": "Réfrégirateur", + "refregirator": "Réfrigérateur", "fan": "Ventilateur", "water_heater": "Chauffe-eau", "curtain": "Rideaux",