import { AnyTypedQuizQuestion } from "@model/questionTypes/shared" interface Nodes { data: { id: string; label: string; parent?: string; } } interface Edges { data: { source: string; target: string; } } export const storeToNodes = (questions: AnyTypedQuizQuestion[]) => { const nodes: Nodes[] = [] const edges: Edges[] = [] questions.forEach((question) => { if (question.content.rule.parentId) { nodes.push({data: { id: question.content.id, label: question.title === "" || question.title === " " ? "noname" : question.title }}) // nodes.push({ // data: { // id: "delete" + question.content.id, // label: "X", // parent: question.content.id, // } // },) if (question.content.rule.parentId !== "root") edges.push({data: { source: question.content.rule.parentId, target: question.content.id }}) } }) return [...nodes, ...edges]; }