11import { ReactElement , useEffect , useState } from 'react'
22
3+ import {
4+ ExploreGenomeTypesDictionary ,
5+ genomeTypesOptions ,
6+ TGenomeOptionsKeys ,
7+ } from '@core/enum/explore-genome-types-enum'
38import { t } from '@i18n'
49import { Dialog } from '@ui/dialog'
510import { Input } from '@ui/input'
11+ import { Select } from '@ui/select'
612import { ISolutionEntryDescription } from '@service-providers/common'
713import { validatePresetName } from '@utils/validation/validatePresetName'
814
@@ -11,7 +17,7 @@ interface ISolutionCreateDialogProps {
1117 isOpen ?: boolean
1218 controlName : string
1319 onClose : ( ) => void
14- onCreate : ( solutionName : string ) => void
20+ onCreate : ( solutionName : string , rubric ?: TGenomeOptionsKeys ) => void
1521}
1622
1723export const SolutionCreateDialog = ( {
@@ -22,6 +28,9 @@ export const SolutionCreateDialog = ({
2228 onCreate,
2329} : ISolutionCreateDialogProps ) : ReactElement => {
2430 const [ solutionName , setSolutionName ] = useState ( '' )
31+ const [ rubric , setRubric ] =
32+ useState < TGenomeOptionsKeys | undefined > ( undefined )
33+ const [ selectValue , setSelectValue ] = useState < string | undefined > ( undefined )
2534 const [ isValidationError , setIsValidationError ] = useState ( false )
2635 const [ isSameNameError , setIsSameNameError ] = useState ( false )
2736
@@ -45,14 +54,30 @@ export const SolutionCreateDialog = ({
4554 )
4655 } , [ solutionName , solutions ] )
4756
57+ const onChangeRubric = ( e : React . ChangeEvent < HTMLSelectElement > ) => {
58+ const { value } = e . target
59+ setSelectValue ( value )
60+
61+ if ( value === 'empty' ) {
62+ setRubric ( undefined )
63+ return
64+ }
65+
66+ const rubricKey = Object . entries ( ExploreGenomeTypesDictionary ) . find (
67+ ( [ , val ] ) => val === value ,
68+ ) ?. [ 0 ]
69+
70+ setRubric ( rubricKey as TGenomeOptionsKeys )
71+ }
72+
4873 return (
4974 < Dialog
5075 isOpen = { isOpen }
5176 onClose = { onClose }
5277 title = { t ( 'solutionControl.createDialog.title' , { controlName } ) }
5378 applyText = { t ( 'general.create' ) }
5479 isApplyDisabled = { hasError || ! solutionName }
55- onApply = { ( ) => onCreate ( solutionName ) }
80+ onApply = { ( ) => onCreate ( solutionName , rubric ) }
5681 >
5782 < Input
5883 value = { solutionName }
@@ -62,6 +87,19 @@ export const SolutionCreateDialog = ({
6287 } ) }
6388 onChange = { event => setSolutionName ( event . target . value ) }
6489 />
90+
91+ < div className = "flex flex-col mt-[16px] text-12" >
92+ < label > { t ( 'solutionControl.createDialog.assignSolutionPack' ) } </ label >
93+ < Select
94+ options = { genomeTypesOptions }
95+ className = "py-[5px] px-[4px]"
96+ value = { selectValue }
97+ onChange = { onChangeRubric }
98+ reset
99+ resetText = "Choose the type"
100+ />
101+ </ div >
102+
65103 { hasError && (
66104 < div className = "text-red-secondary text-12" > { errorText } </ div >
67105 ) }
0 commit comments