diff --git a/src/app/app.module.ts b/src/app/app.module.ts index a773986b..6acdfe72 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -3,6 +3,7 @@ import { BrowserModule } from '@angular/platform-browser'; import { RouteReuseStrategy } from '@angular/router'; import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; +import { FormsModule } from '@angular/forms'; import { AppComponent } from './app.component'; import { AppRoutingModule } from './app-routing.module'; @@ -51,6 +52,7 @@ import { TeamPage } from './pages/team/team.page'; FontAwesomeModule, IonicModule.forRoot(), AppRoutingModule, + FormsModule, ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production, // Register the ServiceWorker as soon as the app is stable diff --git a/src/app/models/training.ts b/src/app/models/training.ts index 928b6e98..03eaaf65 100644 --- a/src/app/models/training.ts +++ b/src/app/models/training.ts @@ -11,12 +11,12 @@ export interface Training { // actual date of training date: Date; - timeFrom: Date; - timeTo: Date; + timeFrom: string; + timeTo: string; // Fields for calculation - startDate: Date; - endDate: Date; + startDate: string; + endDate: string; repeatAmount: string, repeatFrequency: string, diff --git a/src/app/pages/training/training-create/training-create.page.html b/src/app/pages/training/training-create/training-create.page.html index 73fe64ae..927fafbe 100644 --- a/src/app/pages/training/training-create/training-create.page.html +++ b/src/app/pages/training/training-create/training-create.page.html @@ -13,20 +13,20 @@ - + {{team.name}} - + @@ -34,20 +34,20 @@ - + @@ -58,7 +58,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -77,11 +77,11 @@ Serien Einstellungen - + Täglich Wöchentlich - + 1 2 3 @@ -94,7 +94,8 @@ - + @@ -105,7 +106,9 @@ - + + diff --git a/src/app/pages/training/training-create/training-create.page.ts b/src/app/pages/training/training-create/training-create.page.ts index 316dca90..0ba1b15e 100644 --- a/src/app/pages/training/training-create/training-create.page.ts +++ b/src/app/pages/training/training-create/training-create.page.ts @@ -38,11 +38,11 @@ export class TrainingCreatePage implements OnInit { date: new Date(), - timeFrom: new Date(), - timeTo: new Date(), + timeFrom: new Date().toISOString(), + timeTo: new Date().toISOString(), - startDate: new Date(), - endDate: new Date(), + startDate: new Date().toISOString(), + endDate: new Date().toISOString(), repeatFrequency: "W", repeatAmount: "1", @@ -103,6 +103,14 @@ export class TrainingCreatePage implements OnInit { } async createTraining() { + //Set Hours/Minutes of endDate to TimeFrom of training + const calculatedDate = new Date(this.training.endDate); + calculatedDate.setHours(new Date(this.training.timeFrom).getHours()); + calculatedDate.setMinutes(new Date(this.training.timeFrom).getMinutes()); + calculatedDate.setSeconds(0); + calculatedDate.setMilliseconds(0); + this.training.endDate = calculatedDate.toISOString(); + this.trainingService.setCreateTraining(this.training, this.user); return this.modalCtrl.dismiss({}, "confirm"); } diff --git a/src/app/services/firebase/training.service.ts b/src/app/services/firebase/training.service.ts index 3cb444f0..f7008939 100644 --- a/src/app/services/firebase/training.service.ts +++ b/src/app/services/firebase/training.service.ts @@ -40,6 +40,7 @@ export class TrainingService { async setCreateTraining(training: Training, user: User) { console.log("training"); + console.log(training); return addDoc( collection(this.firestore, `userProfile/${user.uid}/trainings`), training