From 3e9f84c2c79017a1a6f8a83b611fbed363a2422d Mon Sep 17 00:00:00 2001 From: mheggelund Date: Tue, 30 Jan 2024 09:46:20 +0100 Subject: [PATCH] refactor: Refactor VariogramResult component to match data structure. --- .../CaseResultView/CaseResultView.tsx | 2 +- .../VariogramCaseResult.tsx | 53 +++++-------------- .../VariogramResultTable.tsx | 51 ++++++++++++++++++ .../VariogramResults/VariogramResults.tsx | 19 ------- 4 files changed, 64 insertions(+), 61 deletions(-) create mode 100644 src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramResultTable.tsx diff --git a/src/features/Results/CaseResult/CaseResultView/CaseResultView.tsx b/src/features/Results/CaseResult/CaseResultView/CaseResultView.tsx index a2d1e30c..f7944e35 100644 --- a/src/features/Results/CaseResult/CaseResultView/CaseResultView.tsx +++ b/src/features/Results/CaseResult/CaseResultView/CaseResultView.tsx @@ -21,7 +21,7 @@ export const CaseResultView = ({ {caseType === 'Variogram' && ( )} diff --git a/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramCaseResult.tsx b/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramCaseResult.tsx index 8ced63dd..7e09fd8b 100644 --- a/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramCaseResult.tsx +++ b/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramCaseResult.tsx @@ -1,55 +1,26 @@ -import { Table } from '@equinor/eds-core-react'; +import { GetResultDto } from '../../../../../api/generated'; import { CaseCardComponent } from '../../../../../components/CaseCardComponent/CaseCardComponent'; import { ImageView } from '../../../../../components/ImageView/ImageView'; -import { VariogramResultListType } from '../../../../../pages/ModelPages/Results/VariogramResults/VariogramResults'; import * as Styled from './VariogramCaseResult.styled'; +import { VariogramResultTable } from './VariogramResultTable'; export const VariogramCaseResult = ({ - caseList, + resultList, img, }: { - caseList: VariogramResultListType[]; + resultList: GetResultDto[]; img: string; }) => { return ( <> - {caseList.map((caseItem) => ( - - {caseItem.resultList.map((item) => ( - - - - - - - Quality factor - {item.quality} - - - Model area - {item.modelArea} - - - Compute method - {item.computeMethod} - - - Attribute - {item.attribute} - - - Variogram model - {item.family} - - - Sigma - {item.sigma} - - -
-
-
- ))} + {resultList.map((item) => ( + + + + + + + ))} diff --git a/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramResultTable.tsx b/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramResultTable.tsx new file mode 100644 index 00000000..fee64d25 --- /dev/null +++ b/src/features/Results/CaseResult/CaseResultView/VariogramCaseResult/VariogramResultTable.tsx @@ -0,0 +1,51 @@ +/* eslint-disable max-lines-per-function */ +import { Table } from '@equinor/eds-core-react'; + +import { GetResultDto } from '../../../../../api/generated'; + +// const NumberOfDecimals = 2; + +export const VariogramResultTable = ({ data }: { data: GetResultDto }) => { + // const filterValues = (name: string) => { + // return data.resultValues.filter((d) => d.name === name); + // }; + + // const roundResultString = (value: string) => { + // return parseFloat(value).toFixed(NumberOfDecimals); + // }; + + // const channelHeightCount = filterValues('channel-height_count'); + // const channelHeightMean = filterValues('channel-height_mean'); + // const channelHeightSD = filterValues('channel-height_sd'); + + return ( + + + + Quality factor + --Data-- + + + Model area + --Data-- + + + Compute method + --Data-- + + + Attribute + --Data-- + + + Variogram model + --Data-- + + + Sigma + --Data-- + + +
+ ); +}; diff --git a/src/pages/ModelPages/Results/VariogramResults/VariogramResults.tsx b/src/pages/ModelPages/Results/VariogramResults/VariogramResults.tsx index 3e34c4ee..81c42341 100644 --- a/src/pages/ModelPages/Results/VariogramResults/VariogramResults.tsx +++ b/src/pages/ModelPages/Results/VariogramResults/VariogramResults.tsx @@ -4,23 +4,6 @@ import { NoResults } from '../../../../features/Results/NoResults/NoResults'; import { useFetchCases } from '../../../../hooks/useFetchCases'; import { useFetchResults } from '../../../../hooks/useFetchResultts'; -export interface VariogramResultListType { - caseId: number; - title: string; - resultList: VariogramResultType[]; -} - -export interface VariogramResultType { - identifier: number; - family: string; - computeMethod: string; - modelArea: string; - attribute: string; - quality: GLfloat; - sigma: GLfloat; - approved: string; -} - export const VariogramResults = () => { const { data } = useFetchResults(); const cases = useFetchCases(); @@ -29,8 +12,6 @@ export const VariogramResults = () => { (res) => res.resultType === 'Variogram', ); - console.log(variogramResults); - return ( <> {variogramResults !== undefined && variogramResults?.length > 0 ? (