[+] Implement new user model

This commit is contained in:
Hykilpikonna
2020-05-25 21:21:58 -04:00
parent 2839304dc5
commit 254c2690e5
+10 -8
View File
@@ -1,4 +1,5 @@
import {GPAUtils} from '@/logic/utils/gpa-utils'; import {GPAUtils} from '@/logic/utils/gpa-utils';
import Course from '@/logic/course';
const md5 = require('md5'); const md5 = require('md5');
@@ -11,20 +12,20 @@ export default class LoginUser
firstLogin: Date firstLogin: Date
firstName: string firstName: string
lastName: string lastName: string
nickname: string
graduationYear: number graduationYear: number
groups: string
emails: string[] emails: string[]
classes: string[] classes: string[]
birthday: string
avatarUrl: string avatarUrl: string
token: string token: string
courses: Course[]
gradeLevel: number gradeLevel: number
gradeLevelName: string gradeLevelName: string
constructor(json: any) constructor(jsonData: any)
{ {
let json = jsonData.user
this.id = json.id; this.id = json.id;
this.schoolPersonPk = json.schoolPersonPk; this.schoolPersonPk = json.schoolPersonPk;
this.username = json.username; this.username = json.username;
@@ -32,15 +33,16 @@ export default class LoginUser
this.firstLogin = new Date(json.firstLogin); this.firstLogin = new Date(json.firstLogin);
this.firstName = json.firstName; this.firstName = json.firstName;
this.lastName = json.lastName; this.lastName = json.lastName;
this.nickname = json.nickname;
this.graduationYear = +json.graduationYear; this.graduationYear = +json.graduationYear;
this.groups = json.groups;
this.emails = json.emails.split('|').map((e: any) => e.toLowerCase().trim()); this.emails = json.emails.split('|').map((e: any) => e.toLowerCase().trim());
this.classes = json.classes.split('|'); this.classes = json.classes.split('|');
this.birthday = json.birthday;
this.avatarUrl = json.avatarUrl; this.avatarUrl = json.avatarUrl;
this.token = json.token;
// Extracted in newer versions
this.token = jsonData.token;
this.courses = jsonData.courses.map((courseJson: any) => new Course(courseJson));
// Calculated grade level
this.gradeLevel = GPAUtils.getGradeLevel(this.graduationYear); this.gradeLevel = GPAUtils.getGradeLevel(this.graduationYear);
this.gradeLevelName = GPAUtils.gradeLevelName(this.gradeLevel); this.gradeLevelName = GPAUtils.gradeLevelName(this.gradeLevel);