Added functions to send and see proof before valid participation from random challenge
This commit is contained in:
@@ -17,16 +17,16 @@
|
||||
<ion-content style="--background: #f7f6f2;">
|
||||
<div class="mt-4">
|
||||
<app-title-part textInfo="Défi bonus du jour"></app-title-part>
|
||||
<app-challenge-card action="Regarder" tag="+1 pts" color=""></app-challenge-card>
|
||||
<app-challenge-card [data]="randomChallenge()" action="Regarder" tag="+1 pts" color=""></app-challenge-card>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<app-title-part textInfo="Vote en attente"></app-title-part>
|
||||
<app-challenge-card action="Voir" tag="Vote" color=""></app-challenge-card>
|
||||
<app-challenge-card [data]="randomChallenge()" action="Voir" tag="Vote" color=""></app-challenge-card>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<app-title-part textInfo="Défis en cours"></app-title-part>
|
||||
<app-challenge-card action="Participer" tag="Défis" color=""></app-challenge-card>
|
||||
<app-challenge-card [data]="randomChallenge()" action="Participer" tag="Défis" color=""></app-challenge-card>
|
||||
</div>
|
||||
</ion-content>
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {IonicModule} from "@ionic/angular";
|
||||
import {addIcons} from "ionicons";
|
||||
import {walkOutline, addOutline} from "ionicons/icons";
|
||||
import {TitlePartComponent} from "../../components/title-part/title-part.component";
|
||||
import {ChallengeCardComponent} from "../../components/challenge-card/challenge-card.component";
|
||||
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||
import {IonicModule, ToastController} from "@ionic/angular";
|
||||
import { addIcons } from "ionicons";
|
||||
import { walkOutline, addOutline } from "ionicons/icons";
|
||||
import { TitlePartComponent } from "../../components/title-part/title-part.component";
|
||||
import { ChallengeCardComponent } from "../../components/challenge-card/challenge-card.component";
|
||||
import * as signalR from '@microsoft/signalr';
|
||||
import {GetRandomChallengeDto, RandomchallengesService} from "../../services/api";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
|
||||
addIcons({
|
||||
'profile': walkOutline,
|
||||
@@ -20,5 +23,46 @@ addIcons({
|
||||
ChallengeCardComponent
|
||||
]
|
||||
})
|
||||
export class HomeComponent {
|
||||
}
|
||||
export class HomeComponent implements OnInit {
|
||||
|
||||
// private connection: signalR.HubConnection;
|
||||
//
|
||||
// ngOnInit(): void {
|
||||
// this.connection = new signalR.HubConnectionBuilder()
|
||||
// .withUrl('http://localhost:5235/timeHub', {
|
||||
// withCredentials: true
|
||||
// })
|
||||
// .build();
|
||||
//
|
||||
// this.connection.on('ReceiveTime', (time) => {
|
||||
// console.log('Server time:', time);
|
||||
// });
|
||||
//
|
||||
// this.connection.start()
|
||||
// .then(() => {
|
||||
// console.log('Connected to SignalR');
|
||||
// this.connection.invoke('SendTime');
|
||||
// })
|
||||
// .catch(err => console.error('Connection error:', err));
|
||||
// }
|
||||
|
||||
private randomChallengeService = inject(RandomchallengesService)
|
||||
private toastCtrl = inject(ToastController);
|
||||
|
||||
randomChallenge = signal<GetRandomChallengeDto>({});
|
||||
|
||||
async ngOnInit() {
|
||||
try {
|
||||
const randomChallenge = await firstValueFrom(this.randomChallengeService.generateRandomChallengeEndpoint());
|
||||
this.randomChallenge.set(randomChallenge);
|
||||
}
|
||||
catch {
|
||||
const toast = await this.toastCtrl.create({
|
||||
message: 'Impossible de générer un défi aléatoire',
|
||||
duration: 2000,
|
||||
color: 'danger'
|
||||
});
|
||||
await toast.present();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user