Created
May 21, 2020 17:09
-
-
Save mhamzas/b6b5ee8d2d2a9f3c40d4001cc39cb9b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ({ | |
| loanComplete: function (component, event, helper) { | |
| if (event.getParam('status') === "ERROR") { | |
| console.log('Error'); | |
| } | |
| if (event.getParam('status') === "FINISHED") { | |
| console.log('Finish Started'); | |
| /// Hide Flow Screen | |
| $A.util.addClass(component.find("loanflow"), "slds-hide"); | |
| $A.util.addClass(component.find("flow"), "slds-hide"); | |
| // Show Spinner | |
| $A.util.removeClass(component.find("spinner"), "slds-hide"); | |
| if(component.get('v.ProfileName') == "Progressa Community Login User"){ | |
| // Setting Header | |
| component.set('v.heading', 'Add Documents'); | |
| // Call Document Checklist LWC Component | |
| component.set("v.showDocument", true); | |
| } else { | |
| // Hiding Component | |
| $A.util.addClass(component.find("initform"), "slds-hide"); | |
| // Show Success Screen | |
| $A.util.removeClass(component.find("success"), "slds-hide"); | |
| } | |
| // Hiding Spinner | |
| $A.util.addClass(component.find("spinner"), "slds-hide"); | |
| } | |
| }, | |
| // On 2nd Qualifying Screen Success | |
| statusChange : function (component, event, helper) { | |
| console.log(JSON.stringify(event)); | |
| console.log('SYA ::'+event.getParam('status')); | |
| if (event.getParam('status') === "ERROR") { | |
| console.log('Error'); | |
| } | |
| if (event.getParam('status') === "FINISHED") { | |
| console.log('Finish Started'); | |
| // Marking step completed | |
| component.set('v.additional_info',true); | |
| // Generating Platform Event | |
| helper.credit_report_request(component, event, helper); | |
| //Hide Flow | |
| $A.util.addClass(component.find("flow"), "slds-hide"); | |
| // Showing Spinner | |
| $A.util.removeClass(component.find("spinner"), "slds-hide"); | |
| // Setting Header | |
| component.set('v.heading', 'Waiting for Credit Bureau Hit'); | |
| //var outputVariables = event.getParam("outputVariables"); | |
| //window. | |
| /*console.log('flow data',JSON.stringify(outputVariables) ); | |
| if(typeof JSON.stringify(outputVariables) != "undefined"){ | |
| for(var i = 0; i < outputVariables.length; i++) { | |
| var outputVar = outputVariables[i]; | |
| if(outputVar.name === "accInfoCreated") { | |
| var toastEvent = $A.get("e.force:showToast"); | |
| toastEvent.setParams({ | |
| "title": "Success!", | |
| "message":outputVar.value.Name+"-Account Record Created Successfully", | |
| "type":"success" | |
| }); | |
| toastEvent.fire(); | |
| } | |
| } | |
| }*/ | |
| //console.log("ApplicantID ::" + component.get("v.applicantId")); | |
| //console.log("FlowName ::" + component.get("v.flowname")); | |
| // Send Request for COM Score after Receiving Additional Information | |
| // Subscribing and requesting again for Score | |
| console.log('calling subscribe'); | |
| helper.subscribe(component, event, helper); | |
| // Wait for Score again -> Either Success or Fail | |
| // Show Spinner | |
| //$A.util.removeClass(component.find("spinner"), "slds-hide"); | |
| } | |
| }, | |
| // On Debt Profile Flow Success | |
| debtComplete : function (component, event, helper) { | |
| console.log(JSON.stringify(event)); | |
| console.log('SYA ::'+event.getParam('status')); | |
| if (event.getParam('status') === "ERROR") { | |
| console.log('Error'); | |
| } | |
| if (event.getParam('status') === "FINISHED") { | |
| console.log('Finish Started'); | |
| // Marking step completed | |
| component.set('v.first_pass',true); | |
| //Hide Flow | |
| $A.util.addClass(component.find("debtflow"), "slds-hide"); | |
| // Showing Spinner | |
| $A.util.removeClass(component.find("spinner"), "slds-hide"); | |
| //var outputVariables = event.getParam("outputVariables"); | |
| //window. | |
| /*console.log('flow data',JSON.stringify(outputVariables) ); | |
| if(typeof JSON.stringify(outputVariables) != "undefined"){ | |
| for(var i = 0; i < outputVariables.length; i++) { | |
| var outputVar = outputVariables[i]; | |
| if(outputVar.name === "accInfoCreated") { | |
| var toastEvent = $A.get("e.force:showToast"); | |
| toastEvent.setParams({ | |
| "title": "Success!", | |
| "message":outputVar.value.Name+"-Account Record Created Successfully", | |
| "type":"success" | |
| }); | |
| toastEvent.fire(); | |
| } | |
| } | |
| }*/ | |
| // Requesting COM score | |
| // | |
| // Create Platform Event | |
| var action = component.get('c.callPlatformNotif'); | |
| action.setParams({ | |
| "applId" : component.get("v.applicantId"), | |
| "actType" : 'COM_SCORE_REQUEST', | |
| }); | |
| // Create a callback that is executed after | |
| // the server-side action returns | |
| action.setCallback(this, function(response) { | |
| var state = response.getState(); | |
| if (state === "SUCCESS") { | |
| console.log("From server: " + response.getReturnValue()); | |
| }else if (state === "INCOMPLETE") { | |
| // do something | |
| console.log("From server: " + response.getReturnValue()); | |
| }else if (state === "ERROR") { | |
| var errors = response.getError(); | |
| if (errors){ | |
| if (errors[0] && errors[0].message) { | |
| console.log("Error message: " + errors[0].message); | |
| } | |
| } else { | |
| console.log("Unknown error"); | |
| } | |
| } | |
| }); | |
| $A.enqueueAction(action); | |
| // TODO : Check if User isPartner then show Partner Handoff Component | |
| console.log('Profile Name : ' + component.get('v.ProfileName')); | |
| if(component.get('v.ProfileName') == "Progressa Partner User"){ | |
| // Showing Handoff Page | |
| component.set('v.showHandoff', true); | |
| } else { | |
| // Else Load another flow LOAN APPLICATION | |
| var inputVariables = [{ | |
| name : "recordId", | |
| type : "String", | |
| value : component.get('v.applicantId')//eventData.inputFlowParams | |
| }]; | |
| // Initializing Flow | |
| var flow = component.find("loanflow"); | |
| component.set('v.heading', 'Loan Application'); | |
| flow.startFlow("Personal_and_Household_Details_V2", inputVariables); | |
| //Hide Component | |
| $A.util.addClass(component.find("initform"), "slds-hide"); | |
| //Hide Flow | |
| $A.util.addClass(component.find("flow"), "slds-hide"); | |
| } | |
| // Hiding Spinner | |
| $A.util.addClass(component.find("spinner"), "slds-hide"); | |
| } | |
| }, | |
| // After First Form Submission | |
| onInit: function (component, event, helper) { | |
| //component.set('v.subscription', null); | |
| console.log('onInit Function'); | |
| //from LWC | |
| var eventData = event.getParam('eventParams'); | |
| console.log('eventData :'+ JSON.stringify(eventData)); | |
| //component.set("v.showModal",eventData.showFlow); | |
| // | |
| // Setting Component Variable Value | |
| component.set("v.applicantId", eventData.inputFlowParams); | |
| component.set("v.ProfileName", eventData.profileName); | |
| var appId = eventData.inputFlowParams;//'0cd0v000000CaW7AAK'; | |
| //End from LWC | |
| // | |
| // Hiding Form | |
| $A.util.addClass(component.find("initform"), "slds-hide"); | |
| if(eventData.declined == true){ | |
| component.set("v.reasonsList", eventData.failed_reason); | |
| console.log('failed::'+eventData.failed_reason); | |
| //Showing Failed Screen | |
| $A.util.removeClass(component.find("failed"), "slds-hide"); | |
| // Hiding Main component | |
| $A.util.addClass(component.find("maincard"), "slds-hide"); | |
| } else { | |
| component.set('v.heading', 'Waiting for Credit Bureau Hit'); | |
| //Showing Spinner | |
| $A.util.removeClass(component.find("spinner"), "slds-hide"); | |
| console.log('onInit appId :: '+ appId); | |
| // Generating Platform Event | |
| helper.credit_report_request(component, event, helper); | |
| console.log('calling subscribe'); | |
| helper.subscribe(component, event, helper); | |
| //showing spinner | |
| //helper.checkSubscribeCall(component, event,helper,appId); | |
| //$A.util.removeClass(component.find("spinner"), "slds-hide"); | |
| //helper.displayToast(component, 'success', 'Ready to receive notifications.'); | |
| } | |
| }, | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ({ | |
| subscribe: function(component, event, helper){ | |
| //execute callApexMethod() again after 5 sec each | |
| var pollId = window.setInterval( | |
| $A.getCallback(function() { | |
| // Calling Apex Method | |
| helper.callApexMethod(component,helper,pollId); | |
| }), 5000 | |
| ); | |
| }, | |
| handleResponse : function (response, component){ | |
| var retVal = response.getReturnValue() ; | |
| console.log(retVal); | |
| if(response.getReturnValue().First_Waterfall_Pass__c != response.getReturnValue().First_Waterfall_Pass_Prior__c && component.get('v.first_pass')== false){ | |
| this.onReceiveNotification('FIRST_WATERFALL_PASS', component); | |
| //This will kill your batch job | |
| this.unsubscribe(component); | |
| }else if(response.getReturnValue().First_Waterfall_Fail__c != response.getReturnValue().First_Waterfall_Fail_Prior__c && component.get('v.first_fail')== false){ | |
| this.onReceiveNotification('FIRST_WATERFALL_FAIL', component); | |
| //This will kill your batch job | |
| this.unsubscribe(component); | |
| }else if(response.getReturnValue().Additional_Details_Required__c != response.getReturnValue().Additional_Details_Required_Prior__c && component.get('v.additional_info')== false){ | |
| this.onReceiveNotification('ADDITIONAL_INFO_REQUIRED', component); | |
| //This will kill your batch job | |
| this.unsubscribe(component); | |
| } | |
| }, | |
| unsubscribe : function (component){ | |
| //This will kill your batch job | |
| window.clearInterval(component.get('v.pollId')); | |
| }, | |
| callApexMethod : function (component,helper,pollId){ | |
| // Setting current pollId to stop the loop | |
| component.set('v.pollId', pollId); | |
| // Setting Apex Method | |
| var action = component.get("c.getRLA"); | |
| // Setting Apex Param | |
| action.setParams({ Id : component.get("v.applicantId") }); | |
| // Call Back Action | |
| action.setCallback(this, function(response) { | |
| this.handleResponse(response, component); | |
| }); | |
| $A.enqueueAction(action); | |
| }, | |
| onReceiveNotification: function (message, component) { | |
| // Hiding Spinner | |
| $A.util.addClass(component.find("spinner"), "slds-hide"); | |
| if(message == "FIRST_WATERFALL_FAIL"){ | |
| console.log('FIRST_WATERFALL_FAIL'); | |
| // Marking step completed | |
| component.set('v.first_fail',true); | |
| // Showing Declined Screen | |
| $A.util.addClass(component.find("flow"), "slds-hide"); | |
| $A.util.addClass(component.find("debtflow"), "slds-hide"); | |
| $A.util.addClass(component.find("loanflow"), "slds-hide"); | |
| $A.util.removeClass(component.find("decline"), "slds-hide"); | |
| } else if(message == "FIRST_WATERFALL_PASS"){ | |
| console.log('FIRST_WATERFALL_PASS'); | |
| var inputVariables = [{ | |
| name : "ApplicationId", | |
| type : "String", | |
| value : component.get('v.applicantId')//eventData.inputFlowParams | |
| }]; | |
| // Initializing Flow | |
| var flow = component.find("debtflow"); | |
| component.set('v.heading', 'Debt Profile'); | |
| flow.startFlow("Add_Multiple_Debit_Profiles", inputVariables); | |
| }else if(message == "ADDITIONAL_INFO_REQUIRED"){ | |
| console.log('ADDITIONAL_INFO_REQUIRED'); | |
| //call flow | |
| var inputVariables = [ | |
| { | |
| name : "ApplicationId", | |
| type : "String", | |
| value : component.get('v.applicantId')//eventData.inputFlowParams | |
| } | |
| ]; | |
| // Initializing Flow | |
| var flow = component.find("flow"); | |
| component.set('v.heading', 'Additional Details'); | |
| flow.startFlow("Qualifying_2nd_Screen_Flow", inputVariables); | |
| } | |
| }, | |
| displayToast: function (component, type, message) { | |
| const toastEvent = $A.get('e.force:showToast'); | |
| toastEvent.setParams({ | |
| type: type, | |
| message: message | |
| }); | |
| toastEvent.fire(); | |
| }, | |
| // Method to generate Credit Beaureu Platform Event | |
| credit_report_request : function (component, event, helper){ | |
| // Requesting COM score | |
| // | |
| // Create Platform Event | |
| var action = component.get('c.callPlatformNotif'); | |
| action.setParams({ | |
| "applId" : component.get("v.applicantId"), | |
| "actType" : 'CREDIT_REPORT_REQUEST', | |
| }); | |
| // Create a callback that is executed after | |
| // the server-side action returns | |
| action.setCallback(this, function(response) { | |
| var state = response.getState(); | |
| if (state === "SUCCESS") { | |
| console.log("From server: " + response.getReturnValue()); | |
| }else if (state === "INCOMPLETE") { | |
| // do something | |
| console.log("From server: " + response.getReturnValue()); | |
| }else if (state === "ERROR") { | |
| var errors = response.getError(); | |
| if (errors){ | |
| if (errors[0] && errors[0].message) { | |
| console.log("Error message: " + errors[0].message); | |
| } | |
| } else { | |
| console.log("Unknown error"); | |
| } | |
| } | |
| }); | |
| $A.enqueueAction(action); | |
| }, | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <aura:component implements="flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes" controller="PlatformEventHandler" access="global"> | |
| <!-- Initializing Aura Component --> | |
| <aura:attribute name="applicantId" type="String" default=""/> | |
| <lightning:empApi aura:id="empApi"/> | |
| <aura:attribute name="channel" type="String" default="/event/Foundation_Notification__e"/> | |
| <aura:attribute name="subscription" type="Map"/> | |
| <aura:attribute name="flowname" type="String" default=""/> | |
| <aura:attribute name="reasonsList" type="String[]" default=""/> | |
| <aura:attribute name="pollId" type="String"></aura:attribute> | |
| <aura:attribute name="ProfileName" type="String" default=""/> | |
| <aura:attribute name="showDocument" type="Boolean" default="false"/> | |
| <aura:attribute name="showHandoff" type="Boolean" default="false"/> | |
| <aura:attribute name="notifications" type="List"/> | |
| <aura:attribute name="isMuted" type="Boolean" default="false"/> | |
| <aura:attribute name="heading" type="String" default="New Application"/> | |
| <aura:attribute name="additional_info" type="Boolean" default="false"/> | |
| <aura:attribute name="first_pass" type="Boolean" default="false"/> | |
| <aura:attribute name="first_fail" type="Boolean" default="false"/> | |
| <!--<aura:handler name="init" value="{!this}" action="{!c.onInit}"/>--> | |
| <aura:registerEvent name="toastEvent" type="force:showToast"/> | |
| <aura:attribute name= "application" type = "ResidentialLoanApplication"></aura:attribute> | |
| <div class="slds-grid slds-grid_align-center"> | |
| <div class="slds-col"></div> | |
| <div class="slds-col slds-size_3-of-6"> | |
| <!-- Qualifying Questions Form --> | |
| <lightning:card title="{!v.heading}" aura:id="maincard"> | |
| <c:newApplication onflowLaunch="{!c.onInit}" aura:id="initform" /> | |
| <!-- Loader - Waiting Screen --> | |
| <div aura:id="spinner" class="slds-hide slds-card__body slds-card__body_inner"> | |
| <p>Please Wait!</p> | |
| <lightning:spinner alternativeText="Loading" size="medium"/> | |
| </div> | |
| <!-- Flow --> | |
| <lightning:flow aura:id="flow" onstatuschange="{!c.statusChange}"/> | |
| <!-- Debt Loan Flow --> | |
| <lightning:flow aura:id="debtflow" onstatuschange="{!c.debtComplete}"/> | |
| <!-- Loan Flow --> | |
| <lightning:flow aura:id="loanflow" onstatuschange="{!c.loanComplete}"/> | |
| <aura:renderIf isTrue="{!v.showDocument}"> | |
| <c:documentChecklist aura:id="documents" applicationId="{!v.applicantId}"/> | |
| </aura:renderIf> | |
| <aura:renderIf isTrue="{!v.showHandoff}"> | |
| <c:Handoff aura:id="handoff" recordId="{!v.applicantId}"/> | |
| </aura:renderIf> | |
| </lightning:card> | |
| <!-- FSR Success Screen Component --> | |
| <lightning:card aura:id="success" title="Your application has been submitted successfully" class="slds-hide"> | |
| <div class="slds-card__body slds-card__body_inner"> | |
| <p>Application record has been created. <br/> Next Step: Manual Duplication Review ! <a href="/{!v.applicantId}">Click Here</a> to access Loan Application. </p> | |
| </div> | |
| </lightning:card> | |
| <!-- Decline Screen Component --> | |
| <lightning:card aura:id="decline" title="Thank you for your Application" class="slds-hide"> | |
| <div class="slds-card__body slds-card__body_inner"> | |
| <p>Based on the information you provided, unfortunately we are not able to provide you with a loan at this time. | |
| Our evaluation model considers many different factors when reviewing an application and at this time you have not met our minimum requirements.</p> | |
| <p>If you wish to do so, you are welcome to apply again in 90 days if your employment status, credit bureau, or other aspects of your financial position have changed.</p> | |
| </div> | |
| </lightning:card> | |
| <!-- Failed Screen Component --> | |
| <lightning:card aura:id="failed" title="Thank you for your Application" class="slds-hide"> | |
| <div class="slds-card__body slds-card__body_inner"> | |
| <p>Based on the information you provided, unfortunately we are not able to provide you with a loan at this time because you do not meet the following minimum requirements:</p> | |
| </br> | |
| <ul class="slds-list--ordered"> | |
| <aura:iteration items="{!v.reasonsList}" var="item"> | |
| <li>{!item}</li> | |
| </aura:iteration> | |
| </ul> | |
| </br> | |
| <p>You are welcome to apply again in the future when you are able to meet the above requirements.</p> | |
| </div> | |
| </lightning:card> | |
| <div class="container"> | |
| <!-- Header --> | |
| <!-- | |
| <div class="slds-p-around_x-small slds-border_bottom slds-theme_shade"> | |
| <div class="slds-grid slds-grid_align-spread slds-grid_vertical-align-center"> | |
| <div> | |
| <span class="slds-badge">{!v.notifications.length}</span> | |
| </div> | |
| <div> | |
| <lightning:buttonIcon onclick="{!c.onClear}" iconName="utility:delete" title="Clear notifications" | |
| alternativeText="Clear notifications" variant="border-filled"/> | |
| <lightning:buttonIcon onclick="{!c.onToggleMute}" | |
| iconName="{!v.isMuted ? 'utility:volume_off' : 'utility:volume_high'}" | |
| title="{!v.isMuted ? 'Unmute notifications' : 'Mute notifications'}" | |
| alternativeText="Toggle mute" variant="border-filled"/> | |
| </div> | |
| </div> | |
| </div> --> | |
| <!-- Notification list --> | |
| <!-- | |
| <div class="slds-container_fluid slds-scrollable_y content"> | |
| <aura:iteration items="{!v.notifications}" var="notification"> | |
| <div class="slds-p-around_small slds-border_top"> | |
| <div class="slds-grid slds-grid_align-spread slds-has-flexi-truncate"> | |
| <p>{!notification.message}</p> | |
| <p class="slds-text-color_weak slds-p-left_x-small">{!notification.time}</p> | |
| </div> | |
| </div> | |
| </aura:iteration> | |
| </div> --> | |
| </div> | |
| </div> | |
| <div class="slds-col"></div> | |
| </div> | |
| </aura:component> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment