Skip to content

Commit

Permalink
chore: Refactor quality factor level in results.
Browse files Browse the repository at this point in the history
  • Loading branch information
mheggelund committed Dec 5, 2024
1 parent ef8f9e2 commit 3d4030c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Table } from '@equinor/eds-core-react';
import { roundResultString } from '../../../../../../../utils/RoundResultString';
import { ResultObjectType } from '../TanStackTable/TanStackTable';
import * as Styled from './SubRowResultItem.styled';

export const SubRowResultItem = ({
resultList,
}: {
Expand All @@ -18,6 +18,7 @@ export const SubRowResultItem = ({
<Table.Cell>Azimuth (deg)</Table.Cell>
<Table.Cell>Range vertical (m)</Table.Cell>
<Table.Cell>SILL/STD (m)</Table.Cell>
<Table.Cell>X/Y/Z quality factor</Table.Cell>
</Styled.HeaderContent>
</Table.Head>
<Table.Body>
Expand All @@ -29,6 +30,13 @@ export const SubRowResultItem = ({
<Table.Cell>{resultItem.azimuth}</Table.Cell>
<Table.Cell>{resultItem.rvertical}</Table.Cell>
<Table.Cell>{resultItem.sigma}</Table.Cell>
<Table.Cell>
<div>
{roundResultString(resultItem.qualityX, 2)} {' / '}
{roundResultString(resultItem.qualityY, 2)} {' / '}
{roundResultString(resultItem.qualityZ, 2)}
</div>
</Table.Cell>
</Table.Row>
))}
</Table.Body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ import {
GetVariogramResultsVariogramResultFileDto,
} from '../../../../../../../api/generated';
import { usePepmContextStore } from '../../../../../../../hooks/GlobalState';
import { roundResultString } from '../../../../../../../utils/RoundResultString';
import { SubRowResult } from '../SubRowResult/SubRowResult';
import * as Styled from './TanStackTable.styled';

const NumberOfDecimals = 3;

export interface ResultObjectType {
variogramResultId: string;
variogramResultFiles: Array<GetVariogramResultsVariogramResultFileDto>;
Expand Down Expand Up @@ -134,16 +133,6 @@ export const TanStackTable = ({
}) => {
const { computeCases } = usePepmContextStore();

const roundResultString = (
value: number,
numberDecimals: number = NumberOfDecimals,
) => {
if (value) {
const res: string = value.toFixed(numberDecimals);
return Number(res);
} else return value;
};

const getSubRows = (computeCaseId: string, identifier: number) => {
const subRowArray: ResultObjectType[] = [];
if (computeCaseId === undefined || resultList === undefined)
Expand Down Expand Up @@ -241,20 +230,6 @@ export const TanStackTable = ({
header: () => <div>Model Area</div>,
id: 'modelArea',
},

{
accessorKey: 'quality',
header: () => <div>X/Y/Z quality factor</div>,
id: 'quality',
enableColumnFilter: false,
cell: ({ row }) => (
<div>
{roundResultString(row.original.qualityX, 2)} {' / '}
{roundResultString(row.original.qualityY, 2)} {' / '}
{roundResultString(row.original.qualityZ, 2)}
</div>
),
},
];

const getRows = () => {
Expand Down
11 changes: 11 additions & 0 deletions src/utils/RoundResultString.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const NumberOfDecimals = 3;

export const roundResultString = (
value: number,
numberDecimals: number = NumberOfDecimals,
) => {
if (value) {
const res: string = value.toFixed(numberDecimals);
return Number(res);
} else return value;
};

0 comments on commit 3d4030c

Please sign in to comment.