@@ -2,7 +2,7 @@ import { type ActiveStepProps } from '@/hooks/useActiveStep'
22import { useTranslation } from 'react-i18next'
33import { useEServiceCreateContext } from '../EServiceCreateContext'
44import { EServiceMutations } from '@/api/eservice'
5- import { SubmitHandler , useForm } from 'react-hook-form'
5+ import { type SubmitHandler , useForm } from 'react-hook-form'
66import { FormProvider } from 'react-hook-form'
77import React from 'react'
88import { type AttributeKey } from '@/types/attribute.types'
@@ -12,13 +12,7 @@ import {
1212 type DescriptorAttributes ,
1313 type UpdateEServiceDescriptorSeed ,
1414} from '@/api/api.generatedTypes'
15- import { SectionContainer } from '@/components/layout/containers'
16- import { Box , Stack } from '@mui/material'
17- import { RHFTextField } from '@/components/shared/react-hook-form-inputs'
18- import { TabContext , TabList , TabPanel } from '@mui/lab'
19- import { Tab } from '@mui/material'
20- import { useActiveTab } from '@/hooks/useActiveTab'
21- import { AddAttributesToForm } from '@/components/shared/AddAttributesToForm'
15+ import { Box } from '@mui/material'
2216import { StepActions } from '@/components/shared/StepActions'
2317import ArrowBackIcon from '@mui/icons-material/ArrowBack'
2418import SaveIcon from '@mui/icons-material/Save'
@@ -29,6 +23,8 @@ import {
2923 CustomizeThresholdDrawer ,
3024 useCustomizeThresholdDrawer ,
3125} from '@/components/shared/CustomizeThresholdDrawer'
26+ import { ThresholdSection } from '../sections/ThresholdSection'
27+ import { AttributesSection } from '../sections/AttributesSection'
3228
3329export type CreateStepThresholdsFormValues = {
3430 dailyCallsPerConsumer ?: number
@@ -39,7 +35,6 @@ export type CreateStepThresholdsFormValues = {
3935export const EServiceCreateStepThresholds : React . FC < ActiveStepProps > = ( ) => {
4036 const { t } = useTranslation ( 'eservice' , { keyPrefix : 'create' } )
4137 const { descriptor, forward, back } = useEServiceCreateContext ( )
42- const { activeTab, updateActiveTab } = useActiveTab ( 'certified' )
4338
4439 const { mutate : updateVersionDraft } = EServiceMutations . useUpdateVersionDraft ( {
4540 suppressSuccessToast : true ,
@@ -124,7 +119,6 @@ export const EServiceCreateStepThresholds: React.FC<ActiveStepProps> = () => {
124119 return
125120 }
126121
127- // TODO: Check if it is correct to default some fields
128122 const payload : UpdateEServiceDescriptorSeed & {
129123 eserviceId : string
130124 descriptorId : string
@@ -147,70 +141,12 @@ export const EServiceCreateStepThresholds: React.FC<ActiveStepProps> = () => {
147141 < >
148142 < FormProvider { ...formMethods } >
149143 < Box component = { 'form' } noValidate onSubmit = { formMethods . handleSubmit ( onSubmit ) } >
150- < SectionContainer title = { t ( 'step2.thresholdSection.title' ) } sx = { { mt : 3 } } >
151- < Stack direction = "row" spacing = { 2 } sx = { { mt : 3 } } >
152- < RHFTextField
153- size = "small"
154- name = "dailyCallsPerConsumer"
155- label = { t ( 'step2.thresholdSection.dailyCallsPerConsumerField.label' ) }
156- type = "number"
157- inputProps = { { min : '1' } }
158- rules = { { required : true , min : 1 } }
159- sx = { { my : 0 , flex : 1 } }
160- />
161-
162- < RHFTextField
163- size = "small"
164- name = "dailyCallsTotal"
165- label = { t ( 'step2.thresholdSection.dailyCallsTotalField.label' ) }
166- type = "number"
167- inputProps = { { min : '1' } }
168- sx = { { my : 0 , flex : 1 } }
169- rules = { {
170- required : true ,
171- min : {
172- value : dailyCallsPerConsumer ?? 1 ,
173- message : t ( 'step2.thresholdSection.dailyCallsTotalField.validation.min' ) ,
174- } ,
175- } }
176- />
177- </ Stack >
178- </ SectionContainer >
179-
180- < SectionContainer
181- title = { t ( 'step3.attributesTitle' , { versionNumber : descriptor ?. version ?? '1' } ) }
182- description = { t ( 'step3.attributesDescription' ) }
183- sx = { { mt : 3 } }
184- >
185- < TabContext value = { activeTab } >
186- < TabList onChange = { updateActiveTab } aria-label = { t ( 'step2.attributes.tabs.ariaLabel' ) } >
187- < Tab label = { t ( 'step2.attributes.tabs.certified' ) } value = "certified" />
188- < Tab label = { t ( 'step2.attributes.tabs.verified' ) } value = "verified" />
189- < Tab label = { t ( 'step2.attributes.tabs.declared' ) } value = "declared" />
190- </ TabList >
191- < TabPanel value = "certified" >
192- < AddAttributesToForm
193- attributeKey = "certified"
194- readOnly = { isEServiceCreatedFromTemplate }
195- />
196- </ TabPanel >
197- < TabPanel value = "verified" >
198- < AddAttributesToForm
199- attributeKey = "verified"
200- readOnly = { isEServiceCreatedFromTemplate }
201- openCreateAttributeDrawer = { handleOpenAttributeCreateDrawerFactory ( 'verified' ) }
202- />
203- </ TabPanel >
204- < TabPanel value = "declared" >
205- < AddAttributesToForm
206- attributeKey = "declared"
207- readOnly = { isEServiceCreatedFromTemplate }
208- openCreateAttributeDrawer = { handleOpenAttributeCreateDrawerFactory ( 'declared' ) }
209- />
210- </ TabPanel >
211- </ TabContext >
212- </ SectionContainer >
213-
144+ < ThresholdSection />
145+ < AttributesSection
146+ version = { descriptor ?. version }
147+ isEServiceCreatedFromTemplate = { isEServiceCreatedFromTemplate }
148+ handleOpenAttributeCreateDrawerFactory = { handleOpenAttributeCreateDrawerFactory }
149+ />
214150 < StepActions
215151 back = { {
216152 label : t ( 'backWithoutSaveBtn' ) ,
0 commit comments