[+] Implement new user model
This commit is contained in:
+10
-8
@@ -1,4 +1,5 @@
|
||||
import {GPAUtils} from '@/logic/utils/gpa-utils';
|
||||
import Course from '@/logic/course';
|
||||
|
||||
const md5 = require('md5');
|
||||
|
||||
@@ -11,20 +12,20 @@ export default class LoginUser
|
||||
firstLogin: Date
|
||||
firstName: string
|
||||
lastName: string
|
||||
nickname: string
|
||||
graduationYear: number
|
||||
groups: string
|
||||
emails: string[]
|
||||
classes: string[]
|
||||
birthday: string
|
||||
avatarUrl: string
|
||||
|
||||
token: string
|
||||
courses: Course[]
|
||||
|
||||
gradeLevel: number
|
||||
gradeLevelName: string
|
||||
|
||||
constructor(json: any)
|
||||
constructor(jsonData: any)
|
||||
{
|
||||
let json = jsonData.user
|
||||
this.id = json.id;
|
||||
this.schoolPersonPk = json.schoolPersonPk;
|
||||
this.username = json.username;
|
||||
@@ -32,15 +33,16 @@ export default class LoginUser
|
||||
this.firstLogin = new Date(json.firstLogin);
|
||||
this.firstName = json.firstName;
|
||||
this.lastName = json.lastName;
|
||||
this.nickname = json.nickname;
|
||||
this.graduationYear = +json.graduationYear;
|
||||
this.groups = json.groups;
|
||||
this.emails = json.emails.split('|').map((e: any) => e.toLowerCase().trim());
|
||||
this.classes = json.classes.split('|');
|
||||
this.birthday = json.birthday;
|
||||
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.gradeLevelName = GPAUtils.gradeLevelName(this.gradeLevel);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user