import { LightningElement, track, wire } from 'lwc';

import stgHealthCheckErrorLastRunDate from '@salesforce/label/c.stgHealthCheckErrorLastRunDate';

import getHealthCheckViewModel from '@salesforce/apex/HealthCheckController.getHealthCheckViewModel';
import updateHealthCheckLastRunDate from '@salesforce/apex/HealthCheckController.updateHealthCheckLastRunDate';

export default class HealthCheck extends LightningElement {
    @track expanded = true;
    @track totalChecks = 0;
    @track passedChecks = 0;
    @track lastRunDate = '';
    @track displayHealthCheckGroup = false;

    @track healthCheckDefinitionsToDisplayList = [];

    LabelReference = {
        stgHealthCheckErrorLastRunDate
    }

    handleHealthCheckRun(){
        updateHealthCheckLastRunDate()
            .then(result => {
                this.lastRunDate = result;

                if(!this.displayHealthCheckGroup) {
                    this.displayHealthCheckGroup = true;
                    return;
                }

                let healthCheckDisplay = this.template.querySelector('c-health-check-display');
                healthCheckDisplay.refreshHealthCheck();
            })
            .catch(error => {
                this.lastRunDate = this.LabelReference.stgHealthCheckErrorLastRunDate;
            });
    }

    @wire(getHealthCheckViewModel)
    healthCheckViewModel({error, data}){
        if (data){
            this.lastRunDate = data.lastRunDate;                
            this.healthCheckDefinitionsToDisplayList = data.healthCheckDefinitionList;  
        } else if (error){
            //console.log('error retrieving health check view model: ', error);
        }
    }

    get displayHealthCheck(){
        return !(!this.displayHealthCheckGroup || !this.healthCheckDefinitionsToDisplayList);
    }

}
@@ -43,13 +43,13 @@
 rom 
-'lwc'
+%22lwc%22
 ;%0A%0Ai
@@ -82,33 +82,33 @@
 astRunDate from 
-'
+%22
 @salesforce/labe
@@ -141,17 +141,17 @@
 tRunDate
-'
+%22
 ;%0A%0Aimpor
@@ -177,25 +177,25 @@
 wModel from 
-'
+%22
 @salesforce/
@@ -244,17 +244,17 @@
 iewModel
-'
+%22
 ;%0Aimport
@@ -288,17 +288,17 @@
 te from 
-'
+%22
 @salesfo
@@ -356,17 +356,17 @@
 tRunDate
-'
+%22
 ;%0A%0Aexpor
@@ -534,10 +534,10 @@
 e = 
-''
+%22%22
 ;%0A  
@@ -694,22 +694,24 @@
 tRunDate
+,
 %0A    %7D
+;
 %0A%0A    ha
@@ -730,16 +730,17 @@
 eckRun()
+ 
 %7B%0A      
@@ -790,22 +790,24 @@
   .then(
+(
 result
+)
  =%3E %7B%0A  
@@ -866,16 +866,17 @@
       if
+ 
 (!this.d
@@ -1074,17 +1074,17 @@
 elector(
-'
+%22
 c-health
@@ -1097,17 +1097,17 @@
 -display
-'
+%22
 );%0A     
@@ -1192,21 +1192,23 @@
  .catch(
+(
 error
+)
  =%3E %7B%0A  
@@ -1376,16 +1376,17 @@
 wModel(%7B
+ 
 error, d
@@ -1388,18 +1388,20 @@
 or, data
+ 
 %7D)
+ 
 %7B%0A      
@@ -1411,16 +1411,17 @@
 f (data)
+ 
 %7B%0A      
@@ -1462,32 +1462,16 @@
 RunDate;
-                
 %0A       
@@ -1549,18 +1549,16 @@
 ionList;
-  
 %0A       
@@ -1575,16 +1575,17 @@
  (error)
+ 
 %7B%0A      
@@ -1703,16 +1703,17 @@
 hCheck()
+ 
 %7B%0A      
@@ -1810,6 +1810,6 @@
   %7D%0A
-%0A
 %7D
+%0A

test precommit