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.
Mobile/api/service/stub/service.stub.catalog.tsx

121 lines
3.2 KiB

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<ExerciceDTO[]> {
return Promise.resolve(this.exercices);
}
getExercices(spec: ESearchExerciceFilter): Promise<ExerciceDTO[]> {
return Promise.resolve(this.exercices);
}
getExercice(id: string): Promise<ExerciceDTO | undefined> {
return Promise.resolve(this.exercices.find((x) => x.Id === id));
}
addExercice(exercice: ExerciceDTO): Promise<ExerciceDTO> {
this.exercices.push(exercice);
return Promise.resolve(exercice);
}
editExercice(
id: string,
exercice: UpdateExerciceDTO
): Promise<UpdateExerciceDTO | undefined> {
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<DeleteDTO> {
const dto: DeleteDTO = {
Id: id,
};
return Promise.resolve(dto);
}
}