1
This commit is contained in:
@@ -65,6 +65,16 @@ export const api = {
|
||||
body: JSON.stringify({ name }),
|
||||
}));
|
||||
},
|
||||
async updateSubject(id: number, name: string) {
|
||||
return parseResponse<Subject>(await fetch(`${API_URL}/subjects/${id}`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ name }),
|
||||
}));
|
||||
},
|
||||
async deleteSubject(id: number) {
|
||||
return parseResponse<{ status: string }>(await fetch(`${API_URL}/subjects/${id}`, { method: "DELETE" }));
|
||||
},
|
||||
async weeks(subjectId: number) {
|
||||
return parseResponse<Week[]>(await fetch(`${API_URL}/subjects/${subjectId}/weeks`, { cache: "no-store" }));
|
||||
},
|
||||
@@ -85,6 +95,9 @@ export const api = {
|
||||
body: JSON.stringify({ number, title: title || null }),
|
||||
}));
|
||||
},
|
||||
async deleteWeek(subjectId: number, weekNumber: number) {
|
||||
return parseResponse<{ status: string }>(await fetch(`${API_URL}/subjects/${subjectId}/weeks/${weekNumber}`, { method: "DELETE" }));
|
||||
},
|
||||
async sources(subjectId: number, weekNumber: number) {
|
||||
return parseResponse<Source[]>(await fetch(`${API_URL}/subjects/${subjectId}/weeks/${weekNumber}/sources`, { cache: "no-store" }));
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user