diff --git a/src/app/components/player-registrations/player-registrations.component.html b/src/app/components/player-registrations/player-registrations.component.html
index 7c97a10..f9f717c 100644
--- a/src/app/components/player-registrations/player-registrations.component.html
+++ b/src/app/components/player-registrations/player-registrations.component.html
@@ -16,6 +16,27 @@
@if (eventRegistration.doublesEvent) {
+
+ Partner
+
+
+
+ Geen
+ @for (player of getFilteredPlayers(eventRegistration); track player.id) {
+
+ {{ player | fullName }}
+
+ }
+
+
+
}
diff --git a/src/app/components/player-registrations/player-registrations.component.ts b/src/app/components/player-registrations/player-registrations.component.ts
index 28071f8..8da67e8 100644
--- a/src/app/components/player-registrations/player-registrations.component.ts
+++ b/src/app/components/player-registrations/player-registrations.component.ts
@@ -15,6 +15,9 @@ import {MatAnchor, MatButton} from "@angular/material/button";
import {MatSnackBar} from "@angular/material/snack-bar";
import {FullNamePipe} from "../../pipes/fullname-pipe";
import {HeaderService} from "../../service/header.service";
+import {MatAutocomplete, MatAutocompleteTrigger} from "@angular/material/autocomplete";
+import {MatInput} from "@angular/material/input";
+import {NgForOf} from "@angular/common";
@Component({
selector: 'app-player-registrations',
@@ -30,11 +33,14 @@ import {HeaderService} from "../../service/header.service";
MatCardActions,
RouterLink,
MatOption,
- MatSelect,
+ // MatSelect,
MatIcon,
MatButton,
MatAnchor,
- FullNamePipe
+ FullNamePipe,
+ MatAutocomplete,
+ MatAutocompleteTrigger,
+ MatInput,
],
providers: [
FullNamePipe
@@ -76,6 +82,49 @@ export class PlayerRegistrationsComponent implements OnInit {
});
}
+ private partnerSearchTerms: Map = new Map();
+
+// Add methods
+ onPartnerSearch(searchTerm: string, eventRegistration: EventRegistration) {
+ this.partnerSearchTerms.set(eventRegistration.id, searchTerm?.toLowerCase() || '');
+ }
+
+ getFilteredPlayers(eventRegistration: EventRegistration): Player[] {
+ const allRelevant = this.getRelevantPlayers(eventRegistration.type);
+ const searchTerm = this.partnerSearchTerms.get(eventRegistration.id);
+
+ if (!searchTerm) {
+ return allRelevant;
+ }
+
+ return allRelevant.filter(player => {
+ const fullName = this.fullNamePipe.transform(player).toLowerCase();
+ return fullName.includes(searchTerm);
+ });
+ }
+
+ displayPartnerName(playerId: number | null): string {
+ if (!playerId || !this.allPlayers) return '';
+ const player = this.allPlayers.find(p => p.id === playerId);
+ return player ? this.fullNamePipe.transform(player) : '';
+ }
+
+ onPartnerSelected(event: any, eventRegistration: EventRegistration) {
+ eventRegistration.partner = event.option.value;
+ }
+
+ onPartnerInputFocus(eventRegistration: EventRegistration) {
+ // If there's already a partner selected, use their name as initial filter
+ if (eventRegistration.partner && this.allPlayers) {
+ const partner = this.allPlayers.find(p => p.id === eventRegistration.partner);
+ if (partner) {
+ const partnerName = this.fullNamePipe.transform(partner);
+ eventRegistration.partner = partnerName;
+ this.partnerSearchTerms.set(eventRegistration.id, partnerName.toLowerCase());
+ }
+ }
+ }
+
saveRegistration(tournamentRegistration: TournamentRegistration, event: MouseEvent) {
this.waitingForBackend = true;
this.registrationService.saveTournamentRegistrations(tournamentRegistration, this.player.id).subscribe(data => {