From 4305ba187bdba2d2f7da6ed1637e9f3bd7df3736 Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Tue, 14 Mar 2023 09:49:01 +0000 Subject: [PATCH] chore: fix types errors --- .vscode/settings.json | 31 ++- src/assets/icons/ico/white-arrow.svg | 1 - .../Analysis/AnalysisConsumption.tsx | 209 ++++++++++-------- .../Analysis/ElecHalfHourChart.spec.tsx | 2 +- src/components/Analysis/MonthlyAnalysis.tsx | 27 ++- .../Analysis/TotalAnalysisChart.spec.tsx | 2 +- src/components/App.tsx | 7 +- src/components/Challenge/ChallengeCard.tsx | 4 +- .../Challenge/ChallengeCardOnGoing.tsx | 4 +- src/components/Challenge/ChallengeView.tsx | 65 +++--- src/components/Challenge/StarsContainer.tsx | 24 +- .../__snapshots__/ChallengeView.spec.tsx.snap | 18 +- src/components/Charts/AxisBottom.spec.tsx | 2 +- src/components/Charts/Bar.spec.tsx | 2 +- .../CommonKit/Card/StyledBorderCard.tsx | 6 +- src/components/CommonKit/Card/StyledCard.tsx | 18 +- .../Card/StyledEcogestureCard.spec.tsx | 2 +- .../CommonKit/Card/StyledEcogestureCard.tsx | 13 +- .../CommonKit/Card/StyledIconCard.tsx | 17 +- .../StyledEcogestureCard.spec.tsx.snap | 12 +- .../StyledIconBorderedButton.spec.tsx | 4 +- .../IconButton/StyledIconButton.spec.tsx | 2 +- .../StyledIconBorderedButton.spec.tsx.snap | 12 +- .../StyledIconButton.spec.tsx.snap | 6 +- .../CommonKit/Switch/StyledSwitch.tsx | 13 +- .../SgeConnectView.spec.tsx.snap | 1 - .../__snapshots__/SgeInit.spec.tsx.snap | 1 + .../__snapshots__/StepAddress.spec.tsx.snap | 1 - .../__snapshots__/StepConsent.spec.tsx.snap | 1 - .../StepIdentityAndPdl.spec.tsx.snap | 1 - .../__snapshots__/Connection.spec.tsx.snap | 4 + .../DataloadConsumptionVisualizer.spec.tsx | 14 +- .../DataloadNoValue.spec.tsx | 2 +- .../DataloadSection.spec.tsx | 2 +- .../DataloadSectionDetail.spec.tsx | 2 +- .../DataloadSectionValue.spec.tsx | 2 +- .../InfoDataConsumptionVisualizer.spec.tsx | 2 +- src/components/Ecogesture/EcogestureCard.tsx | 8 +- .../Ecogesture/EcogestureEmptyList.spec.tsx | 6 + .../Ecogesture/EcogestureList.spec.tsx | 2 + src/components/Ecogesture/EcogestureList.tsx | 16 +- src/components/Ecogesture/EcogestureModal.tsx | 4 +- src/components/Ecogesture/EcogestureView.tsx | 61 +++-- ...ing.spec.tsx => EfficiencyRating.spec.tsx} | 6 +- .../Ecogesture/EfficiencyRating.tsx | 23 ++ .../Ecogesture/EfficientyRating.tsx | 41 ---- .../Ecogesture/SingleEcogesture.spec.tsx | 4 +- .../Ecogesture/SingleEcogesture.tsx | 4 +- .../EcogestureCard.spec.tsx.snap | 24 +- .../EcogestureEmptyList.spec.tsx.snap | 1 + .../EcogestureList.spec.tsx.snap | 12 +- .../EcogestureView.spec.tsx.snap | 10 +- ...sx.snap => EfficiencyRating.spec.tsx.snap} | 16 +- .../SingleEcogesture.spec.tsx.snap | 2 +- .../EcogestureFormEquipment.tsx | 40 ++-- .../EcogestureFormEquipment.spec.tsx.snap | 82 +++---- .../ecogestureFormSingleChoice.scss | 1 - src/components/Header/CozyBar.tsx | 8 + src/components/Header/Header.tsx | 12 +- src/components/Home/FluidButtons.tsx | 4 +- src/components/Home/ReleaseNotesModal.tsx | 4 +- src/components/Konnector/KonnectorModal.tsx | 4 +- .../Konnector/KonnectorModalFooter.spec.tsx | 2 + .../KonnectorModal.spec.tsx.snap | 28 +-- .../ProfileTypeOptions.spec.tsx | 8 +- .../ProfileTypeOptions/ProfileTypeOptions.tsx | 32 ++- .../ProfileTypeFormDateSelection.tsx | 28 ++- src/components/Quiz/QuizQuestionContent.tsx | 30 ++- src/components/Splash/SplashRoot.tsx | 4 +- .../TimeStepSelector/TimeStepSelector.tsx | 36 ++- .../TotalConsumption.spec.tsx | 2 +- src/constants/connectionWaitingText.json | 2 +- src/constants/consumptionConstants/ecs.json | 2 +- .../electricSpecific.json | 2 +- .../consumptionConstants/heating.json | 8 +- src/db/ecogestureData.json | 2 +- src/db/quizEntity.json | 8 +- .../com-grandlyon-ecolyo-fluidsprices.ts | 2 +- src/doctypes/index.ts | 4 +- src/enum/ecogesture.enum.ts | 2 +- src/enum/profileType.enum.ts | 2 +- src/locales/fr.json | 8 +- src/migrations/migration.data.ts | 8 +- src/migrations/migration.spec.ts | 4 +- src/models/profileEcogesture.model.ts | 1 + src/services/challenge.service.spec.ts | 2 +- src/services/connection.service.spec.ts | 18 +- src/services/consumption.service.ts | 34 +-- src/services/customPopup.service.test.ts | 8 +- src/services/customPopup.service.ts | 2 +- src/services/duel.service.spec.ts | 5 +- src/services/fluid.service.spec.ts | 43 ++-- src/services/fluidConfig.service.ts | 2 +- src/services/fluidsPrices.service.ts | 12 +- src/services/initialization.service.spec.ts | 2 +- src/services/performanceIndicator.service.ts | 4 +- .../profileEcogesture.service.spec.ts | 4 +- src/services/profileType.service.spec.ts | 6 +- src/services/profileType.service.ts | 6 +- src/services/queryRunner.service.spec.ts | 8 +- src/services/queryRunner.service.ts | 2 +- src/services/quiz.service.spec.ts | 4 +- src/store/challenge/challenge.reducer.spec.ts | 8 +- src/store/chart/chart.action.spec.ts | 2 +- src/store/chart/chart.reducer.spec.ts | 2 +- src/store/index.ts | 2 +- src/store/profileType/profileType.reducer.ts | 3 +- src/targets/services/aggregatorUsageEvents.ts | 98 ++++---- src/targets/services/fluidsPrices.ts | 16 +- src/targets/services/service.ts | 3 +- src/types/cozy-client.d.ts | 1 - src/utils/date.spec.ts | 2 +- src/utils/hash.spec.ts | 2 +- src/utils/utils.ts | 12 +- tests/__mocks__/actionData.mock.ts | 6 +- ...atachartData.mock.ts => chartData.mock.ts} | 0 tests/__mocks__/ecogesturesData.mock.ts | 16 +- tests/__mocks__/fluidStatusData.mock.ts | 7 + tests/__mocks__/globalStateData.mock.ts | 1 - tests/__mocks__/profileType.mock.ts | 10 +- tests/__mocks__/store.ts | 3 +- 121 files changed, 761 insertions(+), 751 deletions(-) rename src/components/Ecogesture/{EfficientyRating.spec.tsx => EfficiencyRating.spec.tsx} (85%) create mode 100644 src/components/Ecogesture/EfficiencyRating.tsx delete mode 100644 src/components/Ecogesture/EfficientyRating.tsx rename src/components/Ecogesture/__snapshots__/{EfficientyRating.spec.tsx.snap => EfficiencyRating.spec.tsx.snap} (97%) rename tests/__mocks__/{datachartData.mock.ts => chartData.mock.ts} (100%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 39ec8baa4..655e7ed46 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -44,6 +44,7 @@ "cicid", "CONSO", "cozycloud", + "d’éco", "dacc", "Datachart", "dataload", @@ -52,6 +53,8 @@ "Dataloads", "defi", "depense", + "désembouant", + "désembouer", "doctypes", "ecogesture", "Ecogesture", @@ -59,26 +62,35 @@ "ecolyo", "Ecolyo", "ecolyodemo", + "Ecoreno'v", "eglgrandlyon", "elec", + "élec", "enedis", "Enedis", "ENEDIS", "enedissgegrandlyon", "Epgl", + "esnext", "firstname", "fluidchart", "fluidchartslide", + "fluidsprices", "fluidtype", + "Folinge", "Gazpar", "Gier", "grandlyon", "grdf", "GRDF", "grdfgrandlyon", + "Hypervitesse", + "késako", "Konnected", "konnector", "konnectors", + "l'ADEME", + "L’embouage", "lastname", "legalnotice", "llle", @@ -86,19 +98,36 @@ "luxon", "matomo", "Matomo", + "maxpower", "MEGAUNIT", + "Métroooooo", "monthlyanalysis", + "mousseur", + "mousseurs", "multifluid", "MULTIFLUID", "mutlifluid", "numerique", + "oeufs", + "picto", "Picto", + "PIV'EAU", + "profileecogesture", "profiletype", "PROFILETYPE", + "pseudonymisées", "Reinit", + "SHARAPOWATT", "splashscreen", + "swipeable", + "Swipeable", + "Téléo", "testid", "Tétris", - "UNSTARTED" + "timestep", + "UNSTARTED", + "usageevent", + "Usain", + "userchallenge" ] } diff --git a/src/assets/icons/ico/white-arrow.svg b/src/assets/icons/ico/white-arrow.svg index 315176006..3eb09711f 100644 --- a/src/assets/icons/ico/white-arrow.svg +++ b/src/assets/icons/ico/white-arrow.svg @@ -1,4 +1,3 @@ <svg width="9" height="19" viewBox="0 0 9 19" fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg"> <path d="M0.727051 18L8.72705 9L0.727049 6.99382e-07" fill="#FFFFFF"/> -</g> </svg> diff --git a/src/components/Analysis/AnalysisConsumption.tsx b/src/components/Analysis/AnalysisConsumption.tsx index cbe682b86..f1703e78e 100644 --- a/src/components/Analysis/AnalysisConsumption.tsx +++ b/src/components/Analysis/AnalysisConsumption.tsx @@ -8,7 +8,6 @@ import chevronDown from 'assets/icons/ico/chevron-down.svg' import ProfileEditIcon from 'assets/icons/ico/profile-edit.svg' import AnalysisIcon from 'assets/icons/visu/analysis/analysis.svg' import PlaceHolderIcon from 'assets/icons/visu/analysis/no-profile-placeholder.svg' -import AnalysisConsumptionRow from 'components/Analysis/AnalysisConsumptionRow' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' import Loader from 'components/Loader/Loader' import { Client, useClient } from 'cozy-client' @@ -25,6 +24,7 @@ import ProfileTypeService from 'services/profileType.service' import ProfileTypeEntityService from 'services/profileTypeEntity.service' import { AppStore } from 'store' import './analysisConsumption.scss' +import AnalysisConsumptionRow from './AnalysisConsumptionRow' interface AnalysisConsumptionProps { aggregatedPerformanceIndicator: PerformanceIndicator @@ -165,95 +165,130 @@ const AnalysisConsumption: React.FC<AnalysisConsumptionProps> = ({ const Consumption = ( <> - <div className="consumption-title text-20-bold"> - <div className="user-title">{t('analysis.user_consumption')}</div> - <div className={`average-title`}>{t(`analysis.comparison`)}</div> - </div> - <div className="consumption-price"> - <AnalysisConsumptionRow - fluid={FluidType.MULTIFLUID} - userPriceConsumption={userPriceConsumption} - homePriceConsumption={homePriceConsumption} - performanceValue={null} - forecast={forecast} - connected={fluidTypes.length > 0} - noData={false} - /> + <div className="status-header"> + <div> + <StyledIcon icon={AnalysisIcon} size={44} /> + <p className="text-16-normal">{t('analysis.compare.title')}</p> + </div> + {profile.isProfileTypeCompleted && ( + <Button + aria-label={t('analysis.accessibility.button_go_to_profil')} + onClick={goToForm} + classes={{ + root: 'btn-secondary-negative', + label: 'text-16-normal', + }} + > + <StyledIcon icon={ProfileEditIcon} size={40} /> + </Button> + )} </div> - {fluidTypes.map( - (fluid, index) => - performanceIndicators[fluid]?.value && ( - <AnalysisConsumptionRow - key={index} - fluid={fluid} - userPriceConsumption={userPriceConsumption} - homePriceConsumption={homePriceConsumption} - performanceValue={performanceIndicators[fluid].value} - forecast={forecast} - connected={true} - noData={false} - /> - ) - )} - {fluidTypes.length < 3 && <hr className="consumption-sep" />} - {disconnectedFluidTypes.map((fluid, index) => ( - <AnalysisConsumptionRow - key={index} - fluid={fluid} - userPriceConsumption={userPriceConsumption} - homePriceConsumption={homePriceConsumption} - performanceValue={null} - forecast={forecast} - connected={false} - noData={false} - /> - ))} - {emptyFluidTypes.map((fluid, index) => ( - <AnalysisConsumptionRow - key={index} - fluid={fluid} - userPriceConsumption={userPriceConsumption} - homePriceConsumption={homePriceConsumption} - performanceValue={null} - forecast={forecast} - connected={false} - noData={true} - /> - ))} - <Accordion - expanded={activeAverageHome} - onChange={toggleAccordion} - classes={{ - root: 'expansion-panel-root', - }} - > - <AccordionSummary - aria-label={t( - 'profile_type.accessibility.button_toggle_average_home' - )} - expandIcon={ - <Icon icon={chevronDown} size={16} className="accordion-icon" /> - } - classes={{ - root: 'expansion-panel-summary', - content: 'expansion-panel-content', - }} - > - <div className="accordion-title accordion-title"> - {t('analysis.average_home')} + <div className="analysis-graph"> + {!profile.isProfileTypeCompleted ? ( + profileNotCompleted() + ) : isLoading ? ( + <div className="loader-container"> + <Loader color="elec" /> </div> - </AccordionSummary> - <AccordionDetails - classes={{ - root: 'expansion-panel-details', - }} - > - <span className="accordion-desc text-16-normal"> - {t('analysis.average_home_description')} - </span> - </AccordionDetails> - </Accordion> + ) : ( + <> + <div className="consumption-title text-20-bold"> + <div className="user-title">{t('analysis.user_consumption')}</div> + <div className={`average-title`}>{t(`analysis.comparison`)}</div> + </div> + <div className="consumption-price"> + <AnalysisConsumptionRow + fluid={FluidType.MULTIFLUID} + userPriceConsumption={userPriceConsumption} + homePriceConsumption={homePriceConsumption} + performanceValue={null} + forecast={forecast} + connected={fluidTypes.length > 0} + noData={false} + /> + </div> + {fluidTypes.map( + fluid => + performanceIndicators[fluid]?.value && ( + <AnalysisConsumptionRow + key={fluid} + fluid={fluid} + userPriceConsumption={userPriceConsumption} + homePriceConsumption={homePriceConsumption} + performanceValue={performanceIndicators[fluid].value} + forecast={forecast} + connected={true} + noData={false} + /> + ) + )} + {fluidTypes.length < 3 && <hr className="consumption-sep" />} + {disconnectedFluidTypes.map(fluid => ( + <AnalysisConsumptionRow + key={fluid} + fluid={fluid} + userPriceConsumption={userPriceConsumption} + homePriceConsumption={homePriceConsumption} + performanceValue={null} + forecast={forecast} + connected={false} + noData={false} + /> + ))} + {emptyFluidTypes.map(fluid => ( + <AnalysisConsumptionRow + key={fluid} + fluid={fluid} + userPriceConsumption={userPriceConsumption} + homePriceConsumption={homePriceConsumption} + performanceValue={null} + forecast={forecast} + connected={false} + noData={true} + /> + ))} + + <Accordion + expanded={activeAverageHome} + onChange={toggleAccordion} + classes={{ + root: 'expansion-panel-root', + }} + > + <AccordionSummary + aria-label={t( + 'profile_type.accessibility.button_toggle_average_home' + )} + expandIcon={ + <Icon + icon={chevronDown} + size={16} + className="accordion-icon" + /> + } + classes={{ + root: 'expansion-panel-summary', + content: 'expansion-panel-content', + }} + > + <div className="accordion-title accordion-title"> + {t('analysis.average_home')} + </div> + </AccordionSummary> + <AccordionDetails + classes={{ + root: 'expansion-panel-details', + }} + > + <span className="accordion-desc text-16-normal"> + {t('analysis.average_home_description')} + </span> + </AccordionDetails> + </Accordion> + </> + )} + </div> </> ) diff --git a/src/components/Analysis/ElecHalfHourChart.spec.tsx b/src/components/Analysis/ElecHalfHourChart.spec.tsx index 8cb7b89ca..8cb417f25 100644 --- a/src/components/Analysis/ElecHalfHourChart.spec.tsx +++ b/src/components/Analysis/ElecHalfHourChart.spec.tsx @@ -4,7 +4,7 @@ import React from 'react' import * as reactRedux from 'react-redux' import { Provider } from 'react-redux' import configureStore from 'redux-mock-store' -import { dataLoadArray } from '../../../tests/__mocks__/datachartData.mock' +import { dataLoadArray } from '../../../tests/__mocks__/chartData.mock' import { globalStateData } from '../../../tests/__mocks__/globalStateData.mock' import ElecHalfHourChart from './ElecHalfHourChart' diff --git a/src/components/Analysis/MonthlyAnalysis.tsx b/src/components/Analysis/MonthlyAnalysis.tsx index f7490b959..da0110f45 100644 --- a/src/components/Analysis/MonthlyAnalysis.tsx +++ b/src/components/Analysis/MonthlyAnalysis.tsx @@ -119,18 +119,21 @@ const MonthlyAnalysis: React.FC<MonthlyAnalysisProps> = ({ <> <div className="analysis-content"> <div> - {fluidConfig.map((fluid, index) => { - return fluidTypes.includes(fluid.fluidTypeId) ? ( - <FluidPerformanceIndicator - key={index} - fluidType={fluid.fluidTypeId} - performanceIndicator={ - performanceIndicators[fluid.fluidTypeId] - } - date={analysisDate.minus({ month: 1 }).startOf('month')} - /> - ) : null - })} + {fluidConfig.map( + fluid => + fluidTypes.includes(fluid.fluidTypeId) && ( + <FluidPerformanceIndicator + key={fluid.konnectorConfig.slug} + fluidType={fluid.fluidTypeId} + performanceIndicator={ + performanceIndicators[fluid.fluidTypeId] + } + date={analysisDate + .minus({ month: 1 }) + .startOf('month')} + /> + ) + )} </div> </div> diff --git a/src/components/Analysis/TotalAnalysisChart.spec.tsx b/src/components/Analysis/TotalAnalysisChart.spec.tsx index 86e68adf0..e79e862b6 100644 --- a/src/components/Analysis/TotalAnalysisChart.spec.tsx +++ b/src/components/Analysis/TotalAnalysisChart.spec.tsx @@ -6,7 +6,7 @@ import { Datachart } from 'models' import React from 'react' import { act } from 'react-dom/test-utils' import { Provider } from 'react-redux' -import { graphMonthData } from '../../../tests/__mocks__/datachartData.mock' +import { graphMonthData } from '../../../tests/__mocks__/chartData.mock' import { createMockStore, mockInitialEcolyoState, diff --git a/src/components/App.tsx b/src/components/App.tsx index fd0b11c37..577bf36e4 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -2,8 +2,6 @@ import Navbar from 'components/Navbar/Navbar' import WelcomeModal from 'components/Onboarding/WelcomeModal' import AppRoutes from 'components/Routes/Routes' import SplashRoot from 'components/Splash/SplashRoot' -import SplashScreen from 'components/Splash/SplashScreen' -import SplashScreenError from 'components/Splash/SplashScreenError' import { Content, Layout, Main } from 'cozy-ui/transpiled/react/Layout' import React, { useEffect } from 'react' import { useSelector } from 'react-redux' @@ -26,10 +24,7 @@ export const App = ({ tracker }: AppProps) => { return ( <Layout> - <SplashRoot - splashComponent={SplashScreen} - splashErrorComponent={SplashScreenError} - > + <SplashRoot> {termsStatus.accepted && ( <> <WelcomeModal open={!onboarding.isWelcomeSeen} /> diff --git a/src/components/Challenge/ChallengeCard.tsx b/src/components/Challenge/ChallengeCard.tsx index 32ae1227f..5088f4347 100644 --- a/src/components/Challenge/ChallengeCard.tsx +++ b/src/components/Challenge/ChallengeCard.tsx @@ -14,7 +14,7 @@ interface ChallengeCardProps { index: number cardWidth: number cardHeight: number - isChallengeCardLast: boolean + isChallengeCardLast?: boolean moveToSlide: (slideIndex: number) => void } @@ -24,7 +24,7 @@ const ChallengeCard: React.FC<ChallengeCardProps> = ({ index, cardWidth, cardHeight, - isChallengeCardLast, + isChallengeCardLast = false, moveToSlide, }: ChallengeCardProps) => { const renderCard = (userChallenge: UserChallenge | undefined) => { diff --git a/src/components/Challenge/ChallengeCardOnGoing.tsx b/src/components/Challenge/ChallengeCardOnGoing.tsx index be9eb1452..db3d34996 100644 --- a/src/components/Challenge/ChallengeCardOnGoing.tsx +++ b/src/components/Challenge/ChallengeCardOnGoing.tsx @@ -38,7 +38,7 @@ const ChallengeCardOnGoing: React.FC<ChallengeCardOnGoingProps> = ({ const navigate = useNavigate() const [isOneFluidUp, setIsOneFluidUp] = useState<boolean>(true) const [challengeIcon, setChallengeIcon] = useState<string>(defaultIcon) - const [isDone, setisDone] = useState<boolean>(false) + const [isDone, setIsDone] = useState<boolean>(false) const [isLoading, setIsLoading] = useState<boolean>(false) const { challenge: { currentDataload }, @@ -113,7 +113,7 @@ const ChallengeCardOnGoing: React.FC<ChallengeCardOnGoingProps> = ({ currentDataload ) if (subscribed) { - setisDone(isChallengeDone.isDone) + setIsDone(isChallengeDone.isDone) } } const unlockDuel = async () => { diff --git a/src/components/Challenge/ChallengeView.tsx b/src/components/Challenge/ChallengeView.tsx index 49a0ee304..5f00edbfd 100644 --- a/src/components/Challenge/ChallengeView.tsx +++ b/src/components/Challenge/ChallengeView.tsx @@ -1,6 +1,6 @@ import LeftArrowIcon from 'assets/icons/ico/left-arrow.svg' import RightArrowIcon from 'assets/icons/ico/right-arrow.svg' -import StyledIconbutton from 'components/CommonKit/IconButton/StyledIconButton' +import StyledIconButton from 'components/CommonKit/IconButton/StyledIconButton' import Content from 'components/Content/Content' import CozyBar from 'components/Header/CozyBar' import Header from 'components/Header/Header' @@ -20,16 +20,16 @@ const ChallengeView: React.FC = () => { ) const marginPx = 16 - const cardWitdh = + const cardWidth = window.outerWidth < 500 ? window.outerWidth - marginPx * 6 : 285 const cardHeight = window.outerHeight * 0.6 const [headerHeight, setHeaderHeight] = useState<number>(0) const [touchStart, setTouchStart] = useState<number>() const [touchEnd, setTouchEnd] = useState<number>() - const [index, setindex] = useState<number>(0) - const [lastChallengeIndex, setlastChallengeIndex] = useState<number>(0) + const [index, setIndex] = useState<number>(0) + const [lastChallengeIndex, setLastChallengeIndex] = useState<number>(0) const [isLastDuelDone, setIsLastDuelDone] = useState<boolean>(false) - const [containerTranslation, setcontainerTranslation] = + const [containerTranslation, setContainerTranslation] = useState<number>(marginPx) const defineHeaderHeight = (height: number) => { setHeaderHeight(height) @@ -47,34 +47,34 @@ const ChallengeView: React.FC = () => { (isLastDuelDone && index < userChallengeList.length) ) { if (index === 0) - setcontainerTranslation( - (prev: number) => prev - cardWitdh - marginPx * 1.2 + setContainerTranslation( + (prev: number) => prev - cardWidth - marginPx * 1.2 ) else if (index >= 1) - setcontainerTranslation((prev: number) => prev - cardWitdh - marginPx) - else setcontainerTranslation((prev: number) => prev - cardWitdh) - setindex(prev => prev + 1) + setContainerTranslation((prev: number) => prev - cardWidth - marginPx) + else setContainerTranslation((prev: number) => prev - cardWidth) + setIndex(prev => prev + 1) } - }, [cardWitdh, index, userChallengeList.length]) + }, [cardWidth, index, userChallengeList.length]) const moveSliderLeft = useCallback(() => { if (index > 0) { if (index >= 1) - setcontainerTranslation((prev: number) => prev + cardWitdh + marginPx) - else setcontainerTranslation((prev: number) => prev + cardWitdh) - setindex(prev => prev - 1) + setContainerTranslation((prev: number) => prev + cardWidth + marginPx) + else setContainerTranslation((prev: number) => prev + cardWidth) + setIndex(prev => prev - 1) } if (index <= 1) { - setcontainerTranslation(marginPx) + setContainerTranslation(marginPx) } - }, [cardWitdh, index]) + }, [cardWidth, index]) const moveToSlide = useCallback( (slideIndex: number) => { - setcontainerTranslation(-slideIndex * (cardWitdh + marginPx) + marginPx) - setindex(slideIndex) + setContainerTranslation(-slideIndex * (cardWidth + marginPx) + marginPx) + setIndex(slideIndex) }, - [cardWitdh] + [cardWidth] ) // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -88,7 +88,7 @@ const ChallengeView: React.FC = () => { // if the swipe is too small and can be taken for a touch if (touchStart && touchEnd) { if (touchStart - touchEnd < 5 && -5 < touchStart - touchEnd) return - // Change the following value in order to change the swipe sensibilyy + // Change the following value in order to change the swipe sensibility if (touchStart - touchEnd > 75) { // If swipe left move slider right and add positive translation moveSliderRight() @@ -115,22 +115,22 @@ const ChallengeView: React.FC = () => { challenge.state === UserChallengeState.ONGOING || challenge.state === UserChallengeState.DUEL ) { - setlastChallengeIndex(i) + setLastChallengeIndex(i) if (lastChallengeIndex === 0) return else if (lastChallengeIndex === 1) { - setcontainerTranslation(0 - cardWitdh * lastChallengeIndex) + setContainerTranslation(0 - cardWidth * lastChallengeIndex) } else { - setcontainerTranslation( - 0 - cardWitdh * lastChallengeIndex - marginPx * 1.2 + setContainerTranslation( + 0 - cardWidth * lastChallengeIndex - marginPx * 1.2 ) } if (isLastDuelDone) { - setlastChallengeIndex(i + 1) + setLastChallengeIndex(i + 1) } - setindex(i) + setIndex(i) } }) - }, [userChallengeList, lastChallengeIndex, cardWitdh, isLastDuelDone]) + }, [userChallengeList, lastChallengeIndex, cardWidth, isLastDuelDone]) useEffect(() => { if ( @@ -167,13 +167,12 @@ const ChallengeView: React.FC = () => { > {userChallengeList.map((userChallenge, i) => ( <ChallengeCard - key={i} + key={userChallenge.id} userChallenge={userChallenge} indexSlider={index} index={i} - cardWidth={cardWitdh} + cardWidth={cardWidth} cardHeight={cardHeight} - isChallengeCardLast={false} moveToSlide={moveToSlide} /> ))} @@ -182,7 +181,7 @@ const ChallengeView: React.FC = () => { <ChallengeCard indexSlider={index} index={5} - cardWidth={cardWitdh} + cardWidth={cardWidth} cardHeight={cardHeight} isChallengeCardLast={true} moveToSlide={moveToSlide} @@ -191,13 +190,13 @@ const ChallengeView: React.FC = () => { </div> </div> <div className="sliderButtons"> - <StyledIconbutton + <StyledIconButton onClick={moveSliderLeft} icon={LeftArrowIcon} sized={16} aria-label={t('challenge.accessibility.button_slider_previous')} /> - <StyledIconbutton + <StyledIconButton onClick={moveSliderRight} icon={RightArrowIcon} sized={16} diff --git a/src/components/Challenge/StarsContainer.tsx b/src/components/Challenge/StarsContainer.tsx index 6e4bcedb4..ab6c67731 100644 --- a/src/components/Challenge/StarsContainer.tsx +++ b/src/components/Challenge/StarsContainer.tsx @@ -1,7 +1,7 @@ import starIcon from 'assets/icons/visu/challenge/star.svg' import starFilled from 'assets/icons/visu/challenge/starFilled.svg' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' -import React, { useEffect, useState } from 'react' +import React from 'react' interface StarsContainerProps { result: number @@ -12,30 +12,16 @@ const StarsContainer: React.FC<StarsContainerProps> = ({ result, isQuizBegin, }: StarsContainerProps) => { - const [elements] = useState<string[]>([]) - - useEffect(() => { - const renderStars = () => { - // To be removed when action and explorations will be done - if (result === 5) { - elements.splice(0, elements.length) - } - for (let i = 0; i < 5; i++) { - if (i < result) elements.push(starFilled) - else if (i >= result) elements.push(starIcon) - } - } - renderStars() - }, [result, elements]) + const maxStars = [1, 2, 3, 4, 5] return ( <div className="stars"> - {elements.map((star, i) => { + {maxStars.map(star => { return ( <StyledIcon - key={i} + key={star} className="star" - icon={star} + icon={result >= star ? starFilled : starIcon} size={isQuizBegin ? 25 : 15} /> ) diff --git a/src/components/Challenge/__snapshots__/ChallengeView.spec.tsx.snap b/src/components/Challenge/__snapshots__/ChallengeView.spec.tsx.snap index 487d01b85..3ddca6ea0 100644 --- a/src/components/Challenge/__snapshots__/ChallengeView.spec.tsx.snap +++ b/src/components/Challenge/__snapshots__/ChallengeView.spec.tsx.snap @@ -47,8 +47,7 @@ exports[`ChallengeView component should be rendered correctly 1`] = ` cardWidth={285} index={0} indexSlider={3} - isChallengeCardLast={false} - key="0" + key="CHALLENGE0001" moveToSlide={[Function]} userChallenge={ Object { @@ -199,8 +198,7 @@ exports[`ChallengeView component should be rendered correctly 1`] = ` cardWidth={285} index={1} indexSlider={3} - isChallengeCardLast={false} - key="1" + key="CHALLENGE0002" moveToSlide={[Function]} userChallenge={ Object { @@ -351,8 +349,7 @@ exports[`ChallengeView component should be rendered correctly 1`] = ` cardWidth={285} index={2} indexSlider={3} - isChallengeCardLast={false} - key="2" + key="CHALLENGE0003" moveToSlide={[Function]} userChallenge={ Object { @@ -503,8 +500,7 @@ exports[`ChallengeView component should be rendered correctly 1`] = ` cardWidth={285} index={3} indexSlider={3} - isChallengeCardLast={false} - key="3" + key="CHALLENGE0004" moveToSlide={[Function]} userChallenge={ Object { @@ -655,8 +651,7 @@ exports[`ChallengeView component should be rendered correctly 1`] = ` cardWidth={285} index={4} indexSlider={3} - isChallengeCardLast={false} - key="4" + key="CHALLENGE0005" moveToSlide={[Function]} userChallenge={ Object { @@ -807,8 +802,7 @@ exports[`ChallengeView component should be rendered correctly 1`] = ` cardWidth={285} index={5} indexSlider={3} - isChallengeCardLast={false} - key="5" + key="CHALLENGE0006" moveToSlide={[Function]} userChallenge={ Object { diff --git a/src/components/Charts/AxisBottom.spec.tsx b/src/components/Charts/AxisBottom.spec.tsx index 3ef8f579f..233093039 100644 --- a/src/components/Charts/AxisBottom.spec.tsx +++ b/src/components/Charts/AxisBottom.spec.tsx @@ -5,7 +5,7 @@ import { DateTime } from 'luxon' import React from 'react' import * as reactRedux from 'react-redux' import { Provider } from 'react-redux' -import { graphData } from '../../../tests/__mocks__/datachartData.mock' +import { graphData } from '../../../tests/__mocks__/chartData.mock' import { createMockStore, mockInitialEcolyoState, diff --git a/src/components/Charts/Bar.spec.tsx b/src/components/Charts/Bar.spec.tsx index 5c043ccc5..671f64325 100644 --- a/src/components/Charts/Bar.spec.tsx +++ b/src/components/Charts/Bar.spec.tsx @@ -7,7 +7,7 @@ import React from 'react' import * as reactRedux from 'react-redux' import { Provider } from 'react-redux' import * as chartActions from 'store/chart/chart.actions' -import { graphData } from '../../../tests/__mocks__/datachartData.mock' +import { graphData } from '../../../tests/__mocks__/chartData.mock' import { createMockStore, mockInitialEcolyoState, diff --git a/src/components/CommonKit/Card/StyledBorderCard.tsx b/src/components/CommonKit/Card/StyledBorderCard.tsx index f61f2d440..7f9a6a34d 100644 --- a/src/components/CommonKit/Card/StyledBorderCard.tsx +++ b/src/components/CommonKit/Card/StyledBorderCard.tsx @@ -14,13 +14,11 @@ const CardBase = withStyles({ margin: '1.25rem 0', cursor: 'default', }, -})(CardActionArea) +})(CardActionArea) as React.FC<StyledBorderCardProps> type StyledBorderCardProps = CardActionAreaProps -const StyledBorderCard: React.ComponentType<StyledBorderCardProps> = ({ - ...props -}: StyledBorderCardProps) => { +const StyledBorderCard = ({ ...props }: StyledBorderCardProps) => { return ( <CardBase {...props}> <CardContent>{props.children}</CardContent> diff --git a/src/components/CommonKit/Card/StyledCard.tsx b/src/components/CommonKit/Card/StyledCard.tsx index cdce326b6..c6a10c174 100644 --- a/src/components/CommonKit/Card/StyledCard.tsx +++ b/src/components/CommonKit/Card/StyledCard.tsx @@ -14,36 +14,37 @@ const CardBase = withStyles({ borderRadius: '4px', margin: '10px 0px 20px 0px', }, -})(CardActionArea) +})(CardActionArea) as React.FC<StyledCardProps> const CardElec = withStyles({ root: { border: '1px solid var(--elecColor40)', }, -})(CardBase) +})(CardBase) as React.FC<StyledCardProps> const CardWater = withStyles({ root: { border: '1px solid var(--waterColor40)', }, -})(CardBase) +})(CardBase) as React.FC<StyledCardProps> const CardGas = withStyles({ root: { border: '1px solid var(--gasColor40)', }, -})(CardBase) +})(CardBase) as React.FC<StyledCardProps> + const CardMulti = withStyles({ root: { border: '1px solid var( --greyDark)', }, -})(CardBase) +})(CardBase) as React.FC<StyledCardProps> const CardContentBase = withStyles({ root: { color: 'white', }, -})(CardContent) +})(CardContent) as React.FC<StyledCardProps> interface StyledCardProps extends CardActionAreaProps { fluidType?: FluidType @@ -56,10 +57,7 @@ const GenerateContentCard = ( return <CardContentBase>{children}</CardContentBase> } -const StyledCard: React.ComponentType<StyledCardProps> = ({ - fluidType, - ...props -}: StyledCardProps) => { +const StyledCard = ({ fluidType, ...props }: StyledCardProps) => { switch (fluidType) { case FluidType.ELECTRICITY: return ( diff --git a/src/components/CommonKit/Card/StyledEcogestureCard.spec.tsx b/src/components/CommonKit/Card/StyledEcogestureCard.spec.tsx index 10778e9ec..6b6aac0e0 100644 --- a/src/components/CommonKit/Card/StyledEcogestureCard.spec.tsx +++ b/src/components/CommonKit/Card/StyledEcogestureCard.spec.tsx @@ -8,7 +8,7 @@ describe('StyledEcogestureCard component test', () => { expect(wrapper.getElement()).toMatchSnapshot() }) - it('should render correclty new ecogesture StyledEcogestureCard with newEcogesture', () => { + it('should render correctly new ecogesture StyledEcogestureCard with newEcogesture', () => { const wrapper = mount(<StyledEcogestureCard newEcogesture={true} />) expect(wrapper.getElement()).toMatchSnapshot() }) diff --git a/src/components/CommonKit/Card/StyledEcogestureCard.tsx b/src/components/CommonKit/Card/StyledEcogestureCard.tsx index 0b7bb4aff..08fd62376 100644 --- a/src/components/CommonKit/Card/StyledEcogestureCard.tsx +++ b/src/components/CommonKit/Card/StyledEcogestureCard.tsx @@ -16,7 +16,7 @@ const CardBase = withStyles({ padding: '0.5rem 1rem', minHeight: '72px', }, -})(CardActionArea) +})(CardActionArea) as React.FC<StyledEcogestureCardProps> const CardNew = withStyles({ '@keyframes glowAnimation': { @@ -31,7 +31,7 @@ const CardNew = withStyles({ height: '100%', padding: 0, }, -})(CardBase) +})(CardBase) as React.FC<StyledEcogestureCardProps> const CardBlueBorderContentBase = withStyles({ root: { @@ -39,7 +39,8 @@ const CardBlueBorderContentBase = withStyles({ height: '100%', padding: 0, }, -})(CardBase) +})(CardBase) as React.FC<StyledEcogestureCardProps> + const CardChallengeBase = withStyles({ root: { height: '100%', @@ -48,7 +49,7 @@ const CardChallengeBase = withStyles({ alignItems: 'center', justifyContent: 'center', }, -})(CardContent) +})(CardContent) as React.FC<StyledEcogestureCardProps> const CardContentBase = withStyles({ root: { @@ -56,7 +57,7 @@ const CardContentBase = withStyles({ height: '100%', padding: 0, }, -})(CardContent) +})(CardContent) as React.FC<StyledEcogestureCardProps> interface StyledEcogestureCardProps extends CardActionAreaProps { border?: boolean @@ -67,7 +68,7 @@ const GenerateContentCard = (children: ReactNode): React.ReactFragment => { return <CardChallengeBase>{children}</CardChallengeBase> } -const StyledEcogestureCard: React.ComponentType<StyledEcogestureCardProps> = ({ +const StyledEcogestureCard = ({ border, newEcogesture, ...props diff --git a/src/components/CommonKit/Card/StyledIconCard.tsx b/src/components/CommonKit/Card/StyledIconCard.tsx index 5e879a5cd..58e6b8d4f 100644 --- a/src/components/CommonKit/Card/StyledIconCard.tsx +++ b/src/components/CommonKit/Card/StyledIconCard.tsx @@ -19,34 +19,34 @@ const CardBase = withStyles({ display: 'inline', margin: '0', }, -})(CardActionArea) +})(CardActionArea) as React.FC<StyledIconCardProps> const CardElec = withStyles({ root: { border: '1px solid var(--elecColor40)', }, -})(CardBase) +})(CardBase) as React.FC<StyledIconCardProps> const CardWater = withStyles({ root: { border: '1px solid var(--waterColor40)', }, -})(CardBase) +})(CardBase) as React.FC<StyledIconCardProps> const CardGas = withStyles({ root: { border: '1px solid var(--gasColor40)', }, -})(CardBase) +})(CardBase) as React.FC<StyledIconCardProps> const CardContentBase = withStyles({ root: { color: 'white', }, -})(CardContent) +})(CardContent) as React.FC<StyledIconCardProps> interface StyledIconCardProps extends CardActionAreaProps { - fluidType: FluidType + fluidType?: FluidType } const GenerateContentCard = ( @@ -73,10 +73,7 @@ const GenerateContentCard = ( ) } -const StyledIconCard: React.ComponentType<StyledIconCardProps> = ({ - fluidType, - ...props -}: StyledIconCardProps) => { +const StyledIconCard = ({ fluidType, ...props }: StyledIconCardProps) => { switch (fluidType) { case FluidType.ELECTRICITY: return ( diff --git a/src/components/CommonKit/Card/__snapshots__/StyledEcogestureCard.spec.tsx.snap b/src/components/CommonKit/Card/__snapshots__/StyledEcogestureCard.spec.tsx.snap index cde7efd3f..a370edbda 100644 --- a/src/components/CommonKit/Card/__snapshots__/StyledEcogestureCard.spec.tsx.snap +++ b/src/components/CommonKit/Card/__snapshots__/StyledEcogestureCard.spec.tsx.snap @@ -1,11 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`StyledEcogestureCard component test should render correclty new ecogesture StyledEcogestureCard with newEcogesture 1`] = ` -<StyledEcogestureCard - newEcogesture={true} -/> -`; - exports[`StyledEcogestureCard component test should render correctly border StyledEcogestureCard 1`] = `<StyledEcogestureCard />`; exports[`StyledEcogestureCard component test should render correctly border StyledEcogestureCard with border 1`] = ` @@ -13,3 +7,9 @@ exports[`StyledEcogestureCard component test should render correctly border Styl border={true} /> `; + +exports[`StyledEcogestureCard component test should render correctly new ecogesture StyledEcogestureCard with newEcogesture 1`] = ` +<StyledEcogestureCard + newEcogesture={true} +/> +`; diff --git a/src/components/CommonKit/IconButton/StyledIconBorderedButton.spec.tsx b/src/components/CommonKit/IconButton/StyledIconBorderedButton.spec.tsx index 8a703c146..1890bead1 100644 --- a/src/components/CommonKit/IconButton/StyledIconBorderedButton.spec.tsx +++ b/src/components/CommonKit/IconButton/StyledIconBorderedButton.spec.tsx @@ -10,7 +10,7 @@ describe('StyledIconBorderedButton component test', () => { it('should render correctly UnselectedIconButtonBase ', () => { const wrapper = shallow( - <StyledIconBorderedButton icon={mockProps.icon} size={mockProps.size} /> + <StyledIconBorderedButton icon={mockProps.icon} sized={mockProps.size} /> ) expect(wrapper.getElement()).toMatchSnapshot() @@ -20,7 +20,7 @@ describe('StyledIconBorderedButton component test', () => { const wrapper = shallow( <StyledIconBorderedButton icon={mockProps.icon} - size={mockProps.size} + sized={mockProps.size} selected={true} /> ) diff --git a/src/components/CommonKit/IconButton/StyledIconButton.spec.tsx b/src/components/CommonKit/IconButton/StyledIconButton.spec.tsx index c9a023fc4..d621190f2 100644 --- a/src/components/CommonKit/IconButton/StyledIconButton.spec.tsx +++ b/src/components/CommonKit/IconButton/StyledIconButton.spec.tsx @@ -10,7 +10,7 @@ describe('StyledIconButton component test', () => { } const wrapper = shallow( - <StyledIconButton icon={mockProps.icon} size={mockProps.size} /> + <StyledIconButton icon={mockProps.icon} sized={mockProps.size} /> ) expect(wrapper.getElement()).toMatchSnapshot() diff --git a/src/components/CommonKit/IconButton/__snapshots__/StyledIconBorderedButton.spec.tsx.snap b/src/components/CommonKit/IconButton/__snapshots__/StyledIconBorderedButton.spec.tsx.snap index e8691596e..55ffe0707 100644 --- a/src/components/CommonKit/IconButton/__snapshots__/StyledIconBorderedButton.spec.tsx.snap +++ b/src/components/CommonKit/IconButton/__snapshots__/StyledIconBorderedButton.spec.tsx.snap @@ -2,12 +2,10 @@ exports[`StyledIconBorderedButton component test should render correctly SelectedIconButtonBase 1`] = ` <React.Fragment> - <WithStyles(WithStyles(WithStyles(ForwardRef(IconButton)))) - size={20} - > + <WithStyles(WithStyles(WithStyles(ForwardRef(IconButton))))> <StyledIcon icon="icon" - size={16} + size={20} /> </WithStyles(WithStyles(WithStyles(ForwardRef(IconButton))))> </React.Fragment> @@ -15,12 +13,10 @@ exports[`StyledIconBorderedButton component test should render correctly Selecte exports[`StyledIconBorderedButton component test should render correctly UnselectedIconButtonBase 1`] = ` <React.Fragment> - <WithStyles(WithStyles(WithStyles(ForwardRef(IconButton)))) - size={20} - > + <WithStyles(WithStyles(WithStyles(ForwardRef(IconButton))))> <StyledIcon icon="icon" - size={16} + size={20} /> </WithStyles(WithStyles(WithStyles(ForwardRef(IconButton))))> </React.Fragment> diff --git a/src/components/CommonKit/IconButton/__snapshots__/StyledIconButton.spec.tsx.snap b/src/components/CommonKit/IconButton/__snapshots__/StyledIconButton.spec.tsx.snap index 5f194e789..f91cdd498 100644 --- a/src/components/CommonKit/IconButton/__snapshots__/StyledIconButton.spec.tsx.snap +++ b/src/components/CommonKit/IconButton/__snapshots__/StyledIconButton.spec.tsx.snap @@ -1,12 +1,10 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`StyledIconButton component test should render correctly StyledIconButton 1`] = ` -<WithStyles(WithStyles(ForwardRef(IconButton))) - size={15} -> +<WithStyles(WithStyles(ForwardRef(IconButton)))> <StyledIcon icon="icon" - size={16} + size={15} /> </WithStyles(WithStyles(ForwardRef(IconButton)))> `; diff --git a/src/components/CommonKit/Switch/StyledSwitch.tsx b/src/components/CommonKit/Switch/StyledSwitch.tsx index 9ffe2d19d..87535cd0b 100644 --- a/src/components/CommonKit/Switch/StyledSwitch.tsx +++ b/src/components/CommonKit/Switch/StyledSwitch.tsx @@ -29,7 +29,7 @@ const SwitchBase = withStyles({ marginLeft: 'initial', left: 0, }, -})(Switch) +})(Switch) as React.FC<StyledSwitchProps> const SwitchElec = withStyles({ switchBase: { @@ -41,7 +41,7 @@ const SwitchElec = withStyles({ }, checked: {}, track: {}, -})(SwitchBase) +})(SwitchBase) as React.FC<StyledSwitchProps> const SwitchWater = withStyles({ switchBase: { @@ -53,7 +53,7 @@ const SwitchWater = withStyles({ }, checked: {}, track: {}, -})(SwitchBase) +})(SwitchBase) as React.FC<StyledSwitchProps> const SwitchGas = withStyles({ switchBase: { @@ -65,16 +65,13 @@ const SwitchGas = withStyles({ }, checked: {}, track: {}, -})(SwitchBase) +})(SwitchBase) as React.FC<StyledSwitchProps> interface StyledSwitchProps extends SwitchProps { fluidType?: FluidType } -const StyledSwitch: React.ComponentType<StyledSwitchProps> = ({ - fluidType, - ...props -}: StyledSwitchProps) => { +const StyledSwitch = ({ fluidType, ...props }: StyledSwitchProps) => { if (fluidType !== undefined) { switch (fluidType) { case FluidType.ELECTRICITY: diff --git a/src/components/Connection/SGEConnect/__snapshots__/SgeConnectView.spec.tsx.snap b/src/components/Connection/SGEConnect/__snapshots__/SgeConnectView.spec.tsx.snap index f942fe396..cea387fbd 100644 --- a/src/components/Connection/SGEConnect/__snapshots__/SgeConnectView.spec.tsx.snap +++ b/src/components/Connection/SGEConnect/__snapshots__/SgeConnectView.spec.tsx.snap @@ -642,7 +642,6 @@ exports[`SgeConnectView component should be rendered correctly 1`] = ` "dataConsent": false, "firstName": "", "lastName": "", - "openSGEForm": false, "pdl": null, "pdlConfirm": false, "shouldLaunchAccount": false, diff --git a/src/components/Connection/SGEConnect/__snapshots__/SgeInit.spec.tsx.snap b/src/components/Connection/SGEConnect/__snapshots__/SgeInit.spec.tsx.snap index 8e4012899..9664ddc16 100644 --- a/src/components/Connection/SGEConnect/__snapshots__/SgeInit.spec.tsx.snap +++ b/src/components/Connection/SGEConnect/__snapshots__/SgeInit.spec.tsx.snap @@ -34,6 +34,7 @@ exports[`SgeInit component should be rendered correctly 1`] = ` "firstDataDate": "2019-09-01T00:00:00.000Z", "fluidType": 0, "lastDataDate": "2020-09-01T00:00:00.000Z", + "maintenance": false, "status": 0, } } diff --git a/src/components/Connection/SGEConnect/__snapshots__/StepAddress.spec.tsx.snap b/src/components/Connection/SGEConnect/__snapshots__/StepAddress.spec.tsx.snap index 26812fdf7..bffbbf9d0 100644 --- a/src/components/Connection/SGEConnect/__snapshots__/StepAddress.spec.tsx.snap +++ b/src/components/Connection/SGEConnect/__snapshots__/StepAddress.spec.tsx.snap @@ -23,7 +23,6 @@ exports[`StepAddress component should be rendered correctly 1`] = ` "dataConsent": false, "firstName": "", "lastName": "", - "openSGEForm": false, "pdl": null, "pdlConfirm": false, "shouldLaunchAccount": false, diff --git a/src/components/Connection/SGEConnect/__snapshots__/StepConsent.spec.tsx.snap b/src/components/Connection/SGEConnect/__snapshots__/StepConsent.spec.tsx.snap index b377c4e67..f5fd68d49 100644 --- a/src/components/Connection/SGEConnect/__snapshots__/StepConsent.spec.tsx.snap +++ b/src/components/Connection/SGEConnect/__snapshots__/StepConsent.spec.tsx.snap @@ -23,7 +23,6 @@ exports[`StepConsent component should be rendered correctly 1`] = ` "dataConsent": false, "firstName": "", "lastName": "", - "openSGEForm": false, "pdl": null, "pdlConfirm": false, "shouldLaunchAccount": false, diff --git a/src/components/Connection/SGEConnect/__snapshots__/StepIdentityAndPdl.spec.tsx.snap b/src/components/Connection/SGEConnect/__snapshots__/StepIdentityAndPdl.spec.tsx.snap index d02da53ca..171bb6590 100644 --- a/src/components/Connection/SGEConnect/__snapshots__/StepIdentityAndPdl.spec.tsx.snap +++ b/src/components/Connection/SGEConnect/__snapshots__/StepIdentityAndPdl.spec.tsx.snap @@ -23,7 +23,6 @@ exports[`StepIdentityAndPdl component should be rendered correctly 1`] = ` "dataConsent": false, "firstName": "", "lastName": "", - "openSGEForm": false, "pdl": null, "pdlConfirm": false, "shouldLaunchAccount": false, diff --git a/src/components/Connection/__snapshots__/Connection.spec.tsx.snap b/src/components/Connection/__snapshots__/Connection.spec.tsx.snap index 0dc42e448..3996b0f97 100644 --- a/src/components/Connection/__snapshots__/Connection.spec.tsx.snap +++ b/src/components/Connection/__snapshots__/Connection.spec.tsx.snap @@ -45,6 +45,7 @@ exports[`Connection component test should call EpglInit 1`] = ` "firstDataDate": "2019-09-01T00:00:00.000Z", "fluidType": 0, "lastDataDate": "2020-09-01T00:00:00.000Z", + "maintenance": false, "status": 200, } } @@ -84,6 +85,7 @@ exports[`Connection component test should call EpglInit 1`] = ` "firstDataDate": "2019-09-01T00:00:00.000Z", "fluidType": 0, "lastDataDate": "2020-09-01T00:00:00.000Z", + "maintenance": false, "status": 200, } } @@ -308,6 +310,7 @@ exports[`Connection component test should call GrdfInit 1`] = ` "firstDataDate": "2019-09-01T00:00:00.000Z", "fluidType": 2, "lastDataDate": "2020-09-01T00:00:00.000Z", + "maintenance": false, "status": 200, } } @@ -336,6 +339,7 @@ exports[`Connection component test should call GrdfInit 1`] = ` "firstDataDate": "2019-09-01T00:00:00.000Z", "fluidType": 2, "lastDataDate": "2020-09-01T00:00:00.000Z", + "maintenance": false, "status": 200, } } diff --git a/src/components/ConsumptionVisualizer/DataloadConsumptionVisualizer.spec.tsx b/src/components/ConsumptionVisualizer/DataloadConsumptionVisualizer.spec.tsx index b71bc2437..f332cd631 100644 --- a/src/components/ConsumptionVisualizer/DataloadConsumptionVisualizer.spec.tsx +++ b/src/components/ConsumptionVisualizer/DataloadConsumptionVisualizer.spec.tsx @@ -1,12 +1,14 @@ -import { FluidType } from 'enum/fluid.enum' import { mount } from 'enzyme' -import { Dataload } from 'models' import React from 'react' import { Provider } from 'react-redux' + +import { DataloadState } from 'enum/dataload.enum' +import { FluidType } from 'enum/fluid.enum' +import { Dataload } from 'models' import { BrowserRouter as Router } from 'react-router-dom' import configureStore from 'redux-mock-store' import UsageEventService from 'services/usageEvent.service' -import { baseDataLoad } from '../../../tests/__mocks__/datachartData.mock' +import { baseDataLoad } from '../../../tests/__mocks__/chartData.mock' import { mockInitialChartState, mockInitialEcolyoState, @@ -32,7 +34,11 @@ const dataLoadWithValueDetailEmpty: Dataload = { } const dataLoadWithValueDetail: Dataload = { ...baseDataLoad, - valueDetail: [0.612216, 0.675242, 0.6779610000000003], + valueDetail: [ + { state: DataloadState.VALID, value: 0.612216 }, + { state: DataloadState.VALID, value: 0.675242 }, + { state: DataloadState.VALID, value: 0.6779610000000003 }, + ], } describe('Dataload consumption visualizer component', () => { diff --git a/src/components/ConsumptionVisualizer/DataloadNoValue.spec.tsx b/src/components/ConsumptionVisualizer/DataloadNoValue.spec.tsx index 4594bec2e..8dff84828 100644 --- a/src/components/ConsumptionVisualizer/DataloadNoValue.spec.tsx +++ b/src/components/ConsumptionVisualizer/DataloadNoValue.spec.tsx @@ -4,7 +4,7 @@ import { mount } from 'enzyme' import toJson from 'enzyme-to-json' import { Dataload } from 'models' import React from 'react' -import { baseDataLoad } from '../../../tests/__mocks__/datachartData.mock' +import { baseDataLoad } from '../../../tests/__mocks__/chartData.mock' import DataloadNoValue from './DataloadNoValue' jest.mock('cozy-ui/transpiled/react/I18n', () => { diff --git a/src/components/ConsumptionVisualizer/DataloadSection.spec.tsx b/src/components/ConsumptionVisualizer/DataloadSection.spec.tsx index 2aab5fb6d..32f5bea21 100644 --- a/src/components/ConsumptionVisualizer/DataloadSection.spec.tsx +++ b/src/components/ConsumptionVisualizer/DataloadSection.spec.tsx @@ -4,7 +4,7 @@ import { mount } from 'enzyme' import toJson from 'enzyme-to-json' import { Dataload } from 'models' import React from 'react' -import { baseDataLoad } from '../../../tests/__mocks__/datachartData.mock' +import { baseDataLoad } from '../../../tests/__mocks__/chartData.mock' import DataloadSection from './DataloadSection' jest.mock('cozy-ui/transpiled/react/I18n', () => { diff --git a/src/components/ConsumptionVisualizer/DataloadSectionDetail.spec.tsx b/src/components/ConsumptionVisualizer/DataloadSectionDetail.spec.tsx index 25695cef1..677ebe1a5 100644 --- a/src/components/ConsumptionVisualizer/DataloadSectionDetail.spec.tsx +++ b/src/components/ConsumptionVisualizer/DataloadSectionDetail.spec.tsx @@ -4,7 +4,7 @@ import { mount } from 'enzyme' import toJson from 'enzyme-to-json' import { Dataload } from 'models' import React from 'react' -import { baseDataLoad } from '../../../tests/__mocks__/datachartData.mock' +import { baseDataLoad } from '../../../tests/__mocks__/chartData.mock' import DataloadSectionDetail from './DataloadSectionDetail' jest.mock('cozy-ui/transpiled/react/I18n', () => { diff --git a/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx b/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx index adef58b74..1604ac509 100644 --- a/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx +++ b/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx @@ -7,7 +7,7 @@ import React from 'react' import { baseDataLoad, baseMultiFluidDataLoad, -} from '../../../tests/__mocks__/datachartData.mock' +} from '../../../tests/__mocks__/chartData.mock' import DataloadSectionValue from './DataloadSectionValue' jest.mock('cozy-ui/transpiled/react/I18n', () => { diff --git a/src/components/ConsumptionVisualizer/InfoDataConsumptionVisualizer.spec.tsx b/src/components/ConsumptionVisualizer/InfoDataConsumptionVisualizer.spec.tsx index 4331448bb..a091b1877 100644 --- a/src/components/ConsumptionVisualizer/InfoDataConsumptionVisualizer.spec.tsx +++ b/src/components/ConsumptionVisualizer/InfoDataConsumptionVisualizer.spec.tsx @@ -7,7 +7,7 @@ import { Dataload } from 'models' import React from 'react' import * as reactRedux from 'react-redux' import { Provider } from 'react-redux' -import { baseDataLoad } from '../../../tests/__mocks__/datachartData.mock' +import { baseDataLoad } from '../../../tests/__mocks__/chartData.mock' import { createMockStore, mockInitialEcolyoState, diff --git a/src/components/Ecogesture/EcogestureCard.tsx b/src/components/Ecogesture/EcogestureCard.tsx index d0c502e2c..650846699 100644 --- a/src/components/Ecogesture/EcogestureCard.tsx +++ b/src/components/Ecogesture/EcogestureCard.tsx @@ -7,16 +7,16 @@ import React, { useEffect, useState } from 'react' import { Link as RouterLink } from 'react-router-dom' import { importIconById } from 'utils/utils' import './ecogestureCard.scss' -import EfficientyRating from './EfficientyRating' +import EfficiencyRating from './EfficiencyRating' interface EcogestureCardProps { ecogesture: Ecogesture - selectionCompleted: boolean + selectionCompleted?: boolean } const EcogestureCard: React.FC<EcogestureCardProps> = ({ ecogesture, - selectionCompleted, + selectionCompleted = false, }: EcogestureCardProps) => { const [ecogestureIcon, setEcogestureIcon] = useState<string>('') useEffect(() => { @@ -52,7 +52,7 @@ const EcogestureCard: React.FC<EcogestureCardProps> = ({ {ecogesture.shortName} </div> <div className="ec-content-efficiency"> - <EfficientyRating result={Math.round(ecogesture.efficiency)} /> + <EfficiencyRating result={Math.round(ecogesture.efficiency)} /> </div> </div> </div> diff --git a/src/components/Ecogesture/EcogestureEmptyList.spec.tsx b/src/components/Ecogesture/EcogestureEmptyList.spec.tsx index 09bfb0cc9..1ee33bdda 100644 --- a/src/components/Ecogesture/EcogestureEmptyList.spec.tsx +++ b/src/components/Ecogesture/EcogestureEmptyList.spec.tsx @@ -24,6 +24,7 @@ jest.mock('react-router-dom', () => ({ })) const mockStore = configureStore([]) const mockChangeTab = jest.fn() +const mockHandleClick = () => {} describe('EcogestureEmptyList component', () => { it('should be rendered correctly', () => { const store = mockStore({ @@ -38,6 +39,7 @@ describe('EcogestureEmptyList component', () => { setTab={mockChangeTab} isObjective={true} isSelectionDone={false} + handleReinitClick={mockHandleClick} /> </Provider> ) @@ -56,6 +58,7 @@ describe('EcogestureEmptyList component', () => { setTab={mockChangeTab} isObjective={false} isSelectionDone={true} + handleReinitClick={mockHandleClick} /> </Provider> ) @@ -75,6 +78,7 @@ describe('EcogestureEmptyList component', () => { setTab={mockChangeTab} isObjective={false} isSelectionDone={false} + handleReinitClick={mockHandleClick} /> </Provider> ) @@ -94,6 +98,7 @@ describe('EcogestureEmptyList component', () => { setTab={mockChangeTab} isObjective={false} isSelectionDone={true} + handleReinitClick={mockHandleClick} /> </Provider> ) @@ -115,6 +120,7 @@ describe('EcogestureEmptyList component', () => { setTab={mockChangeTab} isObjective={true} isSelectionDone={true} + handleReinitClick={mockHandleClick} /> </Provider> ) diff --git a/src/components/Ecogesture/EcogestureList.spec.tsx b/src/components/Ecogesture/EcogestureList.spec.tsx index ba1e99165..6d0e6b701 100644 --- a/src/components/Ecogesture/EcogestureList.spec.tsx +++ b/src/components/Ecogesture/EcogestureList.spec.tsx @@ -23,6 +23,7 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { jest.mock('components/Ecogesture/EcogestureCard', () => 'mock-ecogesturecard') const mockStore = configureStore([]) +const mockHandleReinit = () => {} describe('EcogesturesList component', () => { it('should be rendered correctly', async () => { @@ -40,6 +41,7 @@ describe('EcogesturesList component', () => { displaySelection={false} selectionTotal={0} selectionViewed={0} + handleReinitClick={mockHandleReinit} /> </BrowserRouter> </Provider> diff --git a/src/components/Ecogesture/EcogestureList.tsx b/src/components/Ecogesture/EcogestureList.tsx index 49e07606e..5b652f69e 100644 --- a/src/components/Ecogesture/EcogestureList.tsx +++ b/src/components/Ecogesture/EcogestureList.tsx @@ -5,7 +5,7 @@ import SortIcon from 'assets/icons/ico/sort.svg' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' import EcogestureCard from 'components/Ecogesture/EcogestureCard' import { useI18n } from 'cozy-ui/transpiled/react/I18n' -import { EcogestureStatus, Usage } from 'enum/ecogesture.enum' +import { Usage } from 'enum/ecogesture.enum' import { Ecogesture } from 'models' import React, { useState } from 'react' import { useNavigate } from 'react-router-dom' @@ -16,8 +16,7 @@ interface EcogestureListProps { displaySelection: boolean selectionTotal: number selectionViewed: number - index: number - handleReinitClick: () => void + handleReinitClick?: () => void } const EcogestureList: React.FC<EcogestureListProps> = ({ @@ -25,7 +24,6 @@ const EcogestureList: React.FC<EcogestureListProps> = ({ displaySelection, selectionTotal, selectionViewed, - index, handleReinitClick, }: EcogestureListProps) => { const { t } = useI18n() @@ -50,8 +48,8 @@ const EcogestureList: React.FC<EcogestureListProps> = ({ const filterEcogesture = (_ecogestures: Ecogesture[]) => { const filtered = _ecogestures .filter(ecogesture => Usage[ecogesture.usage] === activeFilter) - .map((ecogesture, index) => ( - <div key={index} className="ecogesture-list-item"> + .map(ecogesture => ( + <div key={ecogesture.id} className="ecogesture-list-item"> <EcogestureCard ecogesture={ecogesture} selectionCompleted={selectionViewed === selectionTotal} @@ -169,10 +167,10 @@ const EcogestureList: React.FC<EcogestureListProps> = ({ </div> <div className="ecogesture-content"> {list.length > 0 && activeFilter === Usage[Usage.ALL] - ? list.map((ecogesture, index) => ( + ? list.map(ecogesture => ( <EcogestureCard + key={ecogesture.id} ecogesture={ecogesture} - key={index} selectionCompleted={selectionViewed === selectionTotal} /> )) @@ -188,7 +186,7 @@ const EcogestureList: React.FC<EcogestureListProps> = ({ </div> </div> )} - {!displaySelection && index !== EcogestureStatus.ALL && ( + {!displaySelection && handleReinitClick && ( <button className="reinit-button" onClick={handleReinitClick}> <span>{t('ecogesture.reinit')}</span> </button> diff --git a/src/components/Ecogesture/EcogestureModal.tsx b/src/components/Ecogesture/EcogestureModal.tsx index 419d616a7..b5e5a3216 100644 --- a/src/components/Ecogesture/EcogestureModal.tsx +++ b/src/components/Ecogesture/EcogestureModal.tsx @@ -15,7 +15,7 @@ import { AppStore } from 'store' import { getPicto } from 'utils/picto' import { importIconById } from 'utils/utils' import './ecogestureModal.scss' -import EfficientyRating from './EfficientyRating' +import EfficiencyRating from './EfficiencyRating' interface EcogestureModalProps { open: boolean @@ -101,7 +101,7 @@ const EcogestureModal: React.FC<EcogestureModalProps> = ({ <span className="em-efficiency"> {t('ecogesture_modal.efficiency')} </span> - <EfficientyRating result={Math.round(ecogesture.efficiency)} /> + <EfficiencyRating result={Math.round(ecogesture.efficiency)} /> </div> <div className="em-picto-flow"> {ecogesture.fluidTypes.map((fluid, index) => ( diff --git a/src/components/Ecogesture/EcogestureView.tsx b/src/components/Ecogesture/EcogestureView.tsx index b31774935..7e3ce5e0a 100644 --- a/src/components/Ecogesture/EcogestureView.tsx +++ b/src/components/Ecogesture/EcogestureView.tsx @@ -7,7 +7,7 @@ import Header from 'components/Header/Header' import Loader from 'components/Loader/Loader' import { useClient } from 'cozy-client' import { useI18n } from 'cozy-ui/transpiled/react/I18n' -import { EcogestureStatus } from 'enum/ecogesture.enum' +import { EcogestureTab } from 'enum/ecogesture.enum' import { Ecogesture } from 'models' import { ProfileEcogesture } from 'models/profileEcogesture.model' import React, { useCallback, useEffect, useState } from 'react' @@ -24,20 +24,20 @@ import './ecogestureView.scss' interface TabPanelProps { children?: React.ReactNode - index: number + tab: EcogestureTab value: number } const TabPanel: React.FC<TabPanelProps> = ({ children, - index, + tab, value, }: TabPanelProps) => { return ( <div role="tabpanel" - hidden={value !== index} - id={`simple-tabpanel-${index}`} - aria-labelledby={`simple-tab-${index}`} + hidden={value !== tab} + id={`simple-tabpanel-${tab}`} + aria-labelledby={`simple-tab-${tab}`} > {children} </div> @@ -62,8 +62,8 @@ const EcogestureView: React.FC = () => { const { haveSeenEcogestureModal, isProfileEcogestureCompleted } = useSelector( (state: AppStore) => state.ecolyo.profile ) - const [tabValue, setTabValue] = useState<EcogestureStatus>( - tab ? parseInt(tab) : EcogestureStatus.OBJECTIVE + const [tabValue, setTabValue] = useState<EcogestureTab>( + tab ? parseInt(tab) : EcogestureTab.OBJECTIVE ) const navigate = useNavigate() const [isLoaded, setIsLoaded] = useState<boolean>(false) @@ -130,16 +130,19 @@ const EcogestureView: React.FC = () => { } }, []) - const getLabel = useCallback( - (_tab: number) => { + const getTabLabel = useCallback( + (tab: EcogestureTab) => { + const tabCounts = { + [EcogestureTab.OBJECTIVE]: objectiveEcogestureList.length, + [EcogestureTab.DOING]: doingEcogestureList.length, + [EcogestureTab.ALL]: allEcogestureList.length, + } + return ( <> - {t(`ecogesture.title_tab_${_tab}`)} + {t(`ecogesture.title_tab_${tab}`)} <br /> - {_tab === EcogestureStatus.OBJECTIVE && - `(${objectiveEcogestureList.length})`} - {_tab === EcogestureStatus.DOING && `(${doingEcogestureList.length})`} - {_tab === EcogestureStatus.ALL && `(${allEcogestureList.length})`} + {`(${tabCounts[tab]})`} </> ) }, @@ -205,31 +208,31 @@ const EcogestureView: React.FC = () => { centered={true} > <Tab - label={getLabel(EcogestureStatus.OBJECTIVE)} + label={getTabLabel(EcogestureTab.OBJECTIVE)} className={classNames('single-tab', { - ['active']: tabValue === EcogestureStatus.OBJECTIVE, + ['active']: tabValue === EcogestureTab.OBJECTIVE, })} - {...tabProps(EcogestureStatus.OBJECTIVE)} + {...tabProps(EcogestureTab.OBJECTIVE)} /> <Tab - label={getLabel(EcogestureStatus.DOING)} + label={getTabLabel(EcogestureTab.DOING)} className={classNames('single-tab', { - ['active']: tabValue === EcogestureStatus.DOING, + ['active']: tabValue === EcogestureTab.DOING, })} - {...tabProps(EcogestureStatus.DOING)} + {...tabProps(EcogestureTab.DOING)} /> <Tab - label={getLabel(EcogestureStatus.ALL)} + label={getTabLabel(EcogestureTab.ALL)} className={classNames('single-tab', { - ['active']: tabValue === EcogestureStatus.ALL, + ['active']: tabValue === EcogestureTab.ALL, })} - {...tabProps(EcogestureStatus.ALL)} + {...tabProps(EcogestureTab.ALL)} /> </Tabs> </Header> <Content height={headerHeight}> - <TabPanel value={tabValue} index={EcogestureStatus.OBJECTIVE}> + <TabPanel value={tabValue} tab={EcogestureTab.OBJECTIVE}> {isProfileEcogestureCompleted && (totalAvailable === totalViewed && objectiveEcogestureList.length === 0 ? ( @@ -245,7 +248,6 @@ const EcogestureView: React.FC = () => { displaySelection={totalAvailable !== totalViewed} selectionTotal={totalAvailable} selectionViewed={totalViewed} - index={EcogestureStatus.OBJECTIVE} handleReinitClick={handleReinitClick} /> ))} @@ -259,7 +261,7 @@ const EcogestureView: React.FC = () => { )} </TabPanel> - <TabPanel value={tabValue} index={EcogestureStatus.DOING}> + <TabPanel value={tabValue} tab={EcogestureTab.DOING}> {isProfileEcogestureCompleted && (totalAvailable === totalViewed && doingEcogestureList.length === 0 ? ( @@ -275,7 +277,6 @@ const EcogestureView: React.FC = () => { displaySelection={totalAvailable !== totalViewed} selectionTotal={totalAvailable} selectionViewed={totalViewed} - index={EcogestureStatus.DOING} handleReinitClick={handleReinitClick} /> ))} @@ -289,15 +290,13 @@ const EcogestureView: React.FC = () => { )} </TabPanel> - <TabPanel value={tabValue} index={EcogestureStatus.ALL}> + <TabPanel value={tabValue} tab={EcogestureTab.ALL}> {Boolean(allEcogestureList.length) && ( <EcogestureList list={allEcogestureList} displaySelection={false} selectionTotal={totalAvailable} selectionViewed={totalViewed} - index={EcogestureStatus.ALL} - handleReinitClick={handleReinitClick} /> )} </TabPanel> diff --git a/src/components/Ecogesture/EfficientyRating.spec.tsx b/src/components/Ecogesture/EfficiencyRating.spec.tsx similarity index 85% rename from src/components/Ecogesture/EfficientyRating.spec.tsx rename to src/components/Ecogesture/EfficiencyRating.spec.tsx index 9905357d1..4cf025b1f 100644 --- a/src/components/Ecogesture/EfficientyRating.spec.tsx +++ b/src/components/Ecogesture/EfficiencyRating.spec.tsx @@ -1,4 +1,4 @@ -import EfficientyRating from 'components/Ecogesture/EfficientyRating' +import EfficiencyRating from 'components/Ecogesture/EfficiencyRating' import { mount } from 'enzyme' import toJson from 'enzyme-to-json' import React from 'react' @@ -19,7 +19,7 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { const mockStore = configureStore([]) -describe('EfficientyRating component', () => { +describe('EfficiencyRating component', () => { it('should be rendered correctly', () => { const store = mockStore({ ecolyo: { @@ -29,7 +29,7 @@ describe('EfficientyRating component', () => { }) const wrapper = mount( <Provider store={store}> - <EfficientyRating result={3} /> + <EfficiencyRating result={3} /> </Provider> ) expect(toJson(wrapper)).toMatchSnapshot() diff --git a/src/components/Ecogesture/EfficiencyRating.tsx b/src/components/Ecogesture/EfficiencyRating.tsx new file mode 100644 index 000000000..1bb2adc7a --- /dev/null +++ b/src/components/Ecogesture/EfficiencyRating.tsx @@ -0,0 +1,23 @@ +import thunderEmpty from 'assets/icons/visu/thunderEmpty.svg' +import thunderFilled from 'assets/icons/visu/thunderFilled.svg' +import StyledIcon from 'components/CommonKit/Icon/StyledIcon' +import React from 'react' + +const EfficiencyRating = ({ result }: { result: number }) => { + const maxStars = [1, 2, 3, 4, 5] + + return ( + <div className="thunder"> + {maxStars.map(star => ( + <StyledIcon + key={star} + className="star" + icon={result >= star ? thunderFilled : thunderEmpty} + size={15} + /> + ))} + </div> + ) +} + +export default EfficiencyRating diff --git a/src/components/Ecogesture/EfficientyRating.tsx b/src/components/Ecogesture/EfficientyRating.tsx deleted file mode 100644 index caeb21a2d..000000000 --- a/src/components/Ecogesture/EfficientyRating.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import thunderEmpty from 'assets/icons/visu/thunderEmpty.svg' -import thunderFilled from 'assets/icons/visu/thunderFilled.svg' -import StyledIcon from 'components/CommonKit/Icon/StyledIcon' -import React from 'react' - -interface EfficientyRatingProps { - result: number -} - -const EfficientyRating: React.FC<EfficientyRatingProps> = ({ - result, -}: EfficientyRatingProps) => { - const maxStars = [1, 2, 3, 4, 5] - - return ( - <div className="thunder"> - {maxStars.map((number, i) => { - if (number <= result) - return ( - <StyledIcon - key={i} - className="star" - icon={thunderFilled} - size={15} - /> - ) - else - return ( - <StyledIcon - key={i} - className="star" - icon={thunderEmpty} - size={15} - /> - ) - })} - </div> - ) -} - -export default EfficientyRating diff --git a/src/components/Ecogesture/SingleEcogesture.spec.tsx b/src/components/Ecogesture/SingleEcogesture.spec.tsx index ce940c2a2..140a42012 100644 --- a/src/components/Ecogesture/SingleEcogesture.spec.tsx +++ b/src/components/Ecogesture/SingleEcogesture.spec.tsx @@ -37,8 +37,8 @@ jest.mock('utils/utils', () => { } }) -jest.mock('components/Ecogesture/EfficientyRating', () => () => ( - <div id="EfficientyRating" /> +jest.mock('components/Ecogesture/EfficiencyRating', () => () => ( + <div id="EfficiencyRating" /> )) jest.mock('components/Header/Header', () => () => <div id="Header" />) jest.mock('components/Header/CozyBar', () => () => <div id="CozyBar" />) diff --git a/src/components/Ecogesture/SingleEcogesture.tsx b/src/components/Ecogesture/SingleEcogesture.tsx index 58b9237fa..563ed8ca7 100644 --- a/src/components/Ecogesture/SingleEcogesture.tsx +++ b/src/components/Ecogesture/SingleEcogesture.tsx @@ -22,7 +22,7 @@ import { Location, useLocation, useNavigate, useParams } from 'react-router-dom' import EcogestureService from 'services/ecogesture.service' import { AppStore } from 'store' import { importIconById } from 'utils/utils' -import EfficientyRating from './EfficientyRating' +import EfficiencyRating from './EfficiencyRating' import './singleEcogesture.scss' interface EcogestureLocation extends Location { @@ -160,7 +160,7 @@ const SingleEcogesture: React.FC = () => { <span className="text text-14-normal"> {t('ecogesture_modal.efficiency')} </span> - <EfficientyRating result={Math.round(ecogesture.efficiency)} /> + <EfficiencyRating result={Math.round(ecogesture.efficiency)} /> </div> </div> <div className="styled-container"> diff --git a/src/components/Ecogesture/__snapshots__/EcogestureCard.spec.tsx.snap b/src/components/Ecogesture/__snapshots__/EcogestureCard.spec.tsx.snap index 255097ff6..ff294fcfb 100644 --- a/src/components/Ecogesture/__snapshots__/EcogestureCard.spec.tsx.snap +++ b/src/components/Ecogesture/__snapshots__/EcogestureCard.spec.tsx.snap @@ -90,7 +90,7 @@ exports[`EcogestureCard component should be rendered correctly 1`] = ` } state={ Object { - "selectionCompleted": undefined, + "selectionCompleted": false, } } to={ @@ -120,7 +120,7 @@ exports[`EcogestureCard component should be rendered correctly 1`] = ` } state={ Object { - "selectionCompleted": undefined, + "selectionCompleted": false, } } to={ @@ -143,7 +143,7 @@ exports[`EcogestureCard component should be rendered correctly 1`] = ` onFocus={[Function]} state={ Object { - "selectionCompleted": undefined, + "selectionCompleted": false, } } to={ @@ -201,7 +201,7 @@ exports[`EcogestureCard component should be rendered correctly 1`] = ` onFocus={[Function]} state={ Object { - "selectionCompleted": undefined, + "selectionCompleted": false, } } to={ @@ -217,7 +217,7 @@ exports[`EcogestureCard component should be rendered correctly 1`] = ` onFocus={[Function]} state={ Object { - "selectionCompleted": undefined, + "selectionCompleted": false, } } to={ @@ -328,7 +328,7 @@ exports[`EcogestureCard component should be rendered correctly 1`] = ` <div className="ec-content-efficiency" > - <EfficientyRating + <EfficiencyRating result={4} > <div @@ -337,7 +337,7 @@ exports[`EcogestureCard component should be rendered correctly 1`] = ` <Component className="star" icon="test-file-stub" - key="0" + key="1" size={15} > <div @@ -347,7 +347,7 @@ exports[`EcogestureCard component should be rendered correctly 1`] = ` <Component className="star" icon="test-file-stub" - key="1" + key="2" size={15} > <div @@ -357,7 +357,7 @@ exports[`EcogestureCard component should be rendered correctly 1`] = ` <Component className="star" icon="test-file-stub" - key="2" + key="3" size={15} > <div @@ -367,7 +367,7 @@ exports[`EcogestureCard component should be rendered correctly 1`] = ` <Component className="star" icon="test-file-stub" - key="3" + key="4" size={15} > <div @@ -377,7 +377,7 @@ exports[`EcogestureCard component should be rendered correctly 1`] = ` <Component className="star" icon="test-file-stub" - key="4" + key="5" size={15} > <div @@ -385,7 +385,7 @@ exports[`EcogestureCard component should be rendered correctly 1`] = ` /> </Component> </div> - </EfficientyRating> + </EfficiencyRating> </div> </div> </div> diff --git a/src/components/Ecogesture/__snapshots__/EcogestureEmptyList.spec.tsx.snap b/src/components/Ecogesture/__snapshots__/EcogestureEmptyList.spec.tsx.snap index 328305ab2..ac78b2c1e 100644 --- a/src/components/Ecogesture/__snapshots__/EcogestureEmptyList.spec.tsx.snap +++ b/src/components/Ecogesture/__snapshots__/EcogestureEmptyList.spec.tsx.snap @@ -14,6 +14,7 @@ exports[`EcogestureEmptyList component should be rendered correctly 1`] = ` } > <EcogestureEmptyList + handleReinitClick={[Function]} isObjective={true} isSelectionDone={false} setTab={[MockFunction]} diff --git a/src/components/Ecogesture/__snapshots__/EcogestureList.spec.tsx.snap b/src/components/Ecogesture/__snapshots__/EcogestureList.spec.tsx.snap index 2e84f2bcb..55fd93885 100644 --- a/src/components/Ecogesture/__snapshots__/EcogestureList.spec.tsx.snap +++ b/src/components/Ecogesture/__snapshots__/EcogestureList.spec.tsx.snap @@ -46,6 +46,7 @@ exports[`EcogesturesList component should be rendered correctly 1`] = ` > <EcogestureList displaySelection={false} + handleReinitClick={[Function]} list={ Array [ Object { @@ -100,7 +101,7 @@ exports[`EcogesturesList component should be rendered correctly 1`] = ` "id": "ECOGESTURE002", "impactLevel": 8, "investment": null, - "longDescription": "Cela permet de garder la fraicheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", + "longDescription": "Cela permet de garder la fraîcheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", "longName": "Je ferme mes fenêtres quand la climatisation est en marche", "objective": false, "room": Array [ @@ -1870,7 +1871,7 @@ exports[`EcogesturesList component should be rendered correctly 1`] = ` "viewedInSelection": false, } } - key="0" + key="ECOGESTURE001" selectionCompleted={true} /> <mock-ecogesturecard @@ -1896,7 +1897,7 @@ exports[`EcogesturesList component should be rendered correctly 1`] = ` "id": "ECOGESTURE002", "impactLevel": 8, "investment": null, - "longDescription": "Cela permet de garder la fraicheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", + "longDescription": "Cela permet de garder la fraîcheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", "longName": "Je ferme mes fenêtres quand la climatisation est en marche", "objective": false, "room": Array [ @@ -1908,7 +1909,7 @@ exports[`EcogesturesList component should be rendered correctly 1`] = ` "viewedInSelection": false, } } - key="1" + key="ECOGESTURE002" selectionCompleted={true} /> <mock-ecogesturecard @@ -1949,11 +1950,12 @@ exports[`EcogesturesList component should be rendered correctly 1`] = ` "viewedInSelection": false, } } - key="2" + key="ECOGESTURE0013" selectionCompleted={true} /> <button className="reinit-button" + onClick={[Function]} > <span> ecogesture.reinit diff --git a/src/components/Ecogesture/__snapshots__/EcogestureView.spec.tsx.snap b/src/components/Ecogesture/__snapshots__/EcogestureView.spec.tsx.snap index 6c9d81778..98a75e6b7 100644 --- a/src/components/Ecogesture/__snapshots__/EcogestureView.spec.tsx.snap +++ b/src/components/Ecogesture/__snapshots__/EcogestureView.spec.tsx.snap @@ -562,7 +562,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` height={0} > <TabPanel - index={0} + tab={0} value={0} > <div @@ -898,7 +898,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` </div> </TabPanel> <TabPanel - index={1} + tab={1} value={0} > <div @@ -1234,7 +1234,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` </div> </TabPanel> <TabPanel - index={2} + tab={2} value={0} > <div @@ -1245,8 +1245,6 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` > <mock-ecogesturelist displaySelection={false} - handleReinitClick={[Function]} - index={2} list={ Array [ Object { @@ -1301,7 +1299,7 @@ exports[`EcogestureView component should be rendered correctly 1`] = ` "id": "ECOGESTURE002", "impactLevel": 8, "investment": null, - "longDescription": "Cela permet de garder la fraicheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", + "longDescription": "Cela permet de garder la fraîcheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", "longName": "Je ferme mes fenêtres quand la climatisation est en marche", "objective": false, "room": Array [ diff --git a/src/components/Ecogesture/__snapshots__/EfficientyRating.spec.tsx.snap b/src/components/Ecogesture/__snapshots__/EfficiencyRating.spec.tsx.snap similarity index 97% rename from src/components/Ecogesture/__snapshots__/EfficientyRating.spec.tsx.snap rename to src/components/Ecogesture/__snapshots__/EfficiencyRating.spec.tsx.snap index 596e41d6d..005c98b34 100644 --- a/src/components/Ecogesture/__snapshots__/EfficientyRating.spec.tsx.snap +++ b/src/components/Ecogesture/__snapshots__/EfficiencyRating.spec.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`EfficientyRating component should be rendered correctly 1`] = ` +exports[`EfficiencyRating component should be rendered correctly 1`] = ` <Provider store={ Object { @@ -13,7 +13,7 @@ exports[`EfficientyRating component should be rendered correctly 1`] = ` } } > - <EfficientyRating + <EfficiencyRating result={3} > <div @@ -22,7 +22,7 @@ exports[`EfficientyRating component should be rendered correctly 1`] = ` <StyledIcon className="star" icon="test-file-stub" - key="0" + key="1" size={15} > <Icon @@ -56,7 +56,7 @@ exports[`EfficientyRating component should be rendered correctly 1`] = ` <StyledIcon className="star" icon="test-file-stub" - key="1" + key="2" size={15} > <Icon @@ -90,7 +90,7 @@ exports[`EfficientyRating component should be rendered correctly 1`] = ` <StyledIcon className="star" icon="test-file-stub" - key="2" + key="3" size={15} > <Icon @@ -124,7 +124,7 @@ exports[`EfficientyRating component should be rendered correctly 1`] = ` <StyledIcon className="star" icon="test-file-stub" - key="3" + key="4" size={15} > <Icon @@ -158,7 +158,7 @@ exports[`EfficientyRating component should be rendered correctly 1`] = ` <StyledIcon className="star" icon="test-file-stub" - key="4" + key="5" size={15} > <Icon @@ -190,6 +190,6 @@ exports[`EfficientyRating component should be rendered correctly 1`] = ` </Icon> </StyledIcon> </div> - </EfficientyRating> + </EfficiencyRating> </Provider> `; diff --git a/src/components/Ecogesture/__snapshots__/SingleEcogesture.spec.tsx.snap b/src/components/Ecogesture/__snapshots__/SingleEcogesture.spec.tsx.snap index 075ec115c..2eb812c6f 100644 --- a/src/components/Ecogesture/__snapshots__/SingleEcogesture.spec.tsx.snap +++ b/src/components/Ecogesture/__snapshots__/SingleEcogesture.spec.tsx.snap @@ -64,7 +64,7 @@ exports[`SingleEcogesture component should be rendered correctly 1`] = ` result={4} > <div - id="EfficientyRating" + id="EfficiencyRating" /> </Component> </div> diff --git a/src/components/EcogestureForm/EcogestureFormEquipment.tsx b/src/components/EcogestureForm/EcogestureFormEquipment.tsx index 654b26d15..be3df67a9 100644 --- a/src/components/EcogestureForm/EcogestureFormEquipment.tsx +++ b/src/components/EcogestureForm/EcogestureFormEquipment.tsx @@ -101,26 +101,24 @@ const EcogestureFormEquipment: React.FC<EcogestureFormEquipmentProps> = ({ )} </div> <div className="icons-container"> - {Object.values(EquipmentType).map((equipment, index) => { - return ( - <label key={index} className={'checkbox-equipment'}> - <input - type={'checkbox'} - value={equipment} - name={equipment.toString()} - onChange={() => handleChange(equipment)} - checked={isChecked(equipment)} - className={ - isChecked(equipment) ? 'item-eq checked' : 'item-eq' - } - /> - <EquipmentIcon - equipment={equipment} - isChecked={answer.includes(equipment)} - /> - </label> - ) - })} + {Object.values(EquipmentType).map(equipment => ( + <label key={equipment} className={'checkbox-equipment'}> + <input + type={'checkbox'} + value={equipment} + name={equipment.toString()} + onChange={() => handleChange(equipment)} + checked={isChecked(equipment)} + className={ + isChecked(equipment) ? 'item-eq checked' : 'item-eq' + } + /> + <EquipmentIcon + equipment={equipment} + isChecked={answer.includes(equipment)} + /> + </label> + ))} </div> </div> </div> @@ -128,7 +126,7 @@ const EcogestureFormEquipment: React.FC<EcogestureFormEquipmentProps> = ({ step={step} handlePrevious={handlePrevious} handleNext={handleNext} - disableNextButton={answer === []} + disableNextButton={answer.length == 0} isEcogesture={true} /> </> diff --git a/src/components/EcogestureForm/__snapshots__/EcogestureFormEquipment.spec.tsx.snap b/src/components/EcogestureForm/__snapshots__/EcogestureFormEquipment.spec.tsx.snap index ddc81916d..3d438e9ef 100644 --- a/src/components/EcogestureForm/__snapshots__/EcogestureFormEquipment.spec.tsx.snap +++ b/src/components/EcogestureForm/__snapshots__/EcogestureFormEquipment.spec.tsx.snap @@ -47,7 +47,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` > <label className="checkbox-equipment" - key="0" + key="AIR_CONDITIONING" > <input checked={false} @@ -64,7 +64,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </label> <label className="checkbox-equipment" - key="1" + key="COMPUTER" > <input checked={false} @@ -81,7 +81,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </label> <label className="checkbox-equipment" - key="2" + key="MICROWAVE" > <input checked={false} @@ -98,7 +98,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </label> <label className="checkbox-equipment" - key="3" + key="WASHING_MACHINE" > <input checked={false} @@ -115,7 +115,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </label> <label className="checkbox-equipment" - key="4" + key="DISHWASHER" > <input checked={false} @@ -132,7 +132,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </label> <label className="checkbox-equipment" - key="5" + key="COOKING_PLATES" > <input checked={false} @@ -149,7 +149,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </label> <label className="checkbox-equipment" - key="6" + key="DRYER" > <input checked={false} @@ -166,7 +166,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </label> <label className="checkbox-equipment" - key="7" + key="REFREGIRATOR" > <input checked={false} @@ -183,7 +183,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </label> <label className="checkbox-equipment" - key="8" + key="FAN" > <input checked={false} @@ -200,7 +200,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </label> <label className="checkbox-equipment" - key="9" + key="CURTAIN" > <input checked={false} @@ -217,7 +217,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </label> <label className="checkbox-equipment" - key="10" + key="INTERNET_BOX" > <input checked={false} @@ -234,7 +234,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </label> <label className="checkbox-equipment" - key="11" + key="VENTILATION" > <input checked={false} @@ -251,7 +251,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </label> <label className="checkbox-equipment" - key="12" + key="FREEZER" > <input checked={false} @@ -268,7 +268,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </label> <label className="checkbox-equipment" - key="13" + key="BOILER" > <input checked={false} @@ -285,7 +285,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </label> <label className="checkbox-equipment" - key="14" + key="HYDRAULIC_HEATING" > <input checked={false} @@ -304,7 +304,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </div> </div> <FormNavigation - disableNextButton={false} + disableNextButton={true} handleNext={[Function]} handlePrevious={[Function]} isEcogesture={true} @@ -422,19 +422,19 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` </WithStyles(ForwardRef(Button))> <WithStyles(ForwardRef(Button)) aria-label="profile_type.accessibility.button_next" - className="profile-navigation-button" + className="profile-navigation-button disabled" classes={ Object { "label": "text-16-bold", "root": "btn-profile-next", } } - disabled={false} + disabled={true} onClick={[Function]} > <ForwardRef(Button) aria-label="profile_type.accessibility.button_next" - className="profile-navigation-button" + className="profile-navigation-button disabled" classes={ Object { "colorInherit": "MuiButton-colorInherit", @@ -468,14 +468,14 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` "textSizeSmall": "MuiButton-textSizeSmall", } } - disabled={false} + disabled={true} onClick={[Function]} > <WithStyles(ForwardRef(ButtonBase)) aria-label="profile_type.accessibility.button_next" - className="MuiButton-root btn-profile-next MuiButton-text profile-navigation-button" + className="MuiButton-root btn-profile-next MuiButton-text profile-navigation-button disabled Mui-disabled" component="button" - disabled={false} + disabled={true} focusRipple={true} focusVisibleClassName="Mui-focusVisible" onClick={[Function]} @@ -483,7 +483,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` > <ForwardRef(ButtonBase) aria-label="profile_type.accessibility.button_next" - className="MuiButton-root btn-profile-next MuiButton-text profile-navigation-button" + className="MuiButton-root btn-profile-next MuiButton-text profile-navigation-button disabled Mui-disabled" classes={ Object { "disabled": "Mui-disabled", @@ -492,7 +492,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` } } component="button" - disabled={false} + disabled={true} focusRipple={true} focusVisibleClassName="Mui-focusVisible" onClick={[Function]} @@ -500,8 +500,8 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` > <button aria-label="profile_type.accessibility.button_next" - className="MuiButtonBase-root MuiButton-root btn-profile-next MuiButton-text profile-navigation-button" - disabled={false} + className="MuiButtonBase-root MuiButton-root btn-profile-next MuiButton-text profile-navigation-button disabled Mui-disabled Mui-disabled" + disabled={true} onBlur={[Function]} onClick={[Function]} onDragLeave={[Function]} @@ -514,7 +514,7 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` onTouchEnd={[Function]} onTouchMove={[Function]} onTouchStart={[Function]} - tabIndex={0} + tabIndex={-1} type="button" > <span @@ -522,34 +522,6 @@ exports[`EcogestureFormEquipment component should be rendered correctly 1`] = ` > profile_type.form.button_next > </span> - <WithStyles(memo) - center={false} - > - <ForwardRef(TouchRipple) - center={false} - classes={ - Object { - "child": "MuiTouchRipple-child", - "childLeaving": "MuiTouchRipple-childLeaving", - "childPulsate": "MuiTouchRipple-childPulsate", - "ripple": "MuiTouchRipple-ripple", - "ripplePulsate": "MuiTouchRipple-ripplePulsate", - "rippleVisible": "MuiTouchRipple-rippleVisible", - "root": "MuiTouchRipple-root", - } - } - > - <span - className="MuiTouchRipple-root" - > - <TransitionGroup - childFactory={[Function]} - component={null} - exit={true} - /> - </span> - </ForwardRef(TouchRipple)> - </WithStyles(memo)> </button> </ForwardRef(ButtonBase)> </WithStyles(ForwardRef(ButtonBase))> diff --git a/src/components/EcogestureForm/ecogestureFormSingleChoice.scss b/src/components/EcogestureForm/ecogestureFormSingleChoice.scss index 1afea74c1..93360c88e 100644 --- a/src/components/EcogestureForm/ecogestureFormSingleChoice.scss +++ b/src/components/EcogestureForm/ecogestureFormSingleChoice.scss @@ -2,7 +2,6 @@ @import '../../styles/base/breakpoint'; .ecogesture-profile-container { - overflow-y: scroll; display: flex; flex-direction: column; flex: 1; diff --git a/src/components/Header/CozyBar.tsx b/src/components/Header/CozyBar.tsx index eae7de645..6fbac78f5 100644 --- a/src/components/Header/CozyBar.tsx +++ b/src/components/Header/CozyBar.tsx @@ -9,6 +9,14 @@ import { useNavigate } from 'react-router-dom' import { AppStore } from 'store' import { updateModalIsFeedbacksOpen } from 'store/modal/modal.actions' +declare const cozy: { + bar: { + BarLeft: Function + BarCenter: Function + BarRight: Function + } +} + interface CozyBarProps { titleKey?: string displayBackArrow?: boolean diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index 7cdf129ee..049abd6eb 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -30,7 +30,7 @@ const Header: React.FC<HeaderProps> = ({ }) => { const { t } = useI18n() const navigate = useNavigate() - const header = useRef(null) + const header = useRef<HTMLDivElement>(null) const dispatch = useDispatch() const { screenType } = useSelector((state: AppStore) => state.ecolyo.global) @@ -49,13 +49,9 @@ const Header: React.FC<HeaderProps> = ({ } useEffect(() => { - if (screenType === ScreenType.MOBILE) { - setHeaderHeight( - header.current ? header.current.clientHeight - cozyBarHeight : 0 - ) - } else { - setHeaderHeight(header.current ? header.current.clientHeight : 0) - } + const headerHeight = header.current?.clientHeight || 0 + const adjustment = screenType === ScreenType.MOBILE ? cozyBarHeight : 0 + setHeaderHeight(headerHeight - adjustment) }, [screenType, children, setHeaderHeight]) return ( diff --git a/src/components/Home/FluidButtons.tsx b/src/components/Home/FluidButtons.tsx index bb70374f3..6a4d6ce5b 100644 --- a/src/components/Home/FluidButtons.tsx +++ b/src/components/Home/FluidButtons.tsx @@ -19,9 +19,9 @@ const FluidButtons: React.FC<FluidButtonsProps> = ({ return ( <div className="fluid-buttons"> <div className="content"> - {orderedFluids.map((fluid, key) => ( + {orderedFluids.map(fluid => ( <FluidButton - key={key} + key={fluid} isActive={activeFluid === fluid} fluidType={fluid} /> diff --git a/src/components/Home/ReleaseNotesModal.tsx b/src/components/Home/ReleaseNotesModal.tsx index 507f38650..cc64fcf1b 100644 --- a/src/components/Home/ReleaseNotesModal.tsx +++ b/src/components/Home/ReleaseNotesModal.tsx @@ -47,8 +47,8 @@ const ReleaseNotesModal: React.FC<ReleaseNotesModalProps> = ({ </div> <div className="release-note-message text-16-normal"> {releaseNotes.notes.length > 0 && - releaseNotes.notes.map((note, index) => ( - <div key={index} className="release-note-part"> + releaseNotes.notes.map(note => ( + <div key={note.title} className="release-note-part"> <div className="release-note-message text-16-bold"> {note.title} </div> diff --git a/src/components/Konnector/KonnectorModal.tsx b/src/components/Konnector/KonnectorModal.tsx index ea098e2d3..017909438 100644 --- a/src/components/Konnector/KonnectorModal.tsx +++ b/src/components/Konnector/KonnectorModal.tsx @@ -63,7 +63,7 @@ const KonnectorModal: React.FC<KonnectorModalProps> = ({ <div className="kmodal-waiting-text text-18-italic"> {shuffledWaitingTexts.map((text, idx) => ( <div - key={idx} + key={text.second} className={classNames('waiting-text', { ['show']: idx === index % shuffledWaitingTexts.length, })} @@ -84,7 +84,7 @@ const KonnectorModal: React.FC<KonnectorModalProps> = ({ ) : ( firstConnectionWaitingTexts.map((text, idx) => ( <div - key={idx} + key={text.second} className={classNames('waiting-text', { ['show']: idx === index % firstConnectionWaitingTexts.length, })} diff --git a/src/components/Konnector/KonnectorModalFooter.spec.tsx b/src/components/Konnector/KonnectorModalFooter.spec.tsx index 19c858bc6..3665d47b1 100644 --- a/src/components/Konnector/KonnectorModalFooter.spec.tsx +++ b/src/components/Konnector/KonnectorModalFooter.spec.tsx @@ -4,8 +4,10 @@ import { FluidType } from 'enum/fluid.enum' import { KonnectorError } from 'enum/konnectorError.enum' import { mount } from 'enzyme' import toJson from 'enzyme-to-json' +import { GlobalState } from 'models' import React from 'react' import { Provider } from 'react-redux' +import { MockStoreEnhanced } from 'redux-mock-store' import { accountsData } from '../../../tests/__mocks__/accountsData.mock' import { createMockStore, diff --git a/src/components/Konnector/__snapshots__/KonnectorModal.spec.tsx.snap b/src/components/Konnector/__snapshots__/KonnectorModal.spec.tsx.snap index 4e833e5a8..7e78bb723 100644 --- a/src/components/Konnector/__snapshots__/KonnectorModal.spec.tsx.snap +++ b/src/components/Konnector/__snapshots__/KonnectorModal.spec.tsx.snap @@ -491,7 +491,7 @@ exports[`KonnectorModal component should be rendered correctly 1`] = ` Le saviez-vous ? </p> <p> - Pour acheminer l’eau sur Lyon (Lugdunum !) l’acqueduc de Gier faisait 86 km à l’époque Romaine ! + Pour acheminer l’eau sur Lyon (Lugdunum !) l’aqueduc de Gier faisait 86 km à l’époque Romaine ! </p> </div> <div @@ -825,7 +825,7 @@ exports[`KonnectorModal component should be rendered correctly 1`] = ` > <div className="waiting-text show" - key="0" + key="" > <p> La première fois cela peut prendre quelques minutes, par la suite, seulement quelques secondes. @@ -834,7 +834,7 @@ exports[`KonnectorModal component should be rendered correctly 1`] = ` </div> <div className="waiting-text" - key="1" + key="" > <p> Afin de limiter le temps de ce premier chargement, un historique réduit de vos consommations va être chargé. Vous aurez tout de même accès à un an d'historique dès à présent. @@ -843,7 +843,7 @@ exports[`KonnectorModal component should be rendered correctly 1`] = ` </div> <div className="waiting-text" - key="2" + key="" > <p> Demain matin, vous aurez accès à l'ensemble de vos données (jusqu'à trois ans d'historique). @@ -852,18 +852,18 @@ exports[`KonnectorModal component should be rendered correctly 1`] = ` </div> <div className="waiting-text" - key="3" + key="Pour acheminer l’eau sur Lyon (Lugdunum !) l’aqueduc de Gier faisait 86 km à l’époque Romaine !" > <p> Le saviez-vous ? </p> <p> - Pour acheminer l’eau sur Lyon (Lugdunum !) l’acqueduc de Gier faisait 86 km à l’époque Romaine ! + Pour acheminer l’eau sur Lyon (Lugdunum !) l’aqueduc de Gier faisait 86 km à l’époque Romaine ! </p> </div> <div className="waiting-text" - key="4" + key="♪♪" > <p> Rien que de l’eau, de l’eau de pluie, de l’eau de la Métroooooo @@ -874,7 +874,7 @@ exports[`KonnectorModal component should be rendered correctly 1`] = ` </div> <div className="waiting-text" - key="5" + key="Environ 90% de notre électricité provient de centrales de production hors de notre métropole." > <p> Le saviez-vous ? @@ -885,7 +885,7 @@ exports[`KonnectorModal component should be rendered correctly 1`] = ` </div> <div className="waiting-text" - key="6" + key="Avec Ecolyo c’est l’eau AVEC le gaz." > <p> « Il y a de l’eau dans le gaz » … @@ -896,7 +896,7 @@ exports[`KonnectorModal component should be rendered correctly 1`] = ` </div> <div className="waiting-text" - key="7" + key="La consommation énergétique résidentielle représente environ 30% de la consommation énergétique totale de notre territoire." > <p> Le saviez-vous ? @@ -907,7 +907,7 @@ exports[`KonnectorModal component should be rendered correctly 1`] = ` </div> <div className="waiting-text" - key="8" + key="La Métropole de Lyon a été territoire d’expérimentation Linky. Le compteur est présent sur notre territoire depuis plus de 10 ans !" > <p> Le saviez-vous ? @@ -918,7 +918,7 @@ exports[`KonnectorModal component should be rendered correctly 1`] = ` </div> <div className="waiting-text" - key="9" + key="10 minutes d'aération par jour permettent à notre habitat d’être plus sain, avec un air renouvelé, moins de polluants et l’évacuation de l’humidité qui stagne et qui nous oblige à consommer plus de chauffage." > <p> Le saviez-vous ? @@ -929,7 +929,7 @@ exports[`KonnectorModal component should be rendered correctly 1`] = ` </div> <div className="waiting-text" - key="10" + key="2°C ! C’est la différence qu’on peut mesurer dans une rue bien arborée en comparaison d’une rue vide : la végétation est donc cruciale pour le bien être en ville l’été et pour limiter l’installation des climatiseurs." > <p> Le saviez-vous ? @@ -940,7 +940,7 @@ exports[`KonnectorModal component should be rendered correctly 1`] = ` </div> <div className="waiting-text" - key="11" + key="Le saviez-vous ? La loi énergie climat de 2019 impose que d’ici 2025, les bâtiments privés résidentiels les plus énergivores soient tous rénovés !" > <p> Il y a les bonnes pratiques de consommations énergétiques (et Ecolyo est là pour cela !) mais aussi et bien sûr, la rénovation. diff --git a/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.spec.tsx b/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.spec.tsx index 99104e658..5189e961c 100644 --- a/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.spec.tsx +++ b/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.spec.tsx @@ -70,11 +70,11 @@ describe('ProfileTypeOptions component', () => { ) expect(wrapper.find('.profile-container').exists()).toBeTruthy() }) - it('should be rendered when housing_type = appartment', () => { + it('should be rendered when housing_type = apartment', () => { const profileTypeCompleted = { ...profileData } const profileTypeData = { ...mockProfileType } profileTypeCompleted.isProfileTypeCompleted = true - profileTypeData.housingType = HousingType.APPARTMENT + profileTypeData.housingType = HousingType.APARTMENT const store = mockStore({ ecolyo: { profile: profileTypeCompleted, @@ -97,7 +97,7 @@ describe('ProfileTypeOptions component', () => { profileTypeData.heating = IndividualOrCollective.INDIVIDUAL profileTypeCompleted.isProfileTypeCompleted = true - profileTypeData.housingType = HousingType.APPARTMENT + profileTypeData.housingType = HousingType.APARTMENT profileTypeData.hasInstalledVentilation = ThreeChoicesAnswer.YES profileTypeData.hasReplacedHeater = ThreeChoicesAnswer.YES const store = mockStore({ @@ -121,7 +121,7 @@ describe('ProfileTypeOptions component', () => { const profileTypeData = { ...mockProfileType } profileTypeCompleted.isProfileTypeCompleted = true - profileTypeData.housingType = HousingType.APPARTMENT + profileTypeData.housingType = HousingType.APARTMENT profileTypeData.individualInsulationWork = [ IndividualInsulationWork.ROOF_INSULATION, IndividualInsulationWork.WINDOW_REPLACEMENT, diff --git a/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.tsx b/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.tsx index b43d907b8..b41aa5dc6 100644 --- a/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.tsx +++ b/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.tsx @@ -107,7 +107,7 @@ const ProfileTypeOptions: React.FC = () => { ? t('profile_type.occupantsNumber.multi') : t('profile_type.occupantsNumber.single')} </div> - {profileType.housingType === HousingType.APPARTMENT && ( + {profileType.housingType === HousingType.APARTMENT && ( <div className="value floor"> {t(`profile_type.floor.${profileType.floor}`)} </div> @@ -172,17 +172,13 @@ const ProfileTypeOptions: React.FC = () => { {t(`profile_type.hot_water.${profileType.hotWater}`)} </div> <div className="value"> - {profileType.warmingFluid !== null && - profileType.heating === IndividualOrCollective.INDIVIDUAL - ? t( - `profile_type.hot_water_fluid.${ - profileType.hotWaterFluid + '_text' - }` - ) - : profileType.heating === - IndividualOrCollective.INDIVIDUAL - ? t('profile_type.hot_water_fluid.no_fluid_text') - : ''} + {profileType.heating === + IndividualOrCollective.INDIVIDUAL && + (profileType.warmingFluid !== null + ? t( + `profile_type.hot_water_fluid.${profileType.hotWaterFluid}_text` + ) + : t('profile_type.hot_water_fluid.no_fluid_text'))} </div> {profileType.hotWater === IndividualOrCollective.INDIVIDUAL && ( @@ -199,13 +195,11 @@ const ProfileTypeOptions: React.FC = () => { {t('profile_type.individual_insulation_work.title')} </div> - {profileType.individualInsulationWork.map((work, index) => { - return ( - <div key={index} className="value"> - {t(`profile_type.individual_insulation_work.${work}`)} - </div> - ) - })} + {profileType.individualInsulationWork.map(work => ( + <div key={work} className="value"> + {t(`profile_type.individual_insulation_work.${work}`)} + </div> + ))} </div> )} <div className="fields"> diff --git a/src/components/ProfileType/ProfileTypeFormDateSelection.tsx b/src/components/ProfileType/ProfileTypeFormDateSelection.tsx index d8bd5306f..fecc5e5d6 100644 --- a/src/components/ProfileType/ProfileTypeFormDateSelection.tsx +++ b/src/components/ProfileType/ProfileTypeFormDateSelection.tsx @@ -194,8 +194,8 @@ const ProfileTypeFormDateSelection: React.FC< defaultValue={selectedYear} onChange={e => handleSelectYear(e)} > - {selectYears.map((year, key) => ( - <MenuItem value={year} key={key} className="date-option"> + {selectYears.map(year => ( + <MenuItem value={year} key={year} className="date-option"> {year} </MenuItem> ))} @@ -211,21 +211,19 @@ const ProfileTypeFormDateSelection: React.FC< > {/* if current year, only show past and present months else show full months */} {selectedYear === DateTime.now().year - ? selectMonths - .slice(0, DateTime.now().month) - .map((month, key) => ( - <MenuItem - value={month.value} - key={key} - className="date-option" - > - {month.label} - </MenuItem> - )) - : selectMonths.map((month, key) => ( + ? selectMonths.slice(0, DateTime.now().month).map(month => ( <MenuItem value={month.value} - key={key} + key={month.value} + className="date-option" + > + {month.label} + </MenuItem> + )) + : selectMonths.map(month => ( + <MenuItem + value={month.value} + key={month.value} className="date-option" > {month.label} diff --git a/src/components/Quiz/QuizQuestionContent.tsx b/src/components/Quiz/QuizQuestionContent.tsx index d0e7588f2..b67835140 100644 --- a/src/components/Quiz/QuizQuestionContent.tsx +++ b/src/components/Quiz/QuizQuestionContent.tsx @@ -97,22 +97,20 @@ const QuizQuestionContent: React.FC<QuizQuestionContent> = ({ {userChallenge.quiz.questions[questionIndex].questionLabel} </p> {userChallenge.quiz.questions[questionIndex].answers.map( - (answer, index) => { - return ( - <div className="answer" key={index}> - <input - type="radio" - id={`answer${index}`} - value={answer.answerLabel} - onChange={handleChange} - checked={userChoice === answer.answerLabel} - /> - <label htmlFor={`answer${index}`} className="text-16-bold"> - {answer.answerLabel} - </label> - </div> - ) - } + (answer, index) => ( + <div className="answer" key={index}> + <input + type="radio" + id={`answer${index}`} + value={answer.answerLabel} + onChange={handleChange} + checked={userChoice === answer.answerLabel} + /> + <label htmlFor={`answer${index}`} className="text-16-bold"> + {answer.answerLabel} + </label> + </div> + ) )} </div> <Button diff --git a/src/components/Splash/SplashRoot.tsx b/src/components/Splash/SplashRoot.tsx index a7432b5eb..01ca16d8a 100644 --- a/src/components/Splash/SplashRoot.tsx +++ b/src/components/Splash/SplashRoot.tsx @@ -28,7 +28,7 @@ import React, { import { useDispatch } from 'react-redux' import ActionService from 'services/action.service' import ChallengeService from 'services/challenge.service' -import CustomPupopService from 'services/customPopup.service' +import CustomPopupService from 'services/customPopup.service' import FluidService from 'services/fluid.service' import InitializationService from 'services/initialization.service' import PartnersInfoService from 'services/partnersInfo.service' @@ -198,7 +198,7 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { setInitStep, setInitStepErrors ) - const customPopupService = new CustomPupopService(client) + const customPopupService = new CustomPopupService(client) const ms = new MigrationService(client, setInitStepErrors) try { const migrationsResult: ReleaseNotes = await ms.runMigrations( diff --git a/src/components/TimeStepSelector/TimeStepSelector.tsx b/src/components/TimeStepSelector/TimeStepSelector.tsx index 213d71c27..3532b3af4 100644 --- a/src/components/TimeStepSelector/TimeStepSelector.tsx +++ b/src/components/TimeStepSelector/TimeStepSelector.tsx @@ -94,25 +94,23 @@ const TimeStepSelector: React.FC<TimeStepSelectorProps> = ({ fluidType === FluidType.ELECTRICITY && 'elec-bar' }`} > - {timeStepArray.map((step, key) => { - return ( - <React.Fragment key={key}> - <li - className={ - step === currentTimeStep ? 'active circle' : 'circle' - } - onClick={() => handleChangeTimeStep(step)} - id={TimeStep[step].toLowerCase()} - > - <span className="clickable-area" /> - <span className={'text text-14-normal'}> - {t(`timestep.${TimeStep[step].toLowerCase()}.period`)} - </span> - </li> - <li className="bar" /> - </React.Fragment> - ) - })} + {timeStepArray.map(step => ( + <React.Fragment key={step}> + <li + className={ + step === currentTimeStep ? 'active circle' : 'circle' + } + onClick={() => handleChangeTimeStep(step)} + id={TimeStep[step].toLowerCase()} + > + <span className="clickable-area" /> + <span className={'text text-14-normal'}> + {t(`timestep.${TimeStep[step].toLowerCase()}.period`)} + </span> + </li> + <li className="bar" /> + </React.Fragment> + ))} </ul> </div> </div> diff --git a/src/components/TotalConsumption/TotalConsumption.spec.tsx b/src/components/TotalConsumption/TotalConsumption.spec.tsx index e41ab2910..7f2101b48 100644 --- a/src/components/TotalConsumption/TotalConsumption.spec.tsx +++ b/src/components/TotalConsumption/TotalConsumption.spec.tsx @@ -6,7 +6,7 @@ import React from 'react' import { act } from 'react-dom/test-utils' import { Provider } from 'react-redux' import configureStore from 'redux-mock-store' -import { graphData } from '../../../tests/__mocks__/datachartData.mock' +import { graphData } from '../../../tests/__mocks__/chartData.mock' import { mockInitialChartState } from '../../../tests/__mocks__/store' import TotalConsumption from './TotalConsumption' diff --git a/src/constants/connectionWaitingText.json b/src/constants/connectionWaitingText.json index da97fb792..61481a407 100644 --- a/src/constants/connectionWaitingText.json +++ b/src/constants/connectionWaitingText.json @@ -1,7 +1,7 @@ [ { "first": "Le saviez-vous ?", - "second": "Pour acheminer l’eau sur Lyon (Lugdunum !) l’acqueduc de Gier faisait 86 km à l’époque Romaine !" + "second": "Pour acheminer l’eau sur Lyon (Lugdunum !) l’aqueduc de Gier faisait 86 km à l’époque Romaine !" }, { "first": "Rien que de l’eau, de l’eau de pluie, de l’eau de la Métroooooo", diff --git a/src/constants/consumptionConstants/ecs.json b/src/constants/consumptionConstants/ecs.json index d092e7c69..3cc4afec5 100644 --- a/src/constants/consumptionConstants/ecs.json +++ b/src/constants/consumptionConstants/ecs.json @@ -46,7 +46,7 @@ 0.19, 0.33, 0.36, 0.6, 0.61, 0.73, 0.92, 0.81, 0.67, 0.46, 0.24, 0.25 ], "efficiency_production_distribution": { - "appartment": 0.55, + "apartment": 0.55, "individual_house": 0.7 }, "coefficient_ecs_consumption": 1.163, diff --git a/src/constants/consumptionConstants/electricSpecific.json b/src/constants/consumptionConstants/electricSpecific.json index dafba211e..33217083a 100644 --- a/src/constants/consumptionConstants/electricSpecific.json +++ b/src/constants/consumptionConstants/electricSpecific.json @@ -7,7 +7,7 @@ "after_1998": 2900, "unknown": 2900 }, - "appartment": { + "apartment": { "before_1948": 1120, "between_1948_and_1974": 1880, "between_1975_and_1989": 1780, diff --git a/src/constants/consumptionConstants/heating.json b/src/constants/consumptionConstants/heating.json index 4cde77178..e3fd84db4 100644 --- a/src/constants/consumptionConstants/heating.json +++ b/src/constants/consumptionConstants/heating.json @@ -8,7 +8,7 @@ "after_1998": 106, "unknown": 106 }, - "appartment": { + "apartment": { "before_1948": 119, "between_1948_and_1974": 150, "between_1975_and_1989": 105, @@ -17,14 +17,14 @@ "unknown": 74 } }, - "adjustment_outisde_facing_walls": { + "adjustment_outside_facing_walls": { "individual_house": { "1": -0.2, "2": -0.15, "3": -0.1, "4": 0 }, - "appartment": { + "apartment": { "1": -0.1, "2": 0, "3": 0.1, @@ -32,7 +32,7 @@ } }, "adjustment_floor": { - "appartment": { + "apartment": { "ground_floor": 0.1, "intermediate_floor": 0, "last_floor": 0.15, diff --git a/src/db/ecogestureData.json b/src/db/ecogestureData.json index 50fe93026..9fb6186e0 100644 --- a/src/db/ecogestureData.json +++ b/src/db/ecogestureData.json @@ -488,7 +488,7 @@ "fluidTypes": [0], "shortName": "Vortex", "longName": "Je nettoie le filtre de ma machine à laver.", - "longDescription": "Repérez la trappe qui existe sur le devant de votre machine (en bas à droite souvent). Ouvrez-la. Dévissez le filtre pour le sortir : attention, un peu d’eau risque de couler (Prenez un bol et une serpillère au cas où).Enlèvez les résidus qui seraient restés dans la trappe : cheveux, pièces etc. Rincez le filtre à l’eau claire. Remettez le filtre en place et hop on referme la trappe ! En étant bien entretenu, votre lave-ligne consomme moins d'énergie, lave mieux votre linge et durera plus longtemps.", + "longDescription": "Repérez la trappe qui existe sur le devant de votre machine (en bas à droite souvent). Ouvrez-la. Dévissez le filtre pour le sortir : attention, un peu d’eau risque de couler (Prenez un bol et une serpillière au cas où).Enlevez les résidus qui seraient restés dans la trappe : cheveux, pièces etc. Rincez le filtre à l’eau claire. Remettez le filtre en place et hop on referme la trappe ! En étant bien entretenu, votre lave-ligne consomme moins d'énergie, lave mieux votre linge et durera plus longtemps.", "impactLevel": 1, "efficiency": 0.5, "difficulty": 1, diff --git a/src/db/quizEntity.json b/src/db/quizEntity.json index ffa6f2a7e..f49a4a8cc 100644 --- a/src/db/quizEntity.json +++ b/src/db/quizEntity.json @@ -133,7 +133,7 @@ "isTrue": false } ], - "explanation": "Ce chiffre peut varier d'un foyer à l'autre et de son activité. Il faut savoir cependant que la quantité de vapeur d’eau produite par les fonctions métaboliques des occupants comme la respiration et la transpiration peut aller jusqu'à 0,2L par personne et par heure. A celà, de l'humidité peut également être créer par les autres activité (lavage, séchage de linge, bain, douche ...) Cette réponse est donc principalement un ordre de grandeur.", + "explanation": "Ce chiffre peut varier d'un foyer à l'autre et de son activité. Il faut savoir cependant que la quantité de vapeur d’eau produite par les fonctions métaboliques des occupants comme la respiration et la transpiration peut aller jusqu'à 0,2L par personne et par heure. A cela, de l'humidité peut également être créer par les autres activité (lavage, séchage de linge, bain, douche ...) Cette réponse est donc principalement un ordre de grandeur.", "source": "string" }, { @@ -205,7 +205,7 @@ "answers": [ { "answerLabel": "Thermique", "isTrue": false }, { - "answerLabel": "Geothermique", + "answerLabel": "Géothermique", "isTrue": true }, { @@ -300,7 +300,7 @@ "source": "string" }, { - "questionLabel": "Quel est l'interêt d'avoir des fenêtre à double vitrage ?", + "questionLabel": "Quel est l’intérêt d'avoir des fenêtre à double vitrage ?", "answers": [ { "answerLabel": "fenêtre plus solide", @@ -406,7 +406,7 @@ } ], "customQuestion": { - "questionLabel": "Quel jour avez-vous le plus consommé parmis les suivants", + "questionLabel": "Quel jour avez-vous le plus consommé parmi les suivants", "type": 0, "timeStep": 20, "interval": 30, diff --git a/src/doctypes/com-grandlyon-ecolyo-fluidsprices.ts b/src/doctypes/com-grandlyon-ecolyo-fluidsprices.ts index 49bd78fb1..5d0990df1 100644 --- a/src/doctypes/com-grandlyon-ecolyo-fluidsprices.ts +++ b/src/doctypes/com-grandlyon-ecolyo-fluidsprices.ts @@ -1 +1 @@ -export const FLUIDPRICES_DOCTYPE = 'com.grandlyon.ecolyo.fluidsprices' +export const FLUIDSPRICES_DOCTYPE = 'com.grandlyon.ecolyo.fluidsprices' diff --git a/src/doctypes/index.ts b/src/doctypes/index.ts index 38dd79001..535698232 100644 --- a/src/doctypes/index.ts +++ b/src/doctypes/index.ts @@ -2,7 +2,7 @@ import { CHALLENGE_DOCTYPE } from './com-grandlyon-ecolyo-challenge' import { DUEL_DOCTYPE } from './com-grandlyon-ecolyo-duel' import { ECOGESTURE_DOCTYPE } from './com-grandlyon-ecolyo-ecogesture' import { EXPLORATION_DOCTYPE } from './com-grandlyon-ecolyo-exploration' -import { FLUIDPRICES_DOCTYPE } from './com-grandlyon-ecolyo-fluidsprices' +import { FLUIDSPRICES_DOCTYPE } from './com-grandlyon-ecolyo-fluidsprices' import { PROFILE_DOCTYPE } from './com-grandlyon-ecolyo-profile' import { PROFILEECOGESTURE_DOCTYPE } from './com-grandlyon-ecolyo-profileecogesture' import { PROFILETYPE_DOCTYPE } from './com-grandlyon-ecolyo-profiletype' @@ -163,7 +163,7 @@ const doctypes = { relationships: {}, }, fluidsPrices: { - doctype: FLUIDPRICES_DOCTYPE, + doctype: FLUIDSPRICES_DOCTYPE, attributes: {}, relationships: {}, }, diff --git a/src/enum/ecogesture.enum.ts b/src/enum/ecogesture.enum.ts index c14162c8e..c43e069b0 100644 --- a/src/enum/ecogesture.enum.ts +++ b/src/enum/ecogesture.enum.ts @@ -40,7 +40,7 @@ export enum EquipmentType { HYDRAULIC_HEATING = 'HYDRAULIC_HEATING', } -export enum EcogestureStatus { +export enum EcogestureTab { OBJECTIVE = 0, DOING = 1, ALL = 2, diff --git a/src/enum/profileType.enum.ts b/src/enum/profileType.enum.ts index 942f67244..bd2c0a3a2 100644 --- a/src/enum/profileType.enum.ts +++ b/src/enum/profileType.enum.ts @@ -1,6 +1,6 @@ export enum HousingType { INDIVIDUAL_HOUSE = 'individual_house', - APPARTMENT = 'appartment', + APARTMENT = 'apartment', } export enum Floor { diff --git a/src/locales/fr.json b/src/locales/fr.json index 294092815..73b709d7d 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -208,7 +208,7 @@ }, "step3": { "info1": "La visualisation de vos données sur Ecolyo demande l'activation du <span>partage de toutes les données.</span>", - "info2": "Pour une expérience optimale, <span>une période de consentement de 1 an</span> est recommandée à partir d'aujourd'hui.", + "info2": "Pour une expérience optimale, <span>une période de consentement de 1 an</span> est recommandée à partir d’aujourd’hui.", "info3": "<p>Veillez également à indiquer une date antérieure pour l'historique (1er calendrier) afin de pouvoir récupérer jusqu'à 3 ans d'historique.</p>" }, "button_go_to_partner_site": "Aller sur GRDF" @@ -497,7 +497,7 @@ }, "ecogesture_info_modal": { "header": "Comment sont choisis les astuces adaptées à mon profil\u00a0?", - "text": "Les astuces adaptés à votre profil sont aujourd'hui choisies en fonction des compteurs individuels que vous possédez (communicants ou non). Ceux présentés ici vous permettent d'agir sur vos consommations individuelles. Des modes de tri plus personnalisables seront proposés à l'avenir.", + "text": "Les astuces adaptés à votre profil sont aujourd’hui choisies en fonction des compteurs individuels que vous possédez (communicants ou non). Ceux présentés ici vous permettent d'agir sur vos consommations individuelles. Des modes de tri plus personnalisables seront proposés à l'avenir.", "button_close": "J'ai compris", "accessibility": { "window_title": "Fenêtre d'information", @@ -669,7 +669,7 @@ "part3_3": "Ces acteurs sont responsables de la relève de vos données. Ces données servent notamment à votre fournisseur d’électricité, de gaz ou d’eau pour permettre la facturation de vos consommations d’énergie. Des fournisseurs d’électricité ou de gaz il y en a des dizaines. Les gestionnaires de réseaux (… et de votre compteur) ne sont qu’au nombre de trois. Nous avons donc décidé de travailler avec eux, au plus près de la donnée brute issue de vos compteurs.", "part3_4": "Il vous faudra donc avoir un compte chez GRDF et Eau Publique du Grand Lyon pour accéder à vos données. Si vous n’en avez pas, il suffira de vous en créer un. Ceci ne sera à faire qu’une fois, au début.", "title4": "Ecolyo se trouve dans un cloud personnel Grand Lyon, qu’est-ce que cela signifie\u00a0?", - "part4_1": "Comme vous avez dû le remarquer, lors de votre première connexion à Ecolyo vous avez dû vous créer un compte Cloud Personnel Grand Lyon. Ce cloud personnel est un espace sécurisé porté par l’ambition de vous apporter visibilité, transparence et maitrise sur l’usage de vos données personnelles, et dont les fonctionnalités vous permettant de récupérer, synchroniser, stocker et partager vos données avec les destinataires de votre choix. Le service Ecolyo se déploie à l’intérieur de cet espace protégé. Dans ce cloud personnel, vous pourrez accéder également à d’autres services. Toutes les données traitées par Ecolyo, mais aussi les autres services que vous seriez amenés à utiliser dans ce cloud personnel restent dans ce Cloud Personnel Grand Lyon et n’en sortent pas, sauf si vous décidez vous-même de partager vos données avec des tiers.", + "part4_1": "Comme vous avez dû le remarquer, lors de votre première connexion à Ecolyo vous avez dû vous créer un compte Cloud Personnel Grand Lyon. Ce cloud personnel est un espace sécurisé porté par l’ambition de vous apporter visibilité, transparence et maîtrise sur l’usage de vos données personnelles, et dont les fonctionnalités vous permettant de récupérer, synchroniser, stocker et partager vos données avec les destinataires de votre choix. Le service Ecolyo se déploie à l’intérieur de cet espace protégé. Dans ce cloud personnel, vous pourrez accéder également à d’autres services. Toutes les données traitées par Ecolyo, mais aussi les autres services que vous seriez amenés à utiliser dans ce cloud personnel restent dans ce Cloud Personnel Grand Lyon et n’en sortent pas, sauf si vous décidez vous-même de partager vos données avec des tiers.", "part4_2": "Pour en savoir plus sur ce cloud et son utilisation, ainsi que la durée de conservation de vos données, vous pouvez lire les conditions générales d’utilisation du service <a href=\"https://manager.cozygrandlyon.cloud/tos/266b4226-8417-42fb-b911-41e86dae8581.pdf?locale=fr\">ici</a>.", "title5": "Et donc concrètement pour Ecolyo, quelles données sont collectées et qui y a accès\u00a0?", "part5_1": "Pour qu’Ecolyo ait accès à vos données de consommations, vous devrez activer vos différents connecteurs. À ce moment-là, pour la connexion aux données de gaz et d’eau à travers un parcours qui vous conduira de manière intuitive sur le site de chacun des gestionnaires de réseaux concerné, vous pourrez donner votre consentement à partager ces données avec le Service Ecolyo, et ce pour une durée limitée dans le temps. Pour l’électricité, le don du consentement et la connexion aux données se fait directement dans notre service. Quid de la durée de ce consentement\u00a0? Pour les données électriques, elle est par défaut d'un an. Pour les données gaz, cela sera à vous de la définir (nous vous recommandons 1 an pour une expérience optimale). Les données utilisées pour vérifier la bonne connexion de vos données d’électricité sont stockées du côté de la Métropole de Lyon sur des serveurs sécurisés.", @@ -977,7 +977,7 @@ "title": "Logement", "question": "De quel type de logement disposez-vous\u00a0?", "individual_house": "Maison individuelle", - "appartment": "Appartement" + "apartment": "Appartement" }, "construction_year": { "title": "Construction", diff --git a/src/migrations/migration.data.ts b/src/migrations/migration.data.ts index 06a3a1b5b..758dfc12f 100644 --- a/src/migrations/migration.data.ts +++ b/src/migrations/migration.data.ts @@ -7,7 +7,7 @@ import { ENEDIS_MONTHLY_ANALYSIS_DATA_DOCTYPE, ENEDIS_MONTH_DOCTYPE, ENEDIS_YEAR_DOCTYPE, - FLUIDPRICES_DOCTYPE, + FLUIDSPRICES_DOCTYPE, GRDF_DAY_DOCTYPE, GRDF_MONTH_DOCTYPE, GRDF_YEAR_DOCTYPE, @@ -278,7 +278,7 @@ export const migrations: Migration[] = [ appVersion: '1.6.0', description: 'Init new doctype fluidPrices --deprecated--', releaseNotes: null, - docTypes: FLUIDPRICES_DOCTYPE, + docTypes: FLUIDSPRICES_DOCTYPE, isCreate: true, isDeprecated: true, run: async (): Promise<any> => { @@ -489,7 +489,7 @@ export const migrations: Migration[] = [ appVersion: '1.7.0', description: 'Init new fluidPrices for water -- deprecated --', releaseNotes: null, - docTypes: FLUIDPRICES_DOCTYPE, + docTypes: FLUIDSPRICES_DOCTYPE, isDeprecated: true, run: async (): Promise<any> => { return [] @@ -523,7 +523,7 @@ export const migrations: Migration[] = [ description: 'Empty fluidPrices db so it can be fetched with right format from remote doctype', releaseNotes: null, - docTypes: FLUIDPRICES_DOCTYPE, + docTypes: FLUIDSPRICES_DOCTYPE, run: async (_client: Client, docs: any[]): Promise<any> => { return docs.map(doc => { doc.deleteAction = true diff --git a/src/migrations/migration.spec.ts b/src/migrations/migration.spec.ts index 01adb4cda..925d7af86 100644 --- a/src/migrations/migration.spec.ts +++ b/src/migrations/migration.spec.ts @@ -1,5 +1,5 @@ import { QueryResult } from 'cozy-client' -import { FLUIDPRICES_DOCTYPE, PROFILE_DOCTYPE } from 'doctypes' +import { FLUIDSPRICES_DOCTYPE, PROFILE_DOCTYPE } from 'doctypes' import { FluidPrice, Profile } from 'models' import { Schema } from 'models/schema.models' import mockClient from '../../tests/__mocks__/client' @@ -201,7 +201,7 @@ describe('migration create', () => { targetSchemaVersion: 1, appVersion: '1.2.4', description: 'Add fluid price', - docTypes: FLUIDPRICES_DOCTYPE, + docTypes: FLUIDSPRICES_DOCTYPE, releaseNotes: null, isCreate: true, run: async (): Promise<FluidPrice[]> => { diff --git a/src/models/profileEcogesture.model.ts b/src/models/profileEcogesture.model.ts index 4e6a6d388..90164e312 100644 --- a/src/models/profileEcogesture.model.ts +++ b/src/models/profileEcogesture.model.ts @@ -13,6 +13,7 @@ interface ProfileEcogestureIndexableTypes { | FluidType | WarmingType | EquipmentType[] + | ProfileEcogesture | string | null } diff --git a/src/services/challenge.service.spec.ts b/src/services/challenge.service.spec.ts index d1e2f3c9a..fdd71daf0 100644 --- a/src/services/challenge.service.spec.ts +++ b/src/services/challenge.service.spec.ts @@ -22,8 +22,8 @@ import { allChallengeEntityData, challengeEntityData, } from '../../tests/__mocks__/challengeEntity.mock' +import { graphData } from '../../tests/__mocks__/chartData.mock' import mockClient from '../../tests/__mocks__/client' -import { graphData } from '../../tests/__mocks__/datachartData.mock' import { allDuelEntity, duelData, diff --git a/src/services/connection.service.spec.ts b/src/services/connection.service.spec.ts index 069504500..9b8e6910b 100644 --- a/src/services/connection.service.spec.ts +++ b/src/services/connection.service.spec.ts @@ -1,3 +1,4 @@ +import { AccountAuthData } from 'models' import { accountsData } from '../../tests/__mocks__/accountsData.mock' import mockClient from '../../tests/__mocks__/client' import { konnectorsData } from '../../tests/__mocks__/konnectorsData.mock' @@ -31,6 +32,11 @@ jest.mock('./triggers.service', () => { }) }) +const mockEGLAuthData: AccountAuthData = { + login: 'login', + password: 'password', +} + describe('Connection service', () => { const connectionService = new ConnectionService(mockClient) @@ -42,8 +48,7 @@ describe('Connection service', () => { const mockResult = { account: accountsData[0], trigger: triggersData[0] } const result = await connectionService.connectNewUser( konnectorsData[0]._id, - 'login', - 'password' + mockEGLAuthData ) expect(result).toEqual(mockResult) }) @@ -53,8 +58,7 @@ describe('Connection service', () => { try { await connectionService.connectNewUser( konnectorsData[0]._id, - 'login', - 'password' + mockEGLAuthData ) } catch (err) { error = err @@ -70,8 +74,7 @@ describe('Connection service', () => { try { await connectionService.connectNewUser( konnectorsData[0]._id, - 'login', - 'password' + mockEGLAuthData ) } catch (err) { error = err @@ -86,8 +89,7 @@ describe('Connection service', () => { try { await connectionService.connectNewUser( konnectorsData[0]._id, - 'login', - 'password' + mockEGLAuthData ) } catch (err) { error = err diff --git a/src/services/consumption.service.ts b/src/services/consumption.service.ts index 0a7f9a622..d22f100a3 100644 --- a/src/services/consumption.service.ts +++ b/src/services/consumption.service.ts @@ -89,7 +89,7 @@ export default class ConsumptionDataManager { ) return formattedData } else if (fluidTypes.length > 1 || isHome) { - const toBeAgreggatedData: ISingleFluidChartData[] = [] + const toBeAggregatedData: ISingleFluidChartData[] = [] for (const fluidType of fluidTypes) { const fetchedData = await this.fetchSingleFluidGraphData( timePeriod, @@ -107,13 +107,13 @@ export default class ConsumptionDataManager { fluidStatus ? fluidStatus[fluidType] : undefined ) // validating output data - toBeAgreggatedData.push({ + toBeAggregatedData.push({ chartData: formattedData, chartFluid: fluidType, }) } const aggregatedData: Datachart | null = - this.aggregateGraphData(toBeAgreggatedData) + this.aggregateGraphData(toBeAggregatedData) return aggregatedData } else return null } @@ -421,8 +421,8 @@ export default class ConsumptionDataManager { } else length = singleFluidCharts[0].chartData.actualData.length for (let i = 0; i < length; i++) { - let agreggatedConvertedValue = 0 - let comparisonAgreggatedConvertedValue = 0 + let aggregatedConvertedValue = 0 + let comparisonAggregatedConvertedValue = 0 const tempAggregatedState: DataloadState[] = [] const tempComparisonAggregatedState: DataloadState[] = [] @@ -449,7 +449,7 @@ export default class ConsumptionDataManager { singleFluidChart.chartFluid, singleFluidChart.chartData.actualData[i].price ) - agreggatedConvertedValue += convertedValue + aggregatedConvertedValue += convertedValue } convertedValueDetail[singleFluidChart.chartFluid] = { @@ -472,7 +472,7 @@ export default class ConsumptionDataManager { singleFluidChart.chartFluid, singleFluidChart.chartData.comparisonData[i].price ) - comparisonAgreggatedConvertedValue += convertedComparisonValue + comparisonAggregatedConvertedValue += convertedComparisonValue } comparisonConvertedValueDetail[singleFluidChart.chartFluid] = { @@ -483,9 +483,9 @@ export default class ConsumptionDataManager { } if (singleFluidCharts.length === noDataCount) - agreggatedConvertedValue = -1 + aggregatedConvertedValue = -1 if (singleFluidCharts.length === comparisonNoDataCount) - comparisonAgreggatedConvertedValue = -1 + comparisonAggregatedConvertedValue = -1 if (singleFluidCharts[0].chartData.actualData[i]) { // Define the aggregated state @@ -493,14 +493,14 @@ export default class ConsumptionDataManager { this._consumptionFormatterService.defineAggregatedDataloadState( tempAggregatedState ) - const acutaldataLoad: Dataload = { + const actualDataLoad: Dataload = { date: singleFluidCharts[0].chartData.actualData[i].date, - value: agreggatedConvertedValue, + value: aggregatedConvertedValue, state: aggregatedDataloadState, valueDetail: - agreggatedConvertedValue === -1 ? null : convertedValueDetail, + aggregatedConvertedValue === -1 ? null : convertedValueDetail, } - resultChartData.actualData.push(acutaldataLoad) + resultChartData.actualData.push(actualDataLoad) } if ( @@ -513,16 +513,16 @@ export default class ConsumptionDataManager { this._consumptionFormatterService.defineAggregatedDataloadState( tempComparisonAggregatedState ) - const comparisondataLoad: Dataload = { + const comparisonDataLoad: Dataload = { date: singleFluidCharts[0].chartData.comparisonData[i].date, - value: comparisonAgreggatedConvertedValue, + value: comparisonAggregatedConvertedValue, state: aggregatedComparisonDataloadState, valueDetail: - comparisonAgreggatedConvertedValue === -1 + comparisonAggregatedConvertedValue === -1 ? null : comparisonConvertedValueDetail, } - resultChartData.comparisonData.push(comparisondataLoad) + resultChartData.comparisonData.push(comparisonDataLoad) } } return resultChartData diff --git a/src/services/customPopup.service.test.ts b/src/services/customPopup.service.test.ts index 7b30e3b92..952019749 100644 --- a/src/services/customPopup.service.test.ts +++ b/src/services/customPopup.service.test.ts @@ -1,6 +1,6 @@ import mockClient from '../../tests/__mocks__/client' import { mockCustomPopup } from '../../tests/__mocks__/customPopup.mock' -import CustomPupopService from './customPopup.service' +import CustomPopupService from './customPopup.service' jest.mock('services/environment.service', () => { return jest.fn(() => { @@ -11,11 +11,11 @@ jest.mock('services/environment.service', () => { }) describe('PartnersInfo service', () => { - const customPupopService = new CustomPupopService(mockClient) + const customPopupService = new CustomPopupService(mockClient) it('should return customPopup data', async () => { mockClient.getStackClient().fetchJSON.mockResolvedValueOnce(mockCustomPopup) - const result = await customPupopService.getCustomPopup() + const result = await customPopupService.getCustomPopup() expect(result).toBe(mockCustomPopup) }) @@ -23,7 +23,7 @@ describe('PartnersInfo service', () => { mockClient.getStackClient().fetchJSON.mockRejectedValue(new Error()) let res try { - res = await customPupopService.getCustomPopup() + res = await customPopupService.getCustomPopup() expect(true).toBe(false) } catch (error) { expect(res).toBe(undefined) diff --git a/src/services/customPopup.service.ts b/src/services/customPopup.service.ts index 1eee45690..32f87726e 100644 --- a/src/services/customPopup.service.ts +++ b/src/services/customPopup.service.ts @@ -11,7 +11,7 @@ import EnvironmentService from './environment.service' const logStack = logger.namespace('customPopupService') -export default class CustomPupopService { +export default class CustomPopupService { private readonly _client: Client constructor(_client: Client) { this._client = _client diff --git a/src/services/duel.service.spec.ts b/src/services/duel.service.spec.ts index f409995f4..dd4ea30f5 100644 --- a/src/services/duel.service.spec.ts +++ b/src/services/duel.service.spec.ts @@ -4,11 +4,8 @@ import { UserDuelState } from 'enum/userDuel.enum' import { DateTime, Duration } from 'luxon' import { DuelEntity, UserDuel } from 'models' import DuelService from 'services/duel.service' +import { fullGraphData, graphData } from '../../tests/__mocks__/chartData.mock' import mockClient from '../../tests/__mocks__/client' -import { - fullGraphData, - graphData, -} from '../../tests/__mocks__/datachartData.mock' import { allDuelData, duelData, diff --git a/src/services/fluid.service.spec.ts b/src/services/fluid.service.spec.ts index f692d9c9a..53fe0add5 100644 --- a/src/services/fluid.service.spec.ts +++ b/src/services/fluid.service.spec.ts @@ -1,5 +1,6 @@ /* eslint-disable camelcase */ import { FluidState, FluidType } from 'enum/fluid.enum' +import { FluidSlugType } from 'enum/fluidSlug.enum' import { DateTime } from 'luxon' import { FluidStatus } from 'models' import { accountsData } from '../../tests/__mocks__/accountsData.mock' @@ -92,7 +93,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedissgegrandlyon', + slug: FluidSlugType.ELECTRICITY, siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -114,7 +115,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'Eau Publique du Grand Lyon', oauth: false, - slug: 'eglgrandlyon', + slug: FluidSlugType.WATER, siteLink: 'https://www.eaudugrandlyon.com/inscription.aspx#subc-now', activation: '', @@ -137,7 +138,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'GRDF', oauth: true, - slug: 'grdfgrandlyon', + slug: FluidSlugType.GAS, siteLink: 'https://monespace.grdf.fr/creation-particulier', activation: '', }, @@ -181,7 +182,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedissgegrandlyon', + slug: FluidSlugType.ELECTRICITY, siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -203,7 +204,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'Eau Publique du Grand Lyon', oauth: false, - slug: 'eglgrandlyon', + slug: FluidSlugType.WATER, siteLink: 'https://www.eaudugrandlyon.com/inscription.aspx#subc-now', activation: '', @@ -226,7 +227,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'GRDF', oauth: true, - slug: 'grdfgrandlyon', + slug: FluidSlugType.GAS, siteLink: 'https://monespace.grdf.fr/creation-particulier', activation: '', }, @@ -270,7 +271,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedissgegrandlyon', + slug: FluidSlugType.ELECTRICITY, siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -292,7 +293,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'Eau Publique du Grand Lyon', oauth: false, - slug: 'eglgrandlyon', + slug: FluidSlugType.WATER, siteLink: 'https://www.eaudugrandlyon.com/inscription.aspx#subc-now', activation: '', @@ -315,7 +316,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'GRDF', oauth: true, - slug: 'grdfgrandlyon', + slug: FluidSlugType.GAS, siteLink: 'https://monespace.grdf.fr/creation-particulier', activation: '', }, @@ -359,7 +360,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedissgegrandlyon', + slug: FluidSlugType.ELECTRICITY, siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -381,7 +382,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'Eau Publique du Grand Lyon', oauth: false, - slug: 'eglgrandlyon', + slug: FluidSlugType.WATER, siteLink: 'https://www.eaudugrandlyon.com/inscription.aspx#subc-now', activation: '', @@ -404,7 +405,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'GRDF', oauth: true, - slug: 'grdfgrandlyon', + slug: FluidSlugType.GAS, siteLink: 'https://monespace.grdf.fr/creation-particulier', activation: '', }, @@ -449,7 +450,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedissgegrandlyon', + slug: FluidSlugType.ELECTRICITY, siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -471,7 +472,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'Eau Publique du Grand Lyon', oauth: false, - slug: 'eglgrandlyon', + slug: FluidSlugType.WATER, siteLink: 'https://www.eaudugrandlyon.com/inscription.aspx#subc-now', activation: '', @@ -494,7 +495,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'GRDF', oauth: true, - slug: 'grdfgrandlyon', + slug: FluidSlugType.GAS, siteLink: 'https://monespace.grdf.fr/creation-particulier', activation: '', }, @@ -544,6 +545,7 @@ describe('Fluid service', () => { { fluidType: FluidType.ELECTRICITY, status: FluidState.DONE, + maintenance: false, firstDataDate: DateTime.fromISO('2019-01-01').setZone('utc', { keepLocalTime: true, }), @@ -560,7 +562,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedissgegrandlyon', + slug: FluidSlugType.ELECTRICITY, siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -578,6 +580,7 @@ describe('Fluid service', () => { { fluidType: FluidType.ELECTRICITY, status: FluidState.DONE, + maintenance: false, firstDataDate: DateTime.local().minus({ day: 31 }).setZone('utc', { keepLocalTime: true, }), @@ -594,7 +597,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedissgegrandlyon', + slug: FluidSlugType.ELECTRICITY, siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -612,6 +615,7 @@ describe('Fluid service', () => { { fluidType: FluidType.ELECTRICITY, status: FluidState.NOT_CONNECTED, + maintenance: false, firstDataDate: DateTime.fromISO('2019-01-01').setZone('utc', { keepLocalTime: true, }), @@ -628,7 +632,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedissgegrandlyon', + slug: FluidSlugType.ELECTRICITY, siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -646,6 +650,7 @@ describe('Fluid service', () => { { fluidType: FluidType.ELECTRICITY, status: FluidState.KONNECTOR_NOT_FOUND, + maintenance: false, firstDataDate: DateTime.fromISO('2019-01-01').setZone('utc', { keepLocalTime: true, }), @@ -662,7 +667,7 @@ describe('Fluid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedissgegrandlyon', + slug: FluidSlugType.ELECTRICITY, siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, diff --git a/src/services/fluidConfig.service.ts b/src/services/fluidConfig.service.ts index b6aae3539..5341c940e 100644 --- a/src/services/fluidConfig.service.ts +++ b/src/services/fluidConfig.service.ts @@ -3,7 +3,7 @@ import { FluidConfig } from 'models' export default class ConfigService { public getFluidConfig(): FluidConfig[] { - return Config.fluidConfig + return Config.fluidConfig as FluidConfig[] } /** diff --git a/src/services/fluidsPrices.service.ts b/src/services/fluidsPrices.service.ts index 700f9ec7b..acbaf7419 100644 --- a/src/services/fluidsPrices.service.ts +++ b/src/services/fluidsPrices.service.ts @@ -1,7 +1,7 @@ import * as Sentry from '@sentry/react' import { Client, Q, QueryDefinition, QueryResult } from 'cozy-client' import logger from 'cozy-logger' -import { FLUIDPRICES_DOCTYPE } from 'doctypes' +import { FLUIDSPRICES_DOCTYPE } from 'doctypes' import { FluidType } from 'enum/fluid.enum' import { DateTime } from 'luxon' import { FluidPrice } from 'models' @@ -22,7 +22,7 @@ export default class FluidPricesService { * @returns {FluidPrice[]} */ public async getAllPrices(): Promise<FluidPrice[]> { - const query: QueryDefinition = Q(FLUIDPRICES_DOCTYPE).limitBy(900) + const query: QueryDefinition = Q(FLUIDSPRICES_DOCTYPE).limitBy(900) // TODO : handle case of 1000+ entries in doctype const { data: fluidsPrices }: QueryResult<FluidPrice[]> = await this._client.query(query) @@ -39,7 +39,7 @@ export default class FluidPricesService { fluidType: FluidType, date: DateTime ): Promise<FluidPrice> { - const query: QueryDefinition = Q(FLUIDPRICES_DOCTYPE) + const query: QueryDefinition = Q(FLUIDSPRICES_DOCTYPE) .indexFields(['startDate']) .where({ startDate: { @@ -60,7 +60,7 @@ export default class FluidPricesService { * @returns {FluidPrice[]} */ public async getAllLastPrices(): Promise<FluidPrice[]> { - const query: QueryDefinition = Q(FLUIDPRICES_DOCTYPE) + const query: QueryDefinition = Q(FLUIDSPRICES_DOCTYPE) .indexFields(['fluidType']) .where({ endDate: { $eq: '' } }) .sortBy([{ fluidType: 'asc' }]) @@ -126,7 +126,7 @@ export default class FluidPricesService { public async checkIfPriceExists( fluidPrice: FluidPrice ): Promise<FluidPrice | null> { - const query: QueryDefinition = Q(FLUIDPRICES_DOCTYPE).where({ + const query: QueryDefinition = Q(FLUIDSPRICES_DOCTYPE).where({ startDate: { $eq: fluidPrice.startDate }, fluidType: { $eq: fluidPrice.fluidType }, }) @@ -145,7 +145,7 @@ export default class FluidPricesService { public async createPrice(newPrice: FluidPrice): Promise<FluidPrice | null> { try { const { data: createdPrice }: QueryResult<FluidPrice> = - await this._client.create(FLUIDPRICES_DOCTYPE, newPrice) + await this._client.create(FLUIDSPRICES_DOCTYPE, newPrice) return createdPrice } catch (error) { const errorMessage = `'Error creating new createdPrice: ${JSON.stringify( diff --git a/src/services/initialization.service.spec.ts b/src/services/initialization.service.spec.ts index 430ede793..3a140471d 100644 --- a/src/services/initialization.service.spec.ts +++ b/src/services/initialization.service.spec.ts @@ -10,8 +10,8 @@ import { UserChallenge } from 'models' import { getActualAnalysisDate } from 'utils/date' import { hashFile } from 'utils/hash' import { allChallengeEntityData } from '../../tests/__mocks__/challengeEntity.mock' +import { graphData } from '../../tests/__mocks__/chartData.mock' import mockClient from '../../tests/__mocks__/client' -import { graphData } from '../../tests/__mocks__/datachartData.mock' import { allDuelEntity } from '../../tests/__mocks__/duelData.mock' import { ecogesturesData } from '../../tests/__mocks__/ecogesturesData.mock' import { allExplorationEntities } from '../../tests/__mocks__/explorationData.mock' diff --git a/src/services/performanceIndicator.service.ts b/src/services/performanceIndicator.service.ts index 59d7f2555..c459f00c6 100644 --- a/src/services/performanceIndicator.service.ts +++ b/src/services/performanceIndicator.service.ts @@ -77,11 +77,11 @@ export default class PerformanceIndicatorService { } } - const agreggatedPerformanceIndicator: PerformanceIndicator = { + const aggregatedPerformanceIndicator: PerformanceIndicator = { value: currentValue, compareValue: compareValue, percentageVariation: currentValue / compareValue - 1, } - return agreggatedPerformanceIndicator + return aggregatedPerformanceIndicator } } diff --git a/src/services/profileEcogesture.service.spec.ts b/src/services/profileEcogesture.service.spec.ts index 75329f55e..5a6e2ee60 100644 --- a/src/services/profileEcogesture.service.spec.ts +++ b/src/services/profileEcogesture.service.spec.ts @@ -9,7 +9,7 @@ const profileEcogestureService = new ProfileEcogestureService(mockClient) describe('ProfileEcogesture service', () => { it('should get the Profile Ecogesture', async () => { - const mockQueryResult: QueryResult<ProfileEcogesture> = { + const mockQueryResult: QueryResult<[ProfileEcogesture]> = { data: [mockProfileEcogestureUpdated], bookmark: '', next: false, @@ -28,7 +28,7 @@ describe('ProfileEcogesture service', () => { EquipmentType.FREEZER, ], } - const mockQueryResult: QueryResult<ProfileEcogesture> = { + const mockQueryResult: QueryResult<[ProfileEcogesture]> = { data: [mockProfileEcogestureUpdated], bookmark: '', next: false, diff --git a/src/services/profileType.service.spec.ts b/src/services/profileType.service.spec.ts index 01fbdce16..298fdfefd 100644 --- a/src/services/profileType.service.spec.ts +++ b/src/services/profileType.service.spec.ts @@ -183,7 +183,7 @@ describe('ProfileType service', () => { }) }) describe('should get the monthly Forecast', () => { - // For month of january + // For month of January const profileTypeService1 = new ProfileTypeService( mockTestProfile1, mockClient, @@ -347,7 +347,7 @@ describe('ProfileType service', () => { }) }) describe('getPreviousFormStep', () => { - it('should get the previus step in function of the current step', () => { + it('should get the previous step in function of the current step', () => { let previousStep = profileTypeFormService.getPreviousFormStep( ProfileTypeStepForm.AREA ) @@ -501,7 +501,7 @@ describe('ProfileType service', () => { const result = ProfileTypeService.checkConsistency(mockProfile) expect(result).toEqual(expectedResult) }) - it('should return consistent profile for appartment', () => { + it('should return consistent profile for apartment', () => { const mockProfile = mockProfileType1 jest .spyOn(DateTime, 'local') diff --git a/src/services/profileType.service.ts b/src/services/profileType.service.ts index 3be40613c..bcfa6b5cd 100644 --- a/src/services/profileType.service.ts +++ b/src/services/profileType.service.ts @@ -85,15 +85,15 @@ export default class ProfileTypeService { // Apply corrections const correctionsNbWalls = - heatingData.adjustment_outisde_facing_walls[housingType] + heatingData.adjustment_outside_facing_walls[housingType] const correctionWalls: number = correctionsNbWalls[outsideFacingWalls] let correctionFloor: number let correctionInsulation: number let correctionFacilities: number - if (this.profileType.housingType === HousingType.APPARTMENT) { - correctionFloor = heatingData.adjustment_floor.appartment[floor] + if (this.profileType.housingType === HousingType.APARTMENT) { + correctionFloor = heatingData.adjustment_floor.apartment[floor] } else correctionFloor = 0 if ( diff --git a/src/services/queryRunner.service.spec.ts b/src/services/queryRunner.service.spec.ts index 1df675451..74597959f 100644 --- a/src/services/queryRunner.service.spec.ts +++ b/src/services/queryRunner.service.spec.ts @@ -506,7 +506,7 @@ describe('queryRunner service', () => { expect(result).toEqual(expectedResult) }) - it('should return the day data of the water fluid and unkown time step', async () => { + it('should return the day data of the water fluid and unknown time step', async () => { const mockTimePeriod = { startDate: DateTime.fromISO('2020-11-01T00:00:00.000Z', { zone: 'utc', @@ -783,7 +783,7 @@ describe('queryRunner service', () => { expect(result).toEqual(expectedResult) }) - it('should return the day data of the gas fluid and unkonwn time step', async () => { + it('should return the day data of the gas fluid and unknown time step', async () => { const mockTimePeriod = { startDate: DateTime.fromISO('2020-11-01T00:00:00.000Z', { zone: 'utc', @@ -1373,13 +1373,13 @@ describe('queryRunner service', () => { skip: 0, } mockClient.query.mockResolvedValue(mockQueryResult) - const result: QueryResult<any> = await queryRunner.fetchFluidRawDoctype( + const result = await queryRunner.fetchFluidRawDoctype( mockTimePeriod, TimeStep.YEAR, FluidType.ELECTRICITY ) expect(result).toEqual(mockQueryResult) - expect(result.data.length).toEqual(3) + expect(result?.data.length).toEqual(3) }) }) }) diff --git a/src/services/queryRunner.service.ts b/src/services/queryRunner.service.ts index ca89801a1..6fa812869 100644 --- a/src/services/queryRunner.service.ts +++ b/src/services/queryRunner.service.ts @@ -354,7 +354,7 @@ export default class QueryRunner { timePeriod: TimePeriod, timeStep: TimeStep, fluidType: FluidType - ): Promise<QueryResult> { + ) { const query: QueryDefinition = this.buildListQuery( timeStep, timePeriod, diff --git a/src/services/quiz.service.spec.ts b/src/services/quiz.service.spec.ts index 82f370ff9..12462ae47 100644 --- a/src/services/quiz.service.spec.ts +++ b/src/services/quiz.service.spec.ts @@ -15,12 +15,12 @@ import { UserQuestion, UserQuiz, } from 'models' -import mockClient from '../../tests/__mocks__/client' import { fullMonthGraphData, graphData, graphMonthData, -} from '../../tests/__mocks__/datachartData.mock' +} from '../../tests/__mocks__/chartData.mock' +import mockClient from '../../tests/__mocks__/client' import { allQuizEntities, customQuestionEntity, diff --git a/src/store/challenge/challenge.reducer.spec.ts b/src/store/challenge/challenge.reducer.spec.ts index fddfec7f8..9359a529b 100644 --- a/src/store/challenge/challenge.reducer.spec.ts +++ b/src/store/challenge/challenge.reducer.spec.ts @@ -1,3 +1,4 @@ +import { DataloadState } from 'enum/dataload.enum' import { UserChallengeState } from 'enum/userChallenge.enum' import { DateTime } from 'luxon' import { ChallengeState, Dataload, UserChallenge } from 'models' @@ -119,7 +120,12 @@ describe('challenge reducer', () => { zone: 'utc', }), value: 20, - valueDetail: [5.0, 10.0, 5.0], + valueDetail: [ + { state: DataloadState.VALID, value: 5.0 }, + { state: DataloadState.VALID, value: 10.0 }, + { state: DataloadState.VALID, value: 5.0 }, + ], + state: DataloadState.VALID, }, ] const updatedUserChallenge: UserChallenge = { diff --git a/src/store/chart/chart.action.spec.ts b/src/store/chart/chart.action.spec.ts index cda42cae7..c7b1b47fa 100644 --- a/src/store/chart/chart.action.spec.ts +++ b/src/store/chart/chart.action.spec.ts @@ -1,6 +1,6 @@ import { TimeStep } from 'enum/timeStep.enum' import { DateTime } from 'luxon' -import { graphData } from '../../../tests/__mocks__/datachartData.mock' +import { graphData } from '../../../tests/__mocks__/chartData.mock' import { setCurrentDatachart, setCurrentDatachartIndex, diff --git a/src/store/chart/chart.reducer.spec.ts b/src/store/chart/chart.reducer.spec.ts index 228c9404b..70b01f7e6 100644 --- a/src/store/chart/chart.reducer.spec.ts +++ b/src/store/chart/chart.reducer.spec.ts @@ -1,6 +1,6 @@ import { TimeStep } from 'enum/timeStep.enum' import { DateTime } from 'luxon' -import { graphData } from '../../../tests/__mocks__/datachartData.mock' +import { graphData } from '../../../tests/__mocks__/chartData.mock' import { mockInitialChartState } from '../../../tests/__mocks__/store' import { SET_CURRENT_DATACHART, diff --git a/src/store/index.ts b/src/store/index.ts index 103f7e398..0b17fa1f0 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -48,7 +48,7 @@ export const ecolyoReducer = combineReducers({ export interface AppStore { ecolyo: EcolyoState - cozy: never + cozy: unknown } const sentryReduxEnhancer = Sentry.createReduxEnhancer({}) diff --git a/src/store/profileType/profileType.reducer.ts b/src/store/profileType/profileType.reducer.ts index bf95bf17d..2cce9c4a7 100644 --- a/src/store/profileType/profileType.reducer.ts +++ b/src/store/profileType/profileType.reducer.ts @@ -3,6 +3,7 @@ import { ConstructionYear, Floor, HotWaterEquipment, + HotWaterFluid, HousingType, IndividualInsulationWork, IndividualOrCollective, @@ -37,7 +38,7 @@ const initialState: ProfileType = { hasReplacedHeater: ThreeChoicesAnswer.UNKNOWN, hotWaterEquipment: HotWaterEquipment.SOLAR, warmingFluid: WarmingType.ELECTRICITY, - hotWaterFluid: FluidType.ELECTRICITY, + hotWaterFluid: HotWaterFluid.ELECTRICITY, cookingFluid: FluidType.ELECTRICITY, updateDate: DateTime.fromISO('0000-01-01T00:00:00.000Z'), equipments: [], diff --git a/src/targets/services/aggregatorUsageEvents.ts b/src/targets/services/aggregatorUsageEvents.ts index a495be5e9..782add87b 100644 --- a/src/targets/services/aggregatorUsageEvents.ts +++ b/src/targets/services/aggregatorUsageEvents.ts @@ -4,7 +4,7 @@ import logger from 'cozy-logger' import { DaccEvent } from 'enum/dacc.enum' import { FluidState, FluidType } from 'enum/fluid.enum' import { FluidSlugType } from 'enum/fluidSlug.enum' -import { WarmingType } from 'enum/profileType.enum' +import { HotWaterFluid, WarmingType } from 'enum/profileType.enum' import { TimeStep } from 'enum/timeStep.enum' import { UsageEventType } from 'enum/usageEvent.enum' import { UsageEventProperties } from 'enum/usageEventProperties.enum' @@ -43,7 +43,7 @@ interface Indicator { const readUsageEvents: UsageEvent[] = [] // Store error events -const errorEvent: { error: any; doctype: string }[] = [] +const errorEvent: { error: unknown; doctype: string }[] = [] const sendIndicator = async ( indicator: Indicator, @@ -73,9 +73,13 @@ const sendIndicator = async ( ) return true } catch (error) { + let errorMessage = 'Failed to do something exceptional' + if (error instanceof Error) { + errorMessage = error.message + } logStack( 'error', - `Error while sending indicator ${indicator.measureName} to remote doctype: ${error.message}` + `Error while sending indicator ${indicator.measureName} to remote doctype: ${errorMessage}` ) Sentry.captureException(JSON.stringify({ error })) throw error @@ -113,7 +117,7 @@ const sendAggregatedEventByDay = async ( ) => { const reducedEvents = reduceEvents(events) for (const item of Object.keys(reducedEvents)) { - const splitedKey = item.split('|') + const splittedKey = item.split('|') let group1 = {} let group2 = {} let group3 = {} @@ -121,27 +125,27 @@ const sendAggregatedEventByDay = async ( group1 = { [groupsKeys.group1]: customValues?.[0] ? customValues[0] - : splitedKey[groupsIndexes[0]], + : splittedKey[groupsIndexes[0]], } } if (groupsKeys.group2 && (groupsIndexes[1] !== 0 || customValues?.[1])) { group2 = { [groupsKeys.group2]: customValues?.[1] ? customValues[1] - : splitedKey[groupsIndexes[1]], + : splittedKey[groupsIndexes[1]], } } if (groupsKeys.group3 && (groupsIndexes[2] !== 0 || customValues?.[2])) { group3 = { [groupsKeys.group3]: customValues?.[2] ? customValues[2] - : splitedKey[groupsIndexes[2]], + : splittedKey[groupsIndexes[2]], } } const indicator: Indicator = { createdBy: 'ecolyo', measureName: eventType, - startDate: DateTime.fromISO(splitedKey[0]).toISODate(), + startDate: DateTime.fromISO(splittedKey[0]).toISODate(), value: reducedEvents[item].length, group1: group1, ...(Object.keys(group2).length > 0 && { group2: group2 }), @@ -312,23 +316,23 @@ const calculPeriodBetweenChallenge = async ( /** * Format a string with all konnectors in success state - * @param konnectorfluidTypes FluidType[] + * @param konnectorFluidTypes FluidType[] * @returns string */ const getConnectedKonnectorSlug = ( - konnectorfluidTypes: FluidType[] + konnectorFluidTypes: FluidType[] ): string => { let slug = '' - if (konnectorfluidTypes.includes(FluidType.ELECTRICITY)) { + if (konnectorFluidTypes.includes(FluidType.ELECTRICITY)) { slug += 'electricity' } - if (konnectorfluidTypes.includes(FluidType.GAS)) { + if (konnectorFluidTypes.includes(FluidType.GAS)) { if (slug.length > 0) { slug += ':' } slug += 'gas' } - if (konnectorfluidTypes.includes(FluidType.WATER)) { + if (konnectorFluidTypes.includes(FluidType.WATER)) { if (slug.length > 0) { slug += ':' } @@ -345,9 +349,9 @@ const calculateConnectedKonnectorPerDay = async (client: Client) => { ) logStack('info', 'calculateConnectedKonnectorPerDay') if (connectedKonnectors.length > 0) { - const konnectorfluidTypes: FluidType[] = [] + const konnectorFluidTypes: FluidType[] = [] for (const konnector of connectedKonnectors) { - konnectorfluidTypes.push(konnector.fluidType) + konnectorFluidTypes.push(konnector.fluidType) } const KonnectorConnectedPerDayIndicator: Indicator = { createdBy: 'ecolyo', @@ -359,7 +363,7 @@ const calculateConnectedKonnectorPerDay = async (client: Client) => { .startOf('day') .toISODate(), value: connectedKonnectors.length, - group1: { categories: getConnectedKonnectorSlug(konnectorfluidTypes) }, + group1: { categories: getConnectedKonnectorSlug(konnectorFluidTypes) }, } await sendIndicator(KonnectorConnectedPerDayIndicator, client) } @@ -372,15 +376,15 @@ const calculateConnectedKonnectorPerDay = async (client: Client) => { * @param fluidType FluidType * @returns Promise<string> */ -const buildProfileWithFuildType = async ( +const buildProfileWithFluidType = async ( client: Client, fluidType: FluidType ): Promise<string> => { - let formatedProfile = '' + let formattedProfile = '' const profile = await new ProfileService(client).getProfile() // If profile is not filled, return empty string - if (!profile?.isProfileTypeCompleted) return formatedProfile + if (!profile?.isProfileTypeCompleted) return formattedProfile const date = DateTime.local().setZone('utc', { keepLocalTime: true, }) @@ -389,58 +393,62 @@ const buildProfileWithFuildType = async ( ) if (fluidType === FluidType.ELECTRICITY) { if (profile && profileType?.warmingFluid === WarmingType.ELECTRICITY) { - formatedProfile = 'chauffage élec' + formattedProfile = 'chauffage élec' } if (profile && profileType?.warmingFluid === WarmingType.WOOD) { - formatedProfile = 'chauffage bois' + formattedProfile = 'chauffage bois' } if (profile && profileType?.warmingFluid === WarmingType.FUEL) { - formatedProfile = 'chauffage fuel' + formattedProfile = 'chauffage fuel' } - if (profile && profileType?.hotWaterFluid === FluidType.ELECTRICITY) { - if (formatedProfile.length === 0) { - formatedProfile = 'ECS' + if (profile && profileType?.hotWaterFluid === HotWaterFluid.ELECTRICITY) { + if (formattedProfile.length === 0) { + formattedProfile = 'ECS' } else { - formatedProfile += ':ECS' + formattedProfile += ':ECS' } } if (profile && profileType?.cookingFluid === FluidType.ELECTRICITY) { - if (formatedProfile.length === 0) { - formatedProfile = 'cuisine élec' + if (formattedProfile.length === 0) { + formattedProfile = 'cuisine élec' } else { - formatedProfile += ':cuisine élec' + formattedProfile += ':cuisine élec' } } - if (formatedProfile.length === 0) { + if (formattedProfile.length === 0) { return 'électricité spécifique' } else { - return formatedProfile + return formattedProfile } } else if (fluidType === FluidType.GAS) { if (profile && profileType?.warmingFluid === WarmingType.GAS) { - formatedProfile = 'chauffage gaz' + formattedProfile = 'chauffage gaz' } - if (profile && profileType && profileType.hotWaterFluid === FluidType.GAS) { - if (formatedProfile.length === 0) { - formatedProfile = 'ECS' + if ( + profile && + profileType && + profileType.hotWaterFluid === HotWaterFluid.GAS + ) { + if (formattedProfile.length === 0) { + formattedProfile = 'ECS' } else { - formatedProfile += ':ECS' + formattedProfile += ':ECS' } } if (profile && profileType && profileType.cookingFluid === FluidType.GAS) { - if (formatedProfile.length === 0) { - formatedProfile = 'cuisine gaz' + if (formattedProfile.length === 0) { + formattedProfile = 'cuisine gaz' } else { - formatedProfile += ':cuisine gaz' + formattedProfile += ':cuisine gaz' } } - if (formatedProfile.length === 0) { + if (formattedProfile.length === 0) { return 'autre' } else { - return formatedProfile + return formattedProfile } } - return formatedProfile + return formattedProfile } const getConsumptionValue = async ( @@ -521,7 +529,7 @@ const calculateConsumptionVariation = async (client: Client) => { group2: { seniority: Math.round(seniority).toString() }, group3: { // eslint-disable-next-line camelcase - fluid_usage: await buildProfileWithFuildType( + fluid_usage: await buildProfileWithFluidType( client, getFluidType(FluidType[fluidType]) ), @@ -688,7 +696,7 @@ const sendHalfHourConsumption = async (client: Client) => { } /** - * Send indicator to dacc, each month send if user has succed to configure a connector with the number of try. + * Send indicator to dacc, each month send if user has succeeded to configure a connector with the number of try. * @param client CozyClient */ const sendKonnectorEvents = async (client: Client) => { @@ -724,7 +732,7 @@ const sendKonnectorEvents = async (client: Client) => { }, true ) - // Remove success from other month, they should have been already proceced + // Remove success from other month, they should have been already processed // successEvents.length = successEventsOfCurrentMonth for (let index = 0; index < successEvents.length; index++) { diff --git a/src/targets/services/fluidsPrices.ts b/src/targets/services/fluidsPrices.ts index 3563e2800..d6a5f0a6a 100644 --- a/src/targets/services/fluidsPrices.ts +++ b/src/targets/services/fluidsPrices.ts @@ -22,7 +22,7 @@ interface PricesProps { client: Client } -const getRemotePricesByfluid = async ( +const getRemotePricesByFluid = async ( client: Client, fluidType: FluidType ): Promise<FluidPrice[]> => { @@ -47,7 +47,7 @@ const synchroPricesToUpdate = async ( fluidType: FluidType ): Promise<string | null> => { const fps = new FluidPricesService(client) - const remotePrices = await getRemotePricesByfluid(client, fluidType) + const remotePrices = await getRemotePricesByFluid(client, fluidType) let firstEditedPrice: string | null = null await Promise.all( remotePrices.map(remotePrice => { @@ -216,8 +216,8 @@ const getDoctypeTypeByFluid = (fluidType: FluidType): string => { if (fluidType === FluidType.WATER) { return EGL_DAY_DOCTYPE } - logStack('error', 'Unkown FluidType') - Sentry.captureException({ error: 'Unkown FluidType Doctype' }) + logStack('error', 'Unknown FluidType') + Sentry.captureException({ error: 'Unknown FluidType Doctype' }) throw new Error() } @@ -228,8 +228,8 @@ const getTimeSetByFluid = (fluidType: FluidType): TimeStep[] => { if (fluidType === FluidType.GAS || fluidType === FluidType.WATER) { return [TimeStep.DAY] } - logStack('error', 'Unkown FluidType') - Sentry.captureException({ error: 'Unkown FluidType' }) + logStack('error', 'Unknown FluidType') + Sentry.captureException({ error: 'Unknown FluidType' }) throw new Error() } @@ -239,11 +239,11 @@ const applyPrices = async (client: Client, fluidType: FluidType) => { const cdm = new ConsumptionDataManager(client) const qr = new QueryRunner(client) - // Synchro dbprices with remote prices + // Synchro db prices with remote prices const firstEditedPriceDate = await synchroPricesToUpdate(client, fluidType) const firstDataDate = await cdm.fetchAllFirstDateData([fluidType]) const prices = await fluidsPricesService.getAllPrices() - // Prices data exsit + // Prices data exist if (prices.length > 0) { logStack('debug', 'fluidPrices data found') const firstMinuteData = await cdm.getFirstDataDateFromDoctypeWithPrice( diff --git a/src/targets/services/service.ts b/src/targets/services/service.ts index c0788e1ff..b9cad1f0e 100644 --- a/src/targets/services/service.ts +++ b/src/targets/services/service.ts @@ -16,8 +16,7 @@ export const runService = (service: Function) => { const client = CozyClient.fromEnv(process.env, { schema }) - return service({ client }).catch((e: ExceptionInformation) => { - // eslint-disable-next-line no-console + return service({ client }).catch((e: unknown) => { console.error(e) process.exit(1) }) diff --git a/src/types/cozy-client.d.ts b/src/types/cozy-client.d.ts index f4d0ae630..c6784da3d 100644 --- a/src/types/cozy-client.d.ts +++ b/src/types/cozy-client.d.ts @@ -85,7 +85,6 @@ declare module 'cozy-client' { export class Client { appMetadata: { version: string; slug: string } options: ClientLogin - idCounter: number isLogged: boolean instanceOptions: ClientInstanceOpts links: unknown diff --git a/src/utils/date.spec.ts b/src/utils/date.spec.ts index dca7d2e2d..d842b9243 100644 --- a/src/utils/date.spec.ts +++ b/src/utils/date.spec.ts @@ -2,7 +2,7 @@ import { FluidType } from 'enum/fluid.enum' import { TimeStep } from 'enum/timeStep.enum' import { DateTime } from 'luxon' import { Dataload } from 'models' -import { graphData } from '../../tests/__mocks__/datachartData.mock' +import { graphData } from '../../tests/__mocks__/chartData.mock' import { compareDates, convertDateToMonthString, diff --git a/src/utils/hash.spec.ts b/src/utils/hash.spec.ts index 6480d4628..de6088124 100644 --- a/src/utils/hash.spec.ts +++ b/src/utils/hash.spec.ts @@ -5,7 +5,7 @@ describe('hash utilis test', () => { describe('hashFile test', () => { it('should return the correct hash of the file', () => { const result = hashFile(ecogesturesData) - expect(result).toBe('a4bfebe7779dbf65f92591b2b6226ac7eb78097e') + expect(result).toBe('21c72fc0b67b0393ee457a25956703ef17b5b724') }) }) }) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 5539950b8..8e4d6e79c 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -147,14 +147,14 @@ export const getPreviousMonthName = (date: DateTime) => { 'octobre', 'novembre', 'décembre', - ] + ] as const return monthNames[date.month - 1] } /** * Return month string according to month index * @param date - DateTime - * @returns month in french + * @returns "de" month in french */ export const getMonthNameWithPrep = (date: DateTime) => { const monthNames = [ @@ -170,7 +170,7 @@ export const getMonthNameWithPrep = (date: DateTime) => { `d'octobre`, 'de novembre', 'de décembre', - ] + ] as const return monthNames[date.month - 1] } @@ -231,9 +231,9 @@ export const getSeason = (): Season => { * @returns Simone\nVEILLE */ export const getChallengeTitleWithLineReturn = (userChallengeId: string) => { - for (const chalModel of challengeData) { - if (chalModel._id === userChallengeId) { - return chalModel.title_line_return + for (const challenge of challengeData) { + if (challenge._id === userChallengeId) { + return challenge.title_line_return } } } diff --git a/tests/__mocks__/actionData.mock.ts b/tests/__mocks__/actionData.mock.ts index 538a3fba4..5cd2ef51f 100644 --- a/tests/__mocks__/actionData.mock.ts +++ b/tests/__mocks__/actionData.mock.ts @@ -1,4 +1,4 @@ -import { Season } from 'enum/ecogesture.enum' +import { EquipmentType, Season } from 'enum/ecogesture.enum' import { Ecogesture } from 'models' export const defaultEcogestureData: Ecogesture[] = [ @@ -145,14 +145,14 @@ export const AllEcogestureData: Ecogesture[] = [ shortName: 'Coup de vent', longName: 'Je ferme mes fenêtres quand la climatisation est en marche', longDescription: - "Cela permet de garder la fraicheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", + "Cela permet de garder la fraîcheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", impactLevel: 8, efficiency: 1, difficulty: 1, room: [0], season: Season.SUMMER, equipment: true, - equipmentType: [0], + equipmentType: [EquipmentType.AIR_CONDITIONING], equipmentInstallation: true, investment: null, action: false, diff --git a/tests/__mocks__/datachartData.mock.ts b/tests/__mocks__/chartData.mock.ts similarity index 100% rename from tests/__mocks__/datachartData.mock.ts rename to tests/__mocks__/chartData.mock.ts diff --git a/tests/__mocks__/ecogesturesData.mock.ts b/tests/__mocks__/ecogesturesData.mock.ts index e20933fb6..3e7b7d7ad 100644 --- a/tests/__mocks__/ecogesturesData.mock.ts +++ b/tests/__mocks__/ecogesturesData.mock.ts @@ -35,7 +35,7 @@ export const ecogesturesData: Ecogesture[] = [ fluidTypes: [FluidType.ELECTRICITY], id: 'ECOGESTURE002', longDescription: - "Cela permet de garder la fraicheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", + "Cela permet de garder la fraîcheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", longName: 'Je ferme mes fenêtres quand la climatisation est en marche', shortName: 'Coup de vent', usage: Usage.AIR_CONDITIONING, @@ -123,7 +123,7 @@ export const ecogesturesHeatingData: Ecogesture[] = [ fluidTypes: [FluidType.GAS], id: 'ECOGESTURE002', longDescription: - "Cela permet de garder la fraicheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", + "Cela permet de garder la fraîcheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", longName: 'Je ferme mes fenêtres quand la climatisation est en marche', shortName: 'Coup de vent', usage: Usage.HEATING, @@ -210,7 +210,7 @@ export const ecogesturesECSData: Ecogesture[] = [ fluidTypes: [FluidType.GAS], id: 'ECOGESTURE002', longDescription: - "Cela permet de garder la fraicheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", + "Cela permet de garder la fraîcheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", longName: 'Je ferme mes fenêtres quand la climatisation est en marche', shortName: 'Coup de vent', usage: Usage.ECS, @@ -298,7 +298,7 @@ export const ecogesturesCookingData: Ecogesture[] = [ fluidTypes: [FluidType.GAS], id: '002', longDescription: - "Cela permet de garder la fraicheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", + "Cela permet de garder la fraîcheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", longName: 'Je ferme mes fenêtres quand la climatisation est en marche', shortName: 'Coup de vent', usage: Usage.COOKING, @@ -414,7 +414,7 @@ export const ecogesturesElecSpecificData: Ecogesture[] = [ fluidTypes: [FluidType.GAS], id: '002', longDescription: - "Cela permet de garder la fraicheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", + "Cela permet de garder la fraîcheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", longName: 'Je ferme mes fenêtres quand la climatisation est en marche', shortName: 'Coup de vent', usage: Usage.ELECTRICITY_SPECIFIC, @@ -501,7 +501,7 @@ export const ecogesturesAirConditioningData: Ecogesture[] = [ fluidTypes: [FluidType.GAS], id: '002', longDescription: - "Cela permet de garder la fraicheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", + "Cela permet de garder la fraîcheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", longName: 'Je ferme mes fenêtres quand la climatisation est en marche', shortName: 'Coup de vent', usage: Usage.AIR_CONDITIONING, @@ -588,7 +588,7 @@ export const ecogesturesColdWaterData: Ecogesture[] = [ fluidTypes: [FluidType.WATER], id: '002', longDescription: - "Cela permet de garder la fraicheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", + "Cela permet de garder la fraîcheur à l'intérieur. Le climatiseur n'est pas là pour refroidir la rue mais bien la pièce.", longName: 'Je ferme mes fenêtres quand la climatisation est en marche', shortName: 'Coup de vent', usage: Usage.COLD_WATER, @@ -636,6 +636,7 @@ export const BoilerEcogesture: Ecogesture[] = [ actionDuration: 3, doing: false, objective: false, + viewedInSelection: false, _id: '001', _rev: '1-67f1ea36efdd892c96bf64a8943154cd', _type: 'com.grandlyon.ecolyo.ecogesture', @@ -664,6 +665,7 @@ export const BoilerEcogestureFalse: Ecogesture[] = [ actionDuration: 3, doing: false, objective: false, + viewedInSelection: false, _id: '001', _rev: '1-67f1ea36efdd892c96bf64a8943154cd', _type: 'com.grandlyon.ecolyo.ecogesture', diff --git a/tests/__mocks__/fluidStatusData.mock.ts b/tests/__mocks__/fluidStatusData.mock.ts index b86ae51b8..684bd3346 100644 --- a/tests/__mocks__/fluidStatusData.mock.ts +++ b/tests/__mocks__/fluidStatusData.mock.ts @@ -9,6 +9,7 @@ export const fluidStatusData: FluidStatus[] = [ { fluidType: 0, status: FluidState.KONNECTOR_NOT_FOUND, + maintenance: false, firstDataDate: DateTime.fromISO('2019-09-01T00:00:00.000Z', { zone: 'utc', }), @@ -34,6 +35,7 @@ export const fluidStatusData: FluidStatus[] = [ { fluidType: 1, status: FluidState.KONNECTOR_NOT_FOUND, + maintenance: false, firstDataDate: DateTime.fromISO('2019-09-01T00:00:00.000Z', { zone: 'utc', }), @@ -59,6 +61,7 @@ export const fluidStatusData: FluidStatus[] = [ { fluidType: 2, status: FluidState.KONNECTOR_NOT_FOUND, + maintenance: false, firstDataDate: DateTime.fromISO('2019-09-01T00:00:00.000Z', { zone: 'utc', }), @@ -99,6 +102,7 @@ export const fluidStatusConnectedData: FluidStatus[] = [ { fluidType: 0, status: FluidState.DONE, + maintenance: false, firstDataDate: DateTime.fromISO('2019-09-01T00:00:00.000Z', { zone: 'utc', }), @@ -135,6 +139,7 @@ export const fluidStatusConnectedData: FluidStatus[] = [ { fluidType: 1, status: FluidState.DONE, + maintenance: false, firstDataDate: DateTime.fromISO('2019-09-01T00:00:00.000Z', { zone: 'utc', }), @@ -160,6 +165,7 @@ export const fluidStatusConnectedData: FluidStatus[] = [ { fluidType: 2, status: FluidState.DONE, + maintenance: false, firstDataDate: DateTime.fromISO('2019-09-01T00:00:00.000Z', { zone: 'utc', }), @@ -186,6 +192,7 @@ export const fluidStatusConnectedData: FluidStatus[] = [ export const SgeStatusWithAccount: FluidStatus = { fluidType: 0, status: FluidState.KONNECTOR_NOT_FOUND, + maintenance: false, firstDataDate: DateTime.fromISO('2019-09-01T00:00:00.000Z', { zone: 'utc', }), diff --git a/tests/__mocks__/globalStateData.mock.ts b/tests/__mocks__/globalStateData.mock.ts index 44350809d..f49b200e9 100644 --- a/tests/__mocks__/globalStateData.mock.ts +++ b/tests/__mocks__/globalStateData.mock.ts @@ -103,7 +103,6 @@ export const globalStateData: GlobalState = { dataConsent: false, pdlConfirm: false, shouldLaunchAccount: false, - openSGEForm: false, }, customPopupModal: { title: '', diff --git a/tests/__mocks__/profileType.mock.ts b/tests/__mocks__/profileType.mock.ts index 45f6ee360..7dcd46722 100644 --- a/tests/__mocks__/profileType.mock.ts +++ b/tests/__mocks__/profileType.mock.ts @@ -35,7 +35,7 @@ export const profileTypeData: ProfileType = { hotWater: IndividualOrCollective.INDIVIDUAL, hotWaterEquipment: HotWaterEquipment.OTHER, hotWaterFluid: 0, - housingType: HousingType.APPARTMENT, + housingType: HousingType.APARTMENT, individualInsulationWork: [], occupantsNumber: 2, outsideFacingWalls: OutsideFacingWalls.TWO, @@ -47,7 +47,7 @@ export const profileTypeData: ProfileType = { } export const mockProfileType: ProfileType = { - housingType: HousingType.APPARTMENT, + housingType: HousingType.APARTMENT, constructionYear: ConstructionYear.AFTER_1998, area: '43', occupantsNumber: 1, @@ -84,7 +84,7 @@ export const mockMonthEcsConsumptionOther = 166 export const mockMonthEcsConsumptionThermo = 110 export const mockProfileType1: ProfileType = { - housingType: HousingType.APPARTMENT, + housingType: HousingType.APARTMENT, constructionYear: ConstructionYear.BETWEEN_1948_AND_1974, area: '43', occupantsNumber: 2, @@ -205,7 +205,7 @@ export const mockMonthlyForecastJanuaryTestProfile1: MonthlyForecast = { } export const mockTestProfile2: ProfileType = { - housingType: HousingType.APPARTMENT, + housingType: HousingType.APARTMENT, constructionYear: ConstructionYear.BETWEEN_1975_AND_1989, area: '50', occupantsNumber: 2, @@ -271,7 +271,7 @@ export const mockMonthlyForecastJanuaryTestProfile2: MonthlyForecast = { } export const mockTestProfile3: ProfileType = { - housingType: HousingType.APPARTMENT, + housingType: HousingType.APARTMENT, constructionYear: ConstructionYear.BETWEEN_1948_AND_1974, area: '50', occupantsNumber: 2, diff --git a/tests/__mocks__/store.ts b/tests/__mocks__/store.ts index a15e2e803..20953e36b 100644 --- a/tests/__mocks__/store.ts +++ b/tests/__mocks__/store.ts @@ -5,6 +5,7 @@ import { ConstructionYear, Floor, HotWaterEquipment, + HotWaterFluid, HousingType, IndividualInsulationWork, IndividualOrCollective, @@ -258,7 +259,7 @@ export const mockInitialProfileTypeState: ProfileType = { hasReplacedHeater: ThreeChoicesAnswer.UNKNOWN, hotWaterEquipment: HotWaterEquipment.SOLAR, warmingFluid: WarmingType.ELECTRICITY, - hotWaterFluid: FluidType.ELECTRICITY, + hotWaterFluid: HotWaterFluid.ELECTRICITY, cookingFluid: FluidType.ELECTRICITY, updateDate: DateTime.fromISO('0000-01-01T00:00:00.000Z'), equipments: [], -- GitLab