From 2117c68d3daea77dd6ffdb8f3cb70c77d324ae7e Mon Sep 17 00:00:00 2001
From: Antonin COQUET <ext.sopra.acoquet@grandlyon.com>
Date: Mon, 17 May 2021 10:51:23 +0200
Subject: [PATCH] fix: check for opening hours of structure on component init

---
 .../structure-opening-status.component.ts                | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/app/structure-list/components/structure-opening-status/structure-opening-status.component.ts b/src/app/structure-list/components/structure-opening-status/structure-opening-status.component.ts
index 2c1e0afa7..55dd76561 100644
--- a/src/app/structure-list/components/structure-opening-status/structure-opening-status.component.ts
+++ b/src/app/structure-list/components/structure-opening-status/structure-opening-status.component.ts
@@ -1,5 +1,6 @@
 import { Component, Input, OnInit } from '@angular/core';
 import { Structure } from '../../../models/structure.model';
+import { StructureService } from '../../../services/structure.service';
 
 @Component({
   selector: 'app-structure-opening-status',
@@ -10,7 +11,11 @@ export class StructureOpeningStatusComponent implements OnInit {
   @Input() public structure: Structure;
   @Input() public isCalledByDetails: boolean;
 
-  constructor() {}
+  constructor(private structureService: StructureService) {}
 
-  ngOnInit(): void {}
+  ngOnInit(): void {
+    if (!this.structure.isOpen && !this.structure.openedOn.day) {
+      this.structure = this.structureService.updateOpeningStructure(this.structure);
+    }
+  }
 }
-- 
GitLab