Commit fe9f2123 authored by Guilhem CARRON's avatar Guilhem CARRON
Browse files

fix(Analysis): Fix analysis navigation and bad month issue

- the december month now shows a proper comparison analysis instead of NaN
parent 758b9fb5
......@@ -82,7 +82,7 @@ const AnalysisConsumption: React.FC<AnalysisConsumptionProps> = ({
analysisDate.year
)
const monthlyForecast: MonthlyForecast = await profileTypeService.getMonthlyForecast(
analysisDate.month - 1
analysisDate.minus({ month: 1 }).startOf('month').month
)
if (subscribed) {
setForecast(monthlyForecast)
......
......@@ -24,7 +24,6 @@ const LastDataConsumptionVisualizer: React.FC<LastDataConsumptionVisualizerProps
)
const moveToDate = () => {
console.log(fluidType)
if (lastDataDate) {
const dateChartService = new DateChartService()
const updatedIndex: number = dateChartService.defineDateIndex(
......
......@@ -8,7 +8,7 @@ import { DateTime } from 'luxon'
import classNames from 'classnames'
import DateChartService from 'services/dateChart.service'
import { isLastDateReached, isLastPeriodReached } from 'utils/date'
import { isLastDateReached } from 'utils/date'
import DateNavigatorFormat from 'components/DateNavigator/DateNavigatorFormat'
import LeftArrowIcon from 'assets/icons/ico/left-arrow.svg'
......@@ -43,10 +43,7 @@ const DateNavigator: React.FC<DateNavigatorProps> = ({
const disableNext: boolean = currentAnalysisDate
? isLastDateReached(currentAnalysisDate, TimeStep.MONTH)
: isLastDateReached(selectedDate, currentTimeStep)
const disableNextSlide: boolean = isLastPeriodReached(
selectedDate,
currentTimeStep
)
const dateChartService = new DateChartService()
const handleClickMove = (increment: number) => {
......@@ -79,21 +76,21 @@ const DateNavigator: React.FC<DateNavigatorProps> = ({
selectedDate,
currentIndex
)
handleClickMove(increment)
if (currentAnalysisDate) {
handleClickMove(-1)
} else handleClickMove(increment)
}
}
const handleChangeNextIndex = () => {
console.log(!isKonnectorActive(fluidStatus, FluidType.MULTIFLUID))
if (
!disableNextSlide &&
isKonnectorActive(fluidStatus, FluidType.MULTIFLUID)
) {
if (!disableNext && isKonnectorActive(fluidStatus, FluidType.MULTIFLUID)) {
const increment: number = dateChartService.defineIncrementForNextIndex(
currentTimeStep,
selectedDate,
currentIndex
)
handleClickMove(increment)
if (currentAnalysisDate) {
handleClickMove(1)
} else handleClickMove(increment)
}
}
......
......@@ -79,7 +79,7 @@ describe('TotalConsumption component', () => {
.find('.euro-value')
.first()
.text()
).toEqual('20,23')
).toEqual('20,38')
})
it('should format multifluid value', async () => {
const component = mount(
......
......@@ -126,21 +126,13 @@ describe('Consumption service', () => {
actualData: [
{
date: DateTime.fromISO('2020-10-01T00:00:00.000Z'),
value: 69.18029999999999,
valueDetail: [
45.127739999999996,
0.9048899999999999,
23.147669999999998,
],
value: 79.131171,
valueDetail: [45.478019999999994, 0.931161, 32.72199],
},
{
date: DateTime.fromISO('2020-10-02T00:00:00.000Z'),
value: 61.65554999999999,
valueDetail: [
40.21918999999999,
0.8064649999999999,
20.629894999999998,
],
value: 70.5240635,
valueDetail: [40.531369999999995, 0.8298785, 29.162815],
},
{
date: DateTime.fromISO('2020-10-03T00:00:00.000Z'),
......@@ -151,13 +143,13 @@ describe('Consumption service', () => {
comparisonData: [
{
date: DateTime.fromISO('2020-09-01T00:00:00.000Z'),
value: 54.090509999999995,
valueDetail: [35.284358, 0.707513, 18.098639],
value: 61.8708707,
valueDetail: [35.558234, 0.7280537, 25.584583],
},
{
date: DateTime.fromISO('2020-09-02T00:00:00.000Z'),
value: 56.57427,
valueDetail: [36.904565999999996, 0.740001, 18.929703],
value: 64.7118939,
valueDetail: [37.191018, 0.7614849, 26.759391],
},
{
date: DateTime.fromISO('2020-09-03T00:00:00.000Z'),
......@@ -180,21 +172,13 @@ describe('Consumption service', () => {
actualData: [
{
date: DateTime.fromISO('2020-10-01T00:00:00.000Z'),
value: 69.18029999999999,
valueDetail: [
45.127739999999996,
0.9048899999999999,
23.147669999999998,
],
value: 79.131171,
valueDetail: [45.478019999999994, 0.931161, 32.72199],
},
{
date: DateTime.fromISO('2020-10-02T00:00:00.000Z'),
value: 61.65554999999999,
valueDetail: [
40.21918999999999,
0.8064649999999999,
20.629894999999998,
],
value: 70.5240635,
valueDetail: [40.531369999999995, 0.8298785, 29.162815],
},
{
date: DateTime.fromISO('2020-10-03T00:00:00.000Z'),
......@@ -246,7 +230,7 @@ describe('Consumption service', () => {
mockFetchFluidData.mockResolvedValueOnce(mockFetchDataActual)
mockFetchFluidData.mockResolvedValueOnce(mockFetchDataComparison)
}
const expectedResult = 69.18029999999999
const expectedResult = 79.131171
const result = await consumptionDataManager.getMaxLoad(
mockTimePeriod,
TimeStep.DAY,
......
......@@ -24,9 +24,9 @@ describe('performanceIndicator service', () => {
it('should return the current timePeriod and the comparison timePeriod for all timeStep', () => {
let expectedResult: PerformanceIndicator = {
value: 4.445499999999999,
compareValue: 6.5084,
percentageVariation: 0.3169596214123288,
value: 5.6091,
compareValue: 7.30015,
percentageVariation: 0.23164592508373127,
}
let result = performanceIndicatorService.aggregatePerformanceIndicators(
performanceIndicator
......@@ -47,9 +47,9 @@ describe('performanceIndicator service', () => {
},
]
expectedResult = {
value: 1.67,
compareValue: 4.6845,
percentageVariation: 0.6435051766463871,
value: 1.6855999999999998,
compareValue: 4.72185,
percentageVariation: 0.6430212734415537,
}
result = performanceIndicatorService.aggregatePerformanceIndicators(
performanceIndicator
......@@ -75,9 +75,9 @@ describe('performanceIndicator service', () => {
},
]
expectedResult = {
compareValue: 6.5084,
percentageVariation: 0.5544988015487677,
value: 2.8994999999999997,
compareValue: 7.30015,
percentageVariation: 0.44506619726991914,
value: 4.0511,
}
result = performanceIndicatorService.aggregatePerformanceIndicators(
performanceIndicator
......@@ -103,7 +103,7 @@ describe('performanceIndicator service', () => {
},
]
expectedResult = {
value: 7.5375,
value: 8.7251,
compareValue: 0,
percentageVariation: -Infinity,
}
......@@ -121,7 +121,7 @@ describe('performanceIndicator service', () => {
},
]
expectedResult = {
value: 4.638,
value: 4.6739999999999995,
compareValue: 0,
percentageVariation: -Infinity,
}
......@@ -140,7 +140,7 @@ describe('performanceIndicator service', () => {
]
expectedResult = {
value: 0,
compareValue: 2.319,
compareValue: 2.3369999999999997,
percentageVariation: 1,
}
result = performanceIndicatorService.aggregatePerformanceIndicators(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment