TD-29: Player Registration Form implemented WIP: Empty spaces as login data
This commit is contained in:
parent
bd720fd5c7
commit
b5a5026a14
9 changed files with 106 additions and 10 deletions
|
@ -49,7 +49,7 @@
|
||||||
"stylelint-scss": "^6.11.0",
|
"stylelint-scss": "^6.11.0",
|
||||||
"typescript": "~5.6.2"
|
"typescript": "~5.6.2"
|
||||||
},
|
},
|
||||||
"api_version": "v0.0.0-rc.2",
|
"api_version": "v0.0.0-rc.3",
|
||||||
"volta": {
|
"volta": {
|
||||||
"node": "22.13.1"
|
"node": "22.13.1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
<main>
|
<main>
|
||||||
<h1>{{title.getTitle()}}</h1>
|
<h1>{{title.getTitle()}}</h1>
|
||||||
<router-outlet />
|
<router-outlet />
|
||||||
|
<app-registration-form></app-registration-form>
|
||||||
</main>
|
</main>
|
|
@ -3,10 +3,12 @@ import { Title } from '@angular/platform-browser';
|
||||||
import { RouterOutlet } from '@angular/router';
|
import { RouterOutlet } from '@angular/router';
|
||||||
import { HeaderComponent } from '@app/header/header.component';
|
import { HeaderComponent } from '@app/header/header.component';
|
||||||
import { NotificationBoxComponent } from '@app/notification-box/notification-box.component';
|
import { NotificationBoxComponent } from '@app/notification-box/notification-box.component';
|
||||||
|
import {RegistrationFormComponent} from "@app/registration-form/registration-form.component";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
imports: [RouterOutlet, HeaderComponent, NotificationBoxComponent],
|
imports: [RouterOutlet, HeaderComponent, NotificationBoxComponent, RegistrationFormComponent],
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrl: './app.component.scss'
|
styleUrl: './app.component.scss'
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { provideAnimationsAsync } from '@angular/platform-browser/animations/asy
|
||||||
import {provideRouter} from '@angular/router';
|
import {provideRouter} from '@angular/router';
|
||||||
|
|
||||||
import {routes} from './app.routes';
|
import {routes} from './app.routes';
|
||||||
|
import {BASE_PATH, Configuration} from "@core/server";
|
||||||
|
|
||||||
export const appConfig: ApplicationConfig = {
|
export const appConfig: ApplicationConfig = {
|
||||||
providers: [
|
providers: [
|
||||||
|
@ -11,5 +12,7 @@ export const appConfig: ApplicationConfig = {
|
||||||
provideAnimationsAsync(),
|
provideAnimationsAsync(),
|
||||||
provideRouter(routes),
|
provideRouter(routes),
|
||||||
provideHttpClient(),
|
provideHttpClient(),
|
||||||
|
Configuration,
|
||||||
|
{provide: BASE_PATH, useValue: 'http://localhost:8080/api/v1'}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
19
src/app/registration-form/registration-form.component.html
Normal file
19
src/app/registration-form/registration-form.component.html
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<div>
|
||||||
|
<form [formGroup]="registrationForm" class="registration-container">
|
||||||
|
<h2>Player Registration</h2>
|
||||||
|
|
||||||
|
<mat-form-field appearance="fill">
|
||||||
|
<mat-label>Username</mat-label>
|
||||||
|
<input formControlName="username" matInput type="text" required>
|
||||||
|
<mat-error> Username is required! </mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field appearance="fill">
|
||||||
|
<mat-label>Password</mat-label>
|
||||||
|
<input formControlName="password" matInput type="password" required>
|
||||||
|
<mat-error> Password is required! </mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<button mat-flat-button (click)="registerPlayer()">Register</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
|
@ -0,0 +1,5 @@
|
||||||
|
.registration-container{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { RegistrationFormComponent } from './registration-form.component';
|
||||||
|
|
||||||
|
describe('RegistrationFormComponent', () => {
|
||||||
|
let component: RegistrationFormComponent;
|
||||||
|
let fixture: ComponentFixture<RegistrationFormComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [RegistrationFormComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(RegistrationFormComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
42
src/app/registration-form/registration-form.component.ts
Normal file
42
src/app/registration-form/registration-form.component.ts
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import {Component} from '@angular/core';
|
||||||
|
import {PlayerRegistrationData, ServerService} from "@core/server";
|
||||||
|
import {MatFormFieldModule} from '@angular/material/form-field';
|
||||||
|
import {FormBuilder, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||||
|
import {MatSelectModule} from '@angular/material/select';
|
||||||
|
import {MatInputModule} from '@angular/material/input';
|
||||||
|
import {MatButtonModule} from "@angular/material/button";
|
||||||
|
import {NotificationService, NotificationType} from "@core/notification/notification.service";
|
||||||
|
import {isEmpty, max} from "rxjs";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-registration-form',
|
||||||
|
imports: [MatFormFieldModule, FormsModule, MatSelectModule, MatInputModule, MatButtonModule, ReactiveFormsModule],
|
||||||
|
templateUrl: './registration-form.component.html',
|
||||||
|
styleUrl: './registration-form.component.scss',
|
||||||
|
standalone: true
|
||||||
|
})
|
||||||
|
export class RegistrationFormComponent {
|
||||||
|
registrationForm: FormGroup;
|
||||||
|
|
||||||
|
|
||||||
|
constructor(private serverApi: ServerService, private formBuilder: FormBuilder, private notifications: NotificationService) {
|
||||||
|
this.registrationForm = this.formBuilder.group<PlayerRegistrationData>({
|
||||||
|
username: "",
|
||||||
|
password: "",
|
||||||
|
})
|
||||||
|
//this.registrationForm.addValidators(isEmpty);
|
||||||
|
}
|
||||||
|
|
||||||
|
registerPlayer() {
|
||||||
|
if (!this.registrationForm.valid) {
|
||||||
|
this.notifications.publish("This form is invalid!", NotificationType.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.serverApi
|
||||||
|
.playerRegister(this.registrationForm.value)
|
||||||
|
.subscribe((response) => {
|
||||||
|
console.log(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
import {Component} from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
|
import {ServerService} from "@core/server";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dashboard',
|
selector: 'app-dashboard',
|
||||||
|
|
Loading…
Add table
Reference in a new issue