import { create } from 'zustand'; import type { LessonTreeNode } from '@flashcard/shared'; import { lessonsApi } from '../api/lessons.js'; interface LessonsState { tree: LessonTreeNode[]; loading: boolean; refresh: () => Promise; } export const useLessons = create((set) => ({ tree: [], loading: false, refresh: async () => { set({ loading: true }); try { set({ tree: await lessonsApi.tree() }); } finally { set({ loading: false }); } }, }));