Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • web-et-numerique/factory/llle_project/ecolyo
1 result
Show changes
Commits on Source (27)
Showing
with 189 additions and 166 deletions
# Related to #000
| :triangular_flag_on_post: Give your MR title the same name that the desired squash commit. In doubt, check the conventional commit [doc][conventional-commits]. examples |
| --- |
| **feat(profile)**: add... |
| **fix(annuaire)**: remove... |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **feat(profile)**: add... |
| **fix(annuaire)**: remove... |
## What does this MR do and why?
......@@ -28,7 +28,18 @@ More reading on checklists can be found in the "Checklist Manifesto": http://atu
"It is common to misconceive how checklists function in complex lines of work. They are not comprehensive how-to guides, whether for building a skyscraper or getting a plane out of trouble. They are quick and simple tools aimed to buttress the skills of expert professionals." - Gawande, Atul. The Checklist Manifesto
--->
### Quality [![Bugs](https://sonarqube.forge.grandlyon.com/api/project_badges/measure?project=ecolyo-mr&metric=bugs&token=3d678f5d0b1736ae2a81986f8bf3bcb32672231c)](https://sonarqube.forge.grandlyon.com/dashboard?id=ecolyo-mr) - [![Code Smells](https://sonarqube.forge.grandlyon.com/api/project_badges/measure?project=ecolyo-mr&metric=code_smells&token=3d678f5d0b1736ae2a81986f8bf3bcb32672231c)](https://sonarqube.forge.grandlyon.com/dashboard?id=ecolyo-mr)
### Quality
#### Bugs & smells summary
_🔁 Re-run Quality job to update_
| Current MR | Dev |
| ----------------------------------------- | ------------------------------------------- |
| [![Bugs][bugs_mr]][dashboard_mr] | [![Bugs][bugs_dev]][dashboard_dev] |
| [![Code Smells][smells_mr]][dashboard_mr] | [![Code Smells][smells_dev]][dashboard_dev] |
#### Quality checklist
- For the code that this change impacts, I believe that the **automated tests validate functionality** that is **highly important to users**. If the existing automated tests do not cover this functionality, I have **added the necessary additional tests** or I have added an issue to describe the automation testing gap and linked it to this MR.
- I have made sure that the **sonar quality coverage is up to standards**.
......@@ -55,4 +66,9 @@ More reading on checklists can be found in the "Checklist Manifesto": http://atu
- When featured on a self-data project release, I have made sure my **app version** in the manifest and package.json is **incremented** and any relative **changes to the permissions are clearly written and transmitted to Cozy**.
[conventional-commits]: https://www.conventionalcommits.org/en/v1.0.0/
[bugs_mr]: https://sonarqube.forge.grandlyon.com/api/project_badges/measure?project=ecolyo-mr&metric=bugs&token=3d678f5d0b1736ae2a81986f8bf3bcb32672231c
[bugs_dev]: https://sonarqube.forge.grandlyon.com/api/project_badges/measure?project=ecolyo&metric=bugs&token=95187318baacb2c9aeab7c8f3046b4b66f08e9b1
[smells_mr]: https://sonarqube.forge.grandlyon.com/api/project_badges/measure?project=ecolyo-mr&metric=code_smells&token=3d678f5d0b1736ae2a81986f8bf3bcb32672231c
[smells_dev]: https://sonarqube.forge.grandlyon.com/api/project_badges/measure?project=ecolyo&metric=code_smells&token=95187318baacb2c9aeab7c8f3046b4b66f08e9b1
[dashboard_mr]: https://sonarqube.forge.grandlyon.com/dashboard?id=ecolyo-mr
[dashboard_dev]: https://sonarqube.forge.grandlyon.com/dashboard?id=ecolyo
......@@ -89,6 +89,7 @@
"firstname",
"fluidchart",
"fluidchartslide",
"FLUIDNAME",
"fluidsprices",
"fluidtype",
"Folinge",
......@@ -100,6 +101,7 @@
"grdfgrandlyon",
"Hypervitesse",
"késako",
"kmodal",
"Konnected",
"konnector",
"konnectors",
......@@ -155,5 +157,5 @@
"userchallenge"
],
"typescript.tsdk": "node_modules/typescript/lib",
"conventionalCommits.scopes": ["ui"]
"conventionalCommits.scopes": ["ui", "ecogestures"]
}
......@@ -19,22 +19,25 @@ module.exports = {
__STACK_ASSETS__: target !== 'mobile',
__PIWIK_TRACKER_URL__: JSON.stringify('https://statweb.grandlyon.com/'),
__PIWIK_SITEID__: 117,
__SENTRY_DSN__: JSON.stringify(
'https://c868f6010f3f431d95be8f70d7f37666@grandlyon.errors.cozycloud.cc/6'
),
__SAU_LINK__: JSON.stringify(
'https://portail-citoyen-sau.guichet-recette.grandlyon.com/ecolyo/'
),
__SAU_IDEA_DIRECT_LINK__: JSON.stringify(
'https://demarches-sau.guichet-recette.grandlyon.com/retour-ecolyo/ecolyo-une-idee/'
),
__SAU_ISSUE_DIRECT_LINK__: JSON.stringify(
'https://demarches-sau.guichet-recette.grandlyon.com/retour-ecolyo/ecolyo-un-probleme/'
),
__SENTRY_DSN__: JSON.stringify(
'https://c868f6010f3f431d95be8f70d7f37666@grandlyon.errors.cozycloud.cc/6'
),
}),
],
optimization: {
minimizer: [
new TerserPlugin({
parallel: true,
//To fix a SAfari 10 bug : https://github.com/zeit/next.js/issues/5630
// To fix a SAfari 10 bug : https://github.com/zeit/next.js/issues/5630
terserOptions: {
safari10: true,
},
......
......@@ -29,6 +29,9 @@ const stackProvidedLibsConfig = {
__SAU_IDEA_DIRECT_LINK__: JSON.stringify(
'https://demarches-sau.guichet-recette.grandlyon.com/retour-ecolyo/ecolyo-une-idee/'
),
__SAU_ISSUE_DIRECT_LINK__: JSON.stringify(
'https://demarches-sau.guichet-recette.grandlyon.com/retour-ecolyo/ecolyo-un-probleme/'
),
__SENTRY_DSN__: JSON.stringify(
'https://c868f6010f3f431d95be8f70d7f37666@grandlyon.errors.cozycloud.cc/6'
),
......
......@@ -23,6 +23,9 @@ module.exports = {
__SAU_IDEA_DIRECT_LINK__: JSON.stringify(
'https://demarches-support.grandlyon.com/retour-ecolyo/ecolyo-une-idee/'
),
__SAU_ISSUE_DIRECT_LINK__: JSON.stringify(
'https://demarches-support.grandlyon.com/retour-ecolyo/ecolyo-un-probleme/'
),
__SENTRY_DSN__: JSON.stringify(
'https://c868f6010f3f431d95be8f70d7f37666@grandlyon.errors.cozycloud.cc/6'
),
......@@ -32,7 +35,7 @@ module.exports = {
minimizer: [
new TerserPlugin({
parallel: true,
//To fix a SAfari 10 bug : https://github.com/zeit/next.js/issues/5630
// To fix a SAfari 10 bug : https://github.com/zeit/next.js/issues/5630
terserOptions: {
safari10: true,
},
......
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M25.7714 6.27598L25.6335 6.42525C25.0024 7.11492 24.6132 7.50794 24.292 7.76302C23.9865 7.36436 23.6835 6.96378 23.3831 6.5613C22.837 5.85463 22.3836 5.34257 21.9187 4.95145C21.3519 4.47152 20.7888 4.19565 20.1823 4.19565C19.863 4.19565 19.5531 4.27501 19.2546 4.4205C18.5233 4.77573 17.9111 5.44272 17.0911 6.58964C16.9872 6.73324 16.7283 7.10358 16.5734 7.32654L16.4543 7.4966L16.254 7.77435L16.2238 7.75168C15.8856 7.49282 15.4793 7.09791 14.8086 6.39691L14.6782 6.26087C13.6711 5.20275 13.3971 4.925 12.9758 4.58111C12.6319 4.30146 12.3352 4.12196 12.0121 4.0426C11.7173 3.96167 11.4027 3.9969 11.1331 4.14102C10.8634 4.28515 10.6594 4.52719 10.5629 4.81729C10.0481 6.24554 9.7866 7.75267 9.79007 9.27083C9.79007 16.2355 13.5993 21.0084 20.1823 21.0084C26.7653 21.0084 30.5745 16.2355 30.5745 9.27083C30.578 7.7525 30.3158 6.24527 29.7998 4.81729C29.7042 4.52714 29.5004 4.28497 29.2309 4.14107C28.9614 3.99716 28.6468 3.96258 28.3525 4.04449C28.0313 4.12574 27.7403 4.30902 27.4077 4.59244C26.9996 4.93822 26.7464 5.20653 25.7714 6.27409V6.27598Z" fill="#121212"/>
<path d="M19 19.1333C19 18.8328 19.158 18.5445 19.4393 18.3319C19.7206 18.1194 20.1022 18 20.5 18C20.8978 18 21.2794 18.1194 21.5607 18.3319C21.842 18.5445 22 18.8328 22 19.1333V33.8667C22 34.1672 21.842 34.4555 21.5607 34.6681C21.2794 34.8806 20.8978 35 20.5 35C20.1022 35 19.7206 34.8806 19.4393 34.6681C19.158 34.4555 19 34.1672 19 33.8667V19.1333Z" fill="#121212"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M31.3446 26.7304C31.2269 26.6705 30.8617 26.5428 30.0185 26.6696C28.8316 26.8482 27.2528 27.4993 25.6937 28.7196C24.1346 29.9399 23.1233 31.316 22.6648 32.4252C22.3391 33.2132 22.3753 33.5985 22.4052 33.727C22.5228 33.7869 22.8881 33.9147 23.7313 33.7878C24.9181 33.6093 26.4969 32.9581 28.056 31.7378C29.6151 30.5176 30.6265 29.1414 31.085 28.0322C31.4107 27.2442 31.3744 26.859 31.3446 26.7304ZM29.9051 34.1003C33.6853 31.1416 35.3931 27.0097 33.7196 24.8715C32.0461 22.7333 27.6249 23.3985 23.8447 26.3572C20.0645 29.3159 18.3567 33.4477 20.0302 35.5859C21.7037 37.7241 26.1248 37.059 29.9051 34.1003Z" fill="#121212"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.40545 26.7304C9.52306 26.6705 9.88835 26.5428 10.7315 26.6696C11.9184 26.8482 13.4972 27.4993 15.0563 28.7196C16.6154 29.9399 17.6267 31.316 18.0852 32.4252C18.4109 33.2132 18.3747 33.5985 18.3448 33.727C18.2272 33.7869 17.8619 33.9147 17.0187 33.7878C15.8319 33.6093 14.2531 32.9581 12.694 31.7378C11.1349 30.5176 10.1235 29.1414 9.66503 28.0322C9.33932 27.2442 9.37555 26.859 9.40545 26.7304ZM10.8449 34.1003C7.06472 31.1416 5.3569 27.0097 7.03042 24.8715C8.70394 22.7333 13.1251 23.3985 16.9053 26.3572C20.6855 29.3159 22.3933 33.4477 20.7198 35.5859C19.0463 37.7241 14.6252 37.059 10.8449 34.1003Z" fill="#121212"/>
</svg>
......@@ -26,7 +26,6 @@ const Comparison = ({
const {
global: { fluidTypes },
analysis: { period, analysisMonth },
chart: { showCompare },
} = useAppSelector(state => state.ecolyo)
const dispatch = useAppDispatch()
const [yearPerformanceIndicators, setYearPerformanceIndicators] = useState<
......
......@@ -49,31 +49,34 @@ const ElecInfoModal = ({
<Icon icon={CloseIcon} size={16} />
</IconButton>
<div className="elecInfoModal">
<div className="title text-18-bold">{t('elec_info_modal.title1')}</div>
<div className="text">
{t('elec_info_modal.text1-1')}
<div className="title text-18-bold">
{t('elec_info_modal.maxPowerTitle')}
</div>
<div>
{t('elec_info_modal.maxPowerDetails-1')}
<br />
{t('elec_info_modal.text1-2')}
{t('elec_info_modal.maxPowerDetails-2')}
</div>
<div className="title text-18-bold">{t('elec_info_modal.title2')}</div>
{offPeakHours && (
<>
<div className="title text-18-bold">
{t('elec_info_modal.title2')}
{t('elec_info_modal.offPeakTitle')}
</div>
<div className="text">
{t('elec_info_modal.text2-1', {
<div>
{t('elec_info_modal.offPeakDetails-1', {
offPeakHours: displayedOffPeakHours,
})}
</div>
</>
)}
<div className="text">
{t('elec_info_modal.text3-1')}
<div className="title text-18-bold">
{t('elec_info_modal.minPowerTitle')}
</div>
<div>
{t('elec_info_modal.minPowerDetails-1')}
<br />
{t('elec_info_modal.text3-2')}
{t('elec_info_modal.minPowerDetails-2')}
<br />
{t('elec_info_modal.text3-3')}
</div>
</div>
</Dialog>
......
......@@ -112,7 +112,7 @@ exports[`ElecHalfHourChart component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY weekend bounce-3 delay--0"
class="bar-ELECTRICITY weekend bounce-3 delay--0"
d="
M0,4
a4,4 0 0 1 4,-4
......@@ -128,7 +128,7 @@ exports[`ElecHalfHourChart component should be rendered correctly 1`] = `
>
<defs>
<lineargradient
class="bar-ELECTRICITY weekend bounce-3 delay--0"
class="bar-ELECTRICITY weekend bounce-3 delay--0"
id="gradient"
x1="0"
x2="0"
......@@ -146,7 +146,7 @@ exports[`ElecHalfHourChart component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY weekend bounce-3 delay--0"
class="bar-ELECTRICITY weekend bounce-3 delay--0"
d="
M0,4
a4,4 0 0 1 4,-4
......@@ -195,7 +195,7 @@ exports[`ElecHalfHourChart component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY weekend bounce-3 delay--1"
class="bar-ELECTRICITY weekend bounce-3 delay--1"
d="
M0,4
a4,4 0 0 1 4,-4
......@@ -211,7 +211,7 @@ exports[`ElecHalfHourChart component should be rendered correctly 1`] = `
>
<defs>
<lineargradient
class="bar-ELECTRICITY weekend bounce-3 delay--1"
class="bar-ELECTRICITY weekend bounce-3 delay--1"
id="gradient"
x1="0"
x2="0"
......@@ -229,7 +229,7 @@ exports[`ElecHalfHourChart component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY weekend bounce-3 delay--1"
class="bar-ELECTRICITY weekend bounce-3 delay--1"
d="
M0,4
a4,4 0 0 1 4,-4
......@@ -278,7 +278,7 @@ exports[`ElecHalfHourChart component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY weekend bounce-3 delay--2"
class="bar-ELECTRICITY weekend bounce-3 delay--2"
d="
M0,4
a4,4 0 0 1 4,-4
......@@ -294,7 +294,7 @@ exports[`ElecHalfHourChart component should be rendered correctly 1`] = `
>
<defs>
<lineargradient
class="bar-ELECTRICITY weekend bounce-3 delay--2"
class="bar-ELECTRICITY weekend bounce-3 delay--2"
id="gradient"
x1="0"
x2="0"
......@@ -312,7 +312,7 @@ exports[`ElecHalfHourChart component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY weekend bounce-3 delay--2"
class="bar-ELECTRICITY weekend bounce-3 delay--2"
d="
M0,4
a4,4 0 0 1 4,-4
......@@ -361,7 +361,7 @@ exports[`ElecHalfHourChart component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY weekend bounce-3 delay--3"
class="bar-ELECTRICITY weekend bounce-3 delay--3"
d="
M0,4
a4,4 0 0 1 4,-4
......@@ -377,7 +377,7 @@ exports[`ElecHalfHourChart component should be rendered correctly 1`] = `
>
<defs>
<lineargradient
class="bar-ELECTRICITY weekend bounce-3 delay--3"
class="bar-ELECTRICITY weekend bounce-3 delay--3"
id="gradient"
x1="0"
x2="0"
......@@ -395,7 +395,7 @@ exports[`ElecHalfHourChart component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY weekend bounce-3 delay--3"
class="bar-ELECTRICITY weekend bounce-3 delay--3"
d="
M0,4
a4,4 0 0 1 4,-4
......
......@@ -66,38 +66,31 @@ exports[`ElecInfoModal component should be rendered correctly with off-peak hour
<div
class="title text-18-bold"
>
elec_info_modal.title1
elec_info_modal.maxPowerTitle
</div>
<div
class="text"
>
elec_info_modal.text1-1
<div>
elec_info_modal.maxPowerDetails-1
<br />
elec_info_modal.text1-2
elec_info_modal.maxPowerDetails-2
</div>
<div
class="title text-18-bold"
>
elec_info_modal.title2
elec_info_modal.offPeakTitle
</div>
<div
class="title text-18-bold"
>
elec_info_modal.title2
<div>
elec_info_modal.offPeakDetails-1
</div>
<div
class="text"
class="title text-18-bold"
>
elec_info_modal.text2-1
elec_info_modal.minPowerTitle
</div>
<div
class="text"
>
elec_info_modal.text3-1
<div>
elec_info_modal.minPowerDetails-1
<br />
elec_info_modal.text3-2
elec_info_modal.minPowerDetails-2
<br />
elec_info_modal.text3-3
</div>
</div>
</div>
......@@ -176,28 +169,23 @@ exports[`ElecInfoModal component should be rendered correctly without off-peak h
<div
class="title text-18-bold"
>
elec_info_modal.title1
elec_info_modal.maxPowerTitle
</div>
<div
class="text"
>
elec_info_modal.text1-1
<div>
elec_info_modal.maxPowerDetails-1
<br />
elec_info_modal.text1-2
elec_info_modal.maxPowerDetails-2
</div>
<div
class="title text-18-bold"
>
elec_info_modal.title2
elec_info_modal.minPowerTitle
</div>
<div
class="text"
>
elec_info_modal.text3-1
<div>
elec_info_modal.minPowerDetails-1
<br />
elec_info_modal.text3-2
elec_info_modal.minPowerDetails-2
<br />
elec_info_modal.text3-3
</div>
</div>
</div>
......
......@@ -152,7 +152,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY undefined disabled bounce-3 delay--0"
class="bar-ELECTRICITY disabled bounce-3 delay--0"
d="
M0,4
a4,4 0 0 1 4,-4
......@@ -168,7 +168,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = `
>
<defs>
<lineargradient
class="bar-ELECTRICITY undefined disabled bounce-3 delay--0"
class="bar-ELECTRICITY disabled bounce-3 delay--0"
id="gradient"
x1="0"
x2="0"
......@@ -186,7 +186,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY undefined disabled bounce-3 delay--0"
class="bar-ELECTRICITY disabled bounce-3 delay--0"
d="
M0,4
a4,4 0 0 1 4,-4
......@@ -235,7 +235,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY undefined disabled bounce-3 delay--1"
class="bar-ELECTRICITY disabled bounce-3 delay--1"
d="
M0,4
a4,4 0 0 1 4,-4
......@@ -251,7 +251,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = `
>
<defs>
<lineargradient
class="bar-ELECTRICITY undefined disabled bounce-3 delay--1"
class="bar-ELECTRICITY disabled bounce-3 delay--1"
id="gradient"
x1="0"
x2="0"
......@@ -269,7 +269,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY undefined disabled bounce-3 delay--1"
class="bar-ELECTRICITY disabled bounce-3 delay--1"
d="
M0,4
a4,4 0 0 1 4,-4
......@@ -318,7 +318,7 @@ exports[`MaxConsumptionCard component should be rendered correctly 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY bar-UNCOMING undefined disabled bounce-3 delay--2"
class="bar-ELECTRICITY bar-UNCOMING disabled bounce-3 delay--2"
d="
M0,4
a4,4 0 0 1 4,-4
......
......@@ -2,7 +2,6 @@ import { render, screen, waitFor } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import React from 'react'
import { Provider } from 'react-redux'
import { profileData } from 'tests/__mocks__/profileData.mock'
import {
createMockEcolyoStore,
mockAnalysisState,
......@@ -34,7 +33,7 @@ jest.mock(
() => 'mock-profileComparatorRow'
)
const profileCompleted = { ...profileData, isProfileTypeCompleted: true }
const profileCompleted = { ...mockProfileState, isProfileTypeCompleted: true }
const storeProfileCompleted = createMockEcolyoStore({
profile: profileCompleted,
analysis: mockAnalysisState,
......
......@@ -167,7 +167,7 @@ const ProfileComparator = ({
<div className="average-title">{t(`analysis.comparison`)}</div>
</div>
<ProfileComparatorRow
fluid={FluidType.MULTIFLUID}
fluidType={FluidType.MULTIFLUID}
userPriceConsumption={userPriceConsumption}
homePriceConsumption={homePriceConsumption}
performanceValue={null}
......@@ -180,7 +180,7 @@ const ProfileComparator = ({
Boolean(indicator.value) && (
<ProfileComparatorRow
key={FluidType[index]}
fluid={index}
fluidType={index}
userPriceConsumption={userPriceConsumption}
homePriceConsumption={homePriceConsumption}
performanceValue={indicator.value}
......@@ -194,7 +194,7 @@ const ProfileComparator = ({
{emptyFluidTypes.map(fluid => (
<ProfileComparatorRow
key={fluid}
fluid={fluid}
fluidType={fluid}
userPriceConsumption={userPriceConsumption}
homePriceConsumption={homePriceConsumption}
performanceValue={null}
......
......@@ -14,7 +14,7 @@ describe('AnalysisConsumptionRow component', () => {
it('should be rendered correctly for Multifluid and at least fluid connected', async () => {
const { container } = render(
<ProfileComparatorRow
fluid={FluidType.MULTIFLUID}
fluidType={FluidType.MULTIFLUID}
userPriceConsumption={20}
homePriceConsumption={18}
performanceValue={null}
......@@ -38,7 +38,7 @@ describe('AnalysisConsumptionRow component', () => {
const mockConnected = false
const { container } = render(
<ProfileComparatorRow
fluid={FluidType.MULTIFLUID}
fluidType={FluidType.MULTIFLUID}
userPriceConsumption={userPriceConsumption}
homePriceConsumption={homePriceConsumption}
performanceValue={null}
......@@ -65,7 +65,7 @@ describe('AnalysisConsumptionRow component', () => {
it('should be rendered correctly for singleFluid connected for average', async () => {
const { container } = render(
<ProfileComparatorRow
fluid={FluidType.ELECTRICITY}
fluidType={FluidType.ELECTRICITY}
userPriceConsumption={userPriceConsumption}
homePriceConsumption={homePriceConsumption}
performanceValue={performanceValue}
......@@ -94,7 +94,7 @@ describe('AnalysisConsumptionRow component', () => {
const mockConnected = false
const { container } = render(
<ProfileComparatorRow
fluid={FluidType.ELECTRICITY}
fluidType={FluidType.ELECTRICITY}
userPriceConsumption={userPriceConsumption}
homePriceConsumption={homePriceConsumption}
performanceValue={performanceValue}
......@@ -123,7 +123,7 @@ describe('AnalysisConsumptionRow component', () => {
const mockPerformanceValue: number | null = null
const { container } = render(
<ProfileComparatorRow
fluid={FluidType.ELECTRICITY}
fluidType={FluidType.ELECTRICITY}
userPriceConsumption={userPriceConsumption}
homePriceConsumption={homePriceConsumption}
performanceValue={mockPerformanceValue}
......@@ -162,7 +162,7 @@ describe('AnalysisConsumptionRow component', () => {
}
const { container } = render(
<ProfileComparatorRow
fluid={FluidType.ELECTRICITY}
fluidType={FluidType.ELECTRICITY}
userPriceConsumption={userPriceConsumption}
homePriceConsumption={homePriceConsumption}
performanceValue={performanceValue}
......
......@@ -7,11 +7,11 @@ import { MonthlyForecast } from 'models'
import React from 'react'
import ConverterService from 'services/converter.service'
import { getPicto } from 'utils/picto'
import { formatNumberValues } from 'utils/utils'
import { formatNumberValues, getFluidName } from 'utils/utils'
import './profileComparatorRow.scss'
interface ProfileComparatorRowProps {
fluid: FluidType
fluidType: FluidType
userPriceConsumption: number
homePriceConsumption: number
performanceValue: number | null
......@@ -21,7 +21,7 @@ interface ProfileComparatorRowProps {
}
const ProfileComparatorRow = ({
fluid,
fluidType,
userPriceConsumption,
homePriceConsumption,
performanceValue,
......@@ -31,91 +31,86 @@ const ProfileComparatorRow = ({
}: ProfileComparatorRowProps) => {
const { t } = useI18n()
const converterService: ConverterService = new ConverterService()
const maxPriceConsumption: number = Math.max(
const maxPriceConsumption = Math.max(
userPriceConsumption,
homePriceConsumption
)
const fluidLoad: number =
forecast && fluid !== FluidType.MULTIFLUID
? forecast.fluidForecast[fluid].load
: 0
const isMulti = fluidType === FluidType.MULTIFLUID
const isElecOrGas =
fluidType === FluidType.ELECTRICITY || fluidType === FluidType.GAS
const FLUIDNAME = getFluidName(fluidType).toUpperCase()
const formatFluidConsumptionForConso = (_fluid: FluidType) => {
if (_fluid === FluidType.MULTIFLUID) {
const fluidLoad =
forecast && !isMulti ? forecast.fluidForecast[fluidType].load : 0
const formatFluidConsumptionForConso = () => {
if (isMulti) {
return `${formatNumberValues(userPriceConsumption).toString()} €`
} else {
if (performanceValue) {
// keeps unit in kWh for electricity and gas
if (_fluid === FluidType.ELECTRICITY || _fluid === FluidType.GAS) {
if (isElecOrGas) {
return `${Math.round(performanceValue)} ${t(
`FLUID.${FluidType[_fluid]}.UNIT`
`FLUID.${FLUIDNAME}.UNIT`
)}`
}
return performanceValue >= 1000 || fluidLoad >= 1000
? formatNumberValues(performanceValue / 1000).toString() +
' ' +
t(`FLUID.${FluidType[_fluid]}.MEGAUNIT`)
: Math.round(performanceValue) +
' ' +
t(`FLUID.${FluidType[_fluid]}.UNIT`)
t(`FLUID.${FLUIDNAME}.MEGAUNIT`)
: Math.round(performanceValue) + ' ' + t(`FLUID.${FLUIDNAME}.UNIT`)
} else {
return '-'
}
}
}
const formatFluidConsumptionForForecast = (_fluid: FluidType) => {
if (_fluid === FluidType.MULTIFLUID) {
const formatFluidConsumptionForForecast = () => {
if (isMulti) {
return `${formatNumberValues(homePriceConsumption).toString()} €`
} else {
// keeps unit in kWh for electricity and gas
if (_fluid === FluidType.ELECTRICITY || _fluid === FluidType.GAS) {
return `${Math.round(fluidLoad)} ${t(
`FLUID.${FluidType[_fluid]}.UNIT`
)}`
if (isElecOrGas) {
return `${Math.round(fluidLoad)} ${t('FLUID.' + FLUIDNAME + '.UNIT')}`
}
return (performanceValue && performanceValue >= 1000) || fluidLoad >= 1000
? formatNumberValues(fluidLoad / 1000).toString() +
' ' +
t(`FLUID.${FluidType[_fluid]}.MEGAUNIT`)
: Math.round(fluidLoad) + ' ' + t(`FLUID.${FluidType[_fluid]}.UNIT`)
t(`FLUID.${FLUIDNAME}.MEGAUNIT`)
: Math.round(fluidLoad) + ' ' + t(`FLUID.${FLUIDNAME}.UNIT`)
}
}
const getWidthForConso = (_fluid: FluidType) => {
if (_fluid === FluidType.MULTIFLUID) {
const getWidthForConso = () => {
if (isMulti) {
return `${(userPriceConsumption / maxPriceConsumption) * 100}%`
} else {
return `${
(converterService.LoadToEuro(performanceValue || 0, _fluid) /
(converterService.LoadToEuro(performanceValue || 0, fluidType) /
maxPriceConsumption) *
100
}%`
}
}
const getWidthForForecast = (_fluid: FluidType) => {
if (_fluid === FluidType.MULTIFLUID) {
const getWidthForForecast = () => {
if (isMulti) {
return `${(homePriceConsumption / maxPriceConsumption) * 100}%`
} else {
const fluidValue: number = forecast
? forecast.fluidForecast[_fluid].value
: 0
const fluidValue = forecast ? forecast.fluidForecast[fluidType].value : 0
return `${(fluidValue / maxPriceConsumption) * 100}%`
}
}
const comparaisonText = connected
? formatFluidConsumptionForConso(fluid)
? formatFluidConsumptionForConso()
: t(`analysis.no_data`)
return (
<div
className={`analysisRow consumption-${FluidType[fluid].toLowerCase()}`}
>
<div className={`analysisRow consumption-${FLUIDNAME.toLowerCase()}`}>
<div className="user-graph">
<div
className={classNames('price', 'text-15-bold', {
className={classNames('price text-15-bold', {
['not-connected']: !connected || noData,
})}
data-testid="userPrice"
......@@ -127,7 +122,7 @@ const ProfileComparatorRow = ({
<div
className="graph"
style={{
width: getWidthForConso(fluid),
width: getWidthForConso(),
}}
/>
</div>
......@@ -135,9 +130,7 @@ const ProfileComparatorRow = ({
</div>
<div className="icon-container">
<StyledIcon
icon={
fluid === FluidType.MULTIFLUID ? EuroIcon : getPicto(fluid, true)
}
icon={isMulti ? EuroIcon : getPicto(fluidType, true)}
size={22}
className={noData ? 'noData' : ''}
/>
......@@ -148,7 +141,7 @@ const ProfileComparatorRow = ({
<div
className="graph"
style={{
width: getWidthForForecast(fluid),
width: getWidthForForecast(),
}}
/>
)}
......@@ -159,7 +152,7 @@ const ProfileComparatorRow = ({
})}
data-testid="averagePrice"
>
{formatFluidConsumptionForForecast(fluid)}
{formatFluidConsumptionForForecast()}
</div>
</div>
</div>
......
......@@ -136,14 +136,14 @@ exports[`AnalysisConsumption component should be rendered correctly with profile
</div>
<mock-profilecomparatorrow
connected="true"
fluid="3"
fluidtype="3"
homepriceconsumption="0"
nodata="false"
userpriceconsumption="156.161853"
/>
<mock-profilecomparatorrow
connected="true"
fluid="0"
fluidtype="0"
homepriceconsumption="0"
nodata="false"
performancevalue="178.54"
......@@ -151,7 +151,7 @@ exports[`AnalysisConsumption component should be rendered correctly with profile
/>
<mock-profilecomparatorrow
connected="true"
fluid="1"
fluidtype="1"
homepriceconsumption="0"
nodata="false"
performancevalue="7763.98"
......@@ -159,7 +159,7 @@ exports[`AnalysisConsumption component should be rendered correctly with profile
/>
<mock-profilecomparatorrow
connected="true"
fluid="2"
fluidtype="2"
homepriceconsumption="0"
nodata="false"
performancevalue="1317.67"
......
......@@ -5,6 +5,7 @@ import { ScaleLinear } from 'd3-scale'
import { select, selectAll } from 'd3-selection'
import { FluidType } from 'enums'
import React, { useEffect, useRef } from 'react'
import { getFluidName } from 'utils/utils'
interface AxisRightProps {
yScale: ScaleLinear<number, number>
......@@ -24,12 +25,10 @@ const AxisRight = ({
isAnalysis,
}: AxisRightProps) => {
const { t } = useI18n()
const fluidStyle =
fluidType === FluidType.MULTIFLUID ? 'MULTIFLUID' : FluidType[fluidType]
const isMultiFluid = fluidStyle !== 'MULTIFLUID'
const isMulti = fluidType === FluidType.MULTIFLUID
const fluidStyle = getFluidName(fluidType).toLocaleUpperCase()
const yAxisRef = useRef<SVGGElement>(null)
const newMarginRight =
fluidType === FluidType.MULTIFLUID ? marginRight - 10 : marginRight
const newMarginRight = isMulti ? marginRight - 10 : marginRight
const formatFluidValue = (value: NumberValue, unit: 'UNIT' | 'MEGAUNIT') => {
const fluidUnit = t(`FLUID.${fluidStyle}.${unit}`)
......@@ -54,7 +53,7 @@ const AxisRight = ({
.tickSize(-width)
.tickSizeOuter(0)
.tickFormat(d =>
Number(d) >= 1000 && isMultiFluid
Number(d) >= 1000 && !isMulti
? formatMultiFluidValue(d)
: formatSingleFluidValue(d)
)
......
......@@ -10,6 +10,7 @@ import {
setSelectedDate,
} from 'store/chart/chart.slice'
import { useAppDispatch, useAppSelector } from 'store/hooks'
import { getFluidName } from 'utils/utils'
interface BarProps {
index: number
......@@ -56,9 +57,8 @@ const Bar = ({
const [compareAnimationEnded, setCompareAnimationEnded] = useState(false)
const browser = detect()
const fluidStyle =
fluidType === FluidType.MULTIFLUID ? 'MULTIFLUID' : FluidType[fluidType]
const isMulti = fluidType === FluidType.MULTIFLUID
const FLUIDNAME = getFluidName(fluidType).toUpperCase()
const handleClick = () => {
if (!isSwitching && !isDuel && clickable) {
......@@ -133,7 +133,16 @@ const Bar = ({
const edgeBrowser = browser && browser.name !== 'edge'
const bounce = edgeBrowser ? '1' : '3'
const baseStyles = `bar-${fluidStyle} ${upcoming} ${weekdays} ${selected} ${disabled}`
const baseStyles = [
`bar-${FLUIDNAME}`,
upcoming,
weekdays,
selected,
disabled,
]
.filter(Boolean)
.join(' ')
if (clicked) {
return `${baseStyles} ${clickedAnim}`
}
......@@ -147,7 +156,7 @@ const Bar = ({
const animate = `bounce-2 delay--${clicked ? 0 : index}`
const animationClass = compareAnimationEnded ? '' : animate
return `bar-compare-${fluidStyle} ${selected} ${animationClass} ${clickedAnim}`
return `bar-compare-${FLUIDNAME} ${selected} ${animationClass} ${clickedAnim}`
}
const barBackgroundClass = isSelectedDate
......
......@@ -40,7 +40,7 @@ exports[`Bar component test should correctly render Bar with isDuel 1`] = `
</lineargradient>
</defs>
<path
class="bar-MULTIFLUID undefined bounce-3 delay--4"
class="bar-MULTIFLUID bounce-3 delay--4"
d="
M0,-12.295074999999997
a-12.295074999999997,-12.295074999999997 0 0 1 -12.295074999999997,12.295074999999997
......@@ -56,7 +56,7 @@ exports[`Bar component test should correctly render Bar with isDuel 1`] = `
>
<defs>
<lineargradient
class="bar-MULTIFLUID undefined bounce-3 delay--4"
class="bar-MULTIFLUID bounce-3 delay--4"
id="gradient"
x1="0"
x2="0"
......@@ -130,7 +130,7 @@ exports[`Bar component test should correctly render Bar with isSwitching 1`] = `
</lineargradient>
</defs>
<path
class="bar-MULTIFLUID undefined selected bounce-2 delay"
class="bar-MULTIFLUID selected bounce-2 delay"
d="
M0,-12.295074999999997
a-12.295074999999997,-12.295074999999997 0 0 1 -12.295074999999997,12.295074999999997
......@@ -146,7 +146,7 @@ exports[`Bar component test should correctly render Bar with isSwitching 1`] = `
>
<defs>
<lineargradient
class="bar-MULTIFLUID undefined selected bounce-2 delay"
class="bar-MULTIFLUID selected bounce-2 delay"
id="gradient"
x1="0"
x2="0"
......@@ -164,7 +164,7 @@ exports[`Bar component test should correctly render Bar with isSwitching 1`] = `
</lineargradient>
</defs>
<path
class="bar-MULTIFLUID undefined selected bounce-2 delay"
class="bar-MULTIFLUID selected bounce-2 delay"
d="
M0,-12.295074999999997
a-12.295074999999997,-12.295074999999997 0 0 1 -12.295074999999997,12.295074999999997
......@@ -220,7 +220,7 @@ exports[`Bar component test should correctly render Bar with showCompare 1`] = `
</lineargradient>
</defs>
<path
class="bar-MULTIFLUID undefined selected bounce-2 delay"
class="bar-MULTIFLUID selected bounce-2 delay"
d="
M1.2500000000000002,-12.295074999999997
a-12.295074999999997,-12.295074999999997 0 0 1 -12.295074999999997,12.295074999999997
......@@ -236,7 +236,7 @@ exports[`Bar component test should correctly render Bar with showCompare 1`] = `
>
<defs>
<lineargradient
class="bar-MULTIFLUID undefined selected bounce-2 delay"
class="bar-MULTIFLUID selected bounce-2 delay"
id="gradient"
x1="0"
x2="0"
......@@ -254,7 +254,7 @@ exports[`Bar component test should correctly render Bar with showCompare 1`] = `
</lineargradient>
</defs>
<path
class="bar-MULTIFLUID undefined selected bounce-2 delay"
class="bar-MULTIFLUID selected bounce-2 delay"
d="
M1.2500000000000002,-12.295074999999997
a-12.295074999999997,-12.295074999999997 0 0 1 -12.295074999999997,12.295074999999997
......@@ -344,7 +344,7 @@ exports[`Bar component test should correctly render Electricity Bar 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY undefined selected bounce-2 delay"
class="bar-ELECTRICITY selected bounce-2 delay"
d="
M0,-12.295074999999997
a-12.295074999999997,-12.295074999999997 0 0 1 -12.295074999999997,12.295074999999997
......@@ -360,7 +360,7 @@ exports[`Bar component test should correctly render Electricity Bar 1`] = `
>
<defs>
<lineargradient
class="bar-ELECTRICITY undefined selected bounce-2 delay"
class="bar-ELECTRICITY selected bounce-2 delay"
id="gradient"
x1="0"
x2="0"
......@@ -378,7 +378,7 @@ exports[`Bar component test should correctly render Electricity Bar 1`] = `
</lineargradient>
</defs>
<path
class="bar-ELECTRICITY undefined selected bounce-2 delay"
class="bar-ELECTRICITY selected bounce-2 delay"
d="
M0,-12.295074999999997
a-12.295074999999997,-12.295074999999997 0 0 1 -12.295074999999997,12.295074999999997
......@@ -434,7 +434,7 @@ exports[`Bar component test should correctly render Gas Bar 1`] = `
</lineargradient>
</defs>
<path
class="bar-GAS undefined selected bounce-2 delay"
class="bar-GAS selected bounce-2 delay"
d="
M0,-12.295074999999997
a-12.295074999999997,-12.295074999999997 0 0 1 -12.295074999999997,12.295074999999997
......@@ -450,7 +450,7 @@ exports[`Bar component test should correctly render Gas Bar 1`] = `
>
<defs>
<lineargradient
class="bar-GAS undefined selected bounce-2 delay"
class="bar-GAS selected bounce-2 delay"
id="gradient"
x1="0"
x2="0"
......@@ -468,7 +468,7 @@ exports[`Bar component test should correctly render Gas Bar 1`] = `
</lineargradient>
</defs>
<path
class="bar-GAS undefined selected bounce-2 delay"
class="bar-GAS selected bounce-2 delay"
d="
M0,-12.295074999999997
a-12.295074999999997,-12.295074999999997 0 0 1 -12.295074999999997,12.295074999999997
......@@ -524,7 +524,7 @@ exports[`Bar component test should correctly render Multifluid Bar 1`] = `
</lineargradient>
</defs>
<path
class="bar-MULTIFLUID undefined selected bounce-2 delay"
class="bar-MULTIFLUID selected bounce-2 delay"
d="
M0,-12.295074999999997
a-12.295074999999997,-12.295074999999997 0 0 1 -12.295074999999997,12.295074999999997
......@@ -540,7 +540,7 @@ exports[`Bar component test should correctly render Multifluid Bar 1`] = `
>
<defs>
<lineargradient
class="bar-MULTIFLUID undefined selected bounce-2 delay"
class="bar-MULTIFLUID selected bounce-2 delay"
id="gradient"
x1="0"
x2="0"
......@@ -558,7 +558,7 @@ exports[`Bar component test should correctly render Multifluid Bar 1`] = `
</lineargradient>
</defs>
<path
class="bar-MULTIFLUID undefined selected bounce-2 delay"
class="bar-MULTIFLUID selected bounce-2 delay"
d="
M0,-12.295074999999997
a-12.295074999999997,-12.295074999999997 0 0 1 -12.295074999999997,12.295074999999997
......@@ -614,7 +614,7 @@ exports[`Bar component test should correctly render Water Bar 1`] = `
</lineargradient>
</defs>
<path
class="bar-WATER undefined selected bounce-2 delay"
class="bar-WATER selected bounce-2 delay"
d="
M0,-12.295074999999997
a-12.295074999999997,-12.295074999999997 0 0 1 -12.295074999999997,12.295074999999997
......@@ -630,7 +630,7 @@ exports[`Bar component test should correctly render Water Bar 1`] = `
>
<defs>
<lineargradient
class="bar-WATER undefined selected bounce-2 delay"
class="bar-WATER selected bounce-2 delay"
id="gradient"
x1="0"
x2="0"
......@@ -648,7 +648,7 @@ exports[`Bar component test should correctly render Water Bar 1`] = `
</lineargradient>
</defs>
<path
class="bar-WATER undefined selected bounce-2 delay"
class="bar-WATER selected bounce-2 delay"
d="
M0,-12.295074999999997
a-12.295074999999997,-12.295074999999997 0 0 1 -12.295074999999997,12.295074999999997
......