mirror of
https://github.com/opelly27/WinStudentGoalTracker.git
synced 2026-05-20 02:57:36 +00:00
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { Component, inject, signal } from '@angular/core';
|
|
import { StudentCard } from '../../components/student-card/student-card';
|
|
import { StudentService } from '../../../shared/services/dummy-student.service';
|
|
import { StudentCardDto } from '../../../shared/classes/student-card.dto';
|
|
|
|
@Component({
|
|
selector: 'app-students',
|
|
imports: [StudentCard],
|
|
templateUrl: './students.html',
|
|
styleUrl: './students.scss',
|
|
})
|
|
export class Students {
|
|
|
|
// ************************** Constructor **************************
|
|
|
|
constructor() {
|
|
this.loadStudents();
|
|
}
|
|
|
|
// ************************** Declarations *************************
|
|
|
|
private readonly studentService = inject(StudentService);
|
|
protected readonly students = signal<StudentCardDto[]>([]);
|
|
|
|
public errorMessage = signal<String | null>(null);
|
|
|
|
// ************************** Properties ***************************
|
|
|
|
// ************************ Public Methods *************************
|
|
|
|
// ************************ Event Handlers *************************
|
|
|
|
// ********************** Support Procedures ***********************
|
|
|
|
// *****************************************************************
|
|
// Loads the list of students assigned to the current user.
|
|
// *****************************************************************
|
|
private loadStudents() {
|
|
this.studentService.getDummyStudentsForUser().then(data => {
|
|
|
|
if (!data.success)
|
|
{
|
|
this.errorMessage.set(data.message);
|
|
}
|
|
else
|
|
{
|
|
this.students.set(data.payload || []);
|
|
}
|
|
});
|
|
}
|
|
}
|