Skip to content

Commit

Permalink
fix: add range with no signals (#2703)
Browse files Browse the repository at this point in the history
close #2687
  • Loading branch information
hamed-musallam committed Oct 5, 2023
1 parent 11f9bb5 commit 0365fdf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/component/panels/RangesPanel/RangesTable.tsx
Expand Up @@ -6,11 +6,11 @@ import { FaLink } from 'react-icons/fa';

import { ContextMenuProps } from '../../elements/ReactTable/ReactTable';
import useTableSortBy from '../../hooks/useTableSortBy';
import NoDataForFid from '../extra/placeholder/NoDataForFid';
import NoTableData from '../extra/placeholder/NoTableData';

import RangesTableRow from './RangesTableRow';
import useMapRanges from './hooks/useMapRanges';
import NoTableData from '../extra/placeholder/NoTableData';
import NoDataForFid from '../extra/placeholder/NoDataForFid';

const tableStyle = css`
border-spacing: 0;
Expand Down
13 changes: 10 additions & 3 deletions src/component/panels/RangesPanel/hooks/useMapRanges.ts
Expand Up @@ -6,21 +6,28 @@ export interface RangeData extends Range {
rowKey: string;
tableMetaInfo: any;
}
//TODO need to refactor the ranges table

function useMapRanges(data) {
return useMemo(() => {
const rangesData: RangeData[] = [];
for (const [i, range] of data.entries()) {
if (range.signals.length === 1) {
if (!range?.signals || range?.signals?.length === 0) {
rangesData.push({
rowKey: v4(),
...range,
});
} else if (range.signals.length === 1) {
const signal = range.signals[0];
rangesData.push({
rowKey: signal.id,
...range,
tableMetaInfo: {
...range.tableMetaInfo,
signal: range.signals[0],
signal,
rowIndex: i,
signalIndex: 0,
id: range.signals[0].id,
id: signal.id,
},
});
} else if (range.signals.length > 1) {
Expand Down

0 comments on commit 0365fdf

Please sign in to comment.