Refactors admin page design to move each 'facet' of admin into its own component.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { Component, inject, output } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
import { TeamMember } from '../interfaces/team-member';
|
||||
import { TeamMemberService } from '../services/team-member.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-admin-team-tab',
|
||||
standalone: true,
|
||||
imports: [CommonModule],
|
||||
templateUrl: './admin-team-tab.component.html',
|
||||
styleUrl: './admin-team-tab.component.scss',
|
||||
})
|
||||
export class AdminTeamTabComponent {
|
||||
private teamMemberService = inject(TeamMemberService);
|
||||
|
||||
readonly openForm = output<void>();
|
||||
readonly editItem = output<TeamMember>();
|
||||
readonly deleteItem = output<number>();
|
||||
|
||||
readonly members$ = this.teamMemberService.getTeamMembers();
|
||||
|
||||
ngOnInit(): void {
|
||||
this.load();
|
||||
}
|
||||
|
||||
async load(): Promise<void> {
|
||||
await firstValueFrom(this.teamMemberService.getTeamMembers());
|
||||
}
|
||||
|
||||
onAdd(): void {
|
||||
this.openForm.emit();
|
||||
}
|
||||
|
||||
onEdit(member: TeamMember): void {
|
||||
this.editItem.emit(member);
|
||||
}
|
||||
|
||||
async onDelete(id: number): Promise<void> {
|
||||
if (!confirm('Delete this team member?')) return;
|
||||
await firstValueFrom(this.teamMemberService.deleteTeamMember(id));
|
||||
await this.load();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user