Skip to content

Commit

Permalink
feat: show info when character creation is not possible
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelRauber committed Jan 26, 2024
1 parent 1484bd7 commit 0c5597c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<pap-h1>Neuen Charakter erstellen</pap-h1>
@if (characterStore.count() > 0) {
<pap-h1>Keine Charaktererstellung möglich</pap-h1>

<form [formGroup]="formGroup" (ngSubmit)="submit()">
<pap-text-input [control]="formGroup.controls['name']" label="Name" autoComplete="nickname" />
<p>
Du hast bereits einen Charakter erstellt, gehe daher bitte zu seinem
<a class="underline" [routerLink]="['/characters', characterStore.entities()[0].id, 'dashboard']">Dashboard</a>.
</p>
} @else {
<pap-h1>Neuen Charakter erstellen</pap-h1>

<pap-submit-button class="mt-4" [disabled]="formGroup.invalid">Charakter erstellen</pap-submit-button>
</form>
<form [formGroup]="formGroup" (ngSubmit)="submit()">
<pap-text-input [control]="formGroup.controls['name']" label="Name" autoComplete="nickname" />

<pap-submit-button class="mt-4" [disabled]="formGroup.invalid">Charakter erstellen</pap-submit-button>
</form>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { H1Component } from '../../headings/h1/h1.component';
import { FormBuilder, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { TextInputComponent } from '../../inputs/text-input/text-input.component';
import { SubmitButtonComponent } from '../../inputs/submit-button/submit-button.component';
import { Router } from '@angular/router';
import { Router, RouterLink } from '@angular/router';
import { CharacterStore } from '../../../stores/character.store';

@Component({
selector: 'pap-create-character',
standalone: true,
imports: [H1Component, TextInputComponent, SubmitButtonComponent, FormsModule, ReactiveFormsModule],
imports: [H1Component, TextInputComponent, SubmitButtonComponent, FormsModule, ReactiveFormsModule, RouterLink],
templateUrl: './create-character.component.html',
styleUrl: './create-character.component.css',
changeDetection: ChangeDetectionStrategy.OnPush,
Expand All @@ -18,8 +18,8 @@ export default class CreateCharacterComponent {
protected readonly formGroup = inject(FormBuilder).group({
name: ['', Validators.required],
});
protected readonly characterStore = inject(CharacterStore);
private readonly router = inject(Router);
private readonly characterStore = inject(CharacterStore);

protected async submit(): Promise<void> {
if (this.formGroup.invalid) {
Expand Down

0 comments on commit 0c5597c

Please sign in to comment.