diff --git a/src/app/components/challenge-card/challenge-card.component.html b/src/app/components/challenge-card/challenge-card.component.html index 7e76a40..b795c64 100644 --- a/src/app/components/challenge-card/challenge-card.component.html +++ b/src/app/components/challenge-card/challenge-card.component.html @@ -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() }} @@ -36,7 +36,7 @@ Défi Quotidien - + diff --git a/src/app/components/challenge-card/challenge-card.component.ts b/src/app/components/challenge-card/challenge-card.component.ts index b96bef7..1632644 100644 --- a/src/app/components/challenge-card/challenge-card.component.ts +++ b/src/app/components/challenge-card/challenge-card.component.ts @@ -25,34 +25,17 @@ export class ChallengeCardComponent { color = input.required(); data = input.required(); - selectedChallenge = signal(null); - proof = viewChild('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) } } } \ No newline at end of file diff --git a/src/app/services/api/.openapi-generator/FILES b/src/app/services/api/.openapi-generator/FILES index ab03aca..f4904d9 100644 --- a/src/app/services/api/.openapi-generator/FILES +++ b/src/app/services/api/.openapi-generator/FILES @@ -43,7 +43,6 @@ model/login-dto.ts model/models.ts model/patch-user-designation-dto.ts model/patch-user-password-dto.ts -model/random-challenge-proof-request.ts model/refresh-token-dto.ts model/update-user-dto.ts model/user-proof-request.ts diff --git a/src/app/services/api/api/randomchallenges.service.ts b/src/app/services/api/api/randomchallenges.service.ts index 56d04b1..e86bbb0 100644 --- a/src/app/services/api/api/randomchallenges.service.ts +++ b/src/app/services/api/api/randomchallenges.service.ts @@ -18,8 +18,6 @@ import { OpenApiHttpParams, QueryParamStyle } from '../query.params'; // @ts-ignore import { GetRandomChallengeDto } from '../model/get-random-challenge-dto'; -// @ts-ignore -import { RandomChallengeProofRequest } from '../model/random-challenge-proof-request'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; @@ -152,21 +150,18 @@ export class RandomchallengesService extends BaseService { /** * @endpoint patch /API/RandomChallenges/{randomChallengeId}/Proof * @param randomChallengeId - * @param randomChallengeProofRequest + * @param proof * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. * @param options additional options */ - public patchProofEndpoint(randomChallengeId: number, randomChallengeProofRequest: RandomChallengeProofRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable; - public patchProofEndpoint(randomChallengeId: number, randomChallengeProofRequest: RandomChallengeProofRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable>; - public patchProofEndpoint(randomChallengeId: number, randomChallengeProofRequest: RandomChallengeProofRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable>; - public patchProofEndpoint(randomChallengeId: number, randomChallengeProofRequest: RandomChallengeProofRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable { + public patchProofEndpoint(randomChallengeId: number, proof?: Blob, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable; + public patchProofEndpoint(randomChallengeId: number, proof?: Blob, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable>; + public patchProofEndpoint(randomChallengeId: number, proof?: Blob, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable>; + public patchProofEndpoint(randomChallengeId: number, proof?: Blob, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable { if (randomChallengeId === null || randomChallengeId === undefined) { throw new Error('Required parameter randomChallengeId was null or undefined when calling patchProofEndpoint.'); } - if (randomChallengeProofRequest === null || randomChallengeProofRequest === undefined) { - throw new Error('Required parameter randomChallengeProofRequest was null or undefined when calling patchProofEndpoint.'); - } let localVarHeaders = this.defaultHeaders; @@ -183,14 +178,27 @@ export class RandomchallengesService extends BaseService { const localVarTransferCache: boolean = options?.transferCache ?? true; - // to determine the Content-Type header const consumes: string[] = [ - 'application/json' + 'multipart/form-data' ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + + const canConsumeForm = this.canConsumeForm(consumes); + + let localVarFormParams: { append(param: string, value: any): any; }; + let localVarUseForm = false; + let localVarConvertFormParamsToString = false; + // use FormData to transmit files using content-type "multipart/form-data" + // see https://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data + localVarUseForm = canConsumeForm; + if (localVarUseForm) { + localVarFormParams = new FormData(); + } else { + localVarFormParams = new HttpParams({encoder: this.encoder}); + } + + if (proof !== undefined) { + localVarFormParams = localVarFormParams.append('proof', proof) as any || localVarFormParams; } let responseType_: 'text' | 'json' | 'blob' = 'json'; @@ -209,7 +217,7 @@ export class RandomchallengesService extends BaseService { return this.httpClient.request('patch', `${basePath}${localVarPath}`, { context: localVarHttpContext, - body: randomChallengeProofRequest, + body: localVarConvertFormParamsToString ? localVarFormParams.toString() : localVarFormParams, responseType: responseType_, ...(withCredentials ? { withCredentials } : {}), headers: localVarHeaders, diff --git a/src/app/services/api/model/models.ts b/src/app/services/api/model/models.ts index 4b3bac8..4e6c56b 100644 --- a/src/app/services/api/model/models.ts +++ b/src/app/services/api/model/models.ts @@ -23,7 +23,6 @@ export * from './get-user-stats-dto'; export * from './login-dto'; export * from './patch-user-designation-dto'; export * from './patch-user-password-dto'; -export * from './random-challenge-proof-request'; export * from './refresh-token-dto'; export * from './update-user-dto'; export * from './user-proof-request'; diff --git a/src/app/services/api/model/random-challenge-proof-request.ts b/src/app/services/api/model/random-challenge-proof-request.ts deleted file mode 100644 index c2e29f0..0000000 --- a/src/app/services/api/model/random-challenge-proof-request.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * BeReadyBackend - * - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -export interface RandomChallengeProofRequest { - proof?: Blob | null; -} -