-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
190 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { | ||
teacherSchool as _school, | ||
teacherLevel as _level, | ||
teacherClass as _class, | ||
teacherStudent as _student, | ||
} from "ecoledirecte-api-types"; | ||
|
||
export class TeachersSchool { | ||
id: number; | ||
code: string; | ||
name: string; | ||
|
||
levels: TeachersLevel[]; | ||
|
||
_raw: _school; | ||
|
||
constructor(o: _school) { | ||
this.id = o.id; | ||
this.code = o.code; | ||
this.name = o.libelle; | ||
|
||
this.levels = o.niveaux.map(l => new TeachersLevel(l)); | ||
|
||
this._raw = o; | ||
} | ||
} | ||
|
||
export class TeachersLevel { | ||
id: number; | ||
code: string; | ||
name: string; | ||
|
||
classes: TeachersClass[]; | ||
|
||
_raw: _level; | ||
|
||
constructor(o: _level) { | ||
this.id = o.id; | ||
this.code = o.code; | ||
this.name = o.libelle; | ||
|
||
this.classes = o.classes.map(c => new TeachersClass(c)); | ||
|
||
this._raw = o; | ||
} | ||
} | ||
|
||
export class TeachersClass { | ||
id: number; | ||
code: string; | ||
name: string; | ||
|
||
isHeadTeacher: boolean; | ||
headTeachers: { | ||
id: number; | ||
firstName: string; | ||
lastName: string; | ||
}[]; | ||
|
||
_raw: _class; | ||
|
||
constructor(o: _class) { | ||
this.id = o.id; | ||
this.code = o.code; | ||
this.name = o.libelle; | ||
|
||
this.isHeadTeacher = o.isPP; | ||
this.headTeachers = o.tabPP.map(r => ({ | ||
id: r.id, | ||
firstName: r.prenom, | ||
lastName: r.nom, | ||
})); | ||
|
||
this._raw = o; | ||
} | ||
} | ||
|
||
export class TeachersStudent { | ||
id: number; | ||
firstName: string; | ||
lastName: string; | ||
|
||
_raw: _student; | ||
|
||
constructor(o: _student) { | ||
this.id = o.id; | ||
this.firstName = o.prenom; | ||
this.lastName = o.nom; | ||
|
||
this._raw = o; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Function that fetches school (input: token) | ||
|
||
import { makeRequest } from "../util"; | ||
import { schoolsResSuccess, Routes } from "ecoledirecte-api-types"; | ||
|
||
export async function getTeachersSchools( | ||
token: string | ||
): Promise<schoolsResSuccess> { | ||
const body: schoolsResSuccess = await makeRequest( | ||
{ | ||
method: "POST", | ||
path: Routes.teacherSchools(), | ||
body: { token }, | ||
guard: true, | ||
teachRoot: true, | ||
}, | ||
{ action: "getTeachersSchools" } | ||
); | ||
|
||
return body; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Function that retrieves students for specific class | ||
// input: token, class id | ||
|
||
import { Routes, studentsResSuccess } from "ecoledirecte-api-types"; | ||
import { makeRequest } from "../util"; | ||
|
||
export async function getTeachersStudents( | ||
token: string, | ||
classId: number | ||
): Promise<studentsResSuccess> { | ||
const body: studentsResSuccess = await makeRequest( | ||
{ | ||
method: "POST", | ||
path: Routes.teacherStudents(classId), | ||
body: { token }, | ||
guard: true, | ||
teachRoot: true, | ||
}, | ||
{ action: "getTeachersStudents" } | ||
); | ||
|
||
return body; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters