Add matchesadd

This commit is contained in:
ExostFlash 2025-06-02 19:00:03 +02:00
parent 5a73a70e02
commit 7782d6f50a
4 changed files with 123 additions and 8 deletions

View file

@ -5,12 +5,26 @@
</div> </div>
<form (ngSubmit)="onSubmit()" class="login-form"> <form (ngSubmit)="onSubmit()" class="login-form">
<div class="input-group"> <div class="input-group">
<input type="email" name="email" [(ngModel)]="email" placeholder="Nom utilisateur" required /> <input
type="email"
name="email"
[(ngModel)]="email"
placeholder="Nom utilisateur"
value="user@test.com"
required
/>
<label class="icon">👤</label> <label class="icon">👤</label>
</div> </div>
<div class="input-group"> <div class="input-group">
<input type="password" name="password" [(ngModel)]="password" placeholder="Mot de passe" required /> <input
type="password"
name="password"
[(ngModel)]="password"
placeholder="Mot de passe"
value="password123"
required
/>
<label class="icon">🔒</label> <label class="icon">🔒</label>
</div> </div>

View file

@ -1 +1,102 @@
<p>matches-add works!</p> <h2>Ajouter un match</h2>
<form (ngSubmit)="onSubmit()">
<fieldset>
<legend>Joueur 1</legend>
<label>Prénom :</label>
<input
type="text"
[(ngModel)]="formData.player1FirstName"
name="player1FirstName"
required
/>
<label>Nom :</label>
<input
type="text"
[(ngModel)]="formData.player1Name"
name="player1Name"
required
/>
<label>Club :</label>
<input
type="text"
[(ngModel)]="formData.player1Club"
name="player1Club"
required
/>
</fieldset>
<fieldset>
<legend>Joueur 2</legend>
<label>Prénom :</label>
<input
type="text"
[(ngModel)]="formData.player2FirstName"
name="player2FirstName"
required
/>
<label>Nom :</label>
<input
type="text"
[(ngModel)]="formData.player2Name"
name="player2Name"
required
/>
<label>Club :</label>
<input
type="text"
[(ngModel)]="formData.player2Club"
name="player2Club"
required
/>
</fieldset>
<fieldset>
<legend>Arbitre</legend>
<label>Prénom :</label>
<input
type="text"
[(ngModel)]="formData.refereeFirstName"
name="refereeFirstName"
required
/>
<label>Nom :</label>
<input
type="text"
[(ngModel)]="formData.refereeName"
name="refereeName"
required
/>
<label>Niveau :</label>
<select [(ngModel)]="formData.refereelevel" name="refereelevel" required>
<option [value]="0">Départemental</option>
<option [value]="1">Régional</option>
<option [value]="2">National</option>
<option [value]="3">International</option>
</select>
</fieldset>
<fieldset>
<legend>Match</legend>
<label>Ville :</label>
<input type="text" [(ngModel)]="formData.city" name="city" required />
<label>Pays :</label>
<input type="text" [(ngModel)]="formData.country" name="country" required />
<label>Arme :</label>
<select [(ngModel)]="formData.weapon" name="weapon" required>
<option value="Épée">Épée</option>
<option value="Sabre">Sabre</option>
<option value="Fleuret">Fleuret</option>
</select>
</fieldset>
<button type="submit">Créer le match</button>
</form>

View file

@ -1,5 +1,6 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { MatchesService } from '@services/matches/matches.service'; import { MatchesService } from '@services/matches/matches.service';
import { MatchState } from '@interfaces/matches'; import { MatchState } from '@interfaces/matches';
@ -34,7 +35,6 @@ export class MatchesAddComponent {
city: '', city: '',
country: '', country: '',
date: '',
weapon: '', weapon: '',
}; };
@ -82,7 +82,7 @@ export class MatchesAddComponent {
country: this.formData.country, country: this.formData.country,
city: this.formData.city, city: this.formData.city,
weapon: this.formData.weapon, weapon: this.formData.weapon,
date: new Date(this.formData.date), date: new Date(),
state: MatchState.NOT_STARTED, state: MatchState.NOT_STARTED,
}; };

View file

@ -45,7 +45,7 @@ export class MatchesService {
state: MatchState.NOT_STARTED, state: MatchState.NOT_STARTED,
}, },
]; ];
private nextId = 1; private nextMatchId = Math.max(...this.matches.map((m) => m.id)) + 1;
constructor() { constructor() {
console.log('[MatchesService] Initial matches loaded:', this.matches); console.log('[MatchesService] Initial matches loaded:', this.matches);
@ -83,7 +83,7 @@ export class MatchesService {
create(match: Omit<Matches, 'id'>): Observable<Matches> { create(match: Omit<Matches, 'id'>): Observable<Matches> {
const newMatch: Matches = { const newMatch: Matches = {
...match, ...match,
id: this.nextId++, id: this.nextMatchId++,
}; };
this.matches.push(newMatch); this.matches.push(newMatch);