-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d6d9f5
commit 015920f
Showing
8 changed files
with
161 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
apps/fantalytic-mobile/src/app/fantasy-football/const/fantasy-football.const.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { PositionTypes } from '../../../../../../libs/fantalytic-shared/src/index'; | ||
|
||
export const FANTASY_FOOTBALL_STAT_HEADER_MAP = { | ||
[PositionTypes.QB]: { | ||
passingYds: 'Yds', | ||
ints: 'Ints', | ||
passingYdsPerAttempt: 'Yds Per Att', | ||
tds: 'TDs' | ||
}, | ||
[PositionTypes.RB]: { | ||
rushingYds: 'Yds', | ||
rushAttempts: 'Attempts', | ||
rushingTds: 'TDs', | ||
rushing20Yds: '20+ Yd' | ||
}, | ||
[PositionTypes.WR]: { | ||
receptions: 'Rec', | ||
receivingYds: ' Yds', | ||
receivingTds: 'TDs', | ||
receiving20Plus: '20+ Yd', | ||
receiving40Plus: '40+ Yd', | ||
receivingTargets: 'Targets' | ||
}, | ||
[PositionTypes.DEF]: { | ||
rushYdsAllowed: 'Rush Yds', | ||
ydsPerCarry: 'Yds / Carry', | ||
rushTdsAllowed: 'Rush TDs', | ||
completionPctAllowed: 'Comp %', | ||
passYdsAllowed: 'Pass Yds', | ||
ints: 'Ints', | ||
sacks: 'Sacks' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
apps/fantalytic-mobile/src/app/fantasy-football/player-detail/player-detail.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-buttons slot="start"> | ||
<ion-back-button></ion-back-button> | ||
</ion-buttons> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content *ngIf="player$ | async as player"> | ||
|
||
<ion-card> | ||
<img [src]="player.imageUrl" /> | ||
<ion-card-header>{{player.player}}</ion-card-header> | ||
</ion-card> | ||
|
||
<ion-card-content> | ||
<ion-grid> | ||
<ion-row> | ||
<ion-col *ngFor="let stat of player.stats"> | ||
{{stat.text}} | ||
</ion-col> | ||
</ion-row> | ||
<ion-row> | ||
<ion-col *ngFor="let stat of player.stats"> | ||
{{player[stat.key]}} | ||
</ion-col> | ||
</ion-row> | ||
</ion-grid> | ||
</ion-card-content> | ||
</ion-content> |
Empty file.
22 changes: 22 additions & 0 deletions
22
.../fantalytic-mobile/src/app/fantasy-football/player-detail/player-detail.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PlayerDetailComponent } from './player-detail.component'; | ||
|
||
describe('PlayerDetailComponent', () => { | ||
let component: PlayerDetailComponent; | ||
let fixture: ComponentFixture<PlayerDetailComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [PlayerDetailComponent], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(PlayerDetailComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
65 changes: 65 additions & 0 deletions
65
apps/fantalytic-mobile/src/app/fantasy-football/player-detail/player-detail.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* eslint-disable arrow-body-style */ | ||
import { Component, inject } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { combineLatest, EMPTY, map, shareReplay, switchMap } from 'rxjs'; | ||
import { Store } from '@ngrx/store'; | ||
import { getDefenses, getPosition, getQbs, getRbs, getReceivers } from '../ngrx/selectors/fantasy-football.selectors'; | ||
import { PositionTypes } from '../../../../../../libs/fantalytic-shared/src'; | ||
import { IonicModule } from '@ionic/angular'; | ||
import { FANTASY_FOOTBALL_STAT_HEADER_MAP } from '../const/fantasy-football.const'; | ||
|
||
@Component({ | ||
selector: 'pmt-player-detail', | ||
standalone: true, | ||
imports: [CommonModule, IonicModule], | ||
templateUrl: './player-detail.component.html', | ||
styleUrls: ['./player-detail.component.scss'], | ||
}) | ||
export class PlayerDetailComponent { | ||
|
||
private _route = inject(ActivatedRoute); | ||
private _store = inject(Store); | ||
currentPosition$ = this._store.select(getPosition).pipe(shareReplay(1)); | ||
players$ = this.currentPosition$.pipe( | ||
switchMap(position => { | ||
switch(position) { | ||
case PositionTypes.QB: { | ||
return this._store.select(getQbs); | ||
} | ||
case PositionTypes.RB: { | ||
return this._store.select(getRbs); | ||
} | ||
case PositionTypes.WR: { | ||
return this._store.select(getReceivers); | ||
} | ||
case PositionTypes.DEF: { | ||
return this._store.select(getDefenses); | ||
} | ||
default: | ||
return EMPTY; | ||
} | ||
}) | ||
); | ||
player$ = combineLatest([this.players$, this._route.params, this.currentPosition$]).pipe( | ||
map(([players, params, currentPosition]) => { | ||
const selectedPlayer = (players as any[]).find(player => player.id === params.id); | ||
// we only want to show a subset of stats | ||
const stats = Object.keys(selectedPlayer) | ||
.filter(key => !key.includes('id') | ||
&& !key.includes('player') | ||
&& !key.includes('team') | ||
&& !key.includes('year') | ||
&& !key.includes('week') && !key.includes('imageUrl')) | ||
.map(stat => { | ||
const header = FANTASY_FOOTBALL_STAT_HEADER_MAP[currentPosition][stat]; | ||
return {key: stat, text: header}; | ||
}); | ||
return { | ||
...selectedPlayer, | ||
stats | ||
}; | ||
}) | ||
); | ||
|
||
} |