Adds Underwriter's carousel and admin features
This commit is contained in:
@@ -9,20 +9,23 @@ import { StationConfig } from '../interfaces/station-config';
|
||||
import { HistoryEntry } from '../interfaces/history-entry';
|
||||
import { TeamMember } from '../interfaces/team-member';
|
||||
import { CommunityHighlight } from '../interfaces/community-highlight';
|
||||
import { Underwriter } from '../interfaces/underwriter';
|
||||
import { ShowService } from '../services/show.service';
|
||||
import { EventService } from '../services/event.service';
|
||||
import { StationConfigService } from '../services/station-config.service';
|
||||
import { HistoryEntryService } from '../services/history-entry.service';
|
||||
import { TeamMemberService } from '../services/team-member.service';
|
||||
import { CommunityHighlightService } from '../services/community-highlight.service';
|
||||
import { UnderwriterService } from '../services/underwriter.service';
|
||||
import { AdminShowFormComponent } from './admin-show-form.component';
|
||||
import { AdminEventFormComponent } from './admin-event-form.component';
|
||||
import { AdminStationFormComponent } from './admin-station-form.component';
|
||||
import { AdminHistoryFormComponent } from './admin-history-form.component';
|
||||
import { AdminTeamFormComponent } from './admin-team-form.component';
|
||||
import { AdminCommunityFormComponent } from './admin-community-form.component';
|
||||
import { AdminUnderwriterFormComponent } from './admin-underwriter-form.component';
|
||||
|
||||
type TabKey = 'shows' | 'events' | 'station' | 'history' | 'team' | 'community';
|
||||
type TabKey = 'shows' | 'events' | 'station' | 'history' | 'team' | 'community' | 'underwriters';
|
||||
|
||||
@Component({
|
||||
selector: 'app-admin',
|
||||
@@ -37,6 +40,7 @@ type TabKey = 'shows' | 'events' | 'station' | 'history' | 'team' | 'community';
|
||||
AdminHistoryFormComponent,
|
||||
AdminTeamFormComponent,
|
||||
AdminCommunityFormComponent,
|
||||
AdminUnderwriterFormComponent,
|
||||
],
|
||||
templateUrl: './admin.component.html',
|
||||
styleUrl: './admin.component.scss',
|
||||
@@ -48,6 +52,7 @@ export class AdminComponent implements OnInit {
|
||||
private historyEntryService = inject(HistoryEntryService);
|
||||
private teamMemberService = inject(TeamMemberService);
|
||||
private communityHighlightService = inject(CommunityHighlightService);
|
||||
private underwriterService = inject(UnderwriterService);
|
||||
|
||||
activeTab = signal<TabKey>('shows');
|
||||
|
||||
@@ -57,6 +62,7 @@ export class AdminComponent implements OnInit {
|
||||
editingHistory: HistoryEntry | null = null;
|
||||
editingTeam: TeamMember | null = null;
|
||||
editingCommunity: CommunityHighlight | null = null;
|
||||
editingUnderwriter: Underwriter | null = null;
|
||||
|
||||
/** BehaviorSubjects guarantee change detection via the async pipe — start empty, populated on load. */
|
||||
readonly shows$ = new BehaviorSubject<Show[]>([]);
|
||||
@@ -65,6 +71,7 @@ export class AdminComponent implements OnInit {
|
||||
readonly historyEntries$ = new BehaviorSubject<HistoryEntry[]>([]);
|
||||
readonly teamMembers$ = new BehaviorSubject<TeamMember[]>([]);
|
||||
readonly communityHighlights$ = new BehaviorSubject<CommunityHighlight[]>([]);
|
||||
readonly underwriters$ = new BehaviorSubject<Underwriter[]>([]);
|
||||
|
||||
showShowForm = false;
|
||||
showEventForm = false;
|
||||
@@ -72,6 +79,7 @@ export class AdminComponent implements OnInit {
|
||||
showHistoryForm = false;
|
||||
showTeamForm = false;
|
||||
showCommunityForm = false;
|
||||
showUnderwriterForm = false;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loadAll();
|
||||
@@ -107,6 +115,11 @@ export class AdminComponent implements OnInit {
|
||||
this.communityHighlights$.next(data);
|
||||
}
|
||||
|
||||
async reloadUnderwriters(): Promise<void> {
|
||||
const data = await firstValueFrom(this.underwriterService.getUnderwriters());
|
||||
this.underwriters$.next(data);
|
||||
}
|
||||
|
||||
async loadAll(): Promise<void> {
|
||||
await Promise.all([
|
||||
this.reloadShows(),
|
||||
@@ -115,6 +128,7 @@ export class AdminComponent implements OnInit {
|
||||
this.reloadHistoryEntries(),
|
||||
this.reloadTeamMembers(),
|
||||
this.reloadCommunityHighlights(),
|
||||
this.reloadUnderwriters(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -277,4 +291,33 @@ export class AdminComponent implements OnInit {
|
||||
await firstValueFrom(this.communityHighlightService.deleteCommunityHighlight(id));
|
||||
await this.reloadCommunityHighlights();
|
||||
}
|
||||
|
||||
// ── Underwriter CRUD ────────────────────────────────────
|
||||
|
||||
openUnderwriterForm(): void {
|
||||
this.editingUnderwriter = null;
|
||||
this.showUnderwriterForm = true;
|
||||
}
|
||||
|
||||
editUnderwriter(underwriter: Underwriter): void {
|
||||
this.editingUnderwriter = underwriter;
|
||||
this.showUnderwriterForm = true;
|
||||
}
|
||||
|
||||
onUnderwriterSaved(): void {
|
||||
this.reloadUnderwriters();
|
||||
this.showUnderwriterForm = false;
|
||||
this.editingUnderwriter = null;
|
||||
}
|
||||
|
||||
onUnderwriterClosed(): void {
|
||||
this.showUnderwriterForm = false;
|
||||
this.editingUnderwriter = null;
|
||||
}
|
||||
|
||||
async deleteUnderwriter(id: number): Promise<void> {
|
||||
if (!confirm('Delete this underwriter?')) return;
|
||||
await firstValueFrom(this.underwriterService.deleteUnderwriter(id));
|
||||
await this.reloadUnderwriters();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user