forked from kolplattformen/skolplattformen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 Hämta lärare och skolkontakter från api-skolplattfomen och vi…
…sa lärarens namn i schemat (kolplattformen#589) * feat: 🎸 Get list of teachers from api-skolplattfomen * feat: 🎸 teachers and school contacts in hooks * style: 💄 lint * chore: 🤖 fakeData for matching some lessons with teachers * feat: 🎸 Teacher's names in timetable (where available) * test: 💍 fix failing tests (add mocks for new calls)
- Loading branch information
1 parent
0e95486
commit b7dbd35
Showing
19 changed files
with
449 additions
and
5 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
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,47 @@ | ||
import { SchoolContact, Child } from '@skolplattformen/api'; | ||
import { children } from './children' | ||
|
||
export const schoolContacts = (child: Child): SchoolContact[] => schoolContactData.get(child.id) ?? [] | ||
|
||
const [child1,child2] = children() | ||
|
||
const schoolContactData = new Map<string, SchoolContact[]>([ | ||
[ | ||
child1.id, [ | ||
{ | ||
title: "Expedition", | ||
name: null, | ||
phone: "508 000 00", | ||
email: "", | ||
schoolName: "Vallaskolan", | ||
className: null, | ||
}, | ||
{ | ||
title: "Rektor", | ||
name: "Alvar Sträng", | ||
phone: "08-50800001", | ||
email: "alvar.strang@edu.stockholm.se", | ||
schoolName: null, | ||
className: null, | ||
} | ||
]], | ||
[ | ||
child2.id, [ | ||
{ | ||
title: "Expedition", | ||
name: null, | ||
phone: "508 000 00", | ||
email: "", | ||
schoolName: "Vallaskolan", | ||
className: null, | ||
}, | ||
{ | ||
title: "Rektor", | ||
name: "Alvar Sträng", | ||
phone: "08-50800001", | ||
email: "alvar.strang@edu.stockholm.se", | ||
schoolName: null, | ||
className: null, | ||
} | ||
]] | ||
]) |
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,81 @@ | ||
import { Teacher, Child } from '@skolplattformen/api'; | ||
import { children } from './children' | ||
|
||
export const teachers = (child: Child): Teacher[] => teacherData.get(child.id) ?? [] | ||
|
||
const [child1,child2] = children() | ||
|
||
const teacherData = new Map<string, Teacher[]>([ | ||
[ | ||
child1.id, [ | ||
{ | ||
id: 15662220, | ||
firstname: "Cecilia", | ||
sisId: null, | ||
lastname: "Test", | ||
email: "cecilia.test@edu.stockholm.se", | ||
phoneWork: null, | ||
active: true, | ||
status: " S", | ||
timeTableAbbreviation: 'CTE', | ||
}, | ||
{ | ||
id: 15662221, | ||
firstname: "Anna", | ||
lastname: "Test", | ||
sisId: null, | ||
email: "anna.test@edu.stockholm.se", | ||
phoneWork: '08000000', | ||
active: true, | ||
status: " GR", | ||
timeTableAbbreviation: 'ATE', | ||
}, | ||
{ | ||
id: 15662221, | ||
firstname: "Greta", | ||
lastname: "Test", | ||
sisId: null, | ||
email: null, | ||
phoneWork: '08000001', | ||
active: true, | ||
status: " F", | ||
timeTableAbbreviation: 'GTE', | ||
}, | ||
]], | ||
[ | ||
child2.id, [ | ||
{ | ||
id: 15662220, | ||
firstname: "Cecilia", | ||
sisId: null, | ||
lastname: "Test", | ||
email: "cecilia.test@edu.stockholm.se", | ||
phoneWork: null, | ||
active: true, | ||
status: " S", | ||
timeTableAbbreviation: 'CTE', | ||
}, | ||
{ | ||
id: 15662221, | ||
firstname: "Anna", | ||
lastname: "Test", | ||
sisId: null, | ||
email: "anna.test@edu.stockholm.se", | ||
phoneWork: '08000000', | ||
active: true, | ||
status: " GR", | ||
timeTableAbbreviation: 'ATE', | ||
}, | ||
{ | ||
id: 15662221, | ||
firstname: "Greta", | ||
lastname: "Test", | ||
sisId: null, | ||
email: null, | ||
phoneWork: '08000001', | ||
active: true, | ||
status: " F", | ||
timeTableAbbreviation: 'GTE', | ||
}, | ||
]], | ||
]) |
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
50 changes: 50 additions & 0 deletions
50
libs/api-skolplattformen/lib/parse/__tests__/schoolContacts.test.ts
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,50 @@ | ||
import { EtjanstResponse } from '../' | ||
import { schoolContacts } from '../schoolContacts' | ||
|
||
let response: EtjanstResponse | ||
|
||
beforeEach(() => { | ||
response = { | ||
"Success": true, | ||
"Error": null, | ||
"Data": [ | ||
{ | ||
"Title": "Expedition", | ||
"Name": null, | ||
"Phone": "508 000 00", | ||
"Email": "", | ||
"SchoolName": "Påhittade skolan", | ||
"ClassName": null | ||
}, | ||
{ | ||
"Title": "Rektor", | ||
"Name": "Andersson, Anna Bella Cecilia", | ||
"Phone": "08-508 000 00", | ||
"Email": "anna.anderssonn@edu.stockholm.se", | ||
"SchoolName": null, | ||
"ClassName": null | ||
} | ||
] | ||
} | ||
}) | ||
|
||
it('parses teachers correctly', () => { | ||
expect(schoolContacts(response)).toEqual([ | ||
{ | ||
title: 'Expedition', | ||
name: null, | ||
phone: '508 000 00', | ||
email: '', | ||
schoolName: 'Påhittade skolan', | ||
className: null | ||
}, | ||
{ | ||
title: 'Rektor', | ||
name: 'Andersson, Anna Bella Cecilia', | ||
phone: '08-508 000 00', | ||
email: 'anna.anderssonn@edu.stockholm.se', | ||
schoolName: null, | ||
className: null | ||
} | ||
]) | ||
}) |
68 changes: 68 additions & 0 deletions
68
libs/api-skolplattformen/lib/parse/__tests__/teachers.test.ts
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,68 @@ | ||
import { EtjanstResponse } from '../' | ||
import { teachers } from '../teachers' | ||
|
||
let response: EtjanstResponse | ||
|
||
beforeEach(() => { | ||
response = { | ||
"Success": true, | ||
"Error": null, | ||
"Data": [ | ||
{ | ||
"ID": 156735, | ||
"BATCH": "GR", | ||
"SIS_ID": "F154239A-EA4A-4C6C-A112-0B9581132E3D", | ||
"USERNAME": "anna.andersson", | ||
"SCHOOL_SIS_ID": "DE2E1293-0F40-4B91-9D91-1E99355DC257", | ||
"EMAILADDRESS": null, | ||
"STATUS": " GR", | ||
"ERRORCODE": 0, | ||
"FIRSTNAME": "Anna", | ||
"LASTNAME": "Andersson", | ||
"ACTIVE": true, | ||
"TELWORK": "08 508 0000000" | ||
}, | ||
{ | ||
"ID": 156690, | ||
"BATCH": "GR", | ||
"SIS_ID": "9EC59FCA-80AD-4774-AABD-427040207E33", | ||
"USERNAME": "gunnar.grymm", | ||
"SCHOOL_SIS_ID": "DE2E1293-0F40-4B91-9D91-1E99355DC257", | ||
"EMAILADDRESS": "gunnar.grymm@edu.stockholm.se", | ||
"STATUS": " F", | ||
"ERRORCODE": 0, | ||
"FIRSTNAME": "Gunnar", | ||
"LASTNAME": "Grymm", | ||
"ACTIVE": true, | ||
"TELWORK": null | ||
} | ||
] | ||
} | ||
}) | ||
|
||
it('parses teachers correctly', () => { | ||
expect(teachers(response)).toEqual([ | ||
{ | ||
id: 156735, | ||
sisId: 'F154239A-EA4A-4C6C-A112-0B9581132E3D', | ||
firstname: 'Anna', | ||
lastname: 'Andersson', | ||
email: null, | ||
phoneWork: '08 508 0000000', | ||
active: true, | ||
status: ' GR', | ||
timeTableAbbreviation: 'AAN' | ||
}, | ||
{ | ||
id: 156690, | ||
sisId: '9EC59FCA-80AD-4774-AABD-427040207E33', | ||
firstname: 'Gunnar', | ||
lastname: 'Grymm', | ||
email: 'gunnar.grymm@edu.stockholm.se', | ||
phoneWork: null, | ||
active: true, | ||
status: ' F', | ||
timeTableAbbreviation: 'GGR' | ||
}, | ||
]) | ||
}) |
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
Oops, something went wrong.