diff --git a/scripts/createConnections.js b/scripts/createConnections.js index 85e07a2f0108eefd3f77a07a4ff8805bd5cecee7..85fcbdaac31defc1a5cb1a5198cde10ebd823c5a 100644 --- a/scripts/createConnections.js +++ b/scripts/createConnections.js @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ const axios = require('axios') const config = require('./config') diff --git a/scripts/importData.sh b/scripts/importData.sh new file mode 100755 index 0000000000000000000000000000000000000000..3c3f3fb341b55d4748d25e419056189d09f2bb60 --- /dev/null +++ b/scripts/importData.sh @@ -0,0 +1,4 @@ +cozyssid="" +read -p "Please provide Cozyssid (can be found after connection in browser dev tool): " cozyssid +ACH -t cozyssid -u http://cozy.tools:8080 import ./data/dayData.json +rm cozyssid \ No newline at end of file diff --git a/src/components/Action/ActionBegin.tsx b/src/components/Action/ActionBegin.tsx index 6a2c5dcb8279c077a44099600fa9067c0bc32a4d..ee9176d302d6698c2eb0ba9126770409e9649997 100644 --- a/src/components/Action/ActionBegin.tsx +++ b/src/components/Action/ActionBegin.tsx @@ -101,7 +101,6 @@ const ActionBegin: React.FC<ActionBeginProps> = ({ </div> <div className="action-duration text-18"> {t('action.duration', { - // eslint-disable-next-line camelcase // eslint-disable-next-line camelcase smart_count: currentAction.actionDuration, })} diff --git a/src/components/ActivateHalfHourLoad/ActivateHalfHourLoad.spec.tsx b/src/components/ActivateHalfHourLoad/ActivateHalfHourLoad.spec.tsx deleted file mode 100644 index 42801b8be53e3a256e153d752dfc4a7e9ef06dbb..0000000000000000000000000000000000000000 --- a/src/components/ActivateHalfHourLoad/ActivateHalfHourLoad.spec.tsx +++ /dev/null @@ -1,109 +0,0 @@ -import React from 'react' -import { mount } from 'enzyme' -import ActivateHalfHourLoad from './ActivateHalfHourLoad' -import { Provider } from 'react-redux' -import configureStore from 'redux-mock-store' -import * as reactRedux from 'react-redux' -import Button from '@material-ui/core/Button' -import { profileData } from '../../../tests/__mocks__/profile.mock' -import { DateTime } from 'luxon' -import * as profileActions from 'store/profile/profile.actions' - -jest.mock('cozy-ui/transpiled/react/I18n', () => { - return { - useI18n: jest.fn(() => { - return { - t: (str: string) => str, - } - }), - } -}) -jest.mock('components/Hooks/useExploration', () => { - return () => ['', jest.fn()] -}) - -const localSpy = jest.spyOn(DateTime, 'local') -const mockUseSelector = jest.spyOn(reactRedux, 'useSelector') -const mockUseDispatch = jest.spyOn(reactRedux, 'useDispatch') -const updateProfileSpy = jest.spyOn(profileActions, 'updateProfile') - -const mockConfigureStore = configureStore([]) -const mockStore = mockConfigureStore({ - ecolyo: { - profile: profileData, - }, -}) - -describe('ActivateHalfHourLoad component test', () => { - beforeEach(() => { - localSpy.mockClear() - mockUseSelector.mockClear() - mockUseDispatch.mockClear() - updateProfileSpy.mockClear() - }) - - it('should render correctly ActivatehalfHourLoad', () => { - localSpy.mockReturnValue( - DateTime.fromISO('2020-10-10T08:08:08.008Z', { zone: 'utc' }) - ) - mockUseSelector.mockReturnValue(profileData) - mockUseDispatch.mockReturnValue(jest.fn()) - const wrapper = mount( - <Provider store={mockStore}> - <ActivateHalfHourLoad /> - </Provider> - ) - expect(wrapper.getElement()).toMatchSnapshot() - }) - - it('should render correctly ActivatehalfHourLoad with activateHalfHourDate +1 day > today', () => { - const _mockStore = mockConfigureStore({ - ecolyo: { - profile: { - ...profileData, - activateHalfHourDate: DateTime.fromISO('2020-10-10T08:00:00.000Z', { - zone: 'utc', - }), - }, - }, - }) - localSpy.mockReturnValue( - DateTime.fromISO('2020-10-10T08:08:08.008Z', { zone: 'utc' }) - ) - mockUseSelector.mockReturnValue(profileData) - mockUseDispatch.mockReturnValue(jest.fn()) - const wrapper = mount( - <Provider store={_mockStore}> - <ActivateHalfHourLoad /> - </Provider> - ) - expect(wrapper.getElement()).toMatchSnapshot() - }) - - it('should open konnector website when button is clicked and set the activateHalfHourDate in profile', () => { - localSpy.mockReturnValue( - DateTime.fromISO('2020-10-10T08:08:08.008Z', { zone: 'utc' }) - ) - mockUseSelector.mockReturnValue(profileData) - mockUseDispatch.mockReturnValue(jest.fn()) - const wrapper = mount( - <Provider store={mockStore}> - <ActivateHalfHourLoad /> - </Provider> - ) - - global.open = jest.fn() - - wrapper.find(Button).simulate('click') - expect(updateProfileSpy).toBeCalledTimes(1) - expect(updateProfileSpy).toHaveBeenCalledWith({ - activateHalfHourDate: DateTime.fromISO('2020-10-10T08:08:08.008Z', { - zone: 'utc', - }), - }) - expect(global.open).toHaveBeenCalledWith( - 'https://mon-compte-particulier.enedis.fr/donnees/', - '_blank' - ) - }) -}) diff --git a/src/components/ActivateHalfHourLoad/ActivateHalfHourLoad.tsx b/src/components/ActivateHalfHourLoad/ActivateHalfHourLoad.tsx deleted file mode 100644 index e13e3c3927ad17114df940add648ebb1072f6188..0000000000000000000000000000000000000000 --- a/src/components/ActivateHalfHourLoad/ActivateHalfHourLoad.tsx +++ /dev/null @@ -1,97 +0,0 @@ -import React, { Dispatch, useCallback } from 'react' -import { AppStore } from 'store' -import { useDispatch, useSelector } from 'react-redux' -import { IuseI18n, useI18n } from 'cozy-ui/transpiled/react/I18n' -import ConfigService from 'services/fluidConfig.service' -import Button from '@material-ui/core/Button' -import StyledIcon from 'components/CommonKit/Icon/StyledIcon' -import iconEnedisLogo from 'assets/icons/visu/enedis-logo.svg' -import './activateHalfHourLoad.scss' -import useExploration from 'components/Hooks/useExploration' -import { UserExplorationID } from 'enum/userExploration.enum' -import { FluidConfig, Profile } from 'models' -import { decoreText } from 'utils/decoreText' -import { DateTime } from 'luxon' -import { - ProfileActionTypes, - updateProfile, -} from 'store/profile/profile.actions' - -interface ActivateHalfHourLoadProps { - consentActive?: boolean -} - -const ActivateHalfHourLoad: React.FC<ActivateHalfHourLoadProps> = ({ - consentActive = false, -}: ActivateHalfHourLoadProps) => { - const { t }: IuseI18n = useI18n() - const { activateHalfHourDate } = useSelector( - (state: AppStore) => state.ecolyo.profile - ) - const dispatch: Dispatch<ProfileActionTypes> = useDispatch() - const fluidConfig: Array<FluidConfig> = new ConfigService().getFluidConfig() - const [, setValidExploration] = useExploration() - const tradKey: string = consentActive ? 'consent_active' : 'no_consent_active' - - const activateConsent = useCallback(() => { - setValidExploration(UserExplorationID.EXPLORATION004) - const partialProfile: Partial<Profile> = { - activateHalfHourDate: DateTime.local().setZone('utc', { - keepLocalTime: true, - }), - } - dispatch(updateProfile(partialProfile)) - window.open(fluidConfig[0].konnectorConfig.activation, '_blank') - }, [dispatch, fluidConfig, setValidExploration]) - - return ( - <> - <div className="activatehalfhour-box"> - <div className="activatehalfhour-box-header header-text text-16-normal"> - {activateHalfHourDate && - activateHalfHourDate.plus({ days: 1 }).startOf('day') > - DateTime.local().setZone('utc', { - keepLocalTime: true, - }) ? ( - <> - <h2 className="title text-20-bold"> - {t(`timestep.activate.enedis.consent_activated.title`)} - <br /> - {t(`timestep.activate.enedis.consent_activated.title_2`)} - </h2> - {t(`timestep.activate.enedis.consent_activated.info`)} - </> - ) : ( - <> - <h2 className="title text-20-bold"> - {t(`timestep.activate.enedis.${tradKey}.title`)} - </h2> - {decoreText(t(`timestep.activate.enedis.${tradKey}.info`))} - </> - )} - </div> - <Button - aria-label={t( - `timestep.activate.enedis.${tradKey}.accessibility.button_activate` - )} - onClick={activateConsent} - classes={{ - root: 'btn-highlight', - label: 'text-16-bold', - }} - > - <div className="oauthform-button-content"> - <div className="oauthform-button-content-icon"> - <StyledIcon icon={iconEnedisLogo} size={48} /> - </div> - <div className="oauthform-button-text text-18-bold"> - {t(`timestep.activate.enedis.${tradKey}.label1`)} - </div> - </div> - </Button> - </div> - </> - ) -} - -export default ActivateHalfHourLoad diff --git a/src/components/ActivateHalfHourLoad/__snapshots__/ActivateHalfHourLoad.spec.tsx.snap b/src/components/ActivateHalfHourLoad/__snapshots__/ActivateHalfHourLoad.spec.tsx.snap deleted file mode 100644 index 3b624456f0206ebc3dd18b7eb8353c0cf2a910f0..0000000000000000000000000000000000000000 --- a/src/components/ActivateHalfHourLoad/__snapshots__/ActivateHalfHourLoad.spec.tsx.snap +++ /dev/null @@ -1,35 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ActivateHalfHourLoad component test should render correctly ActivatehalfHourLoad 1`] = ` -<Provider - store={ - Object { - "clearActions": [Function], - "dispatch": [Function], - "getActions": [Function], - "getState": [Function], - "replaceReducer": [Function], - "subscribe": [Function], - } - } -> - <ActivateHalfHourLoad /> -</Provider> -`; - -exports[`ActivateHalfHourLoad component test should render correctly ActivatehalfHourLoad with activateHalfHourDate +1 day > today 1`] = ` -<Provider - store={ - Object { - "clearActions": [Function], - "dispatch": [Function], - "getActions": [Function], - "getState": [Function], - "replaceReducer": [Function], - "subscribe": [Function], - } - } -> - <ActivateHalfHourLoad /> -</Provider> -`; diff --git a/src/components/ActivateHalfHourLoad/activateHalfHourLoad.scss b/src/components/ActivateHalfHourLoad/activateHalfHourLoad.scss deleted file mode 100644 index 60a62f65c327a18ba16fa4b7c9390e84b7314195..0000000000000000000000000000000000000000 --- a/src/components/ActivateHalfHourLoad/activateHalfHourLoad.scss +++ /dev/null @@ -1,55 +0,0 @@ -@import 'src/styles/base/breakpoint'; -@import 'src/styles/base/color'; - -// Enedis Half Hour Load Activation -.activatehalfhour-box { - background-color: rgba(18, 18, 18, 0.8); - padding: 0rem 1rem 0rem 0rem; - display: flex; - justify-content: center; - align-items: center; - flex-direction: column; - min-height: 29.5rem; - @media #{$large-phone} { - min-height: 21.5rem; - padding: 0; - } - - .title { - color: $elec-color; - margin-bottom: 18px; - } - - .activatehalfhour-box-header { - text-align: center; - font-weight: bold; - letter-spacing: 0.2px; - margin-bottom: 1.5em; - color: $grey-bright; - width: 50%; - @media #{$large-phone} { - width: 90%; - } - span { - color: $elec-color; - font-weight: bold; - } - } - button.btn-highlight { - margin-left: auto; - margin-right: auto; - width: 50%; - @media #{$large-phone} { - width: 80%; - } - } - .oauthform-button-content { - display: flex; - @media (min-width: $width-large-desktop) { - display: block; - } - } - .oauthform-button-text { - align-self: center; - } -} diff --git a/src/components/Analysis/ElecHalfHourMonthlyAnalysis.tsx b/src/components/Analysis/ElecHalfHourMonthlyAnalysis.tsx index 712283338269cd52f1cc3fc83a48ec4b6c7d34af..dbda249064ae79a0959e606111dc23eff2e7893e 100644 --- a/src/components/Analysis/ElecHalfHourMonthlyAnalysis.tsx +++ b/src/components/Analysis/ElecHalfHourMonthlyAnalysis.tsx @@ -145,7 +145,12 @@ const ElecHalfHourMonthlyAnalysis: React.FC< size={42} /> <div className="text-18-normal title">{t('special_elec.title')}</div> - {isHalfHourActivated ? ( + {!isHalfHourActivated && ( + <div className="activation-text text-18-normal"> + {t(`timestep.half_an_hour.analysis_waiting_data`)} + </div> + )} + {isHalfHourActivated && ( <> <div className="navigator"> <IconButton @@ -174,7 +179,12 @@ const ElecHalfHourMonthlyAnalysis: React.FC< <Icon icon={RigthArrowIcon} size={24} /> </IconButton> </div> - {!isLoading ? ( + {isLoading && ( + <div className="loader-container"> + <StyledSpinner size="5em" fluidType={FluidType.ELECTRICITY} /> + </div> + )} + {!isLoading && ( <> {getPowerChart()} {enedisAnalysisValues && ( @@ -241,44 +251,8 @@ const ElecHalfHourMonthlyAnalysis: React.FC< </div> )} </> - ) : ( - <div className="loader-container"> - <StyledSpinner size="5em" fluidType={FluidType.ELECTRICITY} /> - </div> )} </> - ) : ( - <> - <div className="activation-text text-18-normal"> - {t(`timestep.activate.enedis.no_consent_active.text_analysis`)} - </div> - <Button - aria-label={t( - `timestep.activate.enedis.no_consent_active.accessibility.button_activate` - )} - onClick={() => { - setValidExploration(UserExplorationID.EXPLORATION004) - window.open(fluidConfig[0].konnectorConfig.activation, '_blank') - }} - classes={{ - root: 'btn-highlight', - label: 'text-16-bold', - }} - > - <div className="oauthform-button-content"> - <div className="oauthform-button-content-icon"> - <StyledIcon icon={iconEnedisLogo} size={48} /> - </div> - <div className="oauthform-button-text text-18-bold"> - <div> - {t( - `timestep.activate.enedis.no_consent_active.accessibility.button_activate` - )} - </div> - </div> - </div> - </Button> - </> )} <ElecInfoModal open={openInfoModal} handleCloseClick={toggleOpenModal} /> </div> diff --git a/src/components/Analysis/__snapshots__/ElecHalfHourMonthlyAnalysis.spec.tsx.snap b/src/components/Analysis/__snapshots__/ElecHalfHourMonthlyAnalysis.spec.tsx.snap index 28a533d97ce044334a6213acf0d79b18e3bf25ec..5fd55796f77f6f1cb91b218931ece226b2a9b85b 100644 --- a/src/components/Analysis/__snapshots__/ElecHalfHourMonthlyAnalysis.spec.tsx.snap +++ b/src/components/Analysis/__snapshots__/ElecHalfHourMonthlyAnalysis.spec.tsx.snap @@ -47,184 +47,8 @@ exports[`ElecHalfHourMonthlyAnalysis component should be rendered correctly when <div className="activation-text text-18-normal" > - timestep.activate.enedis.no_consent_active.text_analysis + timestep.half_an_hour.analysis_waiting_data </div> - <WithStyles(ForwardRef(Button)) - aria-label="timestep.activate.enedis.no_consent_active.accessibility.button_activate" - classes={ - Object { - "label": "text-16-bold", - "root": "btn-highlight", - } - } - onClick={[Function]} - > - <ForwardRef(Button) - aria-label="timestep.activate.enedis.no_consent_active.accessibility.button_activate" - classes={ - Object { - "colorInherit": "MuiButton-colorInherit", - "contained": "MuiButton-contained", - "containedPrimary": "MuiButton-containedPrimary", - "containedSecondary": "MuiButton-containedSecondary", - "containedSizeLarge": "MuiButton-containedSizeLarge", - "containedSizeSmall": "MuiButton-containedSizeSmall", - "disableElevation": "MuiButton-disableElevation", - "disabled": "Mui-disabled", - "endIcon": "MuiButton-endIcon", - "focusVisible": "Mui-focusVisible", - "fullWidth": "MuiButton-fullWidth", - "iconSizeLarge": "MuiButton-iconSizeLarge", - "iconSizeMedium": "MuiButton-iconSizeMedium", - "iconSizeSmall": "MuiButton-iconSizeSmall", - "label": "MuiButton-label text-16-bold", - "outlined": "MuiButton-outlined", - "outlinedPrimary": "MuiButton-outlinedPrimary", - "outlinedSecondary": "MuiButton-outlinedSecondary", - "outlinedSizeLarge": "MuiButton-outlinedSizeLarge", - "outlinedSizeSmall": "MuiButton-outlinedSizeSmall", - "root": "MuiButton-root btn-highlight", - "sizeLarge": "MuiButton-sizeLarge", - "sizeSmall": "MuiButton-sizeSmall", - "startIcon": "MuiButton-startIcon", - "text": "MuiButton-text", - "textPrimary": "MuiButton-textPrimary", - "textSecondary": "MuiButton-textSecondary", - "textSizeLarge": "MuiButton-textSizeLarge", - "textSizeSmall": "MuiButton-textSizeSmall", - } - } - onClick={[Function]} - > - <WithStyles(ForwardRef(ButtonBase)) - aria-label="timestep.activate.enedis.no_consent_active.accessibility.button_activate" - className="MuiButton-root btn-highlight MuiButton-text" - component="button" - disabled={false} - focusRipple={true} - focusVisibleClassName="Mui-focusVisible" - onClick={[Function]} - type="button" - > - <ForwardRef(ButtonBase) - aria-label="timestep.activate.enedis.no_consent_active.accessibility.button_activate" - className="MuiButton-root btn-highlight MuiButton-text" - classes={ - Object { - "disabled": "Mui-disabled", - "focusVisible": "Mui-focusVisible", - "root": "MuiButtonBase-root", - } - } - component="button" - disabled={false} - focusRipple={true} - focusVisibleClassName="Mui-focusVisible" - onClick={[Function]} - type="button" - > - <button - aria-label="timestep.activate.enedis.no_consent_active.accessibility.button_activate" - className="MuiButtonBase-root MuiButton-root btn-highlight MuiButton-text" - disabled={false} - onBlur={[Function]} - onClick={[Function]} - onDragLeave={[Function]} - onFocus={[Function]} - onKeyDown={[Function]} - onKeyUp={[Function]} - onMouseDown={[Function]} - onMouseLeave={[Function]} - onMouseUp={[Function]} - onTouchEnd={[Function]} - onTouchMove={[Function]} - onTouchStart={[Function]} - tabIndex={0} - type="button" - > - <span - className="MuiButton-label text-16-bold" - > - <div - className="oauthform-button-content" - > - <div - className="oauthform-button-content-icon" - > - <StyledIcon - icon="test-file-stub" - size={48} - > - <Icon - aria-hidden={true} - icon="test-file-stub" - size={48} - spin={false} - > - <Component - aria-hidden={true} - className="styles__icon___23x3R" - height={48} - style={Object {}} - width={48} - > - <svg - aria-hidden={true} - className="styles__icon___23x3R" - height={48} - style={Object {}} - width={48} - > - <use - xlinkHref="#test-file-stub" - /> - </svg> - </Component> - </Icon> - </StyledIcon> - </div> - <div - className="oauthform-button-text text-18-bold" - > - <div> - timestep.activate.enedis.no_consent_active.accessibility.button_activate - </div> - </div> - </div> - </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))> - </ForwardRef(Button)> - </WithStyles(ForwardRef(Button))> <mock-elecinfomodal handleCloseClick={[Function]} open={false} diff --git a/src/components/FluidChart/FluidChart.tsx b/src/components/FluidChart/FluidChart.tsx index e24c47f472b1d04c783a36a042affd8fa4c6c2f2..ff1a4bc3cd0016ff7fac04fffe00890665d2b211 100644 --- a/src/components/FluidChart/FluidChart.tsx +++ b/src/components/FluidChart/FluidChart.tsx @@ -1,22 +1,21 @@ -import React, { useState, useEffect } from 'react' -import './fluidChart.scss' -import { useI18n } from 'cozy-ui/transpiled/react/I18n' +import useExploration from 'components/Hooks/useExploration' import { useClient } from 'cozy-client' +import { useI18n } from 'cozy-ui/transpiled/react/I18n' +import React, { useEffect, useState } from 'react' import { useSelector } from 'react-redux' import { AppStore } from 'store' -import useExploration from 'components/Hooks/useExploration' +import './fluidChart.scss' +import StyledSwitch from 'components/CommonKit/Switch/StyledSwitch' +import HalfHourNoData from 'components/HalfHourNoData/HalfHourNoData' +import TimeStepSelector from 'components/TimeStepSelector/TimeStepSelector' import { FluidType } from 'enum/fluid.enum' import { TimeStep } from 'enum/timeStep.enum' +import { UsageEventType } from 'enum/usageEvent.enum' import { UserExplorationID } from 'enum/userExploration.enum' import ConsumptionService from 'services/consumption.service' - -import StyledSwitch from 'components/CommonKit/Switch/StyledSwitch' -import TimeStepSelector from 'components/TimeStepSelector/TimeStepSelector' -import ActivateHalfHourLoad from 'components/ActivateHalfHourLoad/ActivateHalfHourLoad' -import FluidChartSwipe from './FluidChartSwipe' -import { UsageEventType } from 'enum/usageEvent.enum' import UsageEventService from 'services/usageEvent.service' +import FluidChartSwipe from './FluidChartSwipe' interface FluidChartProps { fluidType: FluidType @@ -34,10 +33,10 @@ const FluidChart: React.FC<FluidChartProps> = ({ (state: AppStore) => state.ecolyo.chart ) const [, setValidExploration] = useExploration() - const [isMinuteBlocked, setMinuteBlocked] = useState<boolean>(false) - const [isEnedisConsentTimeout, setEnedisConsentKO] = useState<boolean>(false) const [isLoaded, setIsLoaded] = useState<boolean>(false) const [showCompare, setShowCompare] = useState<boolean>(false) + const [containsHalfHourData, setContainsHalfHourData] = + useState<boolean>(false) const handleChangeSwitch = async () => { if (!showCompare) { @@ -52,94 +51,79 @@ const FluidChart: React.FC<FluidChartProps> = ({ useEffect(() => { let subscribed = true - let isEnedisConsentValid = true async function loadData() { const consumptionService = new ConsumptionService(client) - let activateHalfHourLoad = false if (fluidType === FluidType.ELECTRICITY) { - activateHalfHourLoad = await consumptionService.checkDoctypeEntries( + const halfHourData = await consumptionService.checkDoctypeEntries( FluidType.ELECTRICITY, TimeStep.HALF_AN_HOUR ) - } - if (currentTimeStep === TimeStep.HALF_AN_HOUR && activateHalfHourLoad) { - isEnedisConsentValid = - await consumptionService.checkEnedisHalHourConsent(selectedDate) + if (halfHourData) { + setContainsHalfHourData(true) + } } if (subscribed) { - if (!activateHalfHourLoad) { - setMinuteBlocked(true) - } - setEnedisConsentKO(!isEnedisConsentValid) setIsLoaded(true) } } + loadData() + return () => { subscribed = false } }, [client, fluidStatus, selectedDate, currentTimeStep, fluidType]) useEffect(() => { - if (!isMinuteBlocked && currentTimeStep === TimeStep.HALF_AN_HOUR) { + if (containsHalfHourData && currentTimeStep === TimeStep.HALF_AN_HOUR) { setValidExploration(UserExplorationID.EXPLORATION004) } else if (currentTimeStep === TimeStep.YEAR) { setValidExploration(UserExplorationID.EXPLORATION003) } - }, [isMinuteBlocked, currentTimeStep, setValidExploration]) + }, [containsHalfHourData, currentTimeStep, setValidExploration]) + + const getCompareLabel = (currentTimeStep: TimeStep) => { + return t(`timestep.${TimeStep[currentTimeStep].toLowerCase()}.comparelabel`) + } return ( <> {isLoaded && ( - <> - <div className="fluidchart-root"> - {isMinuteBlocked && currentTimeStep === TimeStep.HALF_AN_HOUR ? ( - <ActivateHalfHourLoad consentActive={true} /> - ) : isEnedisConsentTimeout && - currentTimeStep === TimeStep.HALF_AN_HOUR ? ( - <ActivateHalfHourLoad consentActive={false} /> - ) : ( - <div className="fluidchart-content"> - <FluidChartSwipe + <div className="fluidchart-root"> + {currentTimeStep === TimeStep.HALF_AN_HOUR && + !containsHalfHourData ? ( + <HalfHourNoData /> + ) : ( + <div className="fluidchart-content"> + <FluidChartSwipe + fluidType={fluidType} + showCompare={ + currentTimeStep === TimeStep.YEAR ? false : showCompare + } + setActive={setActive} + /> + </div> + )} + <TimeStepSelector fluidType={fluidType} /> + {currentTimeStep !== TimeStep.YEAR && ( + <div className="fluidchart-footer" onClick={handleChangeSwitch}> + <div className="fluidchart-footer-compare text-15-normal"> + <StyledSwitch fluidType={fluidType} - showCompare={ - currentTimeStep === TimeStep.YEAR ? false : showCompare - } - setActive={setActive} + checked={showCompare} + inputProps={{ + 'aria-label': t( + 'consumption.accessibility.checkbox_compare' + ), + }} /> + <span className="fluidchart-footer-label graph-switch-text"> + {getCompareLabel(currentTimeStep)} + </span> </div> - )} - <TimeStepSelector fluidType={fluidType} /> - {currentTimeStep !== TimeStep.YEAR ? ( - <div className="fluidchart-footer" onClick={handleChangeSwitch}> - <div className="fluidchart-footer-compare text-15-normal"> - <StyledSwitch - fluidType={fluidType} - checked={showCompare} - inputProps={{ - 'aria-label': t( - 'consumption.accessibility.checkbox_compare' - ), - }} - /> - <span - className={ - showCompare - ? `fluidchart-footer-label graph-switch-text selected` - : `fluidchart-footer-label graph-switch-text` - } - > - {t( - `timestep.${TimeStep[ - currentTimeStep - ].toLowerCase()}.comparelabel` - )} - </span> - </div> - </div> - ) : null} - </div> - </> + </div> + )} + </div> )} </> ) diff --git a/src/components/HalfHourNoData/HalfHourNoData.spec.tsx b/src/components/HalfHourNoData/HalfHourNoData.spec.tsx new file mode 100644 index 0000000000000000000000000000000000000000..84275d83bc6056bb85a120c6f190ee2847e001f4 --- /dev/null +++ b/src/components/HalfHourNoData/HalfHourNoData.spec.tsx @@ -0,0 +1,20 @@ +import React from 'react' +import { mount } from 'enzyme' +import HalfHourNoData from './HalfHourNoData' + +jest.mock('cozy-ui/transpiled/react/I18n', () => { + return { + useI18n: jest.fn(() => { + return { + t: (str: string) => str, + } + }), + } +}) + +describe('HalfHourNoData component', () => { + it('should render correctly HalfHourNoData', () => { + const component = mount(<HalfHourNoData />) + expect(component).toMatchSnapshot() + }) +}) diff --git a/src/components/HalfHourNoData/HalfHourNoData.tsx b/src/components/HalfHourNoData/HalfHourNoData.tsx new file mode 100644 index 0000000000000000000000000000000000000000..1834608414a7e84f390927e8363ac624da88503d --- /dev/null +++ b/src/components/HalfHourNoData/HalfHourNoData.tsx @@ -0,0 +1,15 @@ +import React from 'react' +import { IuseI18n, useI18n } from 'cozy-ui/transpiled/react/I18n' +import './halfHourNoData.scss' + +const HalfHourNoData = () => { + const { t }: IuseI18n = useI18n() + return ( + <div className="halfHour"> + <h2>{t('timestep.half_an_hour.gather_data_title')}</h2> + <p>{t('timestep.half_an_hour.gather_data_subtitle')}</p> + </div> + ) +} + +export default HalfHourNoData diff --git a/src/components/HalfHourNoData/__snapshots__/HalfHourNoData.spec.tsx.snap b/src/components/HalfHourNoData/__snapshots__/HalfHourNoData.spec.tsx.snap new file mode 100644 index 0000000000000000000000000000000000000000..ef55e75a7baa649a8a4924df51b3b59c2da6b06b --- /dev/null +++ b/src/components/HalfHourNoData/__snapshots__/HalfHourNoData.spec.tsx.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`HalfHourNoData component should render correctly HalfHourNoData 1`] = `ReactWrapper {}`; diff --git a/src/components/HalfHourNoData/halfHourNoData.scss b/src/components/HalfHourNoData/halfHourNoData.scss new file mode 100644 index 0000000000000000000000000000000000000000..2691c324d3d3ee41a7d1075eb27ee0a7bbe8f57a --- /dev/null +++ b/src/components/HalfHourNoData/halfHourNoData.scss @@ -0,0 +1,26 @@ +@import 'src/styles/base/color'; +@import 'src/styles/base/breakpoint'; + +.halfHour { + display: flex; + flex-direction: column; + align-items: center; + text-align: center; + padding: 2rem 0; + + // Same height as FluidChartSwipe + height: 25.5rem; + @media #{$large-phone} { + height: 17.5rem; + } + + h2 { + color: $elec-color; + margin-bottom: 3rem; + } + + p { + color: $grey-bright; + padding: 0 0.5rem; + } +} diff --git a/src/db/explorationEntity.json b/src/db/explorationEntity.json index 7261e7650432ac1b8446e75f32e4ac535f231dc1..2b7f221fed48d7fb2c76dab5cee0f91f8dfd1e5c 100644 --- a/src/db/explorationEntity.json +++ b/src/db/explorationEntity.json @@ -38,8 +38,8 @@ { "_id": "EXPLORATION004", "state": 0, - "description": "Dévérouillez la consultation des données électricité à la demi-heure pour remporter 5 étoiles.", - "complementary_description": "Si c'est est déjà fait, allez simplement consulter ces données.", + "description": "Consultez vos données électriques au pas de temps demi-heure.", + "complementary_description": "", "target": 1, "type": 1, "date": null, diff --git a/src/locales/fr.json b/src/locales/fr.json index 95fab822fc39f25b352db68ad0d58239d7ed3a4c..8c4fd0e4e06b89006ea7b96588380bca4baecd9a 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -1242,32 +1242,6 @@ }, "timestep": { "today": "Aujourd'hui", - "activate": { - "enedis": { - "consent_active": { - "title": "La visualisation par 1/2 heure n’est pas activée", - "info": "Pour les visualiser, il vous faut activer l’<span>enregistrement</span> de votre consommation horaire sur votre compte Enedis", - "label1": "Activer sur mon compte Enedis", - "accessibility": { - "button_activate": "Aller sur mon compte Enedis" - } - }, - "no_consent_active": { - "title": "La visualisation par 1/2 heure n’est pas activée", - "info": "Il semble que votre consentement ait expiré, il vous faut ré-activer l’enregistrement de votre consommation horaire sur votre compte Enedis", - "label1": "Ré-activer sur mon compte Enedis", - "accessibility": { - "button_activate": "Aller sur mon compte Enedis" - }, - "text_analysis": "Pour bénéficier d’une analyse approfondie de votre consommation électrique, il vous faut activer l’enregistrement de votre consommation horaire sur votre compte Enedis" - }, - "consent_activated": { - "title": "La récupération de vos données s’effectuera cette nuit.", - "title_2": "À demain !", - "info": "Si vous n’avez pas réussi à activer l'enregistrement de votre consommation horaire, vous pouvez ré-essayer." - } - } - }, "year": { "period": "5 ans", "comparelabel": "Comparer à l'année précédente" @@ -1286,7 +1260,10 @@ }, "half_an_hour": { "period": "Jour", - "comparelabel": "Comparer à la journée précédente" + "comparelabel": "Comparer à la journée précédente", + "gather_data_title": "La récupération de vos données demi-horaires prend environ 24h.", + "gather_data_subtitle": "Votre connexion a bien été prise en compte mais un délai de 24h est en général nécessaire à l’obtention de vos données.\nÀ demain !", + "analysis_waiting_data": "Pour bénéficier d'une analyse approfondie de votre consommation électrique, il nous faut récupérer vos données de consommation horaires. La récupération de ces données prend environ 24h. A\u00a0bientôt\u00a0!" }, "accessibility": { "button_zoom_in": "Sélectionner le pas de temps précédent", diff --git a/src/services/consumption.service.ts b/src/services/consumption.service.ts index 18db7623b1e58e4685dde2a9462ededf81ebd27d..a3e19edf3a085e4ff9d6322f7da2e06251714c39 100644 --- a/src/services/consumption.service.ts +++ b/src/services/consumption.service.ts @@ -380,25 +380,6 @@ export default class ConsumptionDataManager { return false } - public async checkEnedisHalHourConsent( - selectedDate: DateTime - ): Promise<boolean> { - const timePeriod = { - startDate: selectedDate.minus({ days: 3 }).startOf('day'), - endDate: selectedDate, - } - const data = await this._queryRunnerService.fetchFluidData( - timePeriod, - TimeStep.HALF_AN_HOUR, - FluidType.ELECTRICITY - ) - - if (data && data.length > 0) { - return true - } - return false - } - private aggregateGraphData( singleFluidCharts: ISingleFluidChartData[] //,withComparison: boolean = true diff --git a/src/styles/index.scss b/src/styles/index.scss index 6e47ddb514e9faab0bc57307ebb88ca09e5d2b70..19cdba9061ca1592c29f01985bb9e3d5538dd69e 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -17,6 +17,7 @@ @import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap'); :root { + white-space: pre-line; --blue: #{$blue}; --blue40: #{$blue-40}; --blueBackground: #{$blue-radial-gradient};