JSFiddle - React, Tailwind, and code Playground

by Vadim

JavaScript

const contourById = {
  id: '1',
  name: 'Тевлинско-Русскинский',
  field: 'Тевлинско-Русскинское м.',
  stratum: 'ЮС1(Ю1)',
};
const contours = [
  {
    name: 'Линия тектонических нарушений',
    contourInfoDtoList: [
      { id: '1', type: 'Внешний контур нефтеносности' },
      { id: '3', type: 'Внешний контур нефтеносности' },
    ],
  },
  {
    name: 'Зона глинизации',
    contourInfoDtoList: [
      { id: '15', type: 'Зона глинизации' },
      { id: '12', type: 'Зона глинизации' },
    ],
  },
];
const findTypeById = id => {
  const filteredContours = contours
    .map(contour => contour.contourInfoDtoList.filter(item => item.id === id))
    .filter(item => item && item.length > 0)[0];
  return filteredContours;
};
const type = findTypeById(contourById.id)[0].type;
console.log('type:', type)