import { ESearchExerciceFilter } from "@/enum/enum.search-filter.exercice"; import { AbstractServiceApi } from "../api/service.api.abstract"; import { UpdateExerciceDTO } from "../dto/dto.catalog"; import { DeleteDTO } from "../dto/dto.generic"; import { ExerciceDTO } from "../dto/dto.training"; import { ICatalogService } from "../interface/service.interface.catalog"; export class CatalogServiceStub extends AbstractServiceApi implements ICatalogService { exercices: ExerciceDTO[] = [ { Id: "1", Name: "Pompes", Description: "Exercice classique de renforcement des pectoraux et triceps.", Duration: 60, Image: "https://example.com/images/pompes.jpg", Video: "https://example.com/videos/pompes.mp4", NbSet: 3, NbRep: 15, Target: "ARM", RestTime: 0, Passed: false, }, { Id: "2", Name: "Squats", Description: "Travail les jambes, les fessiers et le tronc.", Duration: 90, Image: "https://example.com/images/squats.jpg", Video: "https://example.com/videos/squats.mp4", NbSet: 4, NbRep: 20, Target: "LEG", RestTime: 0, Passed: false, }, { Id: "3", Name: "Gainage", Description: "Renforcement du tronc, gainage statique.", Duration: 45, Image: "https://example.com/images/gainage.jpg", Video: "https://example.com/videos/gainage.mp4", NbSet: 3, NbRep: 1, Target: "CARDIO", RestTime: 0, Passed: false, }, { Id: "4", Name: "Fentes", Description: "Renforcement des jambes, bon pour l'équilibre.", Duration: 80, Image: "https://example.com/images/fentes.jpg", Video: "https://example.com/videos/fentes.mp4", NbSet: 3, NbRep: 12, Target: "LEG", RestTime: 0, Passed: false, }, { Id: "5", Name: "Abdominaux", Description: "Travail des muscles abdominaux avec crunchs.", Duration: 60, Image: "https://example.com/images/abdos.jpg", Video: "https://example.com/videos/abdos.mp4", NbSet: 4, NbRep: 20, Target: "ARM", RestTime: 0, Passed: false, }, ]; getAllExercices(): Promise { return Promise.resolve(this.exercices); } getExercices(spec: ESearchExerciceFilter): Promise { return Promise.resolve(this.exercices); } getExercice(id: string): Promise { return Promise.resolve(this.exercices.find((x) => x.Id === id)); } addExercice(exercice: ExerciceDTO): Promise { this.exercices.push(exercice); return Promise.resolve(exercice); } editExercice( id: string, exercice: UpdateExerciceDTO ): Promise { const ex = this.exercices.find((x) => x.Id === id); if (ex != null) { Object.entries(exercice).forEach(([key, value]) => { if (value !== undefined) { // @ts-ignore : typage des clés non dynamique ex[key] = value; } }); } return Promise.resolve(ex); } deleteExercice(id: string): Promise { const dto: DeleteDTO = { Id: id, }; return Promise.resolve(dto); } }