You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

321 lines
9.2 KiB

  1. import { Component, OnInit, ViewChild } from '@angular/core';
  2. import { IonSlides, ModalController } from '@ionic/angular';
  3. import * as moment from 'moment';
  4. import { ChatPage } from '../chat/chat.page';
  5. import * as faker from 'faker';
  6. import { Router } from '@angular/router';
  7. import { AddPartyPage } from '../add-party/add-party.page';
  8. export type IscoreCard = {
  9. teamName: string,
  10. teamLogo: string,
  11. batting: Array<{
  12. name: string,
  13. jersey: number,
  14. score: number,
  15. ballsPlayed: number,
  16. wicketTo?: string,
  17. boundaries: number,
  18. sixes: number
  19. }>,
  20. bowling: Array<{
  21. name: string,
  22. jersey: number,
  23. runs: number,
  24. overs: number,
  25. wickets: number
  26. }>,
  27. totalScore: number,
  28. totalWickets: number,
  29. overs: number,
  30. extras: number
  31. }
  32. @Component({
  33. selector: 'app-live',
  34. templateUrl: './live.page.html',
  35. styleUrls: ['./live.page.scss'],
  36. })
  37. export class LivePage implements OnInit {
  38. @ViewChild('slides') slides: IonSlides;
  39. showScoreCard: boolean = true;
  40. showFixtures: boolean = false;
  41. selectedIndex: number = 0;
  42. slideOpts = {
  43. slidesPerView: 1.5,
  44. spaceBetween: 15,
  45. initialSlide: 0,
  46. centeredSlides: true,
  47. simulateTouch: false,
  48. followFinger: false,
  49. };
  50. matchStats: {
  51. stadium: string,
  52. homeTeam: IscoreCard,
  53. awayTeam: IscoreCard
  54. };
  55. teams = [{
  56. name: 'RCB',
  57. image: 'https://i.pinimg.com/originals/4f/f9/99/4ff99925fd51296daf76425b11c04195.jpg'
  58. }, {
  59. name: 'MI',
  60. image: 'assets/logos/mi.svg',
  61. }, {
  62. name: 'CSK',
  63. image: 'https://www.searchpng.com/wp-content/uploads/2019/02/Chennai-Super-Kings-Logo-PNG-Image-.png'
  64. }];
  65. stadiums = [{
  66. name: 'Chinnaswamy',
  67. sideView: 'https://www.royalchallengers.com/PRRCB01/public/styles/1061x767_landscape/public/2020-04/275679.jpg?h=61617f72&itok=6xKgHpE-',
  68. topView: 'assets/home-team/stadium-tv.svg',
  69. }, {
  70. name: 'IS Bindra',
  71. sideView: 'https://5.imimg.com/data5/VO/UB/MY-3103550/ae-cricket-stadium-lighting-500x500.jpg',
  72. topView: 'assets/home-team/stadium-tv.svg'
  73. }, {
  74. name: 'Chidambaram Stadium',
  75. sideView: 'https://sportzwiki.com/wp-content/uploads/2019/03/11.jpg',
  76. topView: 'assets/home-team/stadium-tv.svg',
  77. }];
  78. bookingSeatsData: Array<{
  79. dateTime: Date,
  80. staduim: {
  81. name: string,
  82. topView: string,
  83. sideView: string,
  84. },
  85. matchType: string,
  86. matchDetails: {
  87. home: {
  88. name: string,
  89. image: string,
  90. },
  91. away: {
  92. name: string,
  93. image: string,
  94. }
  95. },
  96. seatsAvailable: Array<{
  97. stand: 'Grand' | 'Pavilion' | 'First' | 'Second',
  98. seats: Array<{
  99. id: number | string,
  100. price: number
  101. }>
  102. }>
  103. }> = [];
  104. showAddParty: boolean = false;
  105. constructor(
  106. public modalController: ModalController,
  107. private router: Router
  108. ) { }
  109. getFormattedDateTime(dateTime: Date) {
  110. return moment(dateTime).format('DD MMM');
  111. }
  112. getEventDateTime(dateTime: Date) {
  113. return moment(dateTime).format('ddd, MMM DD YYYY hh:mm a');
  114. }
  115. selectIndex() {
  116. this.slides.getActiveIndex().then((index) => this.selectedIndex = index);
  117. }
  118. ngOnInit() {
  119. for (let i = 0; i < 3; i += 1) {
  120. this.bookingSeatsData.push({
  121. dateTime: faker.date.future(),
  122. staduim : this.stadiums[i],
  123. matchType: 'T20 League',
  124. matchDetails: {
  125. home: i !==1 ? this.teams[i] : { name: 'KXIP', image: 'assets/home-team/KXIP.svg' },
  126. away: i ===1 ? this.teams[i] : { name: 'KXIP', image: 'assets/home-team/KXIP.svg' }
  127. },
  128. seatsAvailable: [{
  129. stand: 'Grand',
  130. seats: [],
  131. }, {
  132. stand: 'Pavilion',
  133. seats: [],
  134. }, {
  135. stand: 'First',
  136. seats: [],
  137. }, {
  138. stand: 'Second',
  139. seats: [],
  140. }]
  141. });
  142. }
  143. for (let i = 0; i < this.bookingSeatsData.length; i += 1) {
  144. for (let j = 0; j < this.bookingSeatsData[i].seatsAvailable.length; j += 1) {
  145. let price = faker.commerce.price();
  146. let randomNumber = Math.random() * (15 - 0) + 0;
  147. for (let k = 0; k < randomNumber; k += 1) {
  148. this.bookingSeatsData[i].seatsAvailable[j].seats.push({
  149. id: this.bookingSeatsData[i].seatsAvailable[j].stand + '##' + k.toString(),
  150. price
  151. });
  152. }
  153. }
  154. }
  155. this.matchStats = {
  156. stadium: 'IS Bindra',
  157. homeTeam: {
  158. teamName: 'KXIP',
  159. teamLogo: 'assets/home-team/KXIP.svg',
  160. batting: [{
  161. name: 'V Sehwag',
  162. jersey: 44,
  163. score: 62,
  164. ballsPlayed: 30,
  165. wicketTo: 'c Sachin, b D.Steyn',
  166. boundaries: 8,
  167. sixes: 4,
  168. }, {
  169. name: 'KL Rahul',
  170. jersey: 10,
  171. score: 85,
  172. ballsPlayed: 80,
  173. boundaries: 10,
  174. sixes: 3,
  175. }, {
  176. name: 'G Maxwell',
  177. jersey: 11,
  178. score: 10,
  179. ballsPlayed: 10,
  180. boundaries: 0,
  181. sixes: 1,
  182. }],
  183. bowling: [{
  184. name: 'Harmeet Singh',
  185. jersey: 13,
  186. runs: 22,
  187. overs: 2,
  188. wickets: 1
  189. }, {
  190. name: 'Mishra',
  191. jersey: 25,
  192. runs: 10,
  193. overs: 1,
  194. wickets: 0
  195. }],
  196. totalScore: 157,
  197. overs: 20,
  198. extras: 0,
  199. totalWickets: 1,
  200. },
  201. awayTeam : {
  202. teamName: 'MI',
  203. teamLogo: 'assets/logos/mi.svg',
  204. batting: [{
  205. name: 'S Tendulkar',
  206. jersey: 10,
  207. score: 10,
  208. ballsPlayed: 12,
  209. wicketTo: 'b H.Singh',
  210. boundaries: 0,
  211. sixes: 1,
  212. }, {
  213. name: 'K Pollard',
  214. jersey: 22,
  215. score: 44,
  216. ballsPlayed: 11,
  217. boundaries: 1,
  218. sixes: 5,
  219. }, {
  220. name: 'D Bravo',
  221. jersey: 38,
  222. score: 5,
  223. ballsPlayed: 3,
  224. boundaries: 1,
  225. sixes: 0,
  226. }],
  227. bowling: [{
  228. name: 'D Steyn',
  229. jersey: 12,
  230. runs: 55,
  231. overs: 4,
  232. wickets: 1
  233. }, {
  234. name: 'D Bravo',
  235. jersey: 38,
  236. runs: 40,
  237. overs: 4,
  238. wickets: 0
  239. }, {
  240. name: 'S Tendulkar',
  241. jersey: 10,
  242. runs: 25,
  243. overs: 4,
  244. wickets: 0
  245. }, {
  246. name: 'Trent Boult',
  247. jersey: 17,
  248. runs: 37,
  249. overs: 4,
  250. wickets: 0
  251. }],
  252. totalScore: 60,
  253. overs: 3.2,
  254. extras: 1,
  255. totalWickets: 1,
  256. }
  257. }
  258. if (localStorage.isPartyChatOn = 'no') {
  259. this.showAddParty = true;
  260. }
  261. }
  262. async presentChatModal() {
  263. const modal = await this.modalController.create({
  264. component: ChatPage,
  265. });
  266. return await modal.present();
  267. }
  268. async presentAddChatModal() {
  269. const modal = await this.modalController.create({
  270. component: AddPartyPage,
  271. });
  272. modal.onDidDismiss().then((data) => {
  273. if(data.data.createParty) {
  274. this.showAddParty = false;
  275. }
  276. });
  277. return await modal.present();
  278. }
  279. showBookingDetails(matchData) {
  280. this.router.navigate(['/booking-details' , { matchData: JSON.stringify(matchData) }]);
  281. }
  282. showBookingDetailsByIndex() {
  283. let index = this.selectedIndex;
  284. this.router.navigate(['/booking-details' , { matchData: JSON.stringify(this.bookingSeatsData[index]) }]);
  285. }
  286. showMatchDetails() {
  287. this.router.navigate(['/match-details', { matchStats: JSON.stringify(this.matchStats) }]);
  288. }
  289. }