diff --git a/__mocks__/data/eservice.mocks.ts b/__mocks__/data/eservice.mocks.ts index e06b6761d..df8e1cc16 100644 --- a/__mocks__/data/eservice.mocks.ts +++ b/__mocks__/data/eservice.mocks.ts @@ -110,6 +110,10 @@ const createMockEServiceDescriptorProvider = createMockFactory PurposeServices.getRiskAnalysisLatest(), + queryFn: () => PurposeServices.getRiskAnalysisLatest(params), }) } diff --git a/src/api/purpose/purpose.services.ts b/src/api/purpose/purpose.services.ts index c286fede3..8f4523d03 100644 --- a/src/api/purpose/purpose.services.ts +++ b/src/api/purpose/purpose.services.ts @@ -14,6 +14,7 @@ import type { PurposeVersionResource, PurposeVersionSeed, RejectPurposeVersionPayload, + RetrieveLatestRiskAnalysisConfigurationParams, RetrieveRiskAnalysisConfigurationByVersionParams, ReversePurposeUpdateContent, RiskAnalysisFormConfig, @@ -68,9 +69,10 @@ async function getSingle(purposeId: string) { return REMOVE_ME_remapPurpose(response.data) } -async function getRiskAnalysisLatest() { +async function getRiskAnalysisLatest(params?: RetrieveLatestRiskAnalysisConfigurationParams) { const response = await axiosInstance.get( - `${BACKEND_FOR_FRONTEND_URL}/purposes/riskAnalysis/latest` + `${BACKEND_FOR_FRONTEND_URL}/purposes/riskAnalysis/latest`, + { params } ) return response.data } diff --git a/src/pages/ProviderEServiceCreatePage/components/EServiceCreateStepPurpose/EServiceCreateStepPurposeRiskAnalysis/EServiceCreateStepPurposeRiskAnalysis.tsx b/src/pages/ProviderEServiceCreatePage/components/EServiceCreateStepPurpose/EServiceCreateStepPurposeRiskAnalysis/EServiceCreateStepPurposeRiskAnalysis.tsx index b2f2e52e1..7f7692711 100644 --- a/src/pages/ProviderEServiceCreatePage/components/EServiceCreateStepPurpose/EServiceCreateStepPurposeRiskAnalysis/EServiceCreateStepPurposeRiskAnalysis.tsx +++ b/src/pages/ProviderEServiceCreatePage/components/EServiceCreateStepPurpose/EServiceCreateStepPurposeRiskAnalysis/EServiceCreateStepPurposeRiskAnalysis.tsx @@ -14,7 +14,15 @@ export const EServiceCreateStepPurposeRiskAnalysis: React.FC = () => { const { mutate: addEServiceRiskAnalysis } = EServiceMutations.useAddEServiceRiskAnalysis() const { mutate: updateEServiceRiskAnalysis } = EServiceMutations.useUpdateEServiceRiskAnalysis() - const { data: riskAnalysisLatest } = useQuery(PurposeQueries.getRiskAnalysisLatest()) + const { data: riskAnalysisLatest } = useQuery( + PurposeQueries.getRiskAnalysisLatest({ + /** + * We need to retrieve the risk analysis configuration for the tenant kind of the producer + * because the actual user might be a producer delegate with a different tenant kind. + */ + tenantKind: descriptor?.eservice.producer.tenantKind, + }) + ) if (!riskAnalysisLatest || !descriptor) return