feat: using programstore

ref: N25B-399
This commit is contained in:
JobvAlewijk
2026-01-02 20:43:20 +01:00
parent 469a6c7a69
commit cd1aa84f89
2 changed files with 27 additions and 46 deletions

View File

@@ -181,21 +181,23 @@ function graphReducer() {
*/
function VisProgPage() {
const [showSimpleProgram, setShowSimpleProgram] = useState(false);
const [phases, setPhases] = useState<any[]>([]);
const setProgramState = useProgramStore((state) => state.setProgramState);
const runProgram = () => {
const reducedPhases = graphReducer();
setPhases(reducedPhases);
setShowSimpleProgram(true);
runProgramm();
const phases = graphReducer(); // reduce graph
setProgramState({ phases }); // <-- save to store
setShowSimpleProgram(true); // show SimpleProgram
runProgramm(); // send to backend if needed
};
if (showSimpleProgram) {
return (
<SimpleProgram
phases={phases}
/>
<div>
<button onClick={() => setShowSimpleProgram(false)}>
Back to Editor
</button>
<SimpleProgram/>
</div>
);
}