Skip to content

Commit

Permalink
fix: create a new component for form-header used in each step (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamv-ss authored Nov 21, 2024
1 parent 6706040 commit e354abb
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 55 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Bugfix

- 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)

## 2.1.0-RC1

### Change
Expand Down
41 changes: 41 additions & 0 deletions src/components/StepHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/********************************************************************************
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

type StepHeaderProps = {
step: number
stepName: string
stepDescription: string
}
const StepHeader = ({ step, stepName, stepDescription }: StepHeaderProps) => {
return (
<div className="head-section">
<div className="mx-auto step-highlight d-flex align-items-center justify-content-center">
{step}
</div>
<h4 className="mx-auto d-flex align-items-center justify-content-center">
{stepName}
</h4>
<div className="mx-auto text-center col-9">
{stepDescription}
</div>
</div>
)
}

export default StepHeader
17 changes: 6 additions & 11 deletions src/components/cax-companyData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
import { Autocomplete, TextField } from '@mui/material'
import i18n from '../services/I18nService'
import { Notify } from './Snackbar'
import StepHeader from './StepHeader'

type CountryType = {
id: string
Expand Down Expand Up @@ -389,17 +390,11 @@ export const CompanyDataCax = () => {
return (
<>
<div className="mx-auto col-9 container-registration">
<div className="head-section">
<div className="mx-auto step-highlight d-flex align-items-center justify-content-center">
1
</div>
<h4 className="mx-auto d-flex align-items-center justify-content-center">
{t('registrationStepOne.verifyCompayDataHeading')}
</h4>
<div className="mx-auto text-center col-9">
{t('registrationStepOne.verifyCompayDataSubHeading')}
</div>
</div>
<StepHeader
step={currentActiveStep}
stepName={t('registrationStepOne.verifyCompayDataHeading')}
stepDescription={t('registrationStepOne.verifyCompayDataSubHeading')}
/>
<div className="companydata-form">
<Row className="mx-auto col-9">
<div className={`form-search ${bpnErrorMsg ? 'error' : ''}`}>
Expand Down
17 changes: 6 additions & 11 deletions src/components/cax-companyRole.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
getCurrentStep,
} from '../state/features/user/userApiSlice'
import '../styles/newApp.css'
import StepHeader from './StepHeader'

export const CompanyRoleCax = () => {
const { t, i18n } = useTranslation()
Expand Down Expand Up @@ -272,17 +273,11 @@ export const CompanyRoleCax = () => {
return (
<>
<div className="mx-auto col-9 container-registration">
<div className="head-section">
<div className="mx-auto step-highlight d-flex align-items-center justify-content-center">
3
</div>
<h4 className="mx-auto d-flex align-items-center justify-content-center">
{t('companyRole.title')}
</h4>
<div className="mx-auto text-center col-9">
{t('companyRole.subTitle')}
</div>
</div>
<StepHeader
step={currentActiveStep}
stepName={t('companyRole.title')}
stepDescription={t('companyRole.subTitle')}
/>
<div className="companydata-form mx-auto col-9">
{allConsentData?.companyRoles.map((role, index) => (
<div className="company-role-section" key={index}>
Expand Down
17 changes: 6 additions & 11 deletions src/components/cax-responsibilities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
useUpdateInviteNewUserMutation,
} from '../state/features/applicationInviteUser/applicationInviteUserApiSlice'
import { Notify, SeverityType } from './Snackbar'
import StepHeader from './StepHeader'

export const ResponsibilitiesCax = () => {
const { t } = useTranslation()
Expand Down Expand Up @@ -177,17 +178,11 @@ export const ResponsibilitiesCax = () => {
return (
<>
<div className="mx-auto col-9 container-registration">
<div className="head-section">
<div className="mx-auto step-highlight d-flex align-items-center justify-content-center">
2
</div>
<h4 className="mx-auto d-flex align-items-center justify-content-center">
{t('Responsibility.responsAndAdmin')}
</h4>
<div className="mx-auto text-center col-9">
{t('Responsibility.subTitle')}
</div>
</div>
<StepHeader
step={currentActiveStep}
stepName={t('Responsibility.responsAndAdmin')}
stepDescription={t('Responsibility.subTitle')}
/>
<div className="companydata-form">
<Row className="mx-auto col-9">
<div
Expand Down
17 changes: 6 additions & 11 deletions src/components/dragdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
} from '../state/features/applicationDocuments/applicationDocumentsApiSlice'
import { downloadDocument } from '../helpers/utils'
import { Notify, SeverityType } from './Snackbar'
import StepHeader from './StepHeader'

const getClassNameByStatus = (status: string) => {
switch (status) {
Expand Down Expand Up @@ -198,17 +199,11 @@ export const DragDrop = () => {
return (
<>
<div className="mx-auto col-9 container-registration">
<div className="head-section">
<div className="mx-auto step-highlight d-flex align-items-center justify-content-center">
4
</div>
<h4 className="mx-auto d-flex align-items-center justify-content-center">
{t('documentUpload.title')}
</h4>
<div className="mx-auto text-center col-9">
{t('documentUpload.subTitle')}
</div>
</div>
<StepHeader
step={currentActiveStep}
stepName={t('documentUpload.title')}
stepDescription={t('documentUpload.subTitle')}
/>
<div className="companydata-form mx-auto col-9">
<Dropzone
onChangeStatus={handleChangeStatus}
Expand Down
17 changes: 6 additions & 11 deletions src/components/verifyRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
useUpdateRegistrationMutation,
} from '../state/features/applicationVerifyRegister/applicationVerifyRegisterApiSlice'
import { Notify } from './Snackbar'
import StepHeader from './StepHeader'

export const VerifyRegistration = () => {
const { t } = useTranslation()
Expand Down Expand Up @@ -107,17 +108,11 @@ export const VerifyRegistration = () => {
return (
<>
<div className="mx-auto col-9 container-registration">
<div className="head-section">
<div className="mx-auto step-highlight d-flex align-items-center justify-content-center">
5
</div>
<h4 className="mx-auto d-flex align-items-center justify-content-center">
{t('verifyRegistration.title')}
</h4>
<div className="mx-auto text-center col-9">
{t('verifyRegistration.subtitle')}
</div>
</div>
<StepHeader
step={currentActiveStep}
stepName={t('verifyRegistration.title')}
stepDescription={t('verifyRegistration.subtitle')}
/>
<div className="companydata-form mx-auto col-9">
<Row>
<ul className="list-group-cax px-2">
Expand Down

0 comments on commit e354abb

Please sign in to comment.