From dd63a082a0f8553e9580930ff1e018564e01d25d Mon Sep 17 00:00:00 2001 From: alea Date: Thu, 15 Oct 2026 15:39:55 +0200 Subject: [PATCH] Koblet Techniques Detailed siden til GraphQL backend --- .../pages/Techniques/TechniqueDetailed.tsx | 153 +++++++++++------- frontend/src/routes/AppRoutes.tsx | 2 +- 2 files changed, 99 insertions(+), 56 deletions(-) diff --git a/frontend/src/pages/Techniques/TechniqueDetailed.tsx b/frontend/src/pages/Techniques/TechniqueDetailed.tsx index fa0e36c..ac0e235 100644 --- a/frontend/src/pages/Techniques/TechniqueDetailed.tsx +++ b/frontend/src/pages/Techniques/TechniqueDetailed.tsx @@ -1,12 +1,36 @@ +import { gql } from "@apollo/client"; +import { useQuery } from "@apollo/client/react"; +import { useParams } from "react-router-dom"; + import TechniqueDetailedHeader from "../../components/techniques/specificTechnique/TechniqueDetailedHeader/TechniqueDetailedHeader"; import TechniqueDescription from "../../components/techniques/specificTechnique/TechniqueDescription/TechniqueDescription"; -import TechniqueOverview from "../../components/techniques/specificTechnique/TechniqueOverview/TechniqueOverview.tsx"; +import TechniqueOverview from "../../components/techniques/specificTechnique/TechniqueOverview/TechniqueOverview"; import SubTechniques from "../../components/techniques/specificTechnique/TechniqueSubTechnique/SubTechniques"; import RelatedThreatActors from "../../components/techniques/specificTechnique/RelatedThreatActors/RelatedThreatActors"; -import AssociatedSoftware from "../../components/techniques/specificTechnique/AssociatedSoftware/AssociatedSoftware.tsx"; -//import worldMap from "../../assets/tungnguyen0905-technology-7111765.jpg"; +import AssociatedSoftware from "../../components/techniques/specificTechnique/AssociatedSoftware/AssociatedSoftware"; + import "./TechniqueDetailed.css"; +export const GET_TECHNIQUE = gql` + query GetTechnique($mitreId: String!) { + techniqueByMitreId(mitreId: $mitreId) { + mitreId + name + description + } + } +`; + +interface Technique { + mitreId: string; + name: string; + description: string; +} + +interface GetTechniqueData { + techniqueByMitreId: Technique | null; +} + const subTechniques = [ { mitreId: "T1566.001", @@ -61,71 +85,90 @@ const software = [ ]; function TechniqueDetailed() { + const { mitreId } = useParams(); + + const { + data, + loading, + error, + } = useQuery( + GET_TECHNIQUE, + { + variables: { + mitreId, + }, + } + ); + + console.log(data); + console.log(error); + console.log(loading); + + if (loading) { + return

Loading...

; + } + + if (error) { + return

Error: {error.message}

; + } + + const technique = data?.techniqueByMitreId; + + if (!technique) { + return

Technique not found.

; + } + return (
-
- -
- -
- -
+
+ +
+
+ +
- +
-
-
- - - -
- -
- -
-
+
+
+ + + +
+ +
+ +
+
- ); + ); } + export default TechniqueDetailed; \ No newline at end of file diff --git a/frontend/src/routes/AppRoutes.tsx b/frontend/src/routes/AppRoutes.tsx index d340da8..597487b 100644 --- a/frontend/src/routes/AppRoutes.tsx +++ b/frontend/src/routes/AppRoutes.tsx @@ -35,7 +35,7 @@ function AppRoutes() { }/> } /> } /> - } /> + } />