diff --git a/src/pages/SimpleProgram/SimpleProgram.tsx b/src/pages/SimpleProgram/SimpleProgram.tsx new file mode 100644 index 0000000..b682b1a --- /dev/null +++ b/src/pages/SimpleProgram/SimpleProgram.tsx @@ -0,0 +1,136 @@ +import React from "react"; +import styles from "../VisProgPage/VisProg.module.css"; + +/* ---------- Types (mirrors backend / reducer output) ---------- */ + +type Norm = { + id: string; + label: string; + norm: string; +}; + +type Goal = { + id: string; + label: string; + description: string; + achieved: boolean; +}; + +type TriggerKeyword = { + id: string; + keyword: string; +}; + +type KeywordTrigger = { + id: string; + label: string; + type: string; + keywords: TriggerKeyword[]; +}; + +type Phase = { + id: string; + label: string; + norms: Norm[]; + goals: Goal[]; + triggers: KeywordTrigger[]; +}; + +type SimpleProgramProps = { + phases: Phase[]; +}; + + +/* ---------- Component ---------- */ + + +/** + * SimpleProgram + * + * Read-only oversight view for a reduced program. + * Displays norms, goals, and triggers grouped per phase. + */ +const SimpleProgram: React.FC = ({ phases }) => { + return ( +
+

Simple Program Overview

+ + {phases.map((phase) => ( +
+

{phase.label}

+ + {/* Norms */} +
+

Norms

+ {phase.norms.length === 0 ? ( +

No norms defined.

+ ) : ( +
    + {phase.norms.map((norm) => ( +
  • + {norm.label}: {norm.norm} +
  • + ))} +
+ )} +
+ + {/* Goals */} +
+

Goals

+ {phase.goals.length === 0 ? ( +

No goals defined.

+ ) : ( +
    + {phase.goals.map((goal) => ( +
  • + {goal.label}: {goal.description}{" "} + + [{goal.achieved ? "✔" : "❌"}] + +
  • + ))} +
+ )} +
+ + {/* Triggers */} +
+

Triggers

+ {phase.triggers.length === 0 ? ( +

No triggers defined.

+ ) : ( +
    + {phase.triggers.map((trigger) => ( +
  • + {trigger.label} ({trigger.type}) +
      + {trigger.keywords.map((kw) => ( +
    • {kw.keyword}
    • + ))} +
    +
  • + ))} +
+ )} +
+
+ ))} +
+ ); +}; + +export default SimpleProgram; diff --git a/src/pages/VisProgPage/VisProg.tsx b/src/pages/VisProgPage/VisProg.tsx index 06e072c..60d66de 100644 --- a/src/pages/VisProgPage/VisProg.tsx +++ b/src/pages/VisProgPage/VisProg.tsx @@ -7,7 +7,7 @@ import { MarkerType, } from '@xyflow/react'; import '@xyflow/react/dist/style.css'; -import {useEffect} from "react"; +import {useEffect, useState} from "react"; import {useShallow} from 'zustand/react/shallow'; import {DndToolbar} from './visualProgrammingUI/components/DragDropSidebar.tsx'; import useFlowStore from './visualProgrammingUI/VisProgStores.tsx'; @@ -15,6 +15,7 @@ import type {FlowState} from './visualProgrammingUI/VisProgTypes.tsx'; import styles from './VisProg.module.css' import { NodeReduces, NodeTypes } from './visualProgrammingUI/NodeRegistry.ts'; import SaveLoadPanel from './visualProgrammingUI/components/SaveLoadPanel.tsx'; +import SimpleProgram from "../SimpleProgram/SimpleProgram.tsx"; // --| config starting params for flow |-- @@ -138,7 +139,7 @@ function VisualProgrammingUI() { } // currently outputs the prepared program to the console -function runProgram() { +function runProgramm() { const phases = graphReducer(); const program = {phases} console.log(JSON.stringify(program, null, 2)); @@ -174,6 +175,25 @@ function graphReducer() { * @constructor */ function VisProgPage() { + const [showSimpleProgram, setShowSimpleProgram] = useState(false); + const [phases, setPhases] = useState([]); + + const runProgram = () => { + const reducedPhases = graphReducer(); + setPhases(reducedPhases); + setShowSimpleProgram(true); + runProgramm(); + }; + + if (showSimpleProgram) { + return ( + + ); + } + return ( <>