Fixed error with sending of proofs

This commit is contained in:
2026-04-12 22:10:09 +01:00
parent 6ab77fe800
commit 5ca9954b0b
6 changed files with 29 additions and 56 deletions
@@ -23,7 +23,7 @@
fill="clear"
class="m-0 p-0 min-h-0 text-[11px] font-black bg-black text-white rounded-3xl"
style="--padding-top: 4px; --padding-bottom: 4px;"
(touchstart)="setOpen(true, data().id)">
(touchstart)="setOpen(true)">
{{ action() }}
</ion-button>
</div>
@@ -36,7 +36,7 @@
<ion-toolbar>
<ion-title>Défi Quotidien</ion-title>
<ion-buttons slot="start" style="--ion-color-primary: #0054E9;">
<ion-back-button default-href="" (touchstart)="setOpen(false, null)"></ion-back-button>
<ion-back-button default-href="" (touchstart)="setOpen(false)"></ion-back-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
@@ -25,34 +25,17 @@ export class ChallengeCardComponent {
color = input.required<string>();
data = input.required<GetRandomChallengeDto>();
selectedChallenge = signal<GetRandomChallengeDto>(null);
proof = viewChild<ProofFormComponent>('proofForm');
isModalOpen = false;
async setOpen(isOpen: boolean, randomChallengeId: number) {
if (isOpen) {
try {
const userInfo = await firstValueFrom(this.randomChallengesService.getRandomChallengeEndpoint(randomChallengeId));
this.selectedChallenge.set(userInfo);
this.isModalOpen = isOpen;
} catch {
const toast = await this.toastCtrl.create({
message: 'Impossible de charger les données du défi',
duration: 2000,
color: 'danger'
});
await toast.present();
}
}
async setOpen(isOpen: boolean) {
this.isModalOpen = isOpen;
}
async sendProof(randomChallengeId: number) {
const file = this.proof().proofForm.value.proof;
try {
await firstValueFrom(this.randomChallengesService.patchProofEndpoint(randomChallengeId, file));
await firstValueFrom(this.randomChallengesService.patchProofEndpoint(randomChallengeId, this.proof().proofForm.value.proof));
this.isModalOpen = false;
const toast = await this.toastCtrl.create({
@@ -68,7 +51,6 @@ export class ChallengeCardComponent {
color: 'danger'
});
await toast.present();
console.log(err)
}
}
}