From 37fd7ff55e3c9e97f2df6975fa9a16b9d7e89bbb Mon Sep 17 00:00:00 2001 From: Jordan Gerada <138688996+JordanGerada3@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:23:24 +0200 Subject: [PATCH] fix(OSP): Consent form 400 submission error (#1102) --- CHANGELOG.md | 3 +++ src/components/pages/OSPConsent/CompanyDetails.tsx | 10 ++++++++++ src/components/pages/OSPConsent/index.tsx | 7 +++++++ src/features/registration/registrationApiSlice.ts | 5 +++++ 4 files changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c7f7e07d..dc929329e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/components/pages/OSPConsent/CompanyDetails.tsx b/src/components/pages/OSPConsent/CompanyDetails.tsx index 83a81f265..138f8aa0e 100644 --- a/src/components/pages/OSPConsent/CompanyDetails.tsx +++ b/src/components/pages/OSPConsent/CompanyDetails.tsx @@ -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' @@ -46,6 +47,7 @@ interface CompanyDetailsProps { loading: boolean handleSubmit: () => void submitError: boolean + updateConsents: (data: SubmitData) => void } export const CompanyDetails = ({ @@ -53,6 +55,7 @@ export const CompanyDetails = ({ loading, handleSubmit, submitError, + updateConsents, }: CompanyDetailsProps) => { const tm = useTranslation().t const { t } = useTranslation('registration') @@ -76,6 +79,13 @@ export const CompanyDetails = ({ applicationId ?? '' ) + useEffect(() => { + updateConsents({ + roles: companyRoleChecked, + consents: agreementChecked, + }) + }, [companyRoleChecked, agreementChecked]) + useEffect(() => { updateSelectedRolesAndAgreement() }, [consentData]) diff --git a/src/components/pages/OSPConsent/index.tsx b/src/components/pages/OSPConsent/index.tsx index 5a760479b..d8f31ba9c 100644 --- a/src/components/pages/OSPConsent/index.tsx +++ b/src/components/pages/OSPConsent/index.tsx @@ -26,6 +26,7 @@ import { useFetchAgreementConsentsQuery, useUpdateAgreementConsentsMutation, CONSENT_STATUS, + type SubmitData, } from 'features/registration/registrationApiSlice' import './style.scss' import { SuccessRegistration } from './SuccessRegistration' @@ -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( @@ -131,6 +137,7 @@ export const OSPConsent = () => { loading={loading} handleSubmit={handleSubmit} submitError={submitError} + updateConsents={setConsents} /> ) } diff --git a/src/features/registration/registrationApiSlice.ts b/src/features/registration/registrationApiSlice.ts index 21e6b3150..44208c927 100644 --- a/src/features/registration/registrationApiSlice.ts +++ b/src/features/registration/registrationApiSlice.ts @@ -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',