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