Archived exercises hidden from selects. Password fields Show Password toggle

This commit is contained in:
AG
2025-12-18 21:11:40 +02:00
parent b6cb3059af
commit b32f47c2b5
9 changed files with 103 additions and 32 deletions

Binary file not shown.

View File

@@ -7,7 +7,8 @@ export class ExerciseController {
static async getAllExercises(req: any, res: Response) {
try {
const userId = req.user.userId;
const exercises = await ExerciseService.getAllExercises(userId);
const includeArchived = req.query.includeArchived === 'true';
const exercises = await ExerciseService.getAllExercises(userId, includeArchived);
return sendSuccess(res, exercises);
} catch (error) {
logger.error('Error in getAllExercises', { error });

View File

@@ -1,12 +1,17 @@
import prisma from '../lib/prisma';
export class ExerciseService {
static async getAllExercises(userId: string) {
static async getAllExercises(userId: string, includeArchived: boolean = false) {
const exercises = await prisma.exercise.findMany({
where: {
OR: [
{ userId: null }, // System default
{ userId } // User custom
AND: [
{
OR: [
{ userId: null }, // System default
{ userId } // User custom
]
},
includeArchived ? {} : { isArchived: false }
]
}
});