Slowniki: nazwa EN (nameEn) w cwiczeniach/sprzecie/strefach treningowych (migracja, CRUD, seed EN sprzetu+stref, projekcje API, swagger, testy)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Equipment" ADD COLUMN "nameEn" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Exercise" ADD COLUMN "nameEn" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "FocusArea" ADD COLUMN "nameEn" TEXT;
|
||||
@@ -481,6 +481,7 @@ model GymException {
|
||||
model FocusArea {
|
||||
id String @id @default(cuid())
|
||||
name String @unique
|
||||
nameEn String?
|
||||
muscle String @unique
|
||||
description String?
|
||||
/// Recommended weekly volume range in sets (decision 13 — volume warning).
|
||||
@@ -535,6 +536,7 @@ model CircumferenceMeasurement {
|
||||
model Equipment {
|
||||
id String @id @default(cuid())
|
||||
name String @unique
|
||||
nameEn String?
|
||||
kind EquipmentKind @default(OTHER)
|
||||
spec Json?
|
||||
description String?
|
||||
@@ -549,6 +551,7 @@ model Exercise {
|
||||
id String @id @default(cuid())
|
||||
slug String @unique
|
||||
name String
|
||||
nameEn String?
|
||||
primaryMuscle String
|
||||
secondaryMuscles String[]
|
||||
hasReps Boolean @default(true)
|
||||
|
||||
@@ -14,6 +14,7 @@ export function equipmentSlugFromName(name: string): string {
|
||||
export interface EquipmentSeed {
|
||||
slug: string;
|
||||
name: string;
|
||||
nameEn: string;
|
||||
kind: EquipmentKind;
|
||||
spec: EquipmentSpec | null;
|
||||
description: string;
|
||||
@@ -33,6 +34,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'barbell',
|
||||
name: 'Sztanga',
|
||||
nameEn: 'Barbell',
|
||||
kind: 'BARBELL',
|
||||
spec: { maxLoadKg: 100 },
|
||||
description: 'Sztanga z talerzami.',
|
||||
@@ -40,6 +42,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'dumbbells',
|
||||
name: 'Hantle',
|
||||
nameEn: 'Dumbbells',
|
||||
kind: 'DUMBBELL',
|
||||
spec: { minKg: 2.5, maxKg: 25 },
|
||||
description: 'Hantle wolne.',
|
||||
@@ -47,6 +50,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'bodyweight',
|
||||
name: 'Masa ciała',
|
||||
nameEn: 'Bodyweight',
|
||||
kind: 'BODYWEIGHT',
|
||||
spec: null,
|
||||
description: 'Ćwiczenia z masą ciała.',
|
||||
@@ -54,6 +58,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'cable',
|
||||
name: 'Wyciąg',
|
||||
nameEn: 'Cable machine',
|
||||
kind: 'CABLE',
|
||||
spec: { minKg: 5, maxKg: 50 },
|
||||
description: 'Wyciąg linowy.',
|
||||
@@ -61,6 +66,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'dip-bars',
|
||||
name: 'Drążek do dipów',
|
||||
nameEn: 'Dip station',
|
||||
kind: 'BODYWEIGHT',
|
||||
spec: null,
|
||||
description: 'Stojak do dipów.',
|
||||
@@ -68,6 +74,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'pull-up-bar',
|
||||
name: 'Drążek do podciągania',
|
||||
nameEn: 'Pull-up bar',
|
||||
kind: 'BODYWEIGHT',
|
||||
spec: null,
|
||||
description: 'Drążek do podciągania.',
|
||||
@@ -75,6 +82,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'leg-press',
|
||||
name: 'Leg press',
|
||||
nameEn: 'Leg press',
|
||||
kind: 'MACHINE',
|
||||
spec: { minKg: 20, maxKg: 120 },
|
||||
description: 'Maszyna do prostowania nóg.',
|
||||
@@ -82,6 +90,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'leg-curl',
|
||||
name: 'Leg curl',
|
||||
nameEn: 'Leg curl',
|
||||
kind: 'MACHINE',
|
||||
spec: { minKg: 10, maxKg: 60 },
|
||||
description: 'Maszyna do uginania nóg.',
|
||||
@@ -90,6 +99,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'brama',
|
||||
name: 'Brama',
|
||||
nameEn: 'Cable crossover',
|
||||
kind: 'CABLE',
|
||||
spec: { minKg: 5, maxKg: 50 },
|
||||
description: 'Brama siłowa (wyciąg wielostanowiskowy).',
|
||||
@@ -97,6 +107,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'guma-oporowa',
|
||||
name: 'Guma oporowa',
|
||||
nameEn: 'Resistance band',
|
||||
kind: 'OTHER',
|
||||
spec: null,
|
||||
description: 'Guma oporowa do asysty i oporu.',
|
||||
@@ -104,6 +115,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'laweczka-plaska',
|
||||
name: 'Ławeczka płaska',
|
||||
nameEn: 'Flat bench',
|
||||
kind: 'BENCH',
|
||||
spec: { maxLoadKg: 300 },
|
||||
description: 'Ławka płaska ze stojakami.',
|
||||
@@ -111,6 +123,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'laweczka-skosna',
|
||||
name: 'Ławeczka skośna',
|
||||
nameEn: 'Incline bench',
|
||||
kind: 'BENCH',
|
||||
spec: { maxLoadKg: 300 },
|
||||
description: 'Ławka ze skosem dodatnim/ujemnym.',
|
||||
@@ -118,6 +131,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'suwnica-smitha',
|
||||
name: 'Suwnica smitha',
|
||||
nameEn: 'Smith machine',
|
||||
kind: 'MACHINE',
|
||||
spec: { minKg: 5, maxKg: 120 },
|
||||
description: 'Suwnica Smitha.',
|
||||
@@ -125,14 +139,23 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'butterfly',
|
||||
name: 'Butterfly',
|
||||
nameEn: 'Butterfly',
|
||||
kind: 'MACHINE',
|
||||
spec: { minKg: 5, maxKg: 80 },
|
||||
description: 'Maszyna butterfly (rozpiętki).',
|
||||
},
|
||||
{ slug: 'trx', name: 'TRX', kind: 'OTHER', spec: null, description: 'Zawiesia TRX.' },
|
||||
{
|
||||
slug: 'trx',
|
||||
name: 'TRX',
|
||||
nameEn: 'TRX',
|
||||
kind: 'OTHER',
|
||||
spec: null,
|
||||
description: 'Zawiesia TRX.',
|
||||
},
|
||||
{
|
||||
slug: 'porecze-do-dipow',
|
||||
name: 'Poręcze do dipów',
|
||||
nameEn: 'Dip bars',
|
||||
kind: 'BODYWEIGHT',
|
||||
spec: null,
|
||||
description: 'Poręcze do dipów.',
|
||||
@@ -140,6 +163,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'hammer',
|
||||
name: 'Hammer',
|
||||
nameEn: 'Hammer',
|
||||
kind: 'MACHINE',
|
||||
spec: { minKg: 5, maxKg: 100 },
|
||||
description: 'Maszyna hammer strength.',
|
||||
@@ -147,6 +171,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'drazek',
|
||||
name: 'Drążek',
|
||||
nameEn: 'Pull-up bar',
|
||||
kind: 'BODYWEIGHT',
|
||||
spec: null,
|
||||
description: 'Drążek do podciągania i zwisów.',
|
||||
@@ -154,14 +179,23 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'kettlebell',
|
||||
name: 'Kettlebell',
|
||||
nameEn: 'Kettlebell',
|
||||
kind: 'KETTLEBELL',
|
||||
spec: { minKg: 4, maxKg: 32 },
|
||||
description: 'Kettlebell.',
|
||||
},
|
||||
{ slug: 'kolka', name: 'Kółka', kind: 'OTHER', spec: null, description: 'Kółka gimnastyczne.' },
|
||||
{
|
||||
slug: 'kolka',
|
||||
name: 'Kółka',
|
||||
nameEn: 'Gymnastic rings',
|
||||
kind: 'OTHER',
|
||||
spec: null,
|
||||
description: 'Kółka gimnastyczne.',
|
||||
},
|
||||
{
|
||||
slug: 'laweczka-rzymska',
|
||||
name: 'Ławeczka rzymska',
|
||||
nameEn: 'Roman chair',
|
||||
kind: 'BENCH',
|
||||
spec: { maxLoadKg: 150 },
|
||||
description: 'Ławka rzymska (hyperextension).',
|
||||
@@ -169,6 +203,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'shoulder-press',
|
||||
name: 'Shoulder Press',
|
||||
nameEn: 'Shoulder Press',
|
||||
kind: 'MACHINE',
|
||||
spec: { minKg: 5, maxKg: 100 },
|
||||
description: 'Maszyna do wyciskania na barki.',
|
||||
@@ -176,6 +211,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'sztanga-lamana',
|
||||
name: 'Sztanga łamana',
|
||||
nameEn: 'EZ bar',
|
||||
kind: 'BARBELL',
|
||||
spec: { maxLoadKg: 100 },
|
||||
description: 'Sztanga łamana (EZ).',
|
||||
@@ -183,6 +219,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'triceps-press',
|
||||
name: 'Triceps Press',
|
||||
nameEn: 'Triceps Press',
|
||||
kind: 'MACHINE',
|
||||
spec: { minKg: 5, maxKg: 80 },
|
||||
description: 'Maszyna na triceps.',
|
||||
@@ -190,6 +227,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'modlitewnik',
|
||||
name: 'Modlitewnik',
|
||||
nameEn: 'Preacher curl bench',
|
||||
kind: 'BENCH',
|
||||
spec: { maxLoadKg: 60 },
|
||||
description: 'Modlitewnik do uginania biceps.',
|
||||
@@ -197,6 +235,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'pilka-gimnastyczne',
|
||||
name: 'Piłka gimnastyczne',
|
||||
nameEn: 'Exercise ball',
|
||||
kind: 'OTHER',
|
||||
spec: null,
|
||||
description: 'Piłka gimnastyczna (fitball).',
|
||||
@@ -204,6 +243,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'ab-wheel',
|
||||
name: 'Ab wheel',
|
||||
nameEn: 'Ab wheel',
|
||||
kind: 'OTHER',
|
||||
spec: null,
|
||||
description: 'Kółko do brzucha.',
|
||||
@@ -211,6 +251,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'podwyzszenie-schodki',
|
||||
name: 'Podwyższenie / Schodki',
|
||||
nameEn: 'Step platform',
|
||||
kind: 'OTHER',
|
||||
spec: null,
|
||||
description: 'Podwyższenie lub schodki do wchodzenia.',
|
||||
@@ -218,6 +259,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'skrzynia',
|
||||
name: 'Skrzynia',
|
||||
nameEn: 'Plyo box',
|
||||
kind: 'OTHER',
|
||||
spec: null,
|
||||
description: 'Skrzynia plyometryczna.',
|
||||
@@ -225,6 +267,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'leg-extension-leg-curl',
|
||||
name: 'Leg Extension / Leg Curl',
|
||||
nameEn: 'Leg Extension / Leg Curl',
|
||||
kind: 'MACHINE',
|
||||
spec: { minKg: 5, maxKg: 100 },
|
||||
description: 'Maszyna do prostowania i uginania nóg.',
|
||||
@@ -232,6 +275,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'drabinka',
|
||||
name: 'Drabinka',
|
||||
nameEn: 'Wall bars',
|
||||
kind: 'OTHER',
|
||||
spec: null,
|
||||
description: 'Drabinka gimnastyczna.',
|
||||
@@ -239,6 +283,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'kierownica-talerz',
|
||||
name: 'Kierownica/ Talerz',
|
||||
nameEn: 'Handlebar / Plate',
|
||||
kind: 'OTHER',
|
||||
spec: null,
|
||||
description: 'Kierownica trójkątna lub talerz obciążeniowy.',
|
||||
@@ -246,6 +291,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'suwnica-na-nogi',
|
||||
name: 'Suwnica na nogi',
|
||||
nameEn: 'Leg press sledge',
|
||||
kind: 'MACHINE',
|
||||
spec: { minKg: 10, maxKg: 200 },
|
||||
description: 'Suwnica (prasa) na nogi.',
|
||||
@@ -253,6 +299,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'glute-kickback-machine',
|
||||
name: 'Glute Kickback Machine',
|
||||
nameEn: 'Glute Kickback Machine',
|
||||
kind: 'MACHINE',
|
||||
spec: { minKg: 5, maxKg: 80 },
|
||||
description: 'Maszyna na pośladki (kickback).',
|
||||
@@ -260,6 +307,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'adductor',
|
||||
name: 'Adductor',
|
||||
nameEn: 'Adductor',
|
||||
kind: 'MACHINE',
|
||||
spec: { minKg: 5, maxKg: 80 },
|
||||
description: 'Maszyna na przywodziciele/odwodziciele.',
|
||||
@@ -267,6 +315,7 @@ export const EQUIPMENT: EquipmentSeed[] = [
|
||||
{
|
||||
slug: 'maszyna-na-lydki',
|
||||
name: 'Maszyna na łydki',
|
||||
nameEn: 'Calf machine',
|
||||
kind: 'MACHINE',
|
||||
spec: { minKg: 5, maxKg: 120 },
|
||||
description: 'Maszyna do wspięć na palce.',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
export interface ExerciseSeed {
|
||||
slug: string;
|
||||
name: string;
|
||||
nameEn?: string;
|
||||
primaryMuscle: string;
|
||||
secondaryMuscles: string[];
|
||||
equipment: string[];
|
||||
@@ -18,7 +19,7 @@ export interface ExerciseSeed {
|
||||
commonMistakes: string;
|
||||
}
|
||||
|
||||
export const SEED_VERSION = 2;
|
||||
export const SEED_VERSION = 3;
|
||||
|
||||
/**
|
||||
* Katalog cwiczen (seed version 2) — wygenerowany z docs/database/cwiczenia.csv.
|
||||
|
||||
@@ -969,6 +969,7 @@ export function createAdminRoutes({ prisma }: AppDeps) {
|
||||
const focusAreaSchema = z
|
||||
.object({
|
||||
name: z.string().min(1).max(100),
|
||||
nameEn: z.string().max(100).nullable().optional(),
|
||||
muscle: z.string().min(1).max(50),
|
||||
description: z.string().max(500).nullable().optional(),
|
||||
setsMin: z.number().int().min(0).max(100).nullable().optional(),
|
||||
@@ -985,6 +986,7 @@ export function createAdminRoutes({ prisma }: AppDeps) {
|
||||
});
|
||||
const focusAreaUpdateSchema = z.object({
|
||||
name: z.string().min(1).max(100).optional(),
|
||||
nameEn: z.string().max(100).nullable().optional(),
|
||||
muscle: z.string().min(1).max(50).optional(),
|
||||
description: z.string().max(500).nullable().optional(),
|
||||
setsMin: z.number().int().min(0).max(100).nullable().optional(),
|
||||
|
||||
@@ -22,6 +22,7 @@ import { asyncHandler } from '../lib/asyncHandler.js';
|
||||
const equipmentSchema = z
|
||||
.object({
|
||||
name: z.string().min(1).max(100),
|
||||
nameEn: z.string().max(100).nullable().optional(),
|
||||
description: z.string().max(500).nullable().optional(),
|
||||
kind: equipmentKindSchema,
|
||||
spec: z.unknown().optional(),
|
||||
@@ -35,6 +36,7 @@ const equipmentSchema = z
|
||||
/** Partial update — `spec` is validated against the resulting `kind` in the service. */
|
||||
const equipmentUpdateSchema = z.object({
|
||||
name: z.string().min(1).max(100).optional(),
|
||||
nameEn: z.string().max(100).nullable().optional(),
|
||||
description: z.string().max(500).nullable().optional(),
|
||||
kind: equipmentKindSchema.optional(),
|
||||
spec: z.unknown().optional(),
|
||||
|
||||
@@ -29,6 +29,7 @@ const hasFlagsSchema = {
|
||||
|
||||
const exerciseSchema = z.object({
|
||||
name: z.string().min(1).max(100),
|
||||
nameEn: z.string().max(100).nullable().optional(),
|
||||
primaryMuscle: z.string().min(1).max(50),
|
||||
secondaryMuscles: muscleArraySchema.optional(),
|
||||
description: z.string().max(2000).nullable().optional(),
|
||||
@@ -40,6 +41,7 @@ const exerciseSchema = z.object({
|
||||
|
||||
const exerciseUpdateSchema = z.object({
|
||||
name: z.string().min(1).max(100).optional(),
|
||||
nameEn: z.string().max(100).nullable().optional(),
|
||||
primaryMuscle: z.string().min(1).max(50).optional(),
|
||||
secondaryMuscles: muscleArraySchema.optional(),
|
||||
description: z.string().max(2000).nullable().optional(),
|
||||
|
||||
@@ -13,6 +13,7 @@ const prisma = new PrismaClient();
|
||||
*/
|
||||
const FOCUS_AREAS: Array<{
|
||||
name: string;
|
||||
nameEn: string;
|
||||
muscle: string;
|
||||
description: string;
|
||||
setsMin: number;
|
||||
@@ -20,6 +21,7 @@ const FOCUS_AREAS: Array<{
|
||||
}> = [
|
||||
{
|
||||
name: 'Klatka piersiowa',
|
||||
nameEn: 'Chest',
|
||||
muscle: 'chest',
|
||||
description: 'Wyciskanie, rozpiętki, pompki.',
|
||||
setsMin: 10,
|
||||
@@ -27,6 +29,7 @@ const FOCUS_AREAS: Array<{
|
||||
},
|
||||
{
|
||||
name: 'Plecy',
|
||||
nameEn: 'Back',
|
||||
muscle: 'back',
|
||||
description: 'Podciąganie, wiosłowanie, uginanie.',
|
||||
setsMin: 10,
|
||||
@@ -34,6 +37,7 @@ const FOCUS_AREAS: Array<{
|
||||
},
|
||||
{
|
||||
name: 'Nogi',
|
||||
nameEn: 'Legs',
|
||||
muscle: 'legs',
|
||||
description: 'Przysiady, wykroki, prostowanie nóg.',
|
||||
setsMin: 10,
|
||||
@@ -41,6 +45,7 @@ const FOCUS_AREAS: Array<{
|
||||
},
|
||||
{
|
||||
name: 'Pośladki',
|
||||
nameEn: 'Glutes',
|
||||
muscle: 'glutes',
|
||||
description: 'Hip thrust, mostki, wykroki.',
|
||||
setsMin: 8,
|
||||
@@ -48,6 +53,7 @@ const FOCUS_AREAS: Array<{
|
||||
},
|
||||
{
|
||||
name: 'Barki',
|
||||
nameEn: 'Shoulders',
|
||||
muscle: 'shoulders',
|
||||
description: 'Wyciskanie nad głowę, unoszenia.',
|
||||
setsMin: 8,
|
||||
@@ -55,6 +61,7 @@ const FOCUS_AREAS: Array<{
|
||||
},
|
||||
{
|
||||
name: 'Biceps',
|
||||
nameEn: 'Biceps',
|
||||
muscle: 'biceps',
|
||||
description: 'Uginanie, podciąganie.',
|
||||
setsMin: 6,
|
||||
@@ -62,6 +69,7 @@ const FOCUS_AREAS: Array<{
|
||||
},
|
||||
{
|
||||
name: 'Triceps',
|
||||
nameEn: 'Triceps',
|
||||
muscle: 'triceps',
|
||||
description: 'Osiadanie, wyciskanie francuskie.',
|
||||
setsMin: 6,
|
||||
@@ -69,6 +77,7 @@ const FOCUS_AREAS: Array<{
|
||||
},
|
||||
{
|
||||
name: 'Brzuch / core',
|
||||
nameEn: 'Abs / core',
|
||||
muscle: 'core',
|
||||
description: 'Plank, unoszenia nóg, stabilizacja.',
|
||||
setsMin: 8,
|
||||
@@ -76,6 +85,7 @@ const FOCUS_AREAS: Array<{
|
||||
},
|
||||
{
|
||||
name: 'Łydki',
|
||||
nameEn: 'Calves',
|
||||
muscle: 'calves',
|
||||
description: 'Wspięcia na palce, prostowanie na maszynie.',
|
||||
setsMin: 6,
|
||||
@@ -91,8 +101,14 @@ async function seedEquipment() {
|
||||
const spec = eq.spec === null ? Prisma.JsonNull : (eq.spec as Prisma.InputJsonValue);
|
||||
await prisma.equipment.upsert({
|
||||
where: { name: eq.name },
|
||||
update: { description: eq.description, kind: eq.kind, spec },
|
||||
create: { name: eq.name, description: eq.description, kind: eq.kind, spec },
|
||||
update: { nameEn: eq.nameEn, description: eq.description, kind: eq.kind, spec },
|
||||
create: {
|
||||
name: eq.name,
|
||||
nameEn: eq.nameEn,
|
||||
description: eq.description,
|
||||
kind: eq.kind,
|
||||
spec,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log(`Seeded ${EQUIPMENT.length} equipment items`);
|
||||
@@ -148,6 +164,7 @@ async function seedExercises() {
|
||||
create: {
|
||||
slug: ex.slug,
|
||||
name: ex.name,
|
||||
nameEn: ex.nameEn ?? null,
|
||||
primaryMuscle: ex.primaryMuscle,
|
||||
secondaryMuscles: ex.secondaryMuscles,
|
||||
equipment: { connect: equipmentIds.map((id) => ({ id })) },
|
||||
@@ -200,12 +217,14 @@ async function seedFocusAreas() {
|
||||
where: { muscle: fa.muscle },
|
||||
update: {
|
||||
name: fa.name,
|
||||
nameEn: fa.nameEn,
|
||||
description: fa.description,
|
||||
setsMin: fa.setsMin,
|
||||
setsMax: fa.setsMax,
|
||||
},
|
||||
create: {
|
||||
name: fa.name,
|
||||
nameEn: fa.nameEn,
|
||||
muscle: fa.muscle,
|
||||
description: fa.description,
|
||||
setsMin: fa.setsMin,
|
||||
|
||||
@@ -20,7 +20,7 @@ export async function getCalendar(prisma: PrismaClient, userId: string, month?:
|
||||
},
|
||||
include: {
|
||||
exercises: {
|
||||
include: { exercise: { select: { name: true, primaryMuscle: true } } },
|
||||
include: { exercise: { select: { name: true, nameEn: true, primaryMuscle: true } } },
|
||||
},
|
||||
},
|
||||
orderBy: { date: 'asc' },
|
||||
@@ -35,6 +35,7 @@ export async function getCalendar(prisma: PrismaClient, userId: string, month?:
|
||||
dayOfWeek: d.dayOfWeek,
|
||||
exercises: d.exercises.map((e) => ({
|
||||
name: e.exercise.name,
|
||||
nameEn: e.exercise.nameEn,
|
||||
muscle: e.exercise.primaryMuscle,
|
||||
})),
|
||||
})),
|
||||
|
||||
@@ -84,7 +84,7 @@ export async function getDashboard(prisma: PrismaClient, userId: string) {
|
||||
let nextTraining: {
|
||||
dayId: string;
|
||||
date: string;
|
||||
exercises: { name: string; muscle: string }[];
|
||||
exercises: { name: string; nameEn: string | null; muscle: string }[];
|
||||
} | null = null;
|
||||
let progress: { completed: number; total: number; percent: number } | null = null;
|
||||
let extra: { sets: number } | null = null;
|
||||
@@ -128,7 +128,9 @@ export async function getDashboard(prisma: PrismaClient, userId: string) {
|
||||
const days = await prisma.planDay.findMany({
|
||||
where: { week: { planId: activePlan.id } },
|
||||
include: {
|
||||
exercises: { include: { exercise: { select: { name: true, primaryMuscle: true } } } },
|
||||
exercises: {
|
||||
include: { exercise: { select: { name: true, nameEn: true, primaryMuscle: true } } },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -142,6 +144,7 @@ export async function getDashboard(prisma: PrismaClient, userId: string) {
|
||||
date: upcoming.date!.toISOString(),
|
||||
exercises: upcoming.exercises.map((e) => ({
|
||||
name: e.exercise.name,
|
||||
nameEn: e.exercise.nameEn,
|
||||
muscle: e.exercise.primaryMuscle,
|
||||
})),
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
/** `spec` is validated against `kind` inside the service (unknown at the boundary). */
|
||||
export interface EquipmentInput {
|
||||
name: string;
|
||||
nameEn?: string | null;
|
||||
description?: string | null;
|
||||
kind: EquipmentKind;
|
||||
spec?: unknown;
|
||||
@@ -17,6 +18,7 @@ export interface EquipmentInput {
|
||||
|
||||
export interface EquipmentUpdateInput {
|
||||
name?: string;
|
||||
nameEn?: string | null;
|
||||
description?: string | null;
|
||||
kind?: EquipmentKind;
|
||||
spec?: unknown;
|
||||
@@ -50,6 +52,7 @@ export async function createEquipment(prisma: PrismaClient, data: EquipmentInput
|
||||
const item = await prisma.equipment.create({
|
||||
data: {
|
||||
name: data.name,
|
||||
nameEn: data.nameEn ?? null,
|
||||
description: data.description ?? null,
|
||||
kind: data.kind,
|
||||
spec: toPrismaSpec(checked.spec),
|
||||
@@ -81,6 +84,7 @@ export async function updateEquipment(
|
||||
where: { id },
|
||||
data: {
|
||||
name: data.name,
|
||||
nameEn: data.nameEn,
|
||||
description: data.description,
|
||||
kind,
|
||||
spec: toPrismaSpec(checked.spec),
|
||||
|
||||
@@ -12,6 +12,7 @@ export interface ExerciseProgressPoint {
|
||||
export interface ExerciseProgress {
|
||||
exerciseId: string;
|
||||
name: string;
|
||||
nameEn: string | null;
|
||||
muscle: string;
|
||||
/** Ascending, one point per COMPLETED session. */
|
||||
points: ExerciseProgressPoint[];
|
||||
@@ -25,6 +26,7 @@ export interface RawSet {
|
||||
export interface RawExercise {
|
||||
exerciseId: string;
|
||||
name: string;
|
||||
nameEn: string | null;
|
||||
muscle: string;
|
||||
sets: RawSet[];
|
||||
}
|
||||
@@ -43,7 +45,7 @@ export interface RawSession {
|
||||
export function aggregateExerciseProgress(sessions: RawSession[]): ExerciseProgress[] {
|
||||
const byExercise = new Map<
|
||||
string,
|
||||
{ name: string; muscle: string; points: ExerciseProgressPoint[] }
|
||||
{ name: string; nameEn: string | null; muscle: string; points: ExerciseProgressPoint[] }
|
||||
>();
|
||||
for (const s of sessions) {
|
||||
for (const ex of s.exercises) {
|
||||
@@ -63,6 +65,7 @@ export function aggregateExerciseProgress(sessions: RawSession[]): ExerciseProgr
|
||||
}
|
||||
const entry = byExercise.get(ex.exerciseId) ?? {
|
||||
name: ex.name,
|
||||
nameEn: ex.nameEn,
|
||||
muscle: ex.muscle,
|
||||
points: [],
|
||||
};
|
||||
@@ -81,6 +84,7 @@ export function aggregateExerciseProgress(sessions: RawSession[]): ExerciseProgr
|
||||
.map(([exerciseId, v]) => ({
|
||||
exerciseId,
|
||||
name: v.name,
|
||||
nameEn: v.nameEn,
|
||||
muscle: v.muscle,
|
||||
points: [...v.points].sort((a, b) => a.date.localeCompare(b.date)),
|
||||
}));
|
||||
@@ -94,6 +98,7 @@ export interface LatestExerciseSet {
|
||||
export interface LatestExerciseResult {
|
||||
exerciseId: string;
|
||||
name: string;
|
||||
nameEn: string | null;
|
||||
muscle: string;
|
||||
/** ISO date of the most recent COMPLETED session that included the exercise. */
|
||||
date: string;
|
||||
@@ -109,13 +114,17 @@ export interface LatestExerciseResult {
|
||||
* sets are returned raw (reps/loadKg, null when unrecorded) for plan prefill.
|
||||
*/
|
||||
export function latestExerciseResults(sessions: RawSession[]): LatestExerciseResult[] {
|
||||
const latest = new Map<string, { name: string; muscle: string; date: string; sets: RawSet[] }>();
|
||||
const latest = new Map<
|
||||
string,
|
||||
{ name: string; nameEn: string | null; muscle: string; date: string; sets: RawSet[] }
|
||||
>();
|
||||
for (const s of sessions) {
|
||||
for (const ex of s.exercises) {
|
||||
const existing = latest.get(ex.exerciseId);
|
||||
if (!existing || s.date > existing.date) {
|
||||
latest.set(ex.exerciseId, {
|
||||
name: ex.name,
|
||||
nameEn: ex.nameEn,
|
||||
muscle: ex.muscle,
|
||||
date: s.date,
|
||||
sets: ex.sets,
|
||||
@@ -133,6 +142,7 @@ export function latestExerciseResults(sessions: RawSession[]): LatestExerciseRes
|
||||
return {
|
||||
exerciseId,
|
||||
name: v.name,
|
||||
nameEn: v.nameEn,
|
||||
muscle: v.muscle,
|
||||
date: v.date,
|
||||
sets: v.sets.map((st) => ({ reps: st.reps, loadKg: st.loadKg })),
|
||||
@@ -154,7 +164,7 @@ export async function getExerciseProgress(prisma: PrismaClient, userId: string)
|
||||
where: { removed: false, hidden: false },
|
||||
orderBy: { order: 'asc' },
|
||||
include: {
|
||||
exercise: { select: { id: true, name: true, primaryMuscle: true } },
|
||||
exercise: { select: { id: true, name: true, nameEn: true, primaryMuscle: true } },
|
||||
sets: {
|
||||
where: { removed: false },
|
||||
orderBy: { index: 'asc' },
|
||||
@@ -169,6 +179,7 @@ export async function getExerciseProgress(prisma: PrismaClient, userId: string)
|
||||
exercises: s.exercises.map((e) => ({
|
||||
exerciseId: e.exercise.id,
|
||||
name: e.exercise.name,
|
||||
nameEn: e.exercise.nameEn,
|
||||
muscle: e.exercise.primaryMuscle,
|
||||
sets: e.sets.map((st) => ({ reps: st.reps, loadKg: st.planSet?.loadKg ?? null })),
|
||||
})),
|
||||
@@ -199,7 +210,7 @@ export async function getLatestExerciseResults(prisma: PrismaClient, userId: str
|
||||
where: { removed: false, hidden: false },
|
||||
orderBy: { order: 'asc' },
|
||||
include: {
|
||||
exercise: { select: { id: true, name: true, primaryMuscle: true } },
|
||||
exercise: { select: { id: true, name: true, nameEn: true, primaryMuscle: true } },
|
||||
sets: {
|
||||
where: { removed: false },
|
||||
orderBy: { index: 'asc' },
|
||||
@@ -214,6 +225,7 @@ export async function getLatestExerciseResults(prisma: PrismaClient, userId: str
|
||||
exercises: s.exercises.map((e) => ({
|
||||
exerciseId: e.exercise.id,
|
||||
name: e.exercise.name,
|
||||
nameEn: e.exercise.nameEn,
|
||||
muscle: e.exercise.primaryMuscle,
|
||||
sets: e.sets.map((st) => ({ reps: st.reps, loadKg: st.planSet?.loadKg ?? null })),
|
||||
})),
|
||||
|
||||
@@ -4,6 +4,7 @@ import { conflict, notFound } from '../lib/errors.js';
|
||||
|
||||
export interface ExerciseInput {
|
||||
name: string;
|
||||
nameEn?: string | null;
|
||||
primaryMuscle: string;
|
||||
secondaryMuscles?: string[];
|
||||
description?: string | null;
|
||||
@@ -80,6 +81,7 @@ export async function createExercise(prisma: PrismaClient, data: ExerciseInput)
|
||||
data: {
|
||||
slug,
|
||||
name: data.name,
|
||||
nameEn: data.nameEn ?? null,
|
||||
primaryMuscle: data.primaryMuscle,
|
||||
secondaryMuscles: data.secondaryMuscles ?? [],
|
||||
description: data.description ?? null,
|
||||
@@ -118,6 +120,7 @@ export async function updateExercise(
|
||||
where: { id },
|
||||
data: {
|
||||
name: data.name,
|
||||
nameEn: data.nameEn,
|
||||
primaryMuscle: data.primaryMuscle,
|
||||
secondaryMuscles: data.secondaryMuscles,
|
||||
description: data.description,
|
||||
|
||||
@@ -4,6 +4,7 @@ import { badRequest, conflict, notFound } from '../lib/errors.js';
|
||||
|
||||
export interface FocusAreaInput {
|
||||
name: string;
|
||||
nameEn?: string | null;
|
||||
muscle: string;
|
||||
description?: string | null;
|
||||
setsMin?: number | null;
|
||||
@@ -44,6 +45,7 @@ export async function createFocusArea(prisma: PrismaClient, data: FocusAreaInput
|
||||
const focusArea = await prisma.focusArea.create({
|
||||
data: {
|
||||
name: data.name,
|
||||
nameEn: data.nameEn ?? null,
|
||||
muscle: data.muscle,
|
||||
description: data.description ?? null,
|
||||
setsMin: data.setsMin ?? null,
|
||||
@@ -68,6 +70,7 @@ export async function updateFocusArea(
|
||||
where: { id },
|
||||
data: {
|
||||
name: data.name,
|
||||
nameEn: data.nameEn,
|
||||
muscle: data.muscle,
|
||||
description: data.description,
|
||||
setsMin,
|
||||
|
||||
@@ -4,6 +4,7 @@ import { notFound } from '../lib/errors.js';
|
||||
interface PlanExerciseRef {
|
||||
id: string;
|
||||
name: string;
|
||||
nameEn: string | null;
|
||||
primaryMuscle: string;
|
||||
secondaryMuscles: string[];
|
||||
}
|
||||
@@ -42,6 +43,7 @@ export async function getFocusChain(prisma: PrismaClient, userId: string) {
|
||||
uniqueExercises.set(ex.exerciseId, {
|
||||
id: ex.exercise.id,
|
||||
name: ex.exercise.name,
|
||||
nameEn: ex.exercise.nameEn,
|
||||
primaryMuscle: ex.exercise.primaryMuscle,
|
||||
secondaryMuscles: ex.exercise.secondaryMuscles,
|
||||
});
|
||||
@@ -59,6 +61,7 @@ export async function getFocusChain(prisma: PrismaClient, userId: string) {
|
||||
muscles.map((muscle) => ({
|
||||
muscle,
|
||||
name: focusAreaMap.get(muscle)?.name ?? muscle,
|
||||
nameEn: focusAreaMap.get(muscle)?.nameEn ?? null,
|
||||
exercises: exercises.filter(
|
||||
(p) => p.primaryMuscle === muscle || p.secondaryMuscles.includes(muscle),
|
||||
),
|
||||
|
||||
@@ -259,7 +259,7 @@ export async function getHistory(prisma: PrismaClient, userId: string, month?: s
|
||||
where: { removed: false },
|
||||
orderBy: { order: 'asc' },
|
||||
include: {
|
||||
exercise: { select: { name: true, primaryMuscle: true } },
|
||||
exercise: { select: { name: true, nameEn: true, primaryMuscle: true } },
|
||||
sets: {
|
||||
where: { removed: false },
|
||||
orderBy: { index: 'asc' },
|
||||
@@ -308,6 +308,7 @@ export async function getHistory(prisma: PrismaClient, userId: string, month?: s
|
||||
exercises: exercises.map((e) => ({
|
||||
id: e.id,
|
||||
name: e.exercise.name,
|
||||
nameEn: e.exercise.nameEn,
|
||||
muscle: e.exercise.primaryMuscle,
|
||||
isExtra: e.planExerciseId === null,
|
||||
comments: e.comments.map((c) => ({
|
||||
|
||||
@@ -100,6 +100,7 @@ export interface MessageAttachment {
|
||||
plan: string;
|
||||
exercise: {
|
||||
name: string;
|
||||
nameEn: string | null;
|
||||
sets: {
|
||||
index: number;
|
||||
reps: number | null;
|
||||
@@ -113,7 +114,7 @@ export interface MessageAttachment {
|
||||
}[];
|
||||
} | null;
|
||||
/** Only when exercise == null. */
|
||||
exercises: { name: string; setsDone: number; setsTotal: number }[];
|
||||
exercises: { name: string; nameEn: string | null; setsDone: number; setsTotal: number }[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +144,7 @@ export async function getConversation(prisma: PrismaClient, userId: string, coac
|
||||
where: { removed: false, hidden: false },
|
||||
orderBy: { order: 'asc' },
|
||||
include: {
|
||||
exercise: { select: { name: true } },
|
||||
exercise: { select: { name: true, nameEn: true } },
|
||||
sets: { where: { removed: false } },
|
||||
},
|
||||
},
|
||||
@@ -151,7 +152,7 @@ export async function getConversation(prisma: PrismaClient, userId: string, coac
|
||||
},
|
||||
sessionExercise: {
|
||||
include: {
|
||||
exercise: { select: { name: true } },
|
||||
exercise: { select: { name: true, nameEn: true } },
|
||||
sets: {
|
||||
where: { removed: false },
|
||||
orderBy: { index: 'asc' },
|
||||
@@ -196,12 +197,12 @@ function buildAttachment(m: {
|
||||
startedAt: Date;
|
||||
day: { week: { plan: { title: string } } };
|
||||
exercises: {
|
||||
exercise: { name: string };
|
||||
exercise: { name: string; nameEn: string | null };
|
||||
sets: { reps: number | null }[];
|
||||
}[];
|
||||
} | null;
|
||||
sessionExercise: {
|
||||
exercise: { name: string };
|
||||
exercise: { name: string; nameEn: string | null };
|
||||
sets: {
|
||||
index: number;
|
||||
reps: number | null;
|
||||
@@ -226,6 +227,7 @@ function buildAttachment(m: {
|
||||
if (m.sessionExercise) {
|
||||
attachment.exercise = {
|
||||
name: m.sessionExercise.exercise.name,
|
||||
nameEn: m.sessionExercise.exercise.nameEn,
|
||||
sets: m.sessionExercise.sets.map((st) => ({
|
||||
index: st.index,
|
||||
reps: st.reps,
|
||||
@@ -243,6 +245,7 @@ function buildAttachment(m: {
|
||||
} else {
|
||||
attachment.exercises = m.session.exercises.map((e) => ({
|
||||
name: e.exercise.name,
|
||||
nameEn: e.exercise.nameEn,
|
||||
setsDone: e.sets.filter((st) => st.reps != null).length,
|
||||
setsTotal: e.sets.length,
|
||||
}));
|
||||
|
||||
@@ -146,7 +146,7 @@ export async function getDay(prisma: PrismaClient, dayId: string, userId: string
|
||||
sessions: { orderBy: { startedAt: 'desc' } },
|
||||
exercises: {
|
||||
orderBy: { order: 'asc' },
|
||||
include: { exercise: { select: { name: true, primaryMuscle: true } } },
|
||||
include: { exercise: { select: { name: true, nameEn: true, primaryMuscle: true } } },
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -162,6 +162,7 @@ export async function getDay(prisma: PrismaClient, dayId: string, userId: string
|
||||
exercises: day.exercises.map((e) => ({
|
||||
id: e.id,
|
||||
name: e.exercise.name,
|
||||
nameEn: e.exercise.nameEn,
|
||||
muscle: e.exercise.primaryMuscle,
|
||||
})),
|
||||
},
|
||||
|
||||
@@ -575,6 +575,7 @@ export const openapi: Record<string, unknown> = {
|
||||
required: ['name'],
|
||||
properties: {
|
||||
name: { type: 'string' },
|
||||
nameEn: { type: 'string', nullable: true },
|
||||
description: { type: 'string', nullable: true },
|
||||
},
|
||||
},
|
||||
@@ -617,6 +618,7 @@ export const openapi: Record<string, unknown> = {
|
||||
required: ['name', 'primaryMuscle'],
|
||||
properties: {
|
||||
name: { type: 'string' },
|
||||
nameEn: { type: 'string', nullable: true },
|
||||
primaryMuscle: { type: 'string' },
|
||||
secondaryMuscles: { type: 'array', items: { type: 'string' } },
|
||||
description: { type: 'string', nullable: true },
|
||||
@@ -744,6 +746,7 @@ export const openapi: Record<string, unknown> = {
|
||||
required: ['name', 'muscle'],
|
||||
properties: {
|
||||
name: { type: 'string' },
|
||||
nameEn: { type: 'string', nullable: true },
|
||||
muscle: { type: 'string' },
|
||||
description: { type: 'string', nullable: true },
|
||||
setsMin: { type: 'integer', nullable: true, minimum: 0, maximum: 100 },
|
||||
|
||||
@@ -231,9 +231,13 @@ describe('admin routes', () => {
|
||||
ownerId: ownerId2,
|
||||
});
|
||||
const id = created.body.gym.id;
|
||||
const res = await app.delete(`/api/v1/admin/gyms/${id}`).set('Authorization', `Bearer ${adminToken}`);
|
||||
const res = await app
|
||||
.delete(`/api/v1/admin/gyms/${id}`)
|
||||
.set('Authorization', `Bearer ${adminToken}`);
|
||||
expect(res.status).toBe(204);
|
||||
const again = await app.delete(`/api/v1/admin/gyms/${id}`).set('Authorization', `Bearer ${adminToken}`);
|
||||
const again = await app
|
||||
.delete(`/api/v1/admin/gyms/${id}`)
|
||||
.set('Authorization', `Bearer ${adminToken}`);
|
||||
expect(again.status).toBe(404);
|
||||
});
|
||||
|
||||
@@ -512,9 +516,13 @@ describe('admin routes', () => {
|
||||
it('deletes a user', async () => {
|
||||
const app = buildApp();
|
||||
const { user } = await createUser();
|
||||
const res = await app.delete(`/api/v1/admin/users/${user.id}`).set('Authorization', `Bearer ${adminToken}`);
|
||||
const res = await app
|
||||
.delete(`/api/v1/admin/users/${user.id}`)
|
||||
.set('Authorization', `Bearer ${adminToken}`);
|
||||
expect(res.status).toBe(204);
|
||||
const again = await app.delete(`/api/v1/admin/users/${user.id}`).set('Authorization', `Bearer ${adminToken}`);
|
||||
const again = await app
|
||||
.delete(`/api/v1/admin/users/${user.id}`)
|
||||
.set('Authorization', `Bearer ${adminToken}`);
|
||||
expect(again.status).toBe(404);
|
||||
});
|
||||
|
||||
@@ -526,9 +534,14 @@ describe('admin routes', () => {
|
||||
const res = await app
|
||||
.post('/api/v1/admin/focus-areas')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
.send({ name, muscle, description: 'opis' });
|
||||
.send({ name, nameEn: 'Puzzle', muscle, description: 'opis' });
|
||||
expect(res.status).toBe(201);
|
||||
expect(res.body.focusArea).toMatchObject({ name, muscle, description: 'opis' });
|
||||
expect(res.body.focusArea).toMatchObject({
|
||||
name,
|
||||
nameEn: 'Puzzle',
|
||||
muscle,
|
||||
description: 'opis',
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects a duplicate focus area muscle with 409', async () => {
|
||||
@@ -579,7 +592,12 @@ describe('admin routes', () => {
|
||||
const res = await app
|
||||
.post('/api/v1/admin/focus-areas')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
.send({ name: 'Zly zakres', muscle: `bad-range-${Math.random().toString(36).slice(2)}`, setsMin: 20, setsMax: 10 });
|
||||
.send({
|
||||
name: 'Zly zakres',
|
||||
muscle: `bad-range-${Math.random().toString(36).slice(2)}`,
|
||||
setsMin: 20,
|
||||
setsMax: 10,
|
||||
});
|
||||
expect(res.status).toBe(400);
|
||||
});
|
||||
|
||||
@@ -621,7 +639,9 @@ describe('admin routes', () => {
|
||||
.send({ name: `Licznik CW ${muscle}`, primaryMuscle: muscle });
|
||||
expect(exercise.status).toBe(201);
|
||||
|
||||
const res = await app.get('/api/v1/admin/focus-areas').set('Authorization', `Bearer ${adminToken}`);
|
||||
const res = await app
|
||||
.get('/api/v1/admin/focus-areas')
|
||||
.set('Authorization', `Bearer ${adminToken}`);
|
||||
expect(res.status).toBe(200);
|
||||
const area = res.body.focusAreas.find((a: { id: string }) => a.id === areaId);
|
||||
expect(area.exercisesCount).toBe(1);
|
||||
@@ -639,6 +659,7 @@ describe('admin routes', () => {
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
.send({
|
||||
name: `Cardio ${suffix}`,
|
||||
nameEn: `Cardio EN ${suffix}`,
|
||||
primaryMuscle: 'quads',
|
||||
hasReps: false,
|
||||
hasLoad: false,
|
||||
@@ -649,6 +670,7 @@ describe('admin routes', () => {
|
||||
});
|
||||
expect(res.status).toBe(201);
|
||||
expect(res.body.exercise).toMatchObject({
|
||||
nameEn: `Cardio EN ${suffix}`,
|
||||
hasReps: false,
|
||||
hasLoad: false,
|
||||
hasRir: false,
|
||||
@@ -667,7 +689,9 @@ describe('admin routes', () => {
|
||||
expect(patched.status).toBe(200);
|
||||
expect(patched.body.exercise).toMatchObject({ hasSpeed: true, hasCardio: true, hasTime: true });
|
||||
|
||||
const listed = await app.get('/api/v1/admin/exercises').set('Authorization', `Bearer ${adminToken}`);
|
||||
const listed = await app
|
||||
.get('/api/v1/admin/exercises')
|
||||
.set('Authorization', `Bearer ${adminToken}`);
|
||||
const item = listed.body.exercises.find((e: { id: string }) => e.id === id);
|
||||
expect(item).toMatchObject({ hasSpeed: true, planExercisesCount: 0 });
|
||||
|
||||
|
||||
@@ -31,6 +31,36 @@ describe('equipment catalog (kind + spec)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('stores and updates the English name (nameEn)', async () => {
|
||||
const app = buildApp();
|
||||
const res = await app
|
||||
.post('/api/v1/admin/equipment')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
.send({
|
||||
name: `Ławka ${rand()}`,
|
||||
nameEn: 'Bench',
|
||||
kind: 'BENCH',
|
||||
spec: { maxLoadKg: 300 },
|
||||
});
|
||||
expect(res.status).toBe(201);
|
||||
expect(res.body.equipment.nameEn).toBe('Bench');
|
||||
|
||||
const id = res.body.equipment.id as string;
|
||||
const patched = await app
|
||||
.patch(`/api/v1/admin/equipment/${id}`)
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
.send({ nameEn: 'Flat bench' });
|
||||
expect(patched.status).toBe(200);
|
||||
expect(patched.body.equipment.nameEn).toBe('Flat bench');
|
||||
|
||||
const cleared = await app
|
||||
.patch(`/api/v1/admin/equipment/${id}`)
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
.send({ nameEn: null });
|
||||
expect(cleared.status).toBe(200);
|
||||
expect(cleared.body.equipment.nameEn).toBeNull();
|
||||
});
|
||||
|
||||
it('rejects a missing spec for a load-bearing kind with 400', async () => {
|
||||
const app = buildApp();
|
||||
const res = await app
|
||||
@@ -127,12 +157,18 @@ describe('equipment catalog (kind + spec)', () => {
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
.send({ name: names.bodyweight, kind: 'BODYWEIGHT' });
|
||||
|
||||
const res = await app.get('/api/v1/admin/equipment').set('Authorization', `Bearer ${adminToken}`);
|
||||
const res = await app
|
||||
.get('/api/v1/admin/equipment')
|
||||
.set('Authorization', `Bearer ${adminToken}`);
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.body.equipment).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ name: names.barbell, kind: 'BARBELL', spec: { maxLoadKg: 100 } }),
|
||||
expect.objectContaining({ name: names.dumbbell, kind: 'DUMBBELL', spec: { minKg: 2.5, maxKg: 25 } }),
|
||||
expect.objectContaining({
|
||||
name: names.dumbbell,
|
||||
kind: 'DUMBBELL',
|
||||
spec: { minKg: 2.5, maxKg: 25 },
|
||||
}),
|
||||
expect.objectContaining({ name: names.bodyweight, kind: 'BODYWEIGHT', spec: null }),
|
||||
]),
|
||||
);
|
||||
@@ -161,13 +197,17 @@ describe('equipment catalog (kind + spec)', () => {
|
||||
.send({ equipmentId });
|
||||
expect(linked.status).toBe(200);
|
||||
|
||||
const res = await app.get('/api/v1/admin/equipment').set('Authorization', `Bearer ${adminToken}`);
|
||||
const res = await app
|
||||
.get('/api/v1/admin/equipment')
|
||||
.set('Authorization', `Bearer ${adminToken}`);
|
||||
expect(res.status).toBe(200);
|
||||
const item = res.body.equipment.find((e: { id: string }) => e.id === equipmentId);
|
||||
expect(item).toMatchObject({ exercisesCount: 1, gymsCount: 1 });
|
||||
|
||||
// sprzątanie
|
||||
await app.delete(`/api/v1/admin/exercises/${exercise.body.exercise.id}`).set('Authorization', `Bearer ${adminToken}`);
|
||||
await app
|
||||
.delete(`/api/v1/admin/exercises/${exercise.body.exercise.id}`)
|
||||
.set('Authorization', `Bearer ${adminToken}`);
|
||||
await app
|
||||
.delete(`/api/v1/admin/gyms/${gym.id}/equipment/${linked.body.instance.id}`)
|
||||
.set('Authorization', `Bearer ${adminToken}`);
|
||||
|
||||
@@ -1025,7 +1025,9 @@ describe('trainer — trainee calendar', () => {
|
||||
expect(res.body.month).toBe('2026-08');
|
||||
expect(res.body.days).toHaveLength(2);
|
||||
expect(res.body.days[0]).toMatchObject({ status: 'COMPLETED', dayOfWeek: 1 });
|
||||
expect(res.body.days[0].exercises).toEqual([{ name: 'CalSquat', muscle: 'chest' }]);
|
||||
expect(res.body.days[0].exercises).toEqual([
|
||||
{ name: 'CalSquat', nameEn: null, muscle: 'chest' },
|
||||
]);
|
||||
expect(res.body.days[1]).toMatchObject({ status: 'PLANNED', dayOfWeek: 4 });
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user