File size: 781 Bytes
f91a684 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | export interface SystemDesignTopic {
id: string;
chapter_no: number;
chapter_name: string;
subtitle: string;
level: string;
}
export interface SystemDesignTopicContent extends SystemDesignTopic {
content: any; // Raw JSON object from MongoDB
}
export async function fetchSystemDesignTopics(): Promise<SystemDesignTopic[]> {
const res = await fetch('/api/system-design/topics');
if (!res.ok) throw new Error('Failed to fetch topics');
const data = await res.json();
return data.topics || [];
}
export async function fetchSystemDesignTopicContent(chapterNo: number): Promise<SystemDesignTopicContent> {
const res = await fetch(`/api/system-design/topics/${chapterNo}`);
if (!res.ok) throw new Error('Failed to fetch topic content');
return res.json();
}
|