Merge Anmeldeformular into main #21

Merged
it-as merged 23 commits from Anmeldeformular into main 2024-04-26 14:40:21 +02:00
3 changed files with 67 additions and 35 deletions
Showing only changes of commit 5fb7ecd08e - Show all commits

View File

@ -1,6 +1,8 @@
import {Component, input, OnInit} from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import {ValidatorService} from "angular-iban";
import {StudentRegistration} from "../../../models/student-registration";
import {RegisterService} from "../../../services/register/register.service";
export const MY_DATE_FORMAT= {
parse: {
@ -20,8 +22,6 @@ export const MY_DATE_FORMAT= {
styleUrls: ['./student-register.component.scss'],
})
export class StudentRegisterComponent implements OnInit {
inputText: string = '';
masterFormGroup!: FormGroup;
firstFormGroup!: FormGroup;
secondFormGroup!: FormGroup;
thirdFormGroup!: FormGroup;
@ -62,41 +62,9 @@ export class StudentRegisterComponent implements OnInit {
'Ein späterer rückwirkender Widerruf für aktuell stattfindende bzw. bereits stattgefundene\n' +
'Veranstaltungen ist ausgeschlossen.';
constructor(private _formBuilder: FormBuilder) {}
constructor(private _formBuilder: FormBuilder, private registerService: RegisterService) {}
ngOnInit() {
//TODO Test to group all forms into one master form
// this.masterFormGroup = this._formBuilder.group({
// zeroFormGroup: this._formBuilder.group({
// danceTraining: [''],
// karateTraining: [''],
// freeTraining: [''],
// }, {
// validators: [this.requireAtLeastOne]
// }),
// firstFormGroup: this._formBuilder.group({
// firstName: ['', Validators.required],
// lastName: ['', Validators.required],
// birthdate: ['', Validators.required],
// postalCode: ['', [Validators.required, Validators.pattern(/^\d+$/)]],
// address: ['', Validators.required],
// phone: ['', [Validators.required, Validators.pattern(/^\d+$/)]],
// email: ['', [Validators.required, Validators.email]],
// }),
// secondFormGroup: this._formBuilder.group({
// accountHolder: ['', Validators.required],
// iban: ['', [Validators.required, Validators.pattern(/^\d+$/)]],
// bic: ['', Validators.required],
// nameOfFinancialInstitute: ['', Validators.required],
// amount: ['', [Validators.required, Validators.pattern(/^\d+$/)]],
// einzugsermaechtigung: ['', Validators.required],
// }),
// thirdFormGroup: this._formBuilder.group({
// einwilligung: ['', Validators.required],
// einverstaendniserklaerung: ['', Validators.required],
// }),
// });
// }
this.firstFormGroup = this._formBuilder.group({
firstName: ['', Validators.required],
@ -136,4 +104,31 @@ export class StudentRegisterComponent implements OnInit {
},{emitEvent:false}) //Prevent circular change detection
}
}
submit() {
const studentRegistration: StudentRegistration = {
// First Form Group
firstName: this.firstFormGroup.get('firstName')?.value,
lastName: this.firstFormGroup.get('lastName')?.value,
birthdate: this.firstFormGroup.get('birthdate')?.value,
postalCode: this.firstFormGroup.get('postalCode')?.value,
address: this.firstFormGroup.get('address')?.value,
phone: this.firstFormGroup.get('phone')?.value,
email: this.firstFormGroup.get('email')?.value,
// Second Form Group
accountHolder: this.secondFormGroup.get('accountHolder')?.value,
iban: this.secondFormGroup.get('iban')?.value,
bic: this.secondFormGroup.get('bic')?.value,
nameOfFinancialInstitute: this.secondFormGroup.get('nameOfFinancialInstitute')?.value,
einzugsermaechtigung: this.secondFormGroup.get('einzugsermaechtigung')?.value,
// Third Form Group
einwilligung: this.thirdFormGroup.get('einwilligung')?.value,
einverstaendniserklaerung: this.thirdFormGroup.get('einverstaendniserklaerung')?.value
};
this.registerService.set(studentRegistration);
}
}

View File

@ -0,0 +1,16 @@
export interface StudentRegistration {
firstName: string;
lastName: string;
birthdate: Date;
postalCode: string;
address: string;
phone: string;
email: string;
accountHolder: string;
iban: string;
bic: string;
nameOfFinancialInstitute: string;
einzugsermaechtigung: boolean;
einwilligung: boolean;
einverstaendniserklaerung: boolean;
}

View File

@ -0,0 +1,21 @@
import { Injectable } from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {StudentRegistration} from "../../models/student-registration";
import {Observable} from "rxjs";
import { environment } from 'src/environments/environment';
@Injectable({
providedIn: 'root'
})
export class RegisterService {
private readonly serviceName = 'register';
constructor(private http: HttpClient) { }
public set(registration: StudentRegistration): Observable<boolean> {
const payload = JSON.stringify(registration);
return this.http.post<boolean>(`${environment.apiUrl}${this.serviceName}/set.php`,
payload
);
}
}