Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var lista = JSON.parse(data);
- var listaEmpreendimentos = [];
- lista.map(item => {
- if (item.oportunidade.empreendimento) {
- var index = listaEmpreendimentos.findIndex(
- i =>
- i.oportunidade.empreendimento ===
- item.oportunidade.empreendimento &&
- i.oportunidade.datavenda === item.oportunidade.datavenda
- );
- if (index !== -1) {
- listaEmpreendimentos[index].composicao = listaEmpreendimentos[
- index
- ].composicao.concat(
- item.composicao
- .filter(f => f.tipoparticipante === "Gerente")
- .map(m => m.nome)
- );
- } else {
- listaEmpreendimentos.push({
- oportunidade: {
- empreendimento: item.oportunidade.empreendimento,
- datavenda: item.oportunidade.datavenda
- },
- composicao: item.composicao
- .filter(f => f.tipoparticipante === "Gerente")
- .map(m => m.nome)
- });
- }
- }
- });
- console.log(listaEmpreendimentos);
- });
Add Comment
Please, Sign In to add comment