1+ import { useMemo } from 'react' ;
12import {
23 Checkbox ,
3- Container ,
44 InputSection ,
55 RadioInput ,
66 TextArea ,
@@ -10,15 +10,14 @@ import { randomString } from '@togglecorp/fujs';
1010import {
1111 type ArrayError ,
1212 getErrorObject ,
13- type PartialForm ,
1413 type SetValueArg ,
1514 useFormObject ,
1615} from '@togglecorp/toggle-form' ;
1716
1817import useGlobalEnums from '#hooks/domain/useGlobalEnums' ;
1918import { type GoApiResponse } from '#utils/restRequest' ;
2019
21- import { type EruType } from '../schema' ;
20+ import { type PartialEruItem } from '../schema' ;
2221
2322import i18n from './i18n.json' ;
2423import styles from './styles.module.css' ;
@@ -35,30 +34,29 @@ function readinessLabelSelector(option: ReadinessOption) {
3534 return option . value ;
3635}
3736
38- const defaultCollectionValue : PartialForm < EruType > = {
37+ const defaultCollectionValue : PartialEruItem = {
3938 client_id : randomString ( ) ,
4039} ;
4140
4241interface Props {
4342 index : number ;
44- value : PartialForm < EruType > ;
45- onChange : ( value : SetValueArg < PartialForm < EruType > > , index : number ) => void ;
46- title : string | undefined ;
47- error : ArrayError < EruType > | undefined ;
43+ value : PartialEruItem ;
44+ onChange : ( value : SetValueArg < PartialEruItem > , index : number ) => void ;
45+ error : ArrayError < PartialEruItem > | undefined ;
4846}
4947
5048function EruInputItem ( props : Props ) {
5149 const {
5250 index,
5351 value,
5452 onChange,
55- title,
5653 error : errorFromProps ,
5754 } = props ;
5855
5956 const strings = useTranslation ( i18n ) ;
6057
6158 const {
59+ deployments_eru_type : eruTypeOptions ,
6260 deployments_eru_readiness_status,
6361 } = useGlobalEnums ( ) ;
6462
@@ -72,17 +70,23 @@ function EruInputItem(props: Props) {
7270 ? getErrorObject ( errorFromProps ?. [ value . client_id ] )
7371 : undefined ;
7472
73+ const title = useMemo ( ( ) => (
74+ eruTypeOptions ?. find ( ( eruType ) => eruType . key === value . type ) ?. value
75+ ) , [ eruTypeOptions , value . type ] ) ;
76+
7577 return (
76- < Container
77- childrenContainerClassName = { styles . eruTypes }
78- heading = { title }
78+ < InputSection
79+ title = { title }
80+ className = { styles . eruInputItem }
81+ contentSectionClassName = { styles . content }
7982 >
8083 < InputSection
81- className = { styles . readinessOptions }
8284 title = { strings . eruEquipmentReadiness }
85+ className = { styles . inputSection }
8386 >
8487 < RadioInput
85- listContainerClassName = { styles . readinessList }
88+ className = { styles . readinessInput }
89+ listContainerClassName = { styles . radioList }
8690 name = "equipment_readiness"
8791 value = { value . equipment_readiness }
8892 onChange = { onFieldChange }
@@ -93,11 +97,12 @@ function EruInputItem(props: Props) {
9397 />
9498 </ InputSection >
9599 < InputSection
96- className = { styles . readinessOptions }
97100 title = { strings . eruPeopleReadiness }
101+ className = { styles . inputSection }
98102 >
99103 < RadioInput
100- listContainerClassName = { styles . readinessList }
104+ className = { styles . readinessInput }
105+ listContainerClassName = { styles . radioList }
101106 name = "people_readiness"
102107 value = { value . people_readiness }
103108 onChange = { onFieldChange }
@@ -108,11 +113,12 @@ function EruInputItem(props: Props) {
108113 />
109114 </ InputSection >
110115 < InputSection
111- className = { styles . readinessOptions }
112116 title = { strings . eruFundingReadiness }
117+ className = { styles . inputSection }
113118 >
114119 < RadioInput
115- listContainerClassName = { styles . readinessList }
120+ className = { styles . readinessInput }
121+ listContainerClassName = { styles . radioList }
116122 name = "funding_readiness"
117123 value = { value . funding_readiness }
118124 onChange = { onFieldChange }
@@ -123,8 +129,8 @@ function EruInputItem(props: Props) {
123129 />
124130 </ InputSection >
125131 < InputSection
126- className = { styles . readinessOptions }
127132 title = { strings . eruComments }
133+ className = { styles . inputSection }
128134 >
129135 < TextArea
130136 name = "comment"
@@ -147,8 +153,7 @@ function EruInputItem(props: Props) {
147153 error = { error ?. has_capacity_to_support }
148154 />
149155 </ InputSection >
150- </ Container >
151-
156+ </ InputSection >
152157 ) ;
153158}
154159
0 commit comments