text:
<repo_name>Us3rname/localSports<file_sep>/src/app/pages/admin/team/team-list/team-list.page.ts
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import Amplify, { API, graphqlOperation } from 'aws-amplify';
import * as subscriptions from '../../../../../graphql/subscriptions';
import { ToastService } from '../../../../services/toast.service';
import { LeagueDataService } from '../../../../services/league-data.service';
import { GraphqlRequestService } from '../../../../services/graphql-request.service';

@Component({
  selector: 'app-admin-team-list',
  templateUrl: './team-list.page.html',
  styleUrls: ['./team-list.page.scss'],
})
export class TeamListPage implements OnInit {

  public allTeams = new Array();
  public leagues = new Array();
  public teamsPerLeague = new Array();
  public selectedLeagueId;
  public shownTeams;
  isLoading = true;
  loadingItems = Array(5);
  message;

  constructor(
    private router: Router,
    public toastService: ToastService,
    private leagueDataService: LeagueDataService,
    private graphqlRequestService: GraphqlRequestService
  ) {
    this.selectedLeagueId = null;
    this.shownTeams = new Array();
    this.leagues = new Array();
    this.allTeams = new Array();
    this.teamsPerLeague = new Array();
  }

  ngOnInit() {

  }

  goToTeamCreatePage(event) {
    return this.router.navigate(['/admin/team/create']);
  }

  onTeamSelected(team) {
    this.router.navigate(['/admin/team/edit/' + team.id]);
  }
}
<file_sep>/src/app/pages/admin/sports-hall/sports-hall-create/sports-hall-create.page.ts
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { CreateSportsHallInput, CreateHallInput } from 'src/API';
import { environment } from '../../../../../environments/environment';
import { GraphqlRequestService } from '../../../../services/graphql-request.service';
import { SporthallService } from '../../../../services/sporthall.service';

@Component({
  selector: 'app-sports-hall-create',
  templateUrl: './sports-hall-create.page.html',
  styleUrls: ['./sports-hall-create.page.scss'],
})
export class SportsHallCreatePage implements OnInit {

  public sportsHall: { name: string, street: string, zipCode: string, city: string, phone: string, streetNumber: number };
  private initialSportsHallState = {
    name: '<NAME>eland', street: 'Zwembadweg',
    zipCode: '1234 AV', city: 'Goes', phone: '0113-123456', streetNumber: 89
  };

  public halls = new Array();

  constructor(
    private router: Router,
    private graphqlRequestService: GraphqlRequestService,
    public sporthallService: SporthallService
  ) {
    this.sportsHall = this.initialSportsHallState;
  }

  ngOnInit() {
    this.addEmptyHall();
  }

  async processForm() {

    try {
      const createSportsHallInput: CreateSportsHallInput = {
        name: this.sportsHall.name, sportsHallClubId: environment.clubId, street: this.sportsHall.street,
        zipCode: this.sportsHall.zipCode, city: this.sportsHall.city, phone: this.sportsHall.phone,
        streetNumber: this.sportsHall.streetNumber
      };

      await this.graphqlRequestService.doPrivateMutation('createSportsHall', { input: createSportsHallInput });

      if (this.graphqlRequestService.isSuccessfull) {
        this.saveHalls(this.graphqlRequestService.data);
        return this.router.navigate(['/admin/sports-hall']);
      } else {

      }
    } catch (err) {
      console.log(err);
    }
  }

  saveHalls(sportsHall) {

    for (const hall of this.sporthallService.halls) {
      const createHallInput: CreateHallInput = { name: hall.name, hallSportsHallId: sportsHall.id };
      this.graphqlRequestService.doPrivateMutation('createHall', { input: createHallInput });
    }
  }

  addEmptyHall() {
    this.sporthallService.addEmptyHall();
  }

  removeHall(index, halId) {
    this.sporthallService.removeHall(index, halId);
  }
}
<file_sep>/src/app/pages/admin/sports-hall/sports-hall-edit/sports-hall-edit.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';

import { IonicModule } from '@ionic/angular';

import { SportsHallEditPage } from './sports-hall-edit.page';

const routes: Routes = [
  {
    path: '',
    component: SportsHallEditPage
  }
];

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    RouterModule.forChild(routes)
  ],
  declarations: [SportsHallEditPage]
})
export class SportsHallEditPageModule {}
<file_sep>/src/app/pages/ranking/ranking.page.html
<menu-header headerTitle="Klassement"></menu-header>

<ion-content>

  <ion-grid>
    <ion-row class="ranking-header">
      <ion-col size=1>

      </ion-col>
      <ion-col>
        Team
      </ion-col>
      <ion-col size=1>
        W
      </ion-col>
      <ion-col size=1>
        D
      </ion-col>
      <ion-col size=1>
        L
      </ion-col>
      <ion-col size=1>
        PTS
      </ion-col>
    </ion-row>
    <ion-row *ngFor="let standing of standings;let index=index;">
      <ion-col size=1 class="ion-padding-vertical">
        {{ index + 1 }}
      </ion-col>
      <ion-col class="ion-padding-vertical">
        {{ standing.teamName }}
      </ion-col>
      <ion-col size=1 class="ion-padding-vertical">
        {{ standing.wins }}
      </ion-col>
      <ion-col size=1 class="ion-padding-vertical">
        {{ standing.draws}}
      </ion-col>
      <ion-col size=1 class="ion-padding-vertical">
        {{ standing.loses}}
      </ion-col>
      <ion-col size=1 class="ion-padding-vertical ion-text-center">
        {{ standing.points}}
      </ion-col>
    </ion-row>
  </ion-grid>
</ion-content><file_sep>/src/app/pages/logout/logout.page.ts
import { Component, OnInit } from '@angular/core';
import { Auth } from 'aws-amplify';
import { Router } from '@angular/router';

@Component({
  selector: 'app-logout',
  templateUrl: './logout.page.html',
  styleUrls: ['./logout.page.scss'],
})
export class LogoutPage implements OnInit {

  constructor(private router: Router) { }

  ngOnInit() {
    Auth.signOut()
      .then(data => console.log(data))
      .catch(err => console.log(err));
    this.router.navigate(['/app/tabs/schedule']);
  }

}
<file_sep>/src/app/pages/admin/league/league-create/league-create.page.ts
import { Component, OnInit } from '@angular/core';
import Amplify, { API, graphqlOperation } from 'aws-amplify';
import { Router } from '@angular/router';
import * as mutations from '../../../../../graphql/mutations';
import { CreateLeagueInput } from 'src/API';
import { environment } from '../../../../../environments/environment';
import { GraphqlRequestService } from '../../../../services/graphql-request.service';

@Component({
  selector: 'app-league-create',
  templateUrl: './league-create.page.html',
  styleUrls: ['./league-create.page.scss'],
})
export class LeagueCreatePage implements OnInit {

  public league: { name: string, ranking: number };
  private initialLeagueState = { name: null, ranking: null };

  constructor(private router: Router, private graphqlRequestService: GraphqlRequestService) {
    this.league = this.initialLeagueState;
  }

  ngOnInit() {
  }

  async processForm() {

    try {
      const createLeagueInput: CreateLeagueInput = {
        name: this.league.name, leagueClubId: environment.clubId, ranking: this.league.ranking
      };

      await this.graphqlRequestService.doPrivateMutation('createLeague', { input: createLeagueInput });

      if (this.graphqlRequestService.isSuccessfull) {
        return this.router.navigate(['/admin/league']);
      } else {

      }
    } catch (err) {
      console.log(err);
    }
  }
}
<file_sep>/src/app/pages/club/club-create/club-create.page.ts
import { Component, OnInit } from '@angular/core';
import * as mutations from '../../../../graphql/mutations';
import { CreateLeagueInput, CreateClubInput } from 'src/API';
import Amplify, { API, graphqlOperation } from 'aws-amplify';
import { Router } from '@angular/router';
import { GRAPHQL_AUTH_MODE } from '../../../../../node_modules/@aws-amplify/api/lib/types/index';

@Component({
  selector: 'app-club-create',
  templateUrl: './club-create.page.html',
  styleUrls: ['./club-create.page.scss'],
})
export class ClubCreatePage implements OnInit {

  public club: { name: string, contact: string, country: string };
  private initialLeagueState = { name: null, contact: null, country: null };

  constructor(private router: Router) {
    this.club = this.initialLeagueState;
  }

  ngOnInit() {
  }

  async processForm() {

    try {
      const createClubInput: CreateClubInput = {
        name: this.club.name, contact: this.club.contact, country: this.club.country
      };

      const response = await API.graphql({
        query: mutations.createClub,
        variables: { input: createClubInput },
        authMode: GRAPHQL_AUTH_MODE.AMAZON_COGNITO_USER_POOLS
      });
      return this.router.navigate(['/club']);
    } catch (err) {
      console.log(err);
    }
  }

}
<file_sep>/src/app/services/graphql-request.service.ts
import { Injectable } from '@angular/core';
import Amplify, { API } from 'aws-amplify';
import { GRAPHQL_AUTH_MODE } from '../../../node_modules/@aws-amplify/api/lib/types/index';
import * as queries from '../../graphql/queries';
import * as mutations from '../../graphql/mutations';

@Injectable({
  providedIn: 'root'
})
export class GraphqlRequestService {

  data;
  isSuccessfull = false;
  hasNextToken = false;
  nextToken: string = null;
  private response;
  constructor() { }

  public async doPublicQuery(queryName, variables) {

    variables.limit = 1000;
    const response = await API.graphql({
      query: queries[queryName],
      variables,
      authMode: GRAPHQL_AUTH_MODE.API_KEY
    });

    this.handleResponse(response, queryName);
  }

  public async doPrivateQuery(queryName, variables) {

    variables.limit = 1000;
    const response = await API.graphql({
      query: queries[queryName],
      variables,
      authMode: GRAPHQL_AUTH_MODE.AMAZON_COGNITO_USER_POOLS
    });

    this.handleResponse(response, queryName);
  }

  public async doPrivateMutation(mutationName, variables) {

    this.response = await API.graphql({
      query: mutations[mutationName],
      variables,
      authMode: GRAPHQL_AUTH_MODE.AMAZON_COGNITO_USER_POOLS
    });

    this.handleResponse(this.response, mutationName);
  }

  private handleResponse(response, queryName) {
    // When there's a response with data
    if (response && response.data[queryName] != null) {
      this.isSuccessfull = true;
      this.data = response.data[queryName];

      // When there's a nextToken, to retrieve the rest of the data, store it locally.
      // So that we know for the next time that we can use it.
      if (response.data[queryName].nextToken !== '') {
        this.hasNextToken = true;
        this.nextToken = response.data[queryName].nextToken;
      } else {
        this.hasNextToken = true;
        this.nextToken = null;
      }
    } else {
      this.isSuccessfull = false;
    }
  }

  private parseErrorsFromResponse() {

  }
}
<file_sep>/src/app/services/team-service.ts
import { Injectable } from '@angular/core';
import { GraphqlRequestService } from './graphql-request.service';

@Injectable({
  providedIn: 'root'
})
export class TeamService {

  public allTeams = new Array();

  constructor(private graphqlRequestService: GraphqlRequestService) { }

  async getAllTeams() {
    await this.graphqlRequestService.doPublicQuery('listTeams', {});

    if (this.graphqlRequestService.isSuccessfull) {
      return this.graphqlRequestService.data.items;
    }
  }

  async getAllTeamsSortedPerLeague() {
    const teams = await this.getAllTeams();
    teams.sort(this.sortByTeamName);
    this.orderTeamsPerLeague(teams);
    return this.allTeams;
  }

  private orderTeamsPerLeague(teams) {
    teams.forEach(team => {
      this.addTeamsToLeagueArray(team.leagueId, { items: team, nextTeamToken: null });
    });
  }

  addTeamsToLeagueArray(leagueId, data) {
    // Sort the teams by name
    data.items.sort(this.sortByTeamName);

    if (this.allTeams[leagueId] == null) {
      this.allTeams[leagueId] = {
        items: data.items,
        nextTeamToken: data.nextToken
      };
    } else {
      this.allTeams[leagueId] = {
        items: this.allTeams[leagueId].items.concat(data.items),
        nextTeamToken: data.nextToken
      };
    }

    return this.allTeams;
  }

  private sortByTeamName(a, b) {
    if (a.name < b.name) { return -1; }
    if (a.name > b.name) { return 1; }
    return 0;
  }
}
<file_sep>/src/app/pages/admin/referee/referee-edit/referee-edit.page.ts
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';

@Component({
  selector: 'app-referee-edit',
  templateUrl: './referee-edit.page.html',
  styleUrls: ['./referee-edit.page.scss'],
})
export class RefereeEditPage implements OnInit {

  referee = {
    firstName: 'voornaam', lastName: 'achternaam', street: 'straat', streetNumber: 6, streetNumberAddition: 'a',
    zipCode: '1234ab', city: 'stad', email: 'emailadres', phone: 'telefoon'
  };
  refereeId: string;
  constructor(
    private router: Router,
    private route: ActivatedRoute
  ) {
    this.refereeId = this.route.snapshot.paramMap.get('refereeId');
  }

  ngOnInit() {
  }

  onRefereeMutation(event) {
    return this.router.navigate(['/admin/referee']);
  }
}
<file_sep>/src/app/pages/match-schedule/about-popover/game-action-menu.page..ts
import { Component, Input } from '@angular/core';

import { PopoverController, ModalController } from '@ionic/angular';
import { SubmitScorePage } from './submit-score.page';
@Component({
  template: `
    <ion-list>
      <ion-item button (click)="presentModal()">
        <ion-label>Submit score</ion-label>
      </ion-item>
    </ion-list>
  `
})
export class GameActionMenuPage {

  @Input() game;

  constructor(public popoverCtrl: PopoverController, private modalController: ModalController) { }

  support() {
    // this.app.getRootNavs()[0].push('/support');
    this.popoverCtrl.dismiss();
  }

  async presentModal(event) {
    console.log(this.game);
    const modal = await this.modalController.create({
      component: SubmitScorePage,
      componentProps: {
        game: this.game
      }
    });
    this.popoverCtrl.dismiss();
    return await modal.present();
  }
}
<file_sep>/src/app/services/auth.service.ts
import { Injectable } from '@angular/core';
import Auth from '@aws-amplify/auth';
import { Hub } from '@aws-amplify/core';
import { BehaviorSubject } from 'rxjs';
import { map } from 'rxjs/operators';

export interface AuthState {
  isLoggedIn: boolean;
  username: string | null;
  id: string | null;
  email: string | null;
  name: string | null;
}

const initialAuthState = {
  isLoggedIn: false,
  username: null,
  id: null,
  email: null,
  name: null
};

@Injectable({
  providedIn: 'root'
})
export class AuthService {
  private readonly authState = new BehaviorSubject<AuthState>(
    initialAuthState
  );

  /** AuthState as an Observable */
  readonly auth$ = this.authState.asObservable();

  /** Observe the isLoggedIn slice of the auth state */
  readonly isLoggedIn$ = this.auth$.pipe(map(state => state.isLoggedIn));

  constructor() {
    // Get the user on creation of this service
    Auth.currentAuthenticatedUser().then(
      (user: any) => this.setUser(user),
      err => this.authState.next(initialAuthState)
    );

    // Use Hub channel 'auth' to get notified on changes
    Hub.listen('auth', ({ payload: { event, data, message } }) => {
      if (event === 'signIn') {
        // On 'signIn' event, the data is a CognitoUser object
        this.setUser(data);
      } else {
        this.authState.next(initialAuthState);
      }
    });
  }

  private setUser(user: any) {
    if (!user) {
      return;
    }

    const {
      attributes: { sub: id, email, name },
      username
    } = user;

    this.authState.next({ isLoggedIn: true, id, username, email, name });
  }
}
<file_sep>/src/app/pages/ranking/ranking.page.ts
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

interface Standing {
  teamName: string;
  points: number;
  wins: number;
  draws: number;
  loses: number;
}

@Component({
  selector: 'app-ranking',
  templateUrl: './ranking.page.html',
  styleUrls: ['./ranking.page.scss'],
})
export class RankingPage implements OnInit {

  public standings: Array<Standing> = new Array();

  constructor(
    public router: Router,
  ) { }

  ngOnInit() {
    this.loadRankings();
  }

  getRandomInt(max) {
    return Math.floor(Math.random() * Math.floor(max));
  }

  loadRankings() {

    const teams = ['<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', 'Rentmeester IT',
      '<NAME>', 'De Goffau Admin & Cons.', 'DRV Acc & Adviseurs', '<NAME>', '<NAME>',
      '<NAME>'];

    for (let i = 0; i < 10; i++) {

      this.standings.push(
        {
          teamName: teams[i],
          wins: this.getRandomInt(5),
          draws: this.getRandomInt(5),
          loses: this.getRandomInt(5),
          points: this.getRandomInt(20)

        }
      );
      console.log(this.standings);
    }
  }

}
<file_sep>/src/environments/environment.prod.ts
export const environment = {
  production: true,
  clubId: '92838a75-fa03-40bb-993d-192859797852'
};
<file_sep>/src/app/services/match-schedule/game.service.ts
import { Injectable } from '@angular/core';
import { CreateGameInput } from 'src/API';
import { GraphqlRequestService } from '../graphql-request.service';
import * as mutations from '../../../graphql/mutations';

@Injectable({
  providedIn: 'root'
})
export class GameService {

  constructor(private graphqlRequestService: GraphqlRequestService) { }

  async createGame(createGameInput: CreateGameInput) {

    await this.graphqlRequestService.doPrivateMutation('createGame', { input: createGameInput });
    return this.graphqlRequestService.data;
  }
}
<file_sep>/src/app/tabs/tabs-routing.module.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { TabsPage } from './tabs.page';

const routes: Routes = [
  {
    path: 'tabs',
    component: TabsPage,
    children: [
      {
        path: 'schedule',
        children: [
          {
            path: '',
            loadChildren: () => import('../pages/match-schedule/match-schedule-list/match-schedule-list.module')
              .then(m => m.MatchScheduleListPageModule)
          }
        ]
      },
      {
        path: 'ranking',
        children: [
          {
            path: '',
            loadChildren: () => import('../pages/ranking/ranking.module').then(m => m.RankingModule)
          }
        ]
      },
      {
        path: 'team',
        children: [
          {
            path: '',
            loadChildren: () => import('../pages/team/team-list/team-list.module').then(m => m.TeamListPageModule)
          }
        ]
      },
      {
        path: '',
        redirectTo: 'app/tabs/schedule',
        pathMatch: 'full'
      }
    ]
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class TabsRoutingModule { }

<file_sep>/src/app/pages/admin/sports-hall/sports-hall-edit/sports-hall-edit.page.ts
import { Component, OnInit } from '@angular/core';
import { ToastService } from '../../../../services/toast.service';
import { GraphqlRequestService } from '../../../../services/graphql-request.service';
import { SporthallService } from '../../../../services/sporthall.service';
import { ActivatedRoute, Router } from '@angular/router';
import { UpdateSportsHallInput, UpdateHallInput, CreateHallInput } from 'src/API';
import { AlertController } from '@ionic/angular';

@Component({
  selector: 'app-sports-hall-edit',
  templateUrl: './sports-hall-edit.page.html',
  styleUrls: ['./sports-hall-edit.page.scss'],
})
export class SportsHallEditPage implements OnInit {

  public sportsHall: {
    name: string, street: string, zipCode: string, city: string, phone: string, streetNumber: number,
    halls: { items: [{ id: string }] }
  };
  private initialSportsHallState = {
    name: null, street: null, zipCode: null, city: null, phone: null, streetNumber: null, halls: null
  };

  private sportsHallId;

  constructor(
    private graphqlRequestService: GraphqlRequestService,
    public toastService: ToastService,
    private router: Router,
    private route: ActivatedRoute,
    public alertController: AlertController,
    public sporthallService: SporthallService
  ) {
    this.sportsHall = this.initialSportsHallState;
    this.sportsHallId = this.route.snapshot.paramMap.get('sportsHallId');
  }

  ngOnInit() {
    this.loadSportsHall();
  }

  private async loadSportsHall() {

    await this.graphqlRequestService.doPrivateQuery('getSportsHall', { id: this.sportsHallId });

    if (this.graphqlRequestService.isSuccessfull) {
      this.sportsHall = this.graphqlRequestService.data;
      this.sporthallService.halls = this.sportsHall.halls.items;

      this.sportsHall.halls.items.map((hall) => {
        this.sporthallService.existingHalls[hall.id] = hall;
      });
    } else {
      this.toastService.presentWarningToast('Sporthal kon niet gevonden worden.');
      return this.router.navigate(['/admin/sports-hall']);
    }
  }

  async processForm() {
    const updateSportsHallInput: UpdateSportsHallInput = {
      id: this.sportsHallId, name: this.sportsHall.name, street: this.sportsHall.street,
      zipCode: this.sportsHall.zipCode, city: this.sportsHall.city, phone: this.sportsHall.phone,
      streetNumber: this.sportsHall.streetNumber
    };

    await this.graphqlRequestService.doPrivateMutation('updateSportsHall', { input: updateSportsHallInput });

    if (this.graphqlRequestService.isSuccessfull) {
      this.sporthallService.updateHalls(this.sportsHallId);
      this.toastService.presentSuccessToast('Sporthal is bijgewerkt.');
      return this.router.navigate(['/admin/sports-hall']);
    } else {

    }
  }

  async presentDeleteAlertConfirm(sportsHall) {
    const alert = await this.alertController.create({
      header: 'Waarschuwing!',
      message: 'Weet u zeker dat u de sporthal wilt verwijderen?',
      buttons: [
        {
          text: 'Cancel',
          role: 'cancel',
          cssClass: 'secondary',
        }, {
          text: 'Okay',
          cssClass: 'danger',
          handler: () => {
            this.deleteSportsHall(sportsHall);
          }
        }
      ]
    });

    await alert.present();
  }

  async deleteSportsHall(sportsHall) {
    const sportsHallInput: UpdateSportsHallInput = { id: sportsHall.id };
    await this.graphqlRequestService.doPrivateMutation('updateSportsHall', { input: sportsHallInput });

    if (this.graphqlRequestService.isSuccessfull) {
      return this.router.navigate(['/admin/sports-hall']);
    }
  }

  addEmptyHall() {
    this.sporthallService.addEmptyHall();
  }

  removeHall(index, hallId) {
    this.sporthallService.removeHall(index, hallId);
  }
}
<file_sep>/src/app/components/components.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MenuHeaderComponent } from './menu-header/menu-header.component';
import { BackHeaderComponent } from './back-header/back-header.component';
import { LeagueHeaderComponent } from './teams/league-header/league-header.component';
import { TeamListComponent } from './teams/team-list/team-list.component';

import { RefereeFormComponent } from './referee-form/referee-form.component';
import { IonicModule } from '@ionic/angular';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { InputErrorComponent } from './forms/input-error/input-error.component';
import { CreateGameFormComponent } from './match-schedule/create-game-form/create-game-form.component';
import { DeleteButtonComponent } from './forms/delete-button/delete-button.component';
import { SubmitButtonComponent } from './forms/submit-button/submit-button.component';
import { TextAvatarModule } from './text-avatar';

@NgModule({
  declarations: [
    MenuHeaderComponent, RefereeFormComponent, BackHeaderComponent, LeagueHeaderComponent,
    TeamListComponent, InputErrorComponent, CreateGameFormComponent, DeleteButtonComponent, SubmitButtonComponent
  ],
  imports: [
    IonicModule,
    CommonModule,
    FormsModule,
    TextAvatarModule,
    ReactiveFormsModule
  ],
  exports: [
    MenuHeaderComponent, RefereeFormComponent, BackHeaderComponent, LeagueHeaderComponent,
    TeamListComponent, InputErrorComponent, CreateGameFormComponent, DeleteButtonComponent, SubmitButtonComponent
  ]
})
export class ComponentsModule { }
<file_sep>/src/app/components/teams/team-list/team-list.component.ts
import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
import { GraphqlRequestService } from '../../../services/graphql-request.service';
import Amplify, { API, graphqlOperation } from 'aws-amplify';
import * as subscriptions from '../../../../graphql/subscriptions';
import { ToastService } from '../../../services/toast.service';

@Component({
  selector: 'app-team-list',
  templateUrl: './team-list.component.html',
  styleUrls: ['./team-list.component.scss'],
})
export class TeamListComponent implements OnInit {

  public allTeams = new Array();
  public teamsPerLeague = new Array();
  public shownTeams;
  isLoading;
  loadingItems = new Array(5); // Skeleton loader shows 5 items
  @Input() leagueId: string;

  @Output() teamSelected = new EventEmitter<object>();

  constructor(
    private graphqlRequestService: GraphqlRequestService,
    public toastService: ToastService
  ) { }

  ngOnInit() {
    this.subscribeOnCreateTeam();
    this.subscribeOnUpdateTeam();
    this.subscribeOnDeleteTeam();
  }

  async loadTeams() {

    this.isLoading = true;
    // To prevent that we do a new call each time when we switch league keep track of the teams per league.
    if (this.allTeams[this.leagueId] == null) {

      await this.graphqlRequestService.doPublicQuery('listTeams',
        { filter: { leagueId: { eq: this.leagueId } } });

      if (this.graphqlRequestService.isSuccessfull) {
        this.updateAllTeamsData(this.leagueId, this.graphqlRequestService.data);
      } else {
        console.log('Error');
      }
    }
    this.shownTeams = this.allTeams[this.leagueId].items;
    this.isLoading = false;
  }

  private updateAllTeamsData(leagueId, data) {

    // Sort the teams by name
    data.items.sort(this.sortByTeamName);

    this.allTeams[leagueId] = {
      items: data.items,
      nextTeamToken: data.nextToken
    };
  }

  private sortByTeamName(a, b) {
    if (a.name < b.name) { return -1; }
    if (a.name > b.name) { return 1; }
    return 0;
  }

  onLeagueSelected(leagueId) {
    this.leagueId = leagueId;
    this.loadTeams();
  }

  onTeamSelected(team) {
    this.teamSelected.emit(team);
  }

  private subscribeOnCreateTeam() {

    // Subscribe for new teams when they create it through the app.
    API.graphql(
      graphqlOperation(subscriptions.onCreateTeam)
    ).subscribe({
      next: (teamData) => {
        this.updateTeamsAfterCreate(teamData.value.data.onCreateTeam);
      }
    });
  }

  updateTeamsAfterCreate(team) {
    this.allTeams[team.leagueId].items.push(team);
    this.shownTeams = this.allTeams[this.leagueId].items;
    this.toastService.presentToast('Team is aangemaakt.');
  }

  private subscribeOnUpdateTeam() {
    API.graphql(
      graphqlOperation(subscriptions.onUpdateTeam)
    ).subscribe({
      next: (teamData) => {
        this.updateLocalTeams(teamData);
      }
    });
  }

  private subscribeOnDeleteTeam() {
    API.graphql(
      graphqlOperation(subscriptions.onDeleteTeam)
    ).subscribe({
      next: (teamData) => {
        this.deleteTeam(teamData);
      }
    });
  }

  updateLocalTeams(teamData) {
    const team = teamData.value.data.onUpdateTeam;
    for (let i = 0; i < this.allTeams[this.leagueId].items.length; i++) {
      if (this.allTeams[this.leagueId].items[i].id === team.id) {

        // When the team changes league, we need to remove it from the current league & add it to the new league
        if (this.leagueId !== team.league.id) {
          this.allTeams[this.leagueId].items.splice(i, 1);
        }
        this.allTeams[team.league.id].items[i] = team;
        this.toastService.presentToast('Team is bijgewerkt');
        return;
      }
    }
  }

  deleteTeam(teamData) {
    const team = teamData.value.data.onDeleteTeam;
    for (let i = 0; i < this.allTeams[this.leagueId].items.length; i++) {
      if (this.allTeams[this.leagueId].items[i].id === team.id) {
        this.allTeams[this.leagueId].items.splice(i, 1);
        this.toastService.presentToast('Team is verwijderd');
        return;
      }
    }
  }
}
<file_sep>/src/app/tabs/tabs.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';

import { TabsPage } from './tabs.page';
import { TabsRoutingModule } from './tabs-routing.module';

import { GameScheduleModule } from '../pages/game-schedule/game-schedule.module';
import { RankingModule } from '../pages/ranking/ranking.module';

@NgModule({
  imports: [
    CommonModule,
    IonicModule,
    GameScheduleModule,
    RankingModule,
    TabsRoutingModule
  ],
  declarations: [
    TabsPage,
  ]
})
export class TabsModule { }
<file_sep>/src/graphql/queries.ts
// tslint:disable
// this is an auto generated file. This will be overwritten

export const getSeason = `query GetSeason($id: ID!) {
  getSeason(id: $id) {
    id
    title
    beginDate
    endDate
    leagues {
      items {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const listSeasons = `query ListSeasons(
  $filter: ModelSeasonFilterInput
  $limit: Int
  $nextToken: String
) {
  listSeasons(filter: $filter, limit: $limit, nextToken: $nextToken) {
    items {
      id
      title
      beginDate
      endDate
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    nextToken
  }
}
`;
export const getGame = `query GetGame($id: ID!) {
  getGame(id: $id) {
    id
    gameDay
    scoreHome
    scoreAway
    hall {
      id
      name
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      sportsHall {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    homeTeam {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    awayTeam {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    referee {
      id
      firstName
      lastName
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      email
      phone
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const listGames = `query ListGames(
  $filter: ModelGameFilterInput
  $limit: Int
  $nextToken: String
) {
  listGames(filter: $filter, limit: $limit, nextToken: $nextToken) {
    items {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    nextToken
  }
}
`;
export const getStanding = `query GetStanding($id: ID!) {
  getStanding(id: $id) {
    id
    team
    matchPlayed
    win
    draw
    loses
    goalsFor
    goalsAgainst
    goalDifference
    points
    lastResults
  }
}
`;
export const listStandings = `query ListStandings(
  $filter: ModelStandingFilterInput
  $limit: Int
  $nextToken: String
) {
  listStandings(filter: $filter, limit: $limit, nextToken: $nextToken) {
    items {
      id
      team
      matchPlayed
      win
      draw
      loses
      goalsFor
      goalsAgainst
      goalDifference
      points
      lastResults
    }
    nextToken
  }
}
`;
export const getSportsHall = `query GetSportsHall($id: ID!) {
  getSportsHall(id: $id) {
    id
    name
    street
    streetNumber
    streetNumberAddition
    zipCode
    city
    phone
    halls {
      items {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const listSportsHalls = `query ListSportsHalls(
  $filter: ModelSportsHallFilterInput
  $limit: Int
  $nextToken: String
) {
  listSportsHalls(filter: $filter, limit: $limit, nextToken: $nextToken) {
    items {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      phone
      halls {
        items {
          id
          name
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    nextToken
  }
}
`;
export const getHall = `query GetHall($id: ID!) {
  getHall(id: $id) {
    id
    name
    games {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    sportsHall {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      phone
      halls {
        items {
          id
          name
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const listHalls = `query ListHalls(
  $filter: ModelHallFilterInput
  $limit: Int
  $nextToken: String
) {
  listHalls(filter: $filter, limit: $limit, nextToken: $nextToken) {
    items {
      id
      name
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      sportsHall {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    nextToken
  }
}
`;
export const getLeague = `query GetLeague($id: ID!) {
  getLeague(id: $id) {
    id
    name
    ranking
    owner
    teams {
      items {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const listLeagues = `query ListLeagues(
  $filter: ModelLeagueFilterInput
  $limit: Int
  $nextToken: String
) {
  listLeagues(filter: $filter, limit: $limit, nextToken: $nextToken) {
    items {
      id
      name
      ranking
      owner
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    nextToken
  }
}
`;
export const getTeam = `query GetTeam($id: ID!) {
  getTeam(id: $id) {
    id
    leagueId
    name
    contact
    owner
    league {
      id
      name
      ranking
      owner
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    athletes {
      items {
        id
        name
        email
        phone
        teams {
          id
          leagueId
          name
          contact
          owner
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const listTeams = `query ListTeams(
  $filter: ModelTeamFilterInput
  $limit: Int
  $nextToken: String
) {
  listTeams(filter: $filter, limit: $limit, nextToken: $nextToken) {
    items {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    nextToken
  }
}
`;
export const getAthlete = `query GetAthlete($id: ID!) {
  getAthlete(id: $id) {
    id
    name
    email
    phone
    teams {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const listAthletes = `query ListAthletes(
  $filter: ModelAthleteFilterInput
  $limit: Int
  $nextToken: String
) {
  listAthletes(filter: $filter, limit: $limit, nextToken: $nextToken) {
    items {
      id
      name
      email
      phone
      teams {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    nextToken
  }
}
`;
export const getReferee = `query GetReferee($id: ID!) {
  getReferee(id: $id) {
    id
    firstName
    lastName
    street
    streetNumber
    streetNumberAddition
    zipCode
    city
    email
    phone
    games {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const listReferees = `query ListReferees(
  $filter: ModelRefereeFilterInput
  $limit: Int
  $nextToken: String
) {
  listReferees(filter: $filter, limit: $limit, nextToken: $nextToken) {
    items {
      id
      firstName
      lastName
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      email
      phone
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    nextToken
  }
}
`;
export const listClubs = `query ListClubs(
  $filter: ModelClubFilterInput
  $limit: Int
  $nextToken: String
) {
  listClubs(filter: $filter, limit: $limit, nextToken: $nextToken) {
    items {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
    nextToken
  }
}
`;
export const getClub = `query GetClub($id: ID!) {
  getClub(id: $id) {
    id
    name
    street
    streetNumber
    streetNumberAddition
    zipCode
    country
    contact
    email
    phone
    sportsHalls {
      items {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    leagues {
      items {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    teams {
      items {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    referees {
      items {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
  }
}
`;
<file_sep>/src/app/components/match-schedule/create-game-form/create-game-form.component.ts
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { environment } from '../../../../environments/environment';
import { TeamService } from 'src/app/services/team-service';
import { LeagueDataService } from 'src/app/services/league-data.service';
import { RefereeService } from 'src/app/services/referee.service';
import { SporthallService } from 'src/app/services/sporthall.service';
import { CreateGameInput } from 'src/API';
import { GameService } from 'src/app/services/match-schedule/game.service';

@Component({
  selector: 'app-create-game-form',
  templateUrl: './create-game-form.component.html',
  styleUrls: ['./create-game-form.component.scss'],
})
export class CreateGameFormComponent implements OnInit {

  @Output() gameCreated = new EventEmitter<object>();
  matchScheduleForm: FormGroup;
  submitted = false;

  validationMessages = {
    gameDay: [
      { type: 'required', message: 'Aanvangstijd is verplicht.' }
    ],
    gameHomeTeamId: [
      { type: 'required', message: 'Thuis team is verplicht.' }
    ],
    gameAwayTeamId: [
      { type: 'required', message: 'Uitspelende team is verplicht.' }
    ],
    sportshall: [
      { type: 'required', message: 'Sporthal is verplicht.' }
    ],
    gameHallId: [
      { type: 'required', message: 'Hal is verplicht.' }
    ],
    gameRefereeId: [
      { type: 'required', message: 'Scheidsrechter is verplicht.' }
    ],
    league: [
      { type: 'required', message: 'Divisie is verplicht.' }
    ],
  };

  homeTeams = new Array();
  awayTeams = new Array();
  referees = new Array();
  sportshalls = new Array();
  halls;

  selectedLeague;
  leagues;
  @Input() action;

  constructor(
    private formBuilder: FormBuilder, private leagueService: LeagueDataService, private refereeService: RefereeService,
    private sportsHallService: SporthallService, private gameService: GameService
  ) { }

  ngOnInit() {
    this.matchScheduleForm = this.formBuilder.group({
      gameDay: new FormControl({ value: '2019-10-14T13:48:00+02:00' }, Validators.required),
      gameHomeTeamId: new FormControl({
        value: '3efec6c4-4437-49e7-bd62-904f4ca89c69',
        disabled: this.selectedLeague === null
      }, Validators.required),
      gameAwayTeamId: new FormControl({
        value: 'c6e016b4-3134-4551-b237-6f2c3223d1df',
        disabled: this.selectedLeague === null
      }, Validators.required),
      sportshall: new FormControl({ value: '3999a502-d199-4903-b028-0befa6db7169' }, Validators.required),
      gameHallId: new FormControl({ value: '29fa4261-5ac5-4730-bbd4-4b102153ef15', disabled: this.halls === null }, Validators.required),
      gameRefereeId: ['5d2f76f7-e326-4c7b-88e8-3585fc5df2e3', Validators.required],
    });

    this.loadTeams();
    this.loadReferees();
    this.loadSportsHalls();
  }

  async loadSportsHalls() {
    this.sportshalls = await this.sportsHallService.getSportsHalls();
  }

  async loadTeams() {
    this.leagues = await this.leagueService.getLeagues();
  }

  async loadReferees() {
    this.referees = await this.refereeService.getReferees();
  }

  async processForm(formValues) {
    // This will trigger the error messages (if there are any)
    this.submitted = true;

    // stop here if form is invalid
    if (this.matchScheduleForm.invalid) {
      return;
    }

    const createGameInput: CreateGameInput = {
      gameDay: formValues.gameDay, gameRefereeId: formValues.gameRefereeId,
      clubId: environment.clubId, gameClubId: environment.clubId, gameHallId: formValues.gameHallId,
      gameAwayTeamId: formValues.gameAwayTeamId, gameHomeTeamId: formValues.gameHomeTeamId
    };
    const game = await this.gameService.createGame(createGameInput);
    this.gameCreated.emit(game);
  }

  leagueChanged(event) {

    this.leagues.forEach((league) => {
      if (event.detail.value === league.id) {
        this.selectedLeague = league;
        return;
      }
    });

    this.matchScheduleForm.get('gameHomeTeamId').enable();
    this.matchScheduleForm.get('gameAwayTeamId').enable();

    const teams = this.selectedLeague.teams.items;
    this.homeTeams = teams;
    this.awayTeams = teams;
  }

  onUpdateHomeTeam(event) {
    const homeTeamId = event.detail.value;

    // Remove team from the away team list because they can't play against each other.
    // for (let i = 0; i < this.awayTeams.length; i++) {
    //   const team = this.awayTeams[i];

    //   if (team.id === homeTeamId) {
    //     this.awayTeams.splice(i, 1);
    //     return;
    //   }
    // }
  }

  onSportsHallSelected(event) {
    let selectedSportshall;
    // Find the selected sportshall to get the halls
    this.sportshalls.forEach((sporthall) => {
      if (event.detail.value === sporthall.id) {
        selectedSportshall = sporthall;
        return;
      }
    });

    this.halls = selectedSportshall.halls.items;
  }
}
<file_sep>/src/app/reducers/index.ts
import {
  ActionReducer,
  ActionReducerMap,
  createFeatureSelector,
  createSelector,
  MetaReducer
} from '@ngrx/store';
import { environment } from '../../environments/environment';

import * as fromAuth from './auth.reducer';

export interface State {
  auth: fromAuth.AuthState;
}

export const reducers: ActionReducerMap<State> = {
  auth: fromAuth.reducer
};

export const metaReducers: MetaReducer<State>[] = !environment.production ? [] : [];

export const getAuthState = (state: State) => state.auth;

export const isLoggedIn = createSelector(
  getAuthState,
  fromAuth.isLoggedIn
);

export const getUser = createSelector(
  getAuthState,
  fromAuth.getUser
);
<file_sep>/src/app/components/teams/league-header/league-header.component.ts
import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import { LeagueDataService } from '../../../services/league-data.service';

@Component({
  selector: 'app-league-header',
  templateUrl: './league-header.component.html',
  styleUrls: ['./league-header.component.scss'],
})
export class LeagueHeaderComponent implements OnInit {

  public leagues = new Array();
  private selectedLeagueId;
  @Output() leagueSelected = new EventEmitter<number>();

  constructor(
    private leagueDataService: LeagueDataService,
  ) {
    this.leagues = new Array();
  }

  ngOnInit() {
    this.loadAllLeagues();
  }

  async loadAllLeagues() {

    // Fetch leagues
    this.leagues = await this.leagueDataService.getLeagues();

    // Determine the selected league, on load it's the first one from the result list
    let leagueId = null;
    if (this.leagues.length > 0) {
      leagueId = this.selectedLeagueId = this.leagues[0].id;
    }

    // Send the league id through the component
    this.leagueSelected.emit(leagueId);
  }

  changeLeague(event) {
    this.selectedLeagueId = event.detail.value;
    this.leagueSelected.emit(this.selectedLeagueId);
  }
}
<file_sep>/src/app/services/sporthall.service.ts
import { Injectable } from '@angular/core';
import { UpdateSportsHallInput, UpdateHallInput, CreateHallInput, DeleteHallInput } from 'src/API';
import { GraphqlRequestService } from './graphql-request.service';
import * as uuid from 'uuid';
import { environment } from '../../environments/environment';

@Injectable({
  providedIn: 'root'
})
export class SporthallService {

  // All the existing halls, keep track of these in order to know whether to update.
  public existingHalls = new Array();

  // Halls that need to be deleted
  public hallsToDelete = new Array();

  // Halls that are being added
  public newHalls = new Array();

  public halls = new Array();

  constructor(
    private graphqlRequestService: GraphqlRequestService
  ) { }

  async getSportsHalls() {
    let sportsHalls: any[];

    await this.graphqlRequestService.doPublicQuery('listSportsHalls', {});

    if (this.graphqlRequestService.isSuccessfull) {
      sportsHalls = this.graphqlRequestService.data.items;
    }
    return sportsHalls;
  }

  async updateHalls(sportsHallId) {

    for (const hall of this.hallsToDelete) {
      const deleteHallInput: DeleteHallInput = { id: hall.id };
      this.graphqlRequestService.doPrivateMutation('deleteHall', { input: deleteHallInput });
    }

    for (const hall of this.existingHalls) {
      const updateHallInput: UpdateHallInput = { name: hall.name, id: hall.id };
      this.graphqlRequestService.doPrivateMutation('updateHall', { input: updateHallInput });
    }

    for (const hall of this.newHalls) {
      const createHallInput: CreateHallInput = { name: hall.name, hallSportsHallId: sportsHallId };
      this.graphqlRequestService.doPrivateMutation('createHall', { input: createHallInput });
    }
  }

  addEmptyHall() {
    // Need to generate an unique id for the frontend. Is not being used as an id for the hall itself.
    const newHall = { id: uuid.v4(), name: '' };
    this.halls.push(newHall);
    this.newHalls[newHall.id] = newHall;
  }

  removeHall(index, hallId) {

    // We loop over the halls in the template they have a normal index
    if (this.halls[index]) {
      this.halls.splice(index, 1);
    }

    // When it's an existing hall mark it to delete
    if (this.existingHalls[hallId]) {
      this.hallsToDelete.push(this.existingHalls[hallId]);
      this.existingHalls.splice(hallId, 1);
    }

    if (this.newHalls[hallId]) {
      this.newHalls.splice(hallId, 1);
    }
  }
}
<file_sep>/src/app/pages/profile/profile.page.ts
import { Component, OnInit } from '@angular/core';
import { AuthService } from '../../services/auth.service';
import { Router } from '@angular/router';

@Component({
  selector: 'app-profile',
  templateUrl: './profile.page.html',
  styleUrls: ['./profile.page.scss'],
})
export class ProfilePage implements OnInit {

  isLoggedIn = false;
  user: { id: string; username: string; email: string, name: string } = {
    username: null,
    id: null,
    email: null,
    name: null
  };

  constructor(private authService: AuthService, private router: Router) {

    this.authService.isLoggedIn$.subscribe(
      isLoggedIn => (this.isLoggedIn = isLoggedIn)
    );

    this.authService.auth$.subscribe(({ id, username, email, name }) => {
      this.user = { id, username, email, name };
    });
  }

  ngOnInit() {
    if (!this.isLoggedIn) {
      return this.router.navigate(['/login']);
    }
  }
}
<file_sep>/src/app/pages/game-schedule/game-schedule-routing.module.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { GameSchedulePage } from './game-schedule.page';

const routes: Routes = [
  {
    path: '',
    component: GameSchedulePage
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class GameSchedulePageRoutingModule { }
<file_sep>/src/app/pages/match-schedule/match-schedule-list/match-schedule-list.page.ts
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { HttpClient } from '@angular/common/http';
import { getISOWeek, lastDayOfWeek, getDay, subWeeks } from 'date-fns';
import { API, graphqlOperation } from 'aws-amplify';
import { listGames } from 'src/graphql/queries';
import { startOfWeek, addWeeks } from 'date-fns/esm';
import { PopoverController } from '@ionic/angular';
import { GameActionMenuPage } from '../about-popover/game-action-menu.page.';

@Component({
  selector: 'app-match-schedule-list',
  templateUrl: './match-schedule-list.page.html',
  styleUrls: ['./match-schedule-list.page.scss'],
})
export class MatchScheduleListPage implements OnInit {

  public items = new Array();
  public data;
  public week: string;

  showPreviousWeekBtn = true;
  showNextWeekBtn = true;
  isLoading = false;
  hasError = false;

  public calculationDate;

  constructor(private http: HttpClient, public router: Router, public popoverCtrl: PopoverController) {
    this.calculationDate = new Date();
    this.week = 'Week ' + getISOWeek(this.calculationDate);
  }

  ngOnInit() {
    this.listGames();
  }

  goToGameCreatePage() {
    this.router.navigate(['match-schedule/create']);
  }

  async listGames() {

    // reset so that we do not have old results
    this.items = new Array();
    // Set loader to true, for showing the skeleton
    this.isLoading = true;

    // Request the game schedule for the week that has been passed.
    const data = await API.graphql(graphqlOperation(listGames, {
      filter: {
        gameDay: {
          between: [startOfWeek(this.calculationDate, { weekStartsOn: 1 }), lastDayOfWeek(this.calculationDate, { weekStartsOn: 1 })]
        }
      }
    }
    )).catch((error) => {
      console.log(error);
      this.hasError = true;
      this.isLoading = false;
    });

    // When there's no error format the array for the view in the correct way and reset loading variable
    if (!this.hasError) {
      this.sortResultByDay(data);
      this.isLoading = false;
    }
  }

  sortResultByDay(data) {
    const items = data.data.listGames.items;

    // Sort / format the result per day, so that we show the right games for the right day of the week
    items.map((item) => {

      // Get current day (as int) and use that as the key
      const day = getDay(new Date(item.gameDay));
      if (this.items == null || !this.items.hasOwnProperty(day)) {
        this.items[day] = new Array();
      }

      // Add result to the items list.
      this.items[day].push(item);
    });
  }

  loadPreviousWeek() {
    this.calculationDate = subWeeks(this.calculationDate, 1);
    this.listGames();
    this.week = 'Week ' + getISOWeek(this.calculationDate);
  }

  loadNextWeek() {
    this.calculationDate = addWeeks(this.calculationDate, 1);
    this.listGames();
    this.week = 'Week ' + getISOWeek(this.calculationDate);
  }

  async presentPopover(event, game) {
    console.log(game);
    const popover = await this.popoverCtrl.create({
      component: GameActionMenuPage,
      componentProps: {
        game
      },
      event
    });
    await popover.present();
  }
}
<file_sep>/src/app/services/league-data.service.ts
import { Injectable } from '@angular/core';
import { GraphqlRequestService } from './graphql-request.service';
@Injectable({
  providedIn: 'root'
})
export class LeagueDataService {

  constructor(
    private graphqlRequestService: GraphqlRequestService
  ) { }

  async getLeagues() {

    let leagues = new Array();
    await this.graphqlRequestService.doPublicQuery('listLeagues', {});

    if (this.graphqlRequestService.isSuccessfull) {
      leagues = this.graphqlRequestService.data.items;
      leagues.sort(this.sortByRanking);
    }

    return leagues;
  }

  private sortByRanking(a, b) {
    if (a.ranking === b.ranking) {
      console.log('Rankings should be unique');
      return 0;
    }

    return (a.ranking < b.ranking) ? -1 : 1;
  }
}
<file_sep>/src/app/interfaces/referee.ts
export interface Referee {
    firstName: string;
    lastName: string;
    street: string;
    streetNumber: number;
    streetNumberAddition: string;
    zipCode: string;
    city: string;
    email: string;
    phone: string;
}<file_sep>/src/graphql/mutations.ts
// tslint:disable
// this is an auto generated file. This will be overwritten

export const createSeason = `mutation CreateSeason($input: CreateSeasonInput!) {
  createSeason(input: $input) {
    id
    title
    beginDate
    endDate
    leagues {
      items {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const updateSeason = `mutation UpdateSeason($input: UpdateSeasonInput!) {
  updateSeason(input: $input) {
    id
    title
    beginDate
    endDate
    leagues {
      items {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const deleteSeason = `mutation DeleteSeason($input: DeleteSeasonInput!) {
  deleteSeason(input: $input) {
    id
    title
    beginDate
    endDate
    leagues {
      items {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const createGame = `mutation CreateGame($input: CreateGameInput!) {
  createGame(input: $input) {
    id
    gameDay
    scoreHome
    scoreAway
    hall {
      id
      name
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      sportsHall {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    homeTeam {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    awayTeam {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    referee {
      id
      firstName
      lastName
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      email
      phone
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const updateGame = `mutation UpdateGame($input: UpdateGameInput!) {
  updateGame(input: $input) {
    id
    gameDay
    scoreHome
    scoreAway
    hall {
      id
      name
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      sportsHall {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    homeTeam {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    awayTeam {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    referee {
      id
      firstName
      lastName
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      email
      phone
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const deleteGame = `mutation DeleteGame($input: DeleteGameInput!) {
  deleteGame(input: $input) {
    id
    gameDay
    scoreHome
    scoreAway
    hall {
      id
      name
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      sportsHall {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    homeTeam {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    awayTeam {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    referee {
      id
      firstName
      lastName
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      email
      phone
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const createStanding = `mutation CreateStanding($input: CreateStandingInput!) {
  createStanding(input: $input) {
    id
    team
    matchPlayed
    win
    draw
    loses
    goalsFor
    goalsAgainst
    goalDifference
    points
    lastResults
  }
}
`;
export const updateStanding = `mutation UpdateStanding($input: UpdateStandingInput!) {
  updateStanding(input: $input) {
    id
    team
    matchPlayed
    win
    draw
    loses
    goalsFor
    goalsAgainst
    goalDifference
    points
    lastResults
  }
}
`;
export const deleteStanding = `mutation DeleteStanding($input: DeleteStandingInput!) {
  deleteStanding(input: $input) {
    id
    team
    matchPlayed
    win
    draw
    loses
    goalsFor
    goalsAgainst
    goalDifference
    points
    lastResults
  }
}
`;
export const createSportsHall = `mutation CreateSportsHall($input: CreateSportsHallInput!) {
  createSportsHall(input: $input) {
    id
    name
    street
    streetNumber
    streetNumberAddition
    zipCode
    city
    phone
    halls {
      items {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const updateSportsHall = `mutation UpdateSportsHall($input: UpdateSportsHallInput!) {
  updateSportsHall(input: $input) {
    id
    name
    street
    streetNumber
    streetNumberAddition
    zipCode
    city
    phone
    halls {
      items {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const deleteSportsHall = `mutation DeleteSportsHall($input: DeleteSportsHallInput!) {
  deleteSportsHall(input: $input) {
    id
    name
    street
    streetNumber
    streetNumberAddition
    zipCode
    city
    phone
    halls {
      items {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const createHall = `mutation CreateHall($input: CreateHallInput!) {
  createHall(input: $input) {
    id
    name
    games {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    sportsHall {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      phone
      halls {
        items {
          id
          name
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const updateHall = `mutation UpdateHall($input: UpdateHallInput!) {
  updateHall(input: $input) {
    id
    name
    games {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    sportsHall {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      phone
      halls {
        items {
          id
          name
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const deleteHall = `mutation DeleteHall($input: DeleteHallInput!) {
  deleteHall(input: $input) {
    id
    name
    games {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    sportsHall {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      phone
      halls {
        items {
          id
          name
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const createLeague = `mutation CreateLeague($input: CreateLeagueInput!) {
  createLeague(input: $input) {
    id
    name
    ranking
    owner
    teams {
      items {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const updateLeague = `mutation UpdateLeague($input: UpdateLeagueInput!) {
  updateLeague(input: $input) {
    id
    name
    ranking
    owner
    teams {
      items {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const deleteLeague = `mutation DeleteLeague($input: DeleteLeagueInput!) {
  deleteLeague(input: $input) {
    id
    name
    ranking
    owner
    teams {
      items {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const createTeam = `mutation CreateTeam($input: CreateTeamInput!) {
  createTeam(input: $input) {
    id
    leagueId
    name
    contact
    owner
    league {
      id
      name
      ranking
      owner
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    athletes {
      items {
        id
        name
        email
        phone
        teams {
          id
          leagueId
          name
          contact
          owner
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const updateTeam = `mutation UpdateTeam($input: UpdateTeamInput!) {
  updateTeam(input: $input) {
    id
    leagueId
    name
    contact
    owner
    league {
      id
      name
      ranking
      owner
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    athletes {
      items {
        id
        name
        email
        phone
        teams {
          id
          leagueId
          name
          contact
          owner
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const deleteTeam = `mutation DeleteTeam($input: DeleteTeamInput!) {
  deleteTeam(input: $input) {
    id
    leagueId
    name
    contact
    owner
    league {
      id
      name
      ranking
      owner
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    athletes {
      items {
        id
        name
        email
        phone
        teams {
          id
          leagueId
          name
          contact
          owner
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const createAthlete = `mutation CreateAthlete($input: CreateAthleteInput!) {
  createAthlete(input: $input) {
    id
    name
    email
    phone
    teams {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const updateAthlete = `mutation UpdateAthlete($input: UpdateAthleteInput!) {
  updateAthlete(input: $input) {
    id
    name
    email
    phone
    teams {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const deleteAthlete = `mutation DeleteAthlete($input: DeleteAthleteInput!) {
  deleteAthlete(input: $input) {
    id
    name
    email
    phone
    teams {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const createReferee = `mutation CreateReferee($input: CreateRefereeInput!) {
  createReferee(input: $input) {
    id
    firstName
    lastName
    street
    streetNumber
    streetNumberAddition
    zipCode
    city
    email
    phone
    games {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const updateReferee = `mutation UpdateReferee($input: UpdateRefereeInput!) {
  updateReferee(input: $input) {
    id
    firstName
    lastName
    street
    streetNumber
    streetNumberAddition
    zipCode
    city
    email
    phone
    games {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const deleteReferee = `mutation DeleteReferee($input: DeleteRefereeInput!) {
  deleteReferee(input: $input) {
    id
    firstName
    lastName
    street
    streetNumber
    streetNumberAddition
    zipCode
    city
    email
    phone
    games {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const createClub = `mutation CreateClub($input: CreateClubInput!) {
  createClub(input: $input) {
    id
    name
    street
    streetNumber
    streetNumberAddition
    zipCode
    country
    contact
    email
    phone
    sportsHalls {
      items {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    leagues {
      items {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    teams {
      items {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    referees {
      items {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
  }
}
`;
export const updateClub = `mutation UpdateClub($input: UpdateClubInput!) {
  updateClub(input: $input) {
    id
    name
    street
    streetNumber
    streetNumberAddition
    zipCode
    country
    contact
    email
    phone
    sportsHalls {
      items {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    leagues {
      items {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    teams {
      items {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    referees {
      items {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
  }
}
`;
export const deleteClub = `mutation DeleteClub($input: DeleteClubInput!) {
  deleteClub(input: $input) {
    id
    name
    street
    streetNumber
    streetNumberAddition
    zipCode
    country
    contact
    email
    phone
    sportsHalls {
      items {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    leagues {
      items {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    teams {
      items {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    referees {
      items {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
  }
}
`;
<file_sep>/src/app/reducers/auth.reducer.ts
import * as fromAuth from '../actions/auth.actions';
import { User } from '../interfaces/user';

export interface AuthState {
    isLoggedIn: boolean;
    user: User;
}

export const initialState: AuthState = {
    isLoggedIn: false,
    user: null
};

export function reducer(
    state = initialState,
    action: fromAuth.ActionsUnion
): AuthState {
    switch (action.type) {
        case fromAuth.ActionTypes.Login: {
            return {
                ...state,
                isLoggedIn: action.payload.isLoggedIn,
                user: action.payload.user,
            };
        }

        case fromAuth.ActionTypes.Logout: {
            return {
                ...state,
                isLoggedIn: false,
                user: null
            };
        }

        default: {
            return state;
        }
    }
}

export const isLoggedIn = (state: AuthState) => state.isLoggedIn;
export const getUser = (state: AuthState) => state.user;

<file_sep>/amplify/backend/api/localsportsangular/schema.graphql
type Season @model @auth(rules: [{allow: public, operations: [read]}, { allow: groups, groups: ["admin"] }]) {
  id: ID!
  title: String!
  beginDate: AWSDateTime!
  endDate: AWSDateTime!
  leagues: [League!] @connection
  club: Club! @connection
}

type Game @model @auth(rules: [{allow: public, operations: [read]}, { allow: groups, groups: ["admin"] }]) {
  id: ID!
  gameDay: AWSDateTime!
  homeTeam: Team! @connection
  awayTeam: Team! @connection
  scoreHome: Int
  scoreAway: Int
  hall: Hall! @connection
  referee: Referee @connection
}

type Standing @model @auth(rules: [{allow: public, operations: [read]}])  {
  id: ID!
  team: String!
  matchPlayed: Int
  win: Int
  draw: Int
  loses: Int
  goalsFor: Int
  goalsAgainst: Int
  goalDifference: Int
  points: Int
  lastResults: AWSJSON
}

type SportsHall @model @auth(rules: [{allow: public, operations: [read]}, { allow: groups, groups: ["admin"] }])  {
  id: ID!
  name: String!
  street: String!
  streetNumber: Int!
  streetNumberAddition: String
  zipCode: String!
  city: String!
  phone: AWSPhone
  halls: [Hall!] @connection(name: "SportsHallHalls")
  club: Club! @connection(name: "ClubSportsHall")
}

type Hall @model @auth(rules: [{allow: public, operations: [read]}, { allow: groups, groups: ["admin"] }]) {
  id: ID!
  name: String!
  sportsHall: SportsHall! @connection(name: "SportsHallHalls")
  games: [Game!]
}

type League @model @auth(rules: [{allow: public, operations: [read]}, { allow: groups, groups: ["admin"] }]){
  id: ID!
  name: String!
  ranking: Int!
  club: Club! @connection(name: "ClubLeagues")
  teams: [Team!] @connection(name: "TeamLeague")
  owner: String
}

type Team @model @auth(rules: [{allow: public, operations: [read]}, { allow: groups, groups: ["admin"] }])  {
  id: ID!
  league: League @connection(name: "TeamLeague")
  leagueId: ID!
  name: String!
  contact: String!
  athletes: [Athlete] @connection(name: "TeamMembers")
  club: Club @connection(name: "ClubMembers")
  owner: String
}

type Athlete @model @auth(rules: [{allow: public, operations: [read]}, { allow: groups, groups: ["admin"] }])  {
  id: ID!
  name: String!
  email: AWSEmail
  phone: AWSPhone
  teams: Team @connection(name: "TeamMembers")
}

type Referee @model @auth(rules: [{allow: public, operations: [read]}, { allow: groups, groups: ["admin"] }])  {
  id: ID!
  firstName: String!
  lastName: String!
  street: String
  streetNumber: Int
  streetNumberAddition: String
  zipCode: String
  city: String!
  email: AWSEmail
  phone: AWSPhone
  club: Club @connection(name: "ClubReferees")
  games: [Game!]
}

type Club @model @auth(rules: [{allow: public, operations: [read]}, { allow: groups, groups: ["admin"] }])  {
  id: ID!
  name: String!
  street: String
  streetNumber: String
  streetNumberAddition: String
  zipCode: String
  country: String!
  contact: String!
  email: AWSEmail
  phone: AWSPhone
  leagues: [League!] @connection(name: "ClubLeagues")
  teams: [Team] @connection(name: "ClubMembers")
  referees: [Referee] @connection(name: "ClubReferees")
  sportsHalls: [SportsHall!] @connection(name: "ClubSportsHall")
}<file_sep>/src/app/pages/admin/league/league-edit/league-edit.page.ts
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import Amplify, { API, graphqlOperation } from 'aws-amplify';
import { UpdateLeagueInput, DeleteLeagueInput } from 'src/API';
import * as mutations from '../../../../../graphql/mutations';
import * as queries from '../../../../../graphql/queries';
import { AlertController } from '@ionic/angular';
import { ToastService } from '../../../../services/toast.service';
import { GraphqlRequestService } from '../../../../services/graphql-request.service';

@Component({
  selector: 'app-league-edit',
  templateUrl: './league-edit.page.html',
  styleUrls: ['./league-edit.page.scss'],
})
export class LeagueEditPage implements OnInit {

  public league: any;
  initialStateLeague = { id: null, name: null };
  constructor(
    private route: ActivatedRoute,
    private router: Router,
    public alertController: AlertController,
    public toastService: ToastService,
    public graphqlRequestService: GraphqlRequestService
  ) {
    this.league = this.initialStateLeague;
  }

  ngOnInit() {
    const leagueId = this.route.snapshot.paramMap.get('leagueId');
    this.loadLeague(leagueId);
  }

  async loadLeague(leagueId) {

    await this.graphqlRequestService.doPrivateQuery('getLeague', { id: leagueId });

    if (this.graphqlRequestService.isSuccessfull) {
      this.league = this.graphqlRequestService.data;
    } else {
      this.toastService.presentWarningToast('Divisie kon niet gevonden worden.');
      return this.router.navigate(['/admin/league']);
    }
  }

  async processForm() {
    try {
      const updateLeagueInput: UpdateLeagueInput = { id: this.league.id, name: this.league.name, ranking: this.league.ranking };
      await this.graphqlRequestService.doPrivateMutation('updateLeague', { input: updateLeagueInput });

      if (this.graphqlRequestService.isSuccessfull) {
        return this.router.navigate(['/admin/league']);
      }

    } catch (err) {
      console.log(err);
    }
  }

  async presentDeleteAlertConfirm(league) {
    const alert = await this.alertController.create({
      header: 'Waarschuwing!',
      message: 'Weet u zeker dat u de divisie wil verwijderen?',
      buttons: [
        {
          text: 'Cancel',
          role: 'cancel',
          cssClass: 'secondary',
        }, {
          text: 'Okay',
          cssClass: 'danger',
          handler: () => {
            this.deleteLeague(league);
          }
        }
      ]
    });

    await alert.present();
  }

  async deleteLeague(league) {
    const leagueInput: DeleteLeagueInput = { id: league.id };
    await this.graphqlRequestService.doPrivateMutation('deleteLeague', { input: leagueInput });

    if (this.graphqlRequestService.isSuccessfull) {
      return this.router.navigate(['/admin/league']);
    }
  }
}
<file_sep>/src/app/pages/admin/team/team-create/team-create.page.ts
import { Component, OnInit } from '@angular/core';
import { environment } from '../../../../../environments/environment';
import { LeagueDataService } from '../../../../services/league-data.service';
import { GraphqlRequestService } from '../../../../services/graphql-request.service';
import { Router } from '@angular/router';
import { CreateTeamInput } from '../../../../../API';

@Component({
  selector: 'app-team-create',
  templateUrl: './team-create.page.html',
  styleUrls: ['./team-create.page.scss'],
})
export class TeamCreatePage implements OnInit {

  i = 2;
  defaultHref: '';
  team: CreateTeamInput;
  initialTeamState = {
    name: 'Team ' + this.i++, contact: 'Henkie', teamLeagueId: null, leagueId: null, teamClubId: environment.clubId
  };
  leagues = new Array();

  constructor(
    private router: Router,
    private leagueDataService: LeagueDataService,
    private graphqlRequestService: GraphqlRequestService) {
  }

  ngOnInit() {
    this.team = this.initialTeamState;
    this.loadLeagues();
  }

  async loadLeagues() {
    this.leagues = await this.leagueDataService.getLeagues();
  }

  async processForm() {

    try {
      // General workaround to be able to filter the teams per league.
      this.team.leagueId = this.team.teamLeagueId;
      await this.graphqlRequestService.doPrivateMutation('createTeam', { input: this.team });

      if (this.graphqlRequestService.isSuccessfull) {
        return this.router.navigate(['/admin/team']);
      }

    } catch (err) {
      console.log(err);
    }
  }
}
<file_sep>/src/app/services/graphql-request.service.spec.ts
import { TestBed } from '@angular/core/testing';

import { GraphqlRequestService } from './graphql-request.service';

describe('GraphqlRequestService', () => {
  beforeEach(() => TestBed.configureTestingModule({}));

  it('should be created', () => {
    const service: GraphqlRequestService = TestBed.get(GraphqlRequestService);
    expect(service).toBeTruthy();
  });
});
<file_sep>/src/app/services/sporthall.service.spec.ts
import { TestBed } from '@angular/core/testing';

import { SporthallService } from './sporthall.service';

describe('SporthallService', () => {
  beforeEach(() => TestBed.configureTestingModule({}));

  it('should be created', () => {
    const service: SporthallService = TestBed.get(SporthallService);
    expect(service).toBeTruthy();
  });
});
<file_sep>/src/app/services/referee.service.ts
import { Injectable } from '@angular/core';
import { GraphqlRequestService } from './graphql-request.service';
import { CreateRefereeInput, UpdateRefereeInput, DeleteRefereeInput } from 'src/API';

@Injectable({
  providedIn: 'root'
})
export class RefereeService {

  constructor(
    private graphqlRequestService: GraphqlRequestService
  ) { }

  async getReferees() {
    let referees: any[];

    await this.graphqlRequestService.doPrivateQuery('listReferees', {});

    if (this.graphqlRequestService.isSuccessfull) {
      referees = this.graphqlRequestService.data.items;
    }

    return referees;
  }

  async createReferee(createRefereeInput: CreateRefereeInput) {

    await this.graphqlRequestService.doPrivateMutation('createReferee', { input: createRefereeInput });
    if (this.graphqlRequestService.isSuccessfull) {
      return this.graphqlRequestService.data;
    }
  }

  async updateReferee(updateRefereeInput: UpdateRefereeInput) {

    await this.graphqlRequestService.doPrivateMutation('updateReferee', { input: updateRefereeInput });
    if (this.graphqlRequestService.isSuccessfull) {
      return this.graphqlRequestService.data;
    }
  }

  async deleteReferee(refereeId) {
    const deleteInput: DeleteRefereeInput = { id: refereeId };
    await this.graphqlRequestService.doPrivateMutation('deleteReferee', { input: deleteInput });
    if (this.graphqlRequestService.isSuccessfull) {
      return this.graphqlRequestService.data;
    }
  }
}
<file_sep>/src/app/pages/team/team-list/team-list.page.ts
import { Component, OnInit } from '@angular/core';
import { ToastService } from '../../../services/toast.service';

@Component({
  selector: 'team-list-page',
  templateUrl: './team-list.page.html',
  styleUrls: ['./team-list.page.scss'],
})
export class TeamListPage {

  public allTeams = new Array();

  public teamsPerLeague = new Array();
  public selectedLeagueId;
  public shownTeams;

  constructor(
    public toastService: ToastService
  ) {
    this.selectedLeagueId = null;
    this.shownTeams = new Array();
    this.allTeams = new Array();
    this.teamsPerLeague = new Array();
  }

  // Is being triggerd in app-league-header
  onLeagueSelected(leagueId) {
    this.selectedLeagueId = leagueId;
    console.log(leagueId);
  }
}
<file_sep>/src/app/pages/admin/referee/referee-edit/referee-edit.page.spec.ts
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { RefereeEditPage } from './referee-edit.page';

describe('RefereeEditPage', () => {
  let component: RefereeEditPage;
  let fixture: ComponentFixture<RefereeEditPage>;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ RefereeEditPage ],
      schemas: [CUSTOM_ELEMENTS_SCHEMA],
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(RefereeEditPage);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});
<file_sep>/src/app/pages/admin/admin-routing.module.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

const routes: Routes = [
  {
    path: 'admin',
    children: [
      {
        path: 'team', children: [
          {
            path: '',
            loadChildren: () => import('./team/team-list/team-list.module').then(m => m.TeamListPageModule)
          },
          {
            path: 'create',
            loadChildren: () => import('./team/team-create/team-create.module').then(m => m.TeamCreatePageModule)
          },
          {
            path: 'edit/:teamId',
            loadChildren: () => import('./team/team-edit/team-edit.module').then(m => m.TeamEditPageModule)
          },
        ]
      },
      {
        path: 'league', children: [
          {
            path: '',
            loadChildren: () => import('./league/league-list/league-list.module').then(m => m.LeagueListPageModule)
          },
          {
            path: 'create',
            loadChildren: () => import('./league/league-create/league-create.module').then(m => m.LeagueCreatePageModule)
          },
          {
            path: 'edit/:leagueId',
            loadChildren: () => import('./league/league-edit/league-edit.module').then(m => m.LeagueEditPageModule)
          },
        ]
      },
      {
        path: '',
        redirectTo: 'app/tabs/schedule',
        pathMatch: 'full'
      }
    ]
  },
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class AdminRoutingModule { }

<file_sep>/src/app/pages/admin/referee/referee-list/referee-list.page.ts
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { RefereeService } from '../../../../services/referee.service';
import * as subscriptions from '../../../../../graphql/subscriptions';
import Amplify, { API, graphqlOperation } from 'aws-amplify';
import { ToastService } from '../../../../services/toast.service';

@Component({
  selector: 'app-referee-list',
  templateUrl: './referee-list.page.html',
  styleUrls: ['./referee-list.page.scss'],
})
export class RefereeListPage implements OnInit {

  public referees = new Array();

  constructor(
    private router: Router,
    private refereeService: RefereeService,
    public toastService: ToastService,
  ) { }

  ngOnInit() {
    this.loadReferees();
    this.subscribeOnCreateReferee();
    this.subscribeOnUpdateReferee();
    this.subscribeOnDeleteReferee();

  }

  subscribeOnCreateReferee() {
    API.graphql(
      graphqlOperation(subscriptions.onCreateReferee)
    ).subscribe({
      next: (refereeData) => {
        this.referees.push(refereeData.value.data.onCreateReferee);
        this.toastService.presentToast('Scheidsrechter is aangemaakt.');
      }
    });
  }

  private subscribeOnUpdateReferee() {
    API.graphql(
      graphqlOperation(subscriptions.onUpdateReferee)
    ).subscribe({
      next: (refereeData) => {
        this.updateSportsHall(refereeData);
      }
    });
  }

  private subscribeOnDeleteReferee() {
    API.graphql(
      graphqlOperation(subscriptions.onDeleteReferee)
    ).subscribe({
      next: (refereeData) => {
        this.deleteSportsHall(refereeData);
      }
    });
  }

  private updateSportsHall(refereeData) {
    const sportsHall = refereeData.value.data.onUpdateReferee;
    for (let i = 0; i < this.referees.length; i++) {
      if (this.referees[i].id === sportsHall.id) {
        this.referees[i] = sportsHall;
        this.toastService.presentToast('Scheidsrechter is bijgewerkt');
        return;
      }
    }
  }

  private deleteSportsHall(refereeData) {
    const sportsHall = refereeData.value.data.onDeleteReferee;
    for (let i = 0; i < this.referees.length; i++) {
      if (this.referees[i].id === sportsHall.id) {
        this.referees.splice(i, 1);
        this.toastService.presentToast('Scheidsrechter is verwijderd');
        return;
      }
    }
  }

  private async loadReferees() {
    this.referees = await this.refereeService.getReferees();
  }

  goToRefereeCreatePage() {
    return this.router.navigate(['/admin/referee/create']);
  }

  goToRefereeEditPage(refereeId) {
    return this.router.navigate(['/admin/referee/edit/' + refereeId]);
  }

}
<file_sep>/src/app/app-routing.module.ts
import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';

const routes: Routes = [
  {
    path: '',
    redirectTo: 'app/tabs/schedule',
    pathMatch: 'full'
  },
  {
    path: 'app',
    loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsModule)
  },
  {
    path: 'admin',
    children: [
      {
        path: 'team', children: [
          {
            path: '',
            loadChildren: () => import('./pages/admin/team/team-list/team-list.module').then(m => m.TeamListPageModule)
          },
          {
            path: 'create',
            loadChildren: () => import('./pages/admin/team/team-create/team-create.module').then(m => m.TeamCreatePageModule)
          },
          {
            path: 'edit/:teamId',
            loadChildren: () => import('./pages/admin/team/team-edit/team-edit.module').then(m => m.TeamEditPageModule)
          },
        ]
      },
      {
        path: 'league', children: [
          {
            path: '',
            loadChildren: () => import('./pages/admin/league/league-list/league-list.module').then(m => m.LeagueListPageModule)
          },
          {
            path: 'create',
            loadChildren: () => import('./pages/admin/league/league-create/league-create.module').then(m => m.LeagueCreatePageModule)
          },
          {
            path: 'edit/:leagueId',
            loadChildren: () => import('./pages/admin/league/league-edit/league-edit.module').then(m => m.LeagueEditPageModule)
          },
        ]
      },
      {
        path: 'sports-hall', children: [
          {
            path: '',
            loadChildren: () => import('./pages/admin/sports-hall/sports-hall-list/sports-hall-list.module')
              .then(m => m.SportsHallListPageModule)
          },
          {
            path: 'create',
            loadChildren: () => import('./pages/admin/sports-hall/sports-hall-create/sports-hall-create.module')
              .then(m => m.SportsHallCreatePageModule)
          },
          {
            path: 'edit/:sportsHallId',
            loadChildren: () => import('./pages/admin/sports-hall/sports-hall-edit/sports-hall-edit.module')
              .then(m => m.SportsHallEditPageModule)
          },
        ]
      },
      {
        path: 'referee', children: [
          {
            path: 'edit/:refereeId',
            loadChildren: () => import('./pages/admin/referee/referee-edit/referee-edit.module')
              .then(m => m.RefereeEditPageModule)
          },
          {
            path: 'create',
            loadChildren: () => import('./pages/admin/referee/referee-create/referee-create.module')
              .then(m => m.RefereeCreatePageModule)
          },
          {
            path: '', loadChildren: () => import('./pages/admin/referee/referee-list/referee-list.module')
              .then(m => m.RefereeListPageModule)
          },
        ]
      },
      {
        path: '',
        redirectTo: 'app/tabs/schedule',
        pathMatch: 'full'
      }
    ]
  },
  { path: 'login', loadChildren: './pages/login/login.module#LoginPageModule' },
  { path: 'profile', loadChildren: './pages/profile/profile.module#ProfilePageModule' },
  { path: 'logout', loadChildren: './pages/logout/logout.module#LogoutPageModule' },
  {
    path: 'team', children: [
      {
        path: '',
        loadChildren: () => import('./pages/team/team-list/team-list.module').then(m => m.TeamListPageModule)
      },
    ]
  },
  {
    path: 'club', children: [
      {
        path: '',
        loadChildren: () => import('./pages/club/club-list/club-list.module').then(m => m.ClubListPageModule)
      },
      {
        path: 'create',
        loadChildren: () => import('./pages/club/club-create/club-create.module').then(m => m.ClubCreatePageModule)
      },
    ]
  },
  {
    path: 'match-schedule', children: [
      {
        path: '',
        loadChildren: () => import('./pages/match-schedule/match-schedule-list/match-schedule-list.module')
          .then(m => m.MatchScheduleListPageModule)
      },
      {
        path: 'create',
        loadChildren: () => import('./pages/match-schedule/match-schedule-create/match-schedule-create.module')
          .then(m => m.MatchScheduleCreatePageModule)
      },
    ]
  },
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
  ],
  exports: [RouterModule]
})
export class AppRoutingModule { }
<file_sep>/src/app/pages/admin/sports-hall/sports-hall-list/sports-hall-list.page.ts
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import * as subscriptions from '../../../../../graphql/subscriptions';
import Amplify, { API, graphqlOperation } from 'aws-amplify';
import { ToastService } from '../../../../services/toast.service';
import { GraphqlRequestService } from '../../../../services/graphql-request.service';

@Component({
  selector: 'app-sports-hall-list',
  templateUrl: './sports-hall-list.page.html',
  styleUrls: ['./sports-hall-list.page.scss'],
})
export class SportsHallListPage implements OnInit {

  sportsHalls = new Array();

  constructor(
    private router: Router,
    private graphqlRequestService: GraphqlRequestService,
    public toastService: ToastService,
  ) { }

  ngOnInit() {
    this.loadSportsHalls();
    this.subscribeOnCreateSportsHall();
    this.subscribeOnUpdateSportsHall();
    this.subscribeOnDeleteSportsHall();
  }

  private subscribeOnCreateSportsHall() {
    API.graphql(
      graphqlOperation(subscriptions.onCreateSportsHall)
    ).subscribe({
      next: (sportsHallData) => {
        this.sportsHalls.push(sportsHallData.value.data.onCreateSportsHall);
        this.toastService.presentToast('Sporthal is aangemaakt.');
      }
    });
  }

  private subscribeOnUpdateSportsHall() {
    API.graphql(
      graphqlOperation(subscriptions.onUpdateSportsHall)
    ).subscribe({
      next: (sportsHallData) => {
        this.updateSportsHall(sportsHallData);
      }
    });
  }

  private subscribeOnDeleteSportsHall() {
    API.graphql(
      graphqlOperation(subscriptions.onDeleteSportsHall)
    ).subscribe({
      next: (sportsHallData) => {
        this.deleteSportsHall(sportsHallData);
      }
    });
  }

  private updateSportsHall(sportsHallData) {
    const sportsHall = sportsHallData.value.data.onUpdateSportsHall;
    for (let i = 0; i < this.sportsHalls.length; i++) {
      if (this.sportsHalls[i].id === sportsHall.id) {
        this.sportsHalls[i] = sportsHall;
        this.toastService.presentToast('Sporthal is bijgewerkt');
        return;
      }
    }
  }

  private deleteSportsHall(sportsHallData) {
    const sportsHall = sportsHallData.value.data.onUpdateSportsHall;
    for (let i = 0; i < this.sportsHalls.length; i++) {
      if (this.sportsHalls[i].id === sportsHall.id) {
        this.sportsHalls.splice(i, 1);
        this.toastService.presentToast('Sporthal is verwijderd');
        return;
      }
    }
  }

  private async loadSportsHalls() {

    await this.graphqlRequestService.doPrivateQuery('listSportsHalls', {});

    if (this.graphqlRequestService.isSuccessfull) {
      this.sportsHalls = this.graphqlRequestService.data.items;
    }
  }

  goToSportsHallCreatePage() {
    return this.router.navigate(['/admin/sports-hall/create']);
  }

  goToSportsHallEditPage(sportsHallId) {
    return this.router.navigate(['/admin/sports-hall/edit/' + sportsHallId]);
  }
}
<file_sep>/src/app/pages/admin/team/team-list/team-list.page.scss
.ranking-header {
    font-size: 8pt;
}<file_sep>/src/app/pages/admin/league/league-list/league-list.page.ts
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import Amplify, { API, graphqlOperation } from 'aws-amplify';
import * as queries from '../../../../../graphql/queries';
import * as subscriptions from '../../../../../graphql/subscriptions';
import { ToastService } from '../../../../services/toast.service';
@Component({
  selector: 'app-league-list',
  templateUrl: './league-list.page.html',
  styleUrls: ['./league-list.page.scss'],
})
export class LeagueListPage implements OnInit {

  public allLeagues = new Array();

  constructor(
    private router: Router,
    public toastService: ToastService,
  ) { }

  ngOnInit() {
    this.loadLeagues();
    this.subscribeOnCreateleague();
    this.subscribeOnUpdateLeague();
    this.subscribeOnDeleteLeague();
  }

  subscribeOnCreateleague() {
    API.graphql(
      graphqlOperation(subscriptions.onCreateLeague)
    ).subscribe({
      next: (leagueData) => {
        this.allLeagues.push(leagueData.value.data.onCreateLeague);
        this.toastService.presentToast('Divisie is aangemaakt.');
      }
    });
  }

  async loadLeagues() {
    const allLeagues = await API.graphql(graphqlOperation(queries.listLeagues));

    if (allLeagues) {
      this.allLeagues = allLeagues.data.listLeagues.items;
    }
  }

  goToLeagueCreatePage() {
    return this.router.navigate(['/admin/league/create']);
  }

  goToLeagueEditPage(leagueId) {
    return this.router.navigate(['/admin/league/edit/' + leagueId]);
  }

  subscribeOnUpdateLeague() {
    API.graphql(
      graphqlOperation(subscriptions.onUpdateLeague)
    ).subscribe({
      next: (leagueData) => {
        this.updateLocalLeagues(leagueData);
      }
    });
  }

  subscribeOnDeleteLeague() {
    API.graphql(
      graphqlOperation(subscriptions.onDeleteLeague)
    ).subscribe({
      next: (leagueData) => {
        this.deleteLocalLeague(leagueData);
      }
    });
  }

  updateLocalLeagues(leagueData) {
    const league = leagueData.value.data.onUpdateLeague;
    for (let i = 0; i < this.allLeagues.length; i++) {
      if (this.allLeagues[i].id === league.id) {
        this.allLeagues[i] = league;
        this.toastService.presentToast('Divisie is bijgewerkt');
        return;
      }
    }
  }

  deleteLocalLeague(leagueData) {
    const league = leagueData.value.data.onDeleteLeague;
    for (let i = 0; i < this.allLeagues.length; i++) {
      if (this.allLeagues[i].id === league.id) {
        this.allLeagues.splice(i, 1);
        this.toastService.presentToast('Divisie is verwijderd');
        return;
      }
    }
  }
}
<file_sep>/src/app/actions/auth.actions.ts
import { Action } from '@ngrx/store';
import { User } from '../interfaces/user';

export enum ActionTypes {
    Login = '[Auth Service] Login',
    Logout = '[Auth Service] Logout'
}

export class Login implements Action {
    readonly type = ActionTypes.Login;

    constructor(public payload: { isLoggedIn: boolean, user: User | null }) { }
}

export class Logout implements Action {
    readonly type = ActionTypes.Logout;

    constructor() { }
}

export type ActionsUnion = Login | Logout;
<file_sep>/src/app/pages/club/club-list/club-list.page.ts
import { Component, OnInit } from '@angular/core';
import Amplify, { API, graphqlOperation } from 'aws-amplify';
import * as queries from '../../../../graphql/queries';
@Component({
  selector: 'app-club-list',
  templateUrl: './club-list.page.html',
  styleUrls: ['./club-list.page.scss'],
})
export class ClubListPage implements OnInit {

  constructor() { }

  ngOnInit() {
    this.loadClub();
  }

  async loadClub() {
    const allLeagues = await API.graphql(graphqlOperation(queries.listClubs));
    console.log(allLeagues);
  }

}
<file_sep>/src/app/services/toast.service.ts
import { Injectable } from '@angular/core';
import { ToastController } from '@ionic/angular';

@Injectable({
  providedIn: 'root'
})
export class ToastService {

  private color = 'primary';

  constructor(
    public toastController: ToastController
  ) { }

  presentSuccessToast(message: string) {
    this.color = 'success';
    this.presentToast(message);
  }

  presentWarningToast(message: string) {
    this.color = 'warning';
    this.presentToast(message);
  }

  async presentToast(message: string) {
    const toast = await this.toastController.create({
      message,
      duration: 2000,
      color: this.color,
    });
    toast.present();
  }
}
<file_sep>/src/app/pages/match-schedule/match-schedule-create/match-schedule-create.page.ts
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

@Component({
  selector: 'app-match-schedule-create',
  templateUrl: './match-schedule-create.page.html',
  styleUrls: ['./match-schedule-create.page.scss'],
})
export class MatchScheduleCreatePage implements OnInit {

  constructor(private router: Router) { }

  ngOnInit() {
  }

  onGameCreated() {
    this.router.navigate(['/match-schedule']);
  }
}
<file_sep>/src/app/app.component.ts
import { Component } from '@angular/core';

import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AuthService } from './services/auth.service';

@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.scss']
})
export class AppComponent {
  public appPages = [
    {
      title: 'Wedstrijdschema',
      url: 'app/tabs/schedule',
      icon: 'calendar'
    },
    {
      title: 'Standen',
      url: 'app/tabs/ranking',
      icon: 'podium'
    },
    {
      title: 'Teams',
      url: 'app/tabs/team',
      icon: 'people'
    },
  ];

  public unAuthAccountPages = [
    {
      title: 'Login',
      url: '/login',
      icon: 'log-in'
    }
  ];

  public authPages = [
    {
      title: 'Profiel',
      url: '/profile',
      icon: 'contact'
    },
    {
      title: 'Logout',
      url: '/logout',
      icon: 'log-out'
    }
  ];

  public clubPages = [
    {
      title: 'Divisies',
      url: '/admin/league',
      icon: 'rocket'
    },
    {
      title: 'Team beheer',
      url: '/admin/team',
      icon: 'people'
    },
    {
      title: 'Scheidsrechters',
      url: '/admin/referee',
      icon: 'contacts'
    },
    {
      title: 'Sporthallen',
      url: '/admin/sports-hall',
      icon: 'pin'
    }
  ];

  public usernameAttributes = 'email';
  isLoggedIn = false;

  constructor(
    private platform: Platform,
    private splashScreen: SplashScreen,
    private statusBar: StatusBar,
    private authService: AuthService
  ) {
    this.initializeApp();
  }

  initializeApp() {
    this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      this.splashScreen.hide();
      this.authService.isLoggedIn$.subscribe(
        isLoggedIn => (this.isLoggedIn = isLoggedIn)
      );
    });
  }
}
<file_sep>/src/app/pages/match-schedule/about-popover/submit-score.page.ts
import { Component, Input } from '@angular/core';

import { PopoverController, ModalController } from '@ionic/angular';

@Component({
  templateUrl: './submit-score.page.html',
})
export class SubmitScorePage {

  @Input() game;

  constructor(public modalCtrl: ModalController) { }

  dismissModal() {
    this.modalCtrl.dismiss({
      dismissed: true
    });
  }
}
<file_sep>/src/graphql/subscriptions.ts
// tslint:disable
// this is an auto generated file. This will be overwritten

export const onCreateSeason = `subscription OnCreateSeason {
  onCreateSeason {
    id
    title
    beginDate
    endDate
    leagues {
      items {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onUpdateSeason = `subscription OnUpdateSeason {
  onUpdateSeason {
    id
    title
    beginDate
    endDate
    leagues {
      items {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onDeleteSeason = `subscription OnDeleteSeason {
  onDeleteSeason {
    id
    title
    beginDate
    endDate
    leagues {
      items {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onCreateGame = `subscription OnCreateGame {
  onCreateGame {
    id
    gameDay
    scoreHome
    scoreAway
    hall {
      id
      name
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      sportsHall {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    homeTeam {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    awayTeam {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    referee {
      id
      firstName
      lastName
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      email
      phone
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const onUpdateGame = `subscription OnUpdateGame {
  onUpdateGame {
    id
    gameDay
    scoreHome
    scoreAway
    hall {
      id
      name
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      sportsHall {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    homeTeam {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    awayTeam {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    referee {
      id
      firstName
      lastName
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      email
      phone
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const onDeleteGame = `subscription OnDeleteGame {
  onDeleteGame {
    id
    gameDay
    scoreHome
    scoreAway
    hall {
      id
      name
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      sportsHall {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    homeTeam {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    awayTeam {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    referee {
      id
      firstName
      lastName
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      email
      phone
      games {
        id
        gameDay
        scoreHome
        scoreAway
        hall {
          id
          name
        }
        homeTeam {
          id
          leagueId
          name
          contact
          owner
        }
        awayTeam {
          id
          leagueId
          name
          contact
          owner
        }
        referee {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const onCreateStanding = `subscription OnCreateStanding {
  onCreateStanding {
    id
    team
    matchPlayed
    win
    draw
    loses
    goalsFor
    goalsAgainst
    goalDifference
    points
    lastResults
  }
}
`;
export const onUpdateStanding = `subscription OnUpdateStanding {
  onUpdateStanding {
    id
    team
    matchPlayed
    win
    draw
    loses
    goalsFor
    goalsAgainst
    goalDifference
    points
    lastResults
  }
}
`;
export const onDeleteStanding = `subscription OnDeleteStanding {
  onDeleteStanding {
    id
    team
    matchPlayed
    win
    draw
    loses
    goalsFor
    goalsAgainst
    goalDifference
    points
    lastResults
  }
}
`;
export const onCreateSportsHall = `subscription OnCreateSportsHall {
  onCreateSportsHall {
    id
    name
    street
    streetNumber
    streetNumberAddition
    zipCode
    city
    phone
    halls {
      items {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onUpdateSportsHall = `subscription OnUpdateSportsHall {
  onUpdateSportsHall {
    id
    name
    street
    streetNumber
    streetNumberAddition
    zipCode
    city
    phone
    halls {
      items {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onDeleteSportsHall = `subscription OnDeleteSportsHall {
  onDeleteSportsHall {
    id
    name
    street
    streetNumber
    streetNumberAddition
    zipCode
    city
    phone
    halls {
      items {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onCreateHall = `subscription OnCreateHall {
  onCreateHall {
    id
    name
    games {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    sportsHall {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      phone
      halls {
        items {
          id
          name
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const onUpdateHall = `subscription OnUpdateHall {
  onUpdateHall {
    id
    name
    games {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    sportsHall {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      phone
      halls {
        items {
          id
          name
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const onDeleteHall = `subscription OnDeleteHall {
  onDeleteHall {
    id
    name
    games {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    sportsHall {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      city
      phone
      halls {
        items {
          id
          name
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const onCreateLeague = `subscription OnCreateLeague {
  onCreateLeague {
    id
    name
    ranking
    owner
    teams {
      items {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onUpdateLeague = `subscription OnUpdateLeague {
  onUpdateLeague {
    id
    name
    ranking
    owner
    teams {
      items {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onDeleteLeague = `subscription OnDeleteLeague {
  onDeleteLeague {
    id
    name
    ranking
    owner
    teams {
      items {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onCreateTeam = `subscription OnCreateTeam {
  onCreateTeam {
    id
    leagueId
    name
    contact
    owner
    league {
      id
      name
      ranking
      owner
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    athletes {
      items {
        id
        name
        email
        phone
        teams {
          id
          leagueId
          name
          contact
          owner
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onUpdateTeam = `subscription OnUpdateTeam {
  onUpdateTeam {
    id
    leagueId
    name
    contact
    owner
    league {
      id
      name
      ranking
      owner
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    athletes {
      items {
        id
        name
        email
        phone
        teams {
          id
          leagueId
          name
          contact
          owner
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onDeleteTeam = `subscription OnDeleteTeam {
  onDeleteTeam {
    id
    leagueId
    name
    contact
    owner
    league {
      id
      name
      ranking
      owner
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
    athletes {
      items {
        id
        name
        email
        phone
        teams {
          id
          leagueId
          name
          contact
          owner
        }
      }
      nextToken
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onCreateAthlete = `subscription OnCreateAthlete {
  onCreateAthlete {
    id
    name
    email
    phone
    teams {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const onUpdateAthlete = `subscription OnUpdateAthlete {
  onUpdateAthlete {
    id
    name
    email
    phone
    teams {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const onDeleteAthlete = `subscription OnDeleteAthlete {
  onDeleteAthlete {
    id
    name
    email
    phone
    teams {
      id
      leagueId
      name
      contact
      owner
      league {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      athletes {
        items {
          id
          name
          email
          phone
        }
        nextToken
      }
      club {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        country
        contact
        email
        phone
        sportsHalls {
          nextToken
        }
        leagues {
          nextToken
        }
        teams {
          nextToken
        }
        referees {
          nextToken
        }
      }
    }
  }
}
`;
export const onCreateReferee = `subscription OnCreateReferee {
  onCreateReferee {
    id
    firstName
    lastName
    street
    streetNumber
    streetNumberAddition
    zipCode
    city
    email
    phone
    games {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onUpdateReferee = `subscription OnUpdateReferee {
  onUpdateReferee {
    id
    firstName
    lastName
    street
    streetNumber
    streetNumberAddition
    zipCode
    city
    email
    phone
    games {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onDeleteReferee = `subscription OnDeleteReferee {
  onDeleteReferee {
    id
    firstName
    lastName
    street
    streetNumber
    streetNumberAddition
    zipCode
    city
    email
    phone
    games {
      id
      gameDay
      scoreHome
      scoreAway
      hall {
        id
        name
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        sportsHall {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
      }
      homeTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      awayTeam {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      referee {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
    }
    club {
      id
      name
      street
      streetNumber
      streetNumberAddition
      zipCode
      country
      contact
      email
      phone
      sportsHalls {
        items {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          phone
        }
        nextToken
      }
      leagues {
        items {
          id
          name
          ranking
          owner
        }
        nextToken
      }
      teams {
        items {
          id
          leagueId
          name
          contact
          owner
        }
        nextToken
      }
      referees {
        items {
          id
          firstName
          lastName
          street
          streetNumber
          streetNumberAddition
          zipCode
          city
          email
          phone
        }
        nextToken
      }
    }
  }
}
`;
export const onCreateClub = `subscription OnCreateClub {
  onCreateClub {
    id
    name
    street
    streetNumber
    streetNumberAddition
    zipCode
    country
    contact
    email
    phone
    sportsHalls {
      items {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    leagues {
      items {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    teams {
      items {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    referees {
      items {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
  }
}
`;
export const onUpdateClub = `subscription OnUpdateClub {
  onUpdateClub {
    id
    name
    street
    streetNumber
    streetNumberAddition
    zipCode
    country
    contact
    email
    phone
    sportsHalls {
      items {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    leagues {
      items {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    teams {
      items {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    referees {
      items {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
  }
}
`;
export const onDeleteClub = `subscription OnDeleteClub {
  onDeleteClub {
    id
    name
    street
    streetNumber
    streetNumberAddition
    zipCode
    country
    contact
    email
    phone
    sportsHalls {
      items {
        id
        name
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        phone
        halls {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    leagues {
      items {
        id
        name
        ranking
        owner
        teams {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    teams {
      items {
        id
        leagueId
        name
        contact
        owner
        league {
          id
          name
          ranking
          owner
        }
        athletes {
          nextToken
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
    referees {
      items {
        id
        firstName
        lastName
        street
        streetNumber
        streetNumberAddition
        zipCode
        city
        email
        phone
        games {
          id
          gameDay
          scoreHome
          scoreAway
        }
        club {
          id
          name
          street
          streetNumber
          streetNumberAddition
          zipCode
          country
          contact
          email
          phone
        }
      }
      nextToken
    }
  }
}
`;
<file_sep>/src/app/pages/login/login.page.ts
import { Component, AfterContentInit, OnInit } from '@angular/core';
import { AmplifyService } from 'aws-amplify-angular';
import { Router } from '@angular/router';
import { AuthService } from '../../services/auth.service';

@Component({
  selector: 'app-login',
  templateUrl: './login.page.html',
  styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit {

  // signUpConfig = {
  //   header: 'My Customized Sign Up',
  //   hideAllDefaults: true,
  //   defaultCountryCode: '1',
  //   signUpFields: [
  //     {
  //       label: 'Name',
  //       key: 'name',
  //       required: true,
  //       displayOrder: 1,
  //       type: 'string',
  //     },
  //     {
  //       label: 'Email',
  //       key: 'username',
  //       required: true,
  //       displayOrder: 1,
  //       type: 'email',
  //     },
  //     {
  //       label: 'Password',
  //       key: '<PASSWORD>',
  //       required: true,
  //       displayOrder: 2,
  //       type: 'password'
  //     }
  //   ]
  // };

  amplifyService: AmplifyService;

  isLoggedIn = false;
  user: { id: string; username: string; email: string, name: string };

  constructor(
    public amplify: AmplifyService,
    private router: Router,
    private authService: AuthService
  ) {

    this.amplifyService = amplify;

    this.authService.isLoggedIn$.subscribe(
      isLoggedIn => (this.isLoggedIn = isLoggedIn)
    );

    this.authService.auth$.subscribe(({ id, username, email, name }) => {
      this.user = { id, username, email, name };
    });

  }

  async ngOnInit() {
    // Getting the user details will trigger an event to set the auth state correctly.
    if (this.isLoggedIn) {
      this.router.navigate(['/profile']);
    }
  }
}
<file_sep>/src/app/pages/admin/team/team-edit/team-edit.page.ts
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import Amplify, { API, graphqlOperation } from 'aws-amplify';
import * as mutations from '../../../../../graphql/mutations';
import { UpdateTeamInput, DeleteTeamInput } from '../../../../../API';
import { AlertController } from '@ionic/angular';
import { environment } from '../../../../../environments/environment';
import { LeagueDataService } from '../../../../services/league-data.service';
import { GraphqlRequestService } from '../../../../services/graphql-request.service';
import { ToastService } from '../../../../services/toast.service';

@Component({
  selector: 'app-team-edit',
  templateUrl: './team-edit.page.html',
  styleUrls: ['./team-edit.page.scss'],
})
export class TeamEditPage implements OnInit {

  public team = {
    id: null, name: null, contact: null, teamLeagueId: null, teamClubId: environment.clubId, league: { id: null, ranking: null }
  };
  leagues = new Array();
  constructor(
    private route: ActivatedRoute,
    private router: Router,
    public alertController: AlertController,
    private leagueDataService: LeagueDataService,
    private graphqlRequestService: GraphqlRequestService,
    public toastService: ToastService
  ) {

  }

  ngOnInit() {
    const teamId = this.route.snapshot.paramMap.get('teamId');
    this.loadLeagues().then(() =>
      this.loadTeam(teamId)
    );
  }

  async loadLeagues() {
    this.leagues = await this.leagueDataService.getLeagues();
  }

  async processForm() {
    try {
      const updateTeamInput: UpdateTeamInput = {
        id: this.team.id, leagueId: this.team.league.id, teamLeagueId: this.team.league.id, name: this.team.name, contact: this.team.contact
      };

      await this.graphqlRequestService.doPrivateMutation('updateTeam', { input: updateTeamInput });

      if (this.graphqlRequestService.isSuccessfull) {
        this.toastService.presentSuccessToast('Team is bijgewerkt.');
        return this.router.navigate(['/admin/team']);
      }

    } catch (err) {
      console.log(err);
    }
  }

  async loadTeam(teamId) {
    await this.graphqlRequestService.doPrivateQuery('getTeam', { id: teamId });

    if (this.graphqlRequestService.isSuccessfull) {
      this.team = this.graphqlRequestService.data;
      console.log(this.team);
    } else {
      this.toastService.presentWarningToast('Team kon niet worden gevonden.');
      return this.router.navigate(['/admin/team']);
    }
  }

  async presentDeleteAlertConfirm(team) {
    const alert = await this.alertController.create({
      header: 'Waarschuwing!',
      message: 'Weet u zeker dat u het team wil verwijderen?',
      buttons: [
        {
          text: 'Cancel',
          role: 'cancel',
          cssClass: 'secondary',
        }, {
          text: 'Okay',
          cssClass: 'danger',
          handler: () => {
            this.deleteTeam(team);
          }
        }
      ]
    });

    await alert.present();
  }

  async deleteTeam(team) {
    const teamInput: DeleteTeamInput = { id: team.id };
    await API.graphql(graphqlOperation(mutations.deleteTeam, { input: teamInput }));
    return this.router.navigate(['/admin/team']);
  }
}
<file_sep>/src/app/pages/admin/referee/referee-create/referee-create.page.ts
import { Component, OnInit } from '@angular/core';
import { CreateRefereeInput } from 'src/API';
import { Router } from '@angular/router';
import { RefereeService } from '../../../../services/referee.service';

@Component({
  selector: 'app-referee-create',
  templateUrl: './referee-create.page.html',
  styleUrls: ['./referee-create.page.scss'],
})
export class RefereeCreatePage implements OnInit {

  referee: {
    firstName: string, lastName: string, street: string, streetNumber: number, streetNumberAddition: string,
    zipCode: string, city: string, email: string, phone: string
  };

  // initialReferee = {
  //   firstName: 'voornaam', lastName: 'achternaam', street: 'straat', streetNumber: 6, streetNumberAddition: 'a',
  //   zipCode: '1234ab', city: 'stad', email: '<EMAIL>', phone: 'telefoon'
  // };

  initialReferee = {
    firstName: null, lastName: null, street: null, streetNumber: null, streetNumberAddition: null,
    zipCode: null, city: null, email: null, phone: null
  };

  constructor(
    private router: Router
  ) {
    this.referee = this.initialReferee;
  }

  ngOnInit() {

  }

  async processForm(referee) {
    if (referee !== null) {
      return this.router.navigate(['/admin/referee']);
    } else {
      console.log('Didnt get a referee');
    }
  }

}
<file_sep>/src/app/components/referee-form/referee-form.component.ts
import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
import { RefereeService } from 'src/app/services/referee.service';
import { CreateRefereeInput, UpdateRefereeInput } from 'src/API';
import { Referee } from 'src/app/interfaces/referee';
import { environment } from '../../../environments/environment';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';

@Component({
  selector: 'referee-form',
  templateUrl: './referee-form.component.html',
  styleUrls: ['./referee-form.component.scss'],
})
export class RefereeFormComponent implements OnInit {

  @Input() referee: Referee;
  @Input() action: string;
  @Input() refereeId: string;

  @Output() refereeMutated = new EventEmitter<object>();

  refereeForm: FormGroup;
  submitted = false;

  validationMessages = {
    firstName: [
      { type: 'required', message: 'Naam is verplicht.' }
    ],
    lastName: [
      { type: 'required', message: 'Achternaam is verplicht.' }
    ],
    street: [
      { type: 'required', message: 'Straat is verplicht.' }
    ],
    streetNumber: [
      { type: 'required', message: 'Huisnummer is verplicht.' }
    ],
    zipCode: [
      { type: 'required', message: 'Postcode is verplicht.' }
    ],
    city: [
      { type: 'required', message: 'Stad is verplicht.' }
    ],
    email: [
      { type: 'required', message: 'Email is verplicht.' },
      { type: 'email', message: 'Het e-mailadres is niet valide.' }
    ],
    phone: [
      { type: 'required', message: 'Telefoonnummer is verplicht.' }
    ],
  };

  constructor(
    private refereeService: RefereeService,
    private formBuilder: FormBuilder
  ) { }

  ngOnInit() {
    this.refereeForm = this.formBuilder.group({
      firstName: [this.referee.firstName, Validators.required],
      lastName: [this.referee.lastName, Validators.required],
      street: [this.referee.street, Validators.required],
      streetNumber: [this.referee.streetNumber, Validators.required],
      zipCode: [this.referee.zipCode, Validators.required],
      city: [this.referee.city, Validators.required],
      email: [this.referee.email, [Validators.required, Validators.email]],
      phone: [this.referee.phone, [Validators.required]],
    });
  }

  // convenience getter for easy access to form fields
  get f() { return this.refereeForm.controls; }

  async processForm(formValues) {

    // This will trigger the error messages (if there are any)
    this.submitted = true;

    // stop here if form is invalid
    if (this.refereeForm.invalid) {
      return;
    }

    let referee = formValues;
    if (this.action === 'create') {
      // We need to manually set the club id from the environment
      referee.refereeClubId = environment.clubId;
      const createRefereeInput: CreateRefereeInput = referee;

      referee = await this.refereeService.createReferee(createRefereeInput);
    } else if (this.action === 'edit') {
      // assign the referee id to the object.
      referee.id = this.refereeId;
      const updateRefereeInput: UpdateRefereeInput = referee;
      referee = await this.refereeService.updateReferee(updateRefereeInput);
    }

    this.refereeMutated.emit(referee);
  }

  async deleteReferee() {
    const referee = this.refereeService.deleteReferee(this.refereeId);
    this.refereeMutated.emit(referee);
  }
}

languages: SCSS TypeScript HTML GraphQL

repo_language: SCSS