generated from nhcarrigan/template
feat: add ability to log and display sanctions
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { CommonModule, DatePipe } from "@angular/common";
|
||||
import { Component } from "@angular/core";
|
||||
import { SanctionsService } from "../sanctions.js";
|
||||
|
||||
@Component({
|
||||
imports: [ CommonModule, DatePipe ],
|
||||
selector: "app-sanctions",
|
||||
styleUrl: "./sanctions.css",
|
||||
templateUrl: "./sanctions.html",
|
||||
})
|
||||
export class Sanctions {
|
||||
public sanctions: Array<{
|
||||
number: number;
|
||||
uuid: string;
|
||||
type: string;
|
||||
platform: string;
|
||||
reason: string;
|
||||
username: string;
|
||||
createdAt: string;
|
||||
}> = [];
|
||||
public constructor(
|
||||
private readonly sanctionsService: SanctionsService,
|
||||
) {
|
||||
void this.loadSanctions();
|
||||
}
|
||||
|
||||
private async loadSanctions(): Promise<void> {
|
||||
const sanctions = await this.sanctionsService.getSanctions();
|
||||
this.sanctions = sanctions.sort((a, b) => {
|
||||
return b.createdAt > a.createdAt
|
||||
? 1
|
||||
: -1;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user