From 6d2b5d453faa7d6223ae37e0d3d51531dede91ab Mon Sep 17 00:00:00 2001
From: Hugo Nouts <hnouts@grandlyon.com>
Date: Thu, 28 May 2020 15:17:00 +0200
Subject: [PATCH] fix - boolean return

---
 .../FluidChartContainer/FluidChartContainer.tsx        | 10 +++++-----
 .../ContentComponents/FluidChart/FluidChartContent.tsx |  7 ++++---
 src/services/consumptionDataManagerService.ts          |  4 ++--
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/components/ContainerComponents/FluidChartContainer/FluidChartContainer.tsx b/src/components/ContainerComponents/FluidChartContainer/FluidChartContainer.tsx
index 9a414ff80..4feb58fdd 100644
--- a/src/components/ContainerComponents/FluidChartContainer/FluidChartContainer.tsx
+++ b/src/components/ContainerComponents/FluidChartContainer/FluidChartContainer.tsx
@@ -32,7 +32,7 @@ const FluidChartContainer: React.FC<FluidChartContainerProps> = ({
   const [lastDateWithAllData, setLastDateWithAllData] = useState<DateTime>(
     DateTime.local()
   )
-  const [isMinuteActive, setMinuteActive] = useState<boolean>(false)
+  const [isMinuteBlocked, setMinuteBlocked] = useState<boolean>(false)
   const [referenceDate, setReferenceDate] = useState<DateTime>(DateTime.local())
   const [isLoaded, setIsLoaded] = useState<boolean>(false)
   const [challenge, setChallenge] = useState<UserChallenge | null>(null)
@@ -47,7 +47,7 @@ const FluidChartContainer: React.FC<FluidChartContainerProps> = ({
   useEffect(() => {
     let subscribed = true
     async function loadData() {
-      const halfHourLoad = await consumptionDataManager.checkDoctypeEntries(
+      const activateHalfHourLoad = await consumptionDataManager.checkDoctypeEntries(
         FluidType.ELECTRICITY,
         TimeStep.HALF_AN_HOUR
       )
@@ -63,8 +63,8 @@ const FluidChartContainer: React.FC<FluidChartContainerProps> = ({
       if (subscribed && dataWithAllFluids) {
         setLastDateWithAllData(dataWithAllFluids)
       }
-      if (subscribed && halfHourLoad) {
-        setMinuteActive(true)
+      if (subscribed && activateHalfHourLoad) {
+        setMinuteBlocked(true)
       }
       if (subscribed && currentChallenge) {
         if (
@@ -119,7 +119,7 @@ const FluidChartContainer: React.FC<FluidChartContainerProps> = ({
               lastDateWithAllData={lastDateWithAllData}
               fluidTypes={fluidTypes}
               timeStep={timeStep}
-              halfHourLoad={isMinuteActive}
+              activateHalfHourLoad={isMinuteBlocked}
               multiFluid={multiFluid}
               currentChallenge={challenge}
               consumptionDataManager={consumptionDataManager}
diff --git a/src/components/ContentComponents/FluidChart/FluidChartContent.tsx b/src/components/ContentComponents/FluidChart/FluidChartContent.tsx
index 85228a569..45de13f35 100644
--- a/src/components/ContentComponents/FluidChart/FluidChartContent.tsx
+++ b/src/components/ContentComponents/FluidChart/FluidChartContent.tsx
@@ -31,7 +31,7 @@ interface FluidChartContentProps {
   referenceDate: DateTime
   lastDataDate: DateTime
   lastDateWithAllData: DateTime
-  halfHourLoad: boolean
+  activateHalfHourLoad: boolean
   multiFluid: boolean
   currentChallenge: UserChallenge | null
   consumptionDataManager: IConsumptionDataManager
@@ -47,7 +47,7 @@ const FluidChartContent: React.FC<FluidChartContentProps> = ({
   lastDataDate,
   lastDateWithAllData,
   multiFluid,
-  halfHourLoad,
+  activateHalfHourLoad,
   currentChallenge,
   consumptionDataManager,
   isDataLoaded,
@@ -76,6 +76,7 @@ const FluidChartContent: React.FC<FluidChartContentProps> = ({
     setIndexDisplayed(index)
     setIsLoaded(false)
   }
+  console.log('HOUR LOAD is : ', activateHalfHourLoad, timeStep)
 
   const handleClickData = (
     dataload: IDataload,
@@ -142,7 +143,7 @@ const FluidChartContent: React.FC<FluidChartContentProps> = ({
         />
       </div>
 
-      {!halfHourLoad && timeStep === 10 && (
+      {activateHalfHourLoad && timeStep === 10 && (
         <ActivateHalfHourLoad timeStep={timeStep} />
       )}
 
diff --git a/src/services/consumptionDataManagerService.ts b/src/services/consumptionDataManagerService.ts
index ff2d6ec33..4fa240e30 100644
--- a/src/services/consumptionDataManagerService.ts
+++ b/src/services/consumptionDataManagerService.ts
@@ -293,9 +293,9 @@ export default class ConsumptionDataManager implements IConsumptionDataManager {
   ): Promise<boolean> {
     const queryResult = await this._queryRunner.getEntries(fluideType, timeStep)
     if (queryResult.length > 0) {
-      return true
+      return false
     }
-    return false
+    return true
   }
 
   private aggregateGraphData(
-- 
GitLab