| |
| |
| |
| |
| |
|
|
| const API_BASE = ''; |
|
|
| export interface OSSection { |
| section_no: number; |
| section: string; |
| topic_count: number; |
| level: string; |
| } |
|
|
| export interface OSTopic { |
| id: string; |
| section: string; |
| topic: string; |
| type: string; |
| subtopic?: string; |
| content: Record<string, any>; |
| } |
|
|
| |
| |
| |
| export async function fetchOSSections(): Promise<OSSection[]> { |
| const res = await fetch(`${API_BASE}/api/os/sections`, { |
| method: 'GET', |
| headers: { 'Content-Type': 'application/json' }, |
| }); |
| if (!res.ok) throw new Error(`OS sections fetch failed: ${res.status}`); |
| const data = await res.json(); |
| return data.sections ?? []; |
| } |
|
|
| |
| |
| |
| export async function fetchOSSectionContent(sectionNo: number): Promise<{ section: string; topics: OSTopic[] }> { |
| const res = await fetch(`${API_BASE}/api/os/sections/${sectionNo}`, { |
| method: 'GET', |
| headers: { 'Content-Type': 'application/json' }, |
| }); |
| if (!res.ok) throw new Error(`OS section content fetch failed: ${res.status}`); |
| return res.json(); |
| } |
|
|