Skip to content

Instantly share code, notes, and snippets.

@TheoOliveira
Created June 3, 2020 13:20
Show Gist options
  • Select an option

  • Save TheoOliveira/89e40d7b9c2f41de79034b7e80df86c4 to your computer and use it in GitHub Desktop.

Select an option

Save TheoOliveira/89e40d7b9c2f41de79034b7e80df86c4 to your computer and use it in GitHub Desktop.
({
enviar : function(component, event) {
let action = component.get('c.sendCliente');
//attributes
let nome = component.get('v.cliente.nome');
let cpf = component.get('v.cliente.cpf');
let rg = component.get('v.cliente.rg');
let endereco = component.get('v.cliente.endereco');
let telefone = component.get('v.cliente.telefone');
//set params
action.setParams({
'nome': nome,
'cpf': cpf,
'rg': rg,
'endereco': endereco,
'telefone': telefone
});
component.set('v.showSpinner', true);
action.setCallback(this, function(response) {
component.set('v.showSpinner', false);
var state = response.getState();
if(state === "SUCCESS" )
{
var data = response.getReturnValue();
if(data.hasError)
{
$A.get("e.force:showToast")
.setParams({
"message": data.errorMessage,
"type": 'error',
"mode": 'sticky'})
.fire();
}
else
{
var retorno = data.retorno;
$A.get("e.force:showToast")
.setParams({
"message": data.errorMessage,
"type": 'success',
"mode": 'sticky'})
.fire();
$A.get("e.force:closeQuickAction").fire();
}
}
else
{
$A.get("e.force:showToast")
.setParams({
"message": response.getError()[0].message,
"type": 'error',
"mode": 'sticky'})
.fire();
}
});
$A.enqueueAction(action);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment