I am getting a behavior in a component not behaving as expected.
The Apex and Controller are returning exactly as they should be. When the word Green is passed isGreen should be true and isRed should be false. The opposite is true if Red is passed. What am I missing?
APEX:
public class AccountAlert {
@AuraEnabled
public static String getAccountDetails(Id actId)
{
String alert = 'Green';
List<Account> act = [Select Id, Last_BioQC_Date__c, Last_Syringe_Linearity_Date__c
FROM Account
WHERE ID = :actId];
for(Account a : act)
{
if(a.Last_BioQC_Date__c < Date.today()-45||a.Last_Syringe_Linearity_Date__c < Date.today()-16||a.Last_BioQC_Date__c==NULL||a.Last_Syringe_Linearity_Date__c==NULL)
{
alert = 'Red';
}
}
Return alert;
}
}
Component Controller:
({
doInit : function(component, event, helper) {
var action = component.get("c.getAccountDetails");
action.setParams({
"actId": component.get("v.recordId")
});
action.setCallback(this, function(response) {
var resp = response.getReturnValue();
console.log(resp);
debugger;
if(resp='Red')
{
component.set("v.isRed","true");
component.set("v.isGreen","false");
}
else
{
component.set("v.isRed","false");
component.set("v.isGreen","true");
}
});
$A.enqueueAction(action);
}
})
Component Code:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global" controller="AccountAlert">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="recordId" type="String" />
<aura:attribute name="isGreen" type="Boolean" default="false"/>
<aura:attribute name="isRed" type="Boolean" default="false"/>
<aura:if isTrue="{!v.isRed}">
<div class="slds-box; slds-align_absolute-center" style="background-color:red">
<p>Out of QC Compliance!</p>
</div>
</aura:if>
<aura:if isTrue="{!v.isGreen}">
<div class="slds-box; slds-align_absolute-center" style="background-color:green">
<p>Available for Testing</p>
</div>
</aura:if>
</aura:component>