Adheep's user avatar
Adheep's user avatar
Adheep's user avatar
Adheep
  • Member for 6 years, 8 months
  • Last seen more than 1 year ago
Stats
271
reputation
8k
reached
3
answers
2
questions
Loading…
About

By Day: I am a Software Architect in awesome StartUp company in an Insurance Domain. Lots of learning, lots of coding, lots of failing, lots of coming back with a bang and more over lots of enjoyment in doing what I do.

By Night: I am a wannabe super cool Dad like "Bat Dad" and a caring husband.

By Mid-Night: I am a wannabe entrepreneur who learns lots of emerging technologies and trending stuffs.

Hobby: Loves Bikes, Cars, Trucks and pretty much anything that has wheels

//This method is to reduce the cognitive complexity of prepareColumns method function setTabValues(newTabs: FundFinderTabsType[], parsedColumns: FundFinderColumnType[]) { for (const tab of newTabs) { tab.label = dictionary[tab.label];

  for (const column of tab.columns) {
    column.label = column.label ? dictionary[column.label] : dictionary[column.accessor];

    if (column.tooltip) {
      column.tooltip = dictionary[column.tooltip];
    }
  }

  if (tab.label === 'Literature') {
    tab.columns = parsedColumns;
  }
  if (tab.label === 'Fund Facts') {
    const colsWithNewName = handleColsName(tab.columns);
    tab.columns = colsWithNewName;
  }
}
return newTabs;

}

/**

  • This function iterates the returned data and extracts the names of the documentType stored on literatureCols

  • and sets them as the new columns for the literature tab and updates labels with the received dictionary */ const prepareColumns = useCallback( // eslint-disable-next-line sonarjs/cognitive-complexity, react-hooks/exhaustive-deps (retrievedData: FundFullItem[], groupTab: GroupFundFinderTabsType): FundFinderTabsType[] => { const newTabs: FundFinderTabsType[] = JSON.parse(JSON.stringify(groupTab.tabs)); const cols = [];

    for (const fund of retrievedData) { const { literatureCols } = fund; literatureCols && cols.push(literatureCols); }

    const literatureColsNames = [...new Set(cols.flat())].filter((col) => col !== 'CUSIP'); const parsedColumns: FundFinderColumnType[] = literatureColsNames.map((col) => { return { label: col, accessor: col as keyof FundFullItem }; });

    const tickerIndex = parsedColumns.findIndex((column) => column.accessor === 'TICKER'); if (parsedColumns && parsedColumns.length > 0) { parsedColumns[tickerIndex].label = 'TICKER & CUSIP'; parsedColumns[tickerIndex].sortFieldType = 'string'; parsedColumns.unshift({ label: 'Fund Name', accessor: 'offeringName', sortFieldType: 'string' }); }

    return setTabValues(newTabs, parsedColumns); }, // eslint-disable-next-line react-hooks/exhaustive-deps [dictionary] );

This user doesn’t have any gold badges yet.
2
silver badges
11
bronze badges
8
Score
5
Posts
100
Posts %
6
Score
4
Posts
80
Posts %
6
Score
4
Posts
80
Posts %
3
Score
2
Posts
40
Posts %
3
Score
2
Posts
40
Posts %
3
Score
2
Posts
40
Posts %
Top posts