-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: merge inn upload-form-valitation functionallity
- Loading branch information
1 parent
b2b71cc
commit 79c0db1
Showing
3 changed files
with
158 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,101 @@ | ||
import { Autocomplete, TextField, Typography } from '@equinor/eds-core-react' | ||
/* eslint-disable max-lines-per-function */ | ||
import { | ||
Autocomplete, | ||
AutocompleteChanges, | ||
Label, | ||
TextField, | ||
Typography, | ||
} from '@equinor/eds-core-react' | ||
import MetadataProps from '../AddModelDialog/AddModelDialog' | ||
|
||
import * as Styled from './ModelMetadata.styled' | ||
|
||
export const ModelMetadata = () => { | ||
const fields = [{ name: 'Tor' }] | ||
export const ModelMetadata = ({ | ||
fieldValidationError, | ||
formationValidationError, | ||
metadata, | ||
setMetadata, | ||
}: { | ||
fieldValidationError: boolean | ||
formationValidationError: boolean | ||
metadata: Partial<MetadataProps> | undefined | ||
setMetadata: (metadata: Partial<MetadataProps>) => void | ||
}) => { | ||
const fields = { | ||
description: 'Description string', | ||
field: ['Tor', 'Pål'], | ||
zone: ['Zone 1', 'Zone 2', 'Zone 3'], | ||
formation: ['Rocky', 'Hilly', 'Flat'], | ||
analogue: ['Analouge1', 'Analouge2'], | ||
} | ||
|
||
const handleInput = (e: AutocompleteChanges<string>, target: string) => { | ||
setMetadata({ ...metadata, [target]: e.selectedItems }) | ||
} | ||
return ( | ||
<Styled.ModelMetadata className="model-metadata"> | ||
<Typography variant="h4">Description and metadata</Typography> | ||
<TextField | ||
id="model-description" | ||
className="model-description" | ||
label="Model description (optional)" | ||
value={metadata?.description} | ||
onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => | ||
setMetadata({ ...metadata, description: e.currentTarget.value }) | ||
} | ||
multiline | ||
/> | ||
<Autocomplete label="Field" options={fields}></Autocomplete> | ||
<Autocomplete label="Formation" options={fields}></Autocomplete> | ||
<Autocomplete label="Analogue (optional)" options={fields}></Autocomplete> | ||
<Autocomplete label="Zone (optional)" options={fields}></Autocomplete> | ||
<div className="required-div"> | ||
<Autocomplete | ||
id="field-select" | ||
className={`${ | ||
fieldValidationError && 'model-required model-required2' | ||
}`} | ||
label="Field" | ||
options={fields.field} | ||
onOptionsChange={(e: AutocompleteChanges<string>) => | ||
handleInput(e, 'field') | ||
} | ||
></Autocomplete> | ||
{fieldValidationError && ( | ||
<Label | ||
label="This field is required" | ||
className="required-lable" | ||
></Label> | ||
)} | ||
</div> | ||
<div className="required-div"> | ||
<Autocomplete | ||
className={`${formationValidationError && 'model-required2'}`} | ||
label="Formation" | ||
options={fields.formation} | ||
multiple | ||
onOptionsChange={(e: AutocompleteChanges<string>) => | ||
handleInput(e, 'formation') | ||
} | ||
></Autocomplete> | ||
{formationValidationError && ( | ||
<Label | ||
label="This field is required" | ||
className="required-lable" | ||
></Label> | ||
)} | ||
</div> | ||
<Autocomplete | ||
label="Analogue (optional)" | ||
options={fields.analogue} | ||
multiple | ||
onOptionsChange={(e: AutocompleteChanges<string>) => | ||
setMetadata({ ...metadata, analogue: e.selectedItems }) | ||
} | ||
></Autocomplete> | ||
<Autocomplete | ||
label="Zone (optional)" | ||
options={fields.zone} | ||
onOptionsChange={(e: AutocompleteChanges<string>) => | ||
setMetadata({ ...metadata, zone: e.selectedItems }) | ||
} | ||
></Autocomplete>{' '} | ||
</Styled.ModelMetadata> | ||
) | ||
} |