Skip to content

Commit

Permalink
chore: onClick to add case, conditional caseParameters for compute me…
Browse files Browse the repository at this point in the history
…thod
  • Loading branch information
mheggelund committed Oct 3, 2023
1 parent 1dfedcb commit 6a380df
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 23 deletions.
37 changes: 21 additions & 16 deletions src/features/Compute/ComputeVariogram/CaseCard/CaseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default interface optionTypes {
size?: string
}

export const CaseCard = () => {
export const CaseCard = ({ name }: { name: string }) => {
const [selectedModelArea, setModelArea] = useState<optionTypes>()
const [selectedComputeMethod, setComputeMethod] = useState<optionTypes>()
const [selectedGrainSize, setGrainSize] = useState<optionTypes>()
Expand Down Expand Up @@ -58,7 +58,7 @@ export const CaseCard = () => {
return (
<Styled.Wrapper>
<Styled.Case>
<Typography variant="h4">Variogram/object case N</Typography>
<Typography variant="h4">{name}</Typography>
<Styled.CaseCard>
<CaseCardInputs
modelAreas={modelAreas}
Expand All @@ -72,27 +72,32 @@ export const CaseCard = () => {
<div>
{selectedModelArea && selectedComputeMethod ? (
<Styled.Parameters>
<CaseCardParameters
label={'From grain size'}
type={'grainSize'}
options={grainOptions}
selectedGrainSize={selectedGrainSize}
setGrainSize={setGrainSize}
/>
{selectedComputeMethod.name === 'Net-to-gross' && (
<CaseCardParameters
label={'From grain size'}
type={'grainSize'}
options={grainOptions}
selectedGrainSize={selectedGrainSize}
setGrainSize={setGrainSize}
/>
)}
{selectedComputeMethod.name === 'Continuous parameter' && (
<CaseCardParameters
label={'Parameter'}
type={'parameters'}
options={parameterOptions}
selectedParameters={selectedParameters}
setParameters={setParameters}
/>
)}

<CaseCardParameters
label={'Variogram model'}
type={'variogramModels'}
options={modelOptions}
selectedVariogramModels={selectedVariogramModels}
setVariogramModels={setVariogramModels}
/>
<CaseCardParameters
label={'Parameter'}
type={'parameters'}
options={parameterOptions}
selectedParameters={selectedParameters}
setParameters={setParameters}
/>
</Styled.Parameters>
) : (
<Styled.Parameters>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Button, Typography } from '@equinor/eds-core-react'
import * as Styled from './ComputeCaseInfoActions.styled'

export const ComputeCaseInfoActions = () => {
export const ComputeCaseInfoActions = ({
addCase,
}: {
addCase: () => void
}) => {
return (
<Styled.CaseOverview>
<Styled.Text>
Expand All @@ -11,7 +15,9 @@ export const ComputeCaseInfoActions = () => {
</Typography>
</Styled.Text>
<Styled.Buttons>
<Button variant="outlined">Add Variogram case</Button>
<Button variant="outlined" onClick={addCase}>
Add Variogram case
</Button>
<Button>Run all variograms</Button>
</Styled.Buttons>
</Styled.CaseOverview>
Expand Down
35 changes: 30 additions & 5 deletions src/pages/ModelPages/Compute/ComputeVariogram/ComputeVariogram.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
import { Typography } from '@equinor/eds-core-react'
import { useState } from 'react'
import { CaseCard } from '../../../../features/Compute/ComputeVariogram/CaseCard/CaseCard'
import { ComputeCaseInfoActions } from '../../../../features/Compute/ComputeVariogram/ComputeCaseInfoActions/ComputeCaseInfoActions'
import * as Styled from './ComputeVariogram.styled'

interface Casetype {
id: number
name: string
}
export const ComputeVariogram = () => {
const [cases, setCases] = useState<Casetype[]>([
{ id: 1, name: 'Variogram Case 1' },
])

const AddCase = () => {
const newCase: Casetype = {
id: Math.floor(Math.random() * 100),
name: `Variogram Case ${cases.length + 1}`,
}

setCases([...cases, newCase])
}

return (
<Styled.Case>
<ComputeCaseInfoActions />
<Styled.CaseBorder>
<CaseCard />
</Styled.CaseBorder>
<Styled.AddCaseButton variant="outlined">
<ComputeCaseInfoActions addCase={AddCase} />
{cases.length !== 0 ? (
cases.map((c) => (
<Styled.CaseBorder key={c.id}>
<CaseCard name={c.name} />
</Styled.CaseBorder>
))
) : (
<Typography>Add a Case</Typography>
)}
<Styled.AddCaseButton variant="outlined" onClick={AddCase}>
Add variogram case
</Styled.AddCaseButton>
</Styled.Case>
Expand Down

0 comments on commit 6a380df

Please sign in to comment.