Skip to content

Commit e354abb

Browse files
authored
fix: create a new component for form-header used in each step (eclipse-tractusx#310)
eclipse-tractusx#309
1 parent 6706040 commit e354abb

File tree

7 files changed

+75
-55
lines changed

7 files changed

+75
-55
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Bugfix
6+
7+
- created a new component for form header to avoid duplication of code in each step [#310](https://github.com/eclipse-tractusx/portal-frontend-registration/pull/310)
8+
59
## 2.1.0-RC1
610

711
### Change

src/components/StepHeader.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/********************************************************************************
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Apache License, Version 2.0 which is available at
9+
* https://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations
15+
* under the License.
16+
*
17+
* SPDX-License-Identifier: Apache-2.0
18+
********************************************************************************/
19+
20+
type StepHeaderProps = {
21+
step: number
22+
stepName: string
23+
stepDescription: string
24+
}
25+
const StepHeader = ({ step, stepName, stepDescription }: StepHeaderProps) => {
26+
return (
27+
<div className="head-section">
28+
<div className="mx-auto step-highlight d-flex align-items-center justify-content-center">
29+
{step}
30+
</div>
31+
<h4 className="mx-auto d-flex align-items-center justify-content-center">
32+
{stepName}
33+
</h4>
34+
<div className="mx-auto text-center col-9">
35+
{stepDescription}
36+
</div>
37+
</div>
38+
)
39+
}
40+
41+
export default StepHeader

src/components/cax-companyData.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
import { Autocomplete, TextField } from '@mui/material'
4444
import i18n from '../services/I18nService'
4545
import { Notify } from './Snackbar'
46+
import StepHeader from './StepHeader'
4647

4748
type CountryType = {
4849
id: string
@@ -389,17 +390,11 @@ export const CompanyDataCax = () => {
389390
return (
390391
<>
391392
<div className="mx-auto col-9 container-registration">
392-
<div className="head-section">
393-
<div className="mx-auto step-highlight d-flex align-items-center justify-content-center">
394-
1
395-
</div>
396-
<h4 className="mx-auto d-flex align-items-center justify-content-center">
397-
{t('registrationStepOne.verifyCompayDataHeading')}
398-
</h4>
399-
<div className="mx-auto text-center col-9">
400-
{t('registrationStepOne.verifyCompayDataSubHeading')}
401-
</div>
402-
</div>
393+
<StepHeader
394+
step={currentActiveStep}
395+
stepName={t('registrationStepOne.verifyCompayDataHeading')}
396+
stepDescription={t('registrationStepOne.verifyCompayDataSubHeading')}
397+
/>
403398
<div className="companydata-form">
404399
<Row className="mx-auto col-9">
405400
<div className={`form-search ${bpnErrorMsg ? 'error' : ''}`}>

src/components/cax-companyRole.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
getCurrentStep,
4141
} from '../state/features/user/userApiSlice'
4242
import '../styles/newApp.css'
43+
import StepHeader from './StepHeader'
4344

4445
export const CompanyRoleCax = () => {
4546
const { t, i18n } = useTranslation()
@@ -272,17 +273,11 @@ export const CompanyRoleCax = () => {
272273
return (
273274
<>
274275
<div className="mx-auto col-9 container-registration">
275-
<div className="head-section">
276-
<div className="mx-auto step-highlight d-flex align-items-center justify-content-center">
277-
3
278-
</div>
279-
<h4 className="mx-auto d-flex align-items-center justify-content-center">
280-
{t('companyRole.title')}
281-
</h4>
282-
<div className="mx-auto text-center col-9">
283-
{t('companyRole.subTitle')}
284-
</div>
285-
</div>
276+
<StepHeader
277+
step={currentActiveStep}
278+
stepName={t('companyRole.title')}
279+
stepDescription={t('companyRole.subTitle')}
280+
/>
286281
<div className="companydata-form mx-auto col-9">
287282
{allConsentData?.companyRoles.map((role, index) => (
288283
<div className="company-role-section" key={index}>

src/components/cax-responsibilities.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
useUpdateInviteNewUserMutation,
3939
} from '../state/features/applicationInviteUser/applicationInviteUserApiSlice'
4040
import { Notify, SeverityType } from './Snackbar'
41+
import StepHeader from './StepHeader'
4142

4243
export const ResponsibilitiesCax = () => {
4344
const { t } = useTranslation()
@@ -177,17 +178,11 @@ export const ResponsibilitiesCax = () => {
177178
return (
178179
<>
179180
<div className="mx-auto col-9 container-registration">
180-
<div className="head-section">
181-
<div className="mx-auto step-highlight d-flex align-items-center justify-content-center">
182-
2
183-
</div>
184-
<h4 className="mx-auto d-flex align-items-center justify-content-center">
185-
{t('Responsibility.responsAndAdmin')}
186-
</h4>
187-
<div className="mx-auto text-center col-9">
188-
{t('Responsibility.subTitle')}
189-
</div>
190-
</div>
181+
<StepHeader
182+
step={currentActiveStep}
183+
stepName={t('Responsibility.responsAndAdmin')}
184+
stepDescription={t('Responsibility.subTitle')}
185+
/>
191186
<div className="companydata-form">
192187
<Row className="mx-auto col-9">
193188
<div

src/components/dragdrop.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import {
4949
} from '../state/features/applicationDocuments/applicationDocumentsApiSlice'
5050
import { downloadDocument } from '../helpers/utils'
5151
import { Notify, SeverityType } from './Snackbar'
52+
import StepHeader from './StepHeader'
5253

5354
const getClassNameByStatus = (status: string) => {
5455
switch (status) {
@@ -198,17 +199,11 @@ export const DragDrop = () => {
198199
return (
199200
<>
200201
<div className="mx-auto col-9 container-registration">
201-
<div className="head-section">
202-
<div className="mx-auto step-highlight d-flex align-items-center justify-content-center">
203-
4
204-
</div>
205-
<h4 className="mx-auto d-flex align-items-center justify-content-center">
206-
{t('documentUpload.title')}
207-
</h4>
208-
<div className="mx-auto text-center col-9">
209-
{t('documentUpload.subTitle')}
210-
</div>
211-
</div>
202+
<StepHeader
203+
step={currentActiveStep}
204+
stepName={t('documentUpload.title')}
205+
stepDescription={t('documentUpload.subTitle')}
206+
/>
212207
<div className="companydata-form mx-auto col-9">
213208
<Dropzone
214209
onChangeStatus={handleChangeStatus}

src/components/verifyRegistration.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
useUpdateRegistrationMutation,
3737
} from '../state/features/applicationVerifyRegister/applicationVerifyRegisterApiSlice'
3838
import { Notify } from './Snackbar'
39+
import StepHeader from './StepHeader'
3940

4041
export const VerifyRegistration = () => {
4142
const { t } = useTranslation()
@@ -107,17 +108,11 @@ export const VerifyRegistration = () => {
107108
return (
108109
<>
109110
<div className="mx-auto col-9 container-registration">
110-
<div className="head-section">
111-
<div className="mx-auto step-highlight d-flex align-items-center justify-content-center">
112-
5
113-
</div>
114-
<h4 className="mx-auto d-flex align-items-center justify-content-center">
115-
{t('verifyRegistration.title')}
116-
</h4>
117-
<div className="mx-auto text-center col-9">
118-
{t('verifyRegistration.subtitle')}
119-
</div>
120-
</div>
111+
<StepHeader
112+
step={currentActiveStep}
113+
stepName={t('verifyRegistration.title')}
114+
stepDescription={t('verifyRegistration.subtitle')}
115+
/>
121116
<div className="companydata-form mx-auto col-9">
122117
<Row>
123118
<ul className="list-group-cax px-2">

0 commit comments

Comments
 (0)