Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

134 righe
2.8 KiB

  1. import { Component, OnInit, Input } from '@angular/core';
  2. import { MatchService } from '../../services/match.service';
  3. import { ToastService } from '../../services/toast.service';
  4. interface HighestScoreDetails {
  5. score: {
  6. is_no: string;
  7. balls_faced: string;
  8. text: string;
  9. };
  10. match_id: string;
  11. match_date: string;
  12. vs: any;
  13. }
  14. interface BattingRecord {
  15. matches: string;
  16. innings: string;
  17. not_outs: string;
  18. runs: string;
  19. balls_faced: string;
  20. hundreds: string;
  21. fifties: string;
  22. fours: string;
  23. sixes: string;
  24. average: string;
  25. strike_rate: string;
  26. hs: HighestScoreDetails;
  27. }
  28. interface BestBowlingDetails {
  29. figure: {
  30. wickets: string;
  31. runs_given: string;
  32. text: string;
  33. };
  34. match_id: string;
  35. match_date: string;
  36. vs: HighestScoreDetails;
  37. }
  38. interface BowlingRecord {
  39. matches: string;
  40. innings: string;
  41. overs: string;
  42. balls_bowled: string;
  43. maidens: string;
  44. runs: string;
  45. wickets: string;
  46. average: string;
  47. strike_rate: string;
  48. economy_rate: string;
  49. four_wk_hauls: string;
  50. five_wk_hauls: string;
  51. best_bowling: BestBowlingDetails;
  52. }
  53. interface FieldingRecord {
  54. catches: string;
  55. stumpings: string;
  56. run_outs: string;
  57. }
  58. interface StatsForFormat {
  59. comp_type_id: string;
  60. comp_type: string;
  61. rankings: {
  62. bat: string;
  63. bowl: string;
  64. };
  65. overall: {
  66. batting_record: BattingRecord;
  67. bowling_record: BowlingRecord;
  68. fielding_record: FieldingRecord;
  69. }
  70. }
  71. interface RawPlayerTeamDetails {
  72. id: string;
  73. active: string;
  74. is_primary: string;
  75. is_international: string;
  76. text: string;
  77. }
  78. interface RawPlayerProfile {
  79. player_id: string;
  80. last_updated: string;
  81. fullname: string;
  82. name: string;
  83. dob: string;
  84. date_of_death: string;
  85. place_birth: string;
  86. nick_name: string;
  87. majorteams: {
  88. team: Array<RawPlayerTeamDetails>;
  89. };
  90. stats: {
  91. format: Array<StatsForFormat>;
  92. };
  93. }
  94. export interface RawPlayerData {
  95. profile: RawPlayerProfile;
  96. }
  97. @Component({
  98. selector: 'app-player-details',
  99. templateUrl: './player-details.component.html',
  100. styleUrls: ['./player-details.component.scss'],
  101. })
  102. export class PlayerDetailsComponent implements OnInit {
  103. @Input() playerId: string;
  104. playerDetails: RawPlayerData;
  105. constructor(
  106. private matchService: MatchService,
  107. private toastService: ToastService
  108. ) { }
  109. ngOnInit() {
  110. this.matchService.getPlayerDetails(this.playerId).then((data: RawPlayerData) => {
  111. console.log(data);
  112. this.playerDetails = data;
  113. }, (err) => {
  114. console.log(err);
  115. this.toastService.presentToastWithOptions("Failed to fetch player details", "danger");
  116. });
  117. }
  118. }