diff --git a/src/features/ModelTable/ModelTable.styled.ts b/src/features/ModelTable/ModelTable.styled.ts index 999cf71..e81b18f 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 aba40e7..0cd1d88 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 }) => ( - {row.original.analogues.length > 0 - ? row.original.analogues.map((a) => ( -

{a.name + ', '}

- )) - : 'Not relevant'} + {row.original.analogues.length > 0 ?? + row.original.analogues.map((a) => ( +

{a.name + ', '}

+ ))}
), }, { - accessorKey: 'formation', - id: 'formation', - header: 'Formation', + accessorKey: 'country', + id: 'country', + header: 'Country', enableColumnFilter: false, - size: 150, + size: 120, cell: ({ row }) => ( - {hasSelectedOptions(row.original.metadata, 'Formation') - ? row.original.metadata - .filter((data) => data.metadataType === 'Formation') - .map((f) =>

{f.value + ', '}

) - : 'Not relevant'} + {getRowCountries(row.original.stratigraphicGroups).map((i) => ( +

{i.identifier},

+ ))}
), }, { - accessorKey: 'zone', - id: 'zone', - header: 'Zone', + accessorKey: 'field', + id: 'field', + header: 'Field', enableColumnFilter: false, - size: 150, + size: 120, cell: ({ row }) => ( - {hasSelectedOptions(row.original.metadata, 'Zone') - ? row.original.metadata - .filter((data) => data.metadataType === 'Zone') - .map((z) =>

{z.value + ', '}

) - : 'Not relevant'} + {getRowField(row.original.stratigraphicGroups).map((i) => ( +

{i.identifier},

+ ))}
), }, { - accessorKey: 'field', - id: 'field', - header: 'Field', + accessorKey: 'stratigraphicColumn', + id: 'stratigraphicColumn', + header: 'Stratigraphic column', enableColumnFilter: false, - size: 200, + size: 230, cell: ({ row }) => ( - {hasSelectedOptions(row.original.metadata, 'Field') - ? row.original.metadata - .filter((data) => data.metadataType === 'Field') - .map((filed) => ( -

{filed.value + ', '}

- )) - : 'Not relevant'} + {getRowStratCol(row.original.stratigraphicGroups).map((i) => ( +

{i.identifier},

+ ))} +
+ ), + }, + { + accessorKey: 'group', + id: 'group', + header: 'Level 1 (group)', + enableColumnFilter: false, + size: 150, + cell: ({ row }) => ( + + {getRowGroup(row.original.stratigraphicGroups).map((i) => ( +

{i.identifier},

+ ))}
), }, - { accessorKey: 'isProcessed', id: 'isProcessed',