diff --git a/src/features/ModelTable/ModelTable.styled.ts b/src/features/ModelTable/ModelTable.styled.ts index 999cf714..e81b18fa 100644 --- a/src/features/ModelTable/ModelTable.styled.ts +++ b/src/features/ModelTable/ModelTable.styled.ts @@ -43,10 +43,11 @@ export const Buttons = styled.div` export const List = styled.div` display: flex; - flex-direction: row; + flex-direction: column; white-space: nowrap; > p { + margin: 0; padding-right: ${spacings.X_SMALL}; } `; diff --git a/src/features/ModelTable/ModelTable.tsx b/src/features/ModelTable/ModelTable.tsx index aba40e74..0cd1d882 100644 --- a/src/features/ModelTable/ModelTable.tsx +++ b/src/features/ModelTable/ModelTable.tsx @@ -7,8 +7,12 @@ import { useQuery } from '@tanstack/react-query'; import { useNavigate } from 'react-router-dom'; import { AnalogueModelsService, - MetadataDto, + CountryDto, + FieldDto, OpenAPI, + StratColumnDto, + StratigraphicGroupDto, + StratUnitDto, } from '../../api/generated'; import { useAccessToken } from '../../hooks/useAccessToken'; import * as Styled from './ModelTable.styled'; @@ -28,8 +32,69 @@ export const ModelTable = () => { if (isLoading || !data?.success) return
Loading...
; - const hasSelectedOptions = (metadata: MetadataDto[], type: string) => { - return metadata.filter((d) => d.metadataType === type).length > 0; + const getRowCountries = (stratGroupList: StratigraphicGroupDto[]) => { + const countryList: CountryDto[] = []; + + if (stratGroupList.length > 0) { + stratGroupList.forEach((i) => { + if ( + countryList.filter((item) => item.countryId === i.country.countryId) + .length <= 0 + ) + countryList.push(i.country); + }); + } + return countryList; + }; + + const getRowField = (stratGroupList: StratigraphicGroupDto[]) => { + const fieldList: FieldDto[] = []; + + if (stratGroupList.length > 0) { + stratGroupList.forEach((i) => { + if ( + fieldList.filter((item) => item.fieldId === i.field.fieldId).length <= + 0 + ) + fieldList.push(i.field); + }); + } + return fieldList; + }; + + const getRowStratCol = (stratGroupList: StratigraphicGroupDto[]) => { + const stratColList: StratColumnDto[] = []; + + if (stratGroupList.length > 0) { + stratGroupList.forEach((i) => { + if ( + stratColList.filter( + (item) => item.stratColumnId === i.stratColumn.stratColumnId, + ).length <= 0 + ) + stratColList.push(i.stratColumn); + }); + } + return stratColList; + }; + + const getRowGroup = (stratGroupList: StratigraphicGroupDto[]) => { + const groupList: StratUnitDto[] = []; + + if (stratGroupList.length > 0) { + stratGroupList.forEach((column) => { + column.stratUnits + .filter((item) => item.level === 1) + .forEach((i) => { + if ( + groupList.filter((item) => i.stratUnitId === item.stratUnitId) + .length <= 0 + ) + groupList.push(i); + }); + }); + } + return groupList; }; return ( @@ -52,65 +117,69 @@ export const ModelTable = () => { size: 100, cell: ({ row }) => ({a.name + ', '}
- )) - : 'Not relevant'} + {row.original.analogues.length > 0 ?? + row.original.analogues.map((a) => ( +{a.name + ', '}
+ ))}{f.value + ', '}
) - : 'Not relevant'} + {getRowCountries(row.original.stratigraphicGroups).map((i) => ( +{i.identifier},
+ ))}{z.value + ', '}
) - : 'Not relevant'} + {getRowField(row.original.stratigraphicGroups).map((i) => ( +{i.identifier},
+ ))}{filed.value + ', '}
- )) - : 'Not relevant'} + {getRowStratCol(row.original.stratigraphicGroups).map((i) => ( +{i.identifier},
+ ))} +{i.identifier},
+ ))}