From 867dbedbb25d0dd1892dc50aa0afccf7a1e5d579 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Fri, 29 Nov 2024 15:37:10 +0100 Subject: [PATCH] feat: update read view of a requirement --- .../requirement-assessments/[id=uuid]/+page.server.ts | 9 ++------- .../requirement-assessments/[id=uuid]/+page.svelte | 9 +++++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.server.ts b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.server.ts index acb0fb1c7..177c5ff37 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.server.ts +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.server.ts @@ -12,13 +12,8 @@ export const load = (async ({ fetch, params }) => { const complianceAssessmentScore = await fetch( `${BASE_API_URL}/compliance-assessments/${requirementAssessment.compliance_assessment.id}/global_score/` ).then((res) => res.json()); - const requirement = await fetch( - `${BASE_API_URL}/requirement-nodes/${requirementAssessment.requirement}/` - ).then((res) => res.json()); - const parentRequirementNodeEndpoint = `${BASE_API_URL}/requirement-nodes/?urn=${requirement.parent_urn}`; - const parent = await fetch(parentRequirementNodeEndpoint) - .then((res) => res.json()) - .then((res) => res.results[0]); + const requirement = requirementAssessment.requirement; + const parent = requirementAssessment.requirement.parent_requirement; const tables: Record = {}; diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte index 7f757b20c..7ac137a23 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte @@ -12,13 +12,14 @@ import { page } from '$app/stores'; export let data: PageData; - const threats = data.requirement.threats; - const reference_controls = data.requirement.reference_controls; + const threats = data.requirementAssessment.requirement.associated_threats ?? []; + const reference_controls = + data.requirementAssessment.requirement.associated_reference_controls ?? []; const annotation = data.requirement.annotation; const typical_evidence = data.requirement.typical_evidence; - const has_threats = threats && threats.length > 0; - const has_reference_controls = reference_controls && reference_controls.length > 0; + const has_threats = threats.length > 0; + const has_reference_controls = reference_controls.length > 0; $: mappingInference = { sourceRequirementAssessment: