Skip to content

Commit

Permalink
fix(OSP): Consent form 400 submission error (#1102)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanGerada3 authored Sep 17, 2024
1 parent 1b794dd commit 37fd7ff
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
- Fixed "None" selection issue in Technical Integration -> App Release Process [#1036](https://github.com/eclipse-tractusx/portal-frontend/issues/1036)
- **Technical User Management**
- Display technicalUserManagement button based on role validation [#1073](https://github.com/eclipse-tractusx/portal-frontend/pull/1073)
- **OSP Consent form**
- Display invited company name in OSP consent form (Previously hard coded with 'BMW') [#1083](https://github.com/eclipse-tractusx/portal-frontend/pull/1083)
- Fix OSP consent form 400 submission error [#1102](https://github.com/eclipse-tractusx/portal-frontend/pull/1102/files)
- **Use Case participation**
- Removes use cases without verified credentials from the "Use Case Participation" list [#1088](https://github.com/eclipse-tractusx/portal-frontend/pull/1088)

Expand Down
10 changes: 10 additions & 0 deletions src/components/pages/OSPConsent/CompanyDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
type companyRole,
useFetchAgreementConsentsQuery,
type AgreementData,
type SubmitData,
} from 'features/registration/registrationApiSlice'
import { getApiBase } from 'services/EnvironmentService'
import UserService from 'services/UserService'
Expand All @@ -46,13 +47,15 @@ interface CompanyDetailsProps {
loading: boolean
handleSubmit: () => void
submitError: boolean
updateConsents: (data: SubmitData) => void
}

export const CompanyDetails = ({
applicationId,
loading,
handleSubmit,
submitError,
updateConsents,
}: CompanyDetailsProps) => {
const tm = useTranslation().t
const { t } = useTranslation('registration')
Expand All @@ -76,6 +79,13 @@ export const CompanyDetails = ({
applicationId ?? ''
)

useEffect(() => {
updateConsents({
roles: companyRoleChecked,
consents: agreementChecked,
})
}, [companyRoleChecked, agreementChecked])

useEffect(() => {
updateSelectedRolesAndAgreement()
}, [consentData])
Expand Down
7 changes: 7 additions & 0 deletions src/components/pages/OSPConsent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
useFetchAgreementConsentsQuery,
useUpdateAgreementConsentsMutation,
CONSENT_STATUS,
type SubmitData,
} from 'features/registration/registrationApiSlice'
import './style.scss'
import { SuccessRegistration } from './SuccessRegistration'
Expand Down Expand Up @@ -78,6 +79,11 @@ export const OSPConsent = () => {
)
}

const setConsents = (data: SubmitData) => {
setCompanyRoleChecked(data.roles)
setAgreementChecked(data.consents)
}

const handleSubmit = async () => {
setLoading(true)
const companyRoles = Object.keys(companyRoleChecked).filter(
Expand Down Expand Up @@ -131,6 +137,7 @@ export const OSPConsent = () => {
loading={loading}
handleSubmit={handleSubmit}
submitError={submitError}
updateConsents={setConsents}
/>
)
}
Expand Down
5 changes: 5 additions & 0 deletions src/features/registration/registrationApiSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ export type companyRole = {
descriptions: { de: string; en: string }
}

export type SubmitData = {
roles: { [key: string]: boolean }
consents: { [key: string]: boolean }
}

export enum CONSENT_STATUS {
ACTIVE = 'ACTIVE',
INACTIVE = 'INACTIVE',
Expand Down

0 comments on commit 37fd7ff

Please sign in to comment.