@wger-project/react-components 25.10.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +58 -0
- package/build/OpenSans-Bold.woff +0 -0
- package/build/OpenSans-Light.woff +0 -0
- package/build/assets/index.css +1 -0
- package/build/chunks/browser-ponyfill-DL_vVusK.js +3 -0
- package/build/chunks/browser-ponyfill-DL_vVusK.js.map +1 -0
- package/build/favicon.ico +0 -0
- package/build/index.html +60 -0
- package/build/locales/README.md +10 -0
- package/build/locales/ar/translation.json +240 -0
- package/build/locales/ca/translation.json +35 -0
- package/build/locales/cs/translation.json +257 -0
- package/build/locales/de/translation.json +338 -0
- package/build/locales/el/translation.json +97 -0
- package/build/locales/en/translation.json +332 -0
- package/build/locales/es/translation.json +335 -0
- package/build/locales/fa/translation.json +127 -0
- package/build/locales/fr/translation.json +341 -0
- package/build/locales/he/translation.json +146 -0
- package/build/locales/hr/translation.json +249 -0
- package/build/locales/it/translation.json +338 -0
- package/build/locales/ko/translation.json +331 -0
- package/build/locales/nb_NO/translation.json +50 -0
- package/build/locales/nl/translation.json +242 -0
- package/build/locales/pl/translation.json +261 -0
- package/build/locales/pt/translation.json +342 -0
- package/build/locales/pt_BR/translation.json +259 -0
- package/build/locales/pt_PT/translation.json +334 -0
- package/build/locales/ru/translation.json +116 -0
- package/build/locales/sk/translation.json +10 -0
- package/build/locales/sl/translation.json +326 -0
- package/build/locales/sr/translation.json +240 -0
- package/build/locales/sv/translation.json +165 -0
- package/build/locales/ta/translation.json +331 -0
- package/build/locales/th/translation.json +27 -0
- package/build/locales/tr/translation.json +238 -0
- package/build/locales/uk/translation.json +339 -0
- package/build/locales/uz/translation.json +56 -0
- package/build/locales/vi/translation.json +70 -0
- package/build/locales/zh_Hans/translation.json +336 -0
- package/build/locales/zh_Hant/translation.json +246 -0
- package/build/logo192.png +0 -0
- package/build/logo512.png +0 -0
- package/build/main.js +542 -0
- package/build/main.js.map +1 -0
- package/build/manifest.json +25 -0
- package/build/muscles/SOURCES +2 -0
- package/build/muscles/main/muscle-1.svg +72 -0
- package/build/muscles/main/muscle-10.svg +73 -0
- package/build/muscles/main/muscle-11.svg +72 -0
- package/build/muscles/main/muscle-12.svg +72 -0
- package/build/muscles/main/muscle-13.svg +92 -0
- package/build/muscles/main/muscle-14.svg +73 -0
- package/build/muscles/main/muscle-15.svg +72 -0
- package/build/muscles/main/muscle-16.svg +73 -0
- package/build/muscles/main/muscle-2.svg +72 -0
- package/build/muscles/main/muscle-3.svg +72 -0
- package/build/muscles/main/muscle-4.svg +72 -0
- package/build/muscles/main/muscle-5.svg +72 -0
- package/build/muscles/main/muscle-6.svg +73 -0
- package/build/muscles/main/muscle-7.svg +72 -0
- package/build/muscles/main/muscle-8.svg +72 -0
- package/build/muscles/main/muscle-9.svg +72 -0
- package/build/muscles/muscular_system_back.svg +118 -0
- package/build/muscles/muscular_system_front.svg +99 -0
- package/build/muscles/secondary/muscle-1.svg +72 -0
- package/build/muscles/secondary/muscle-10.svg +73 -0
- package/build/muscles/secondary/muscle-11.svg +72 -0
- package/build/muscles/secondary/muscle-12.svg +72 -0
- package/build/muscles/secondary/muscle-13.svg +92 -0
- package/build/muscles/secondary/muscle-14.svg +73 -0
- package/build/muscles/secondary/muscle-15.svg +72 -0
- package/build/muscles/secondary/muscle-16.svg +73 -0
- package/build/muscles/secondary/muscle-2.svg +72 -0
- package/build/muscles/secondary/muscle-3.svg +72 -0
- package/build/muscles/secondary/muscle-4.svg +72 -0
- package/build/muscles/secondary/muscle-5.svg +72 -0
- package/build/muscles/secondary/muscle-6.svg +73 -0
- package/build/muscles/secondary/muscle-7.svg +72 -0
- package/build/muscles/secondary/muscle-8.svg +72 -0
- package/build/muscles/secondary/muscle-9.svg +72 -0
- package/build/robots.txt +3 -0
- package/index.html +59 -0
- package/package.json +125 -0
- package/src/.sass-cache/166f82406a0edab65b7f8fd8256819ee2f34bebf/App.module.scssc +0 -0
- package/src/@types/i18next.d.ts +13 -0
- package/src/App.tsx +25 -0
- package/src/assets/images/discord-logo.svg +1 -0
- package/src/assets/images/get-it-on-google-play.svg +1 -0
- package/src/assets/images/logo.png +0 -0
- package/src/assets/images/twitter-logo-50.png +0 -0
- package/src/assets/images/twitter.svg +5 -0
- package/src/components/BodyWeight/Form/WeightForm.test.tsx +100 -0
- package/src/components/BodyWeight/Form/WeightForm.tsx +102 -0
- package/src/components/BodyWeight/Table/ActionButton/ActionButton.test.tsx +65 -0
- package/src/components/BodyWeight/Table/ActionButton/ActionButton.tsx +67 -0
- package/src/components/BodyWeight/Table/Fab/Fab.tsx +35 -0
- package/src/components/BodyWeight/Table/index.test.tsx +33 -0
- package/src/components/BodyWeight/Table/index.tsx +98 -0
- package/src/components/BodyWeight/Table/table.module.css +5 -0
- package/src/components/BodyWeight/Table/table.module.css.map +1 -0
- package/src/components/BodyWeight/Table/table.module.scss +0 -0
- package/src/components/BodyWeight/Table/table.mosule.css +2 -0
- package/src/components/BodyWeight/Table/table.mosule.css.map +1 -0
- package/src/components/BodyWeight/TableDashboard/TableDashboard.test.tsx +24 -0
- package/src/components/BodyWeight/TableDashboard/TableDashboard.tsx +62 -0
- package/src/components/BodyWeight/WeightChart/index.test.tsx +66 -0
- package/src/components/BodyWeight/WeightChart/index.tsx +105 -0
- package/src/components/BodyWeight/body_weight.module.css +8 -0
- package/src/components/BodyWeight/body_weight.module.css.map +1 -0
- package/src/components/BodyWeight/body_weight.module.scss +8 -0
- package/src/components/BodyWeight/index.test.tsx +92 -0
- package/src/components/BodyWeight/index.tsx +40 -0
- package/src/components/BodyWeight/model.ts +40 -0
- package/src/components/BodyWeight/queries/index.ts +49 -0
- package/src/components/BodyWeight/utils.test.ts +44 -0
- package/src/components/BodyWeight/utils.ts +22 -0
- package/src/components/BodyWeight/widgets/FilterButtons.test.tsx +57 -0
- package/src/components/BodyWeight/widgets/FilterButtons.tsx +69 -0
- package/src/components/BodyWeight/widgets/fab.tsx +33 -0
- package/src/components/Calendar/Components/CalendarComponent.test.tsx +141 -0
- package/src/components/Calendar/Components/CalendarComponent.tsx +250 -0
- package/src/components/Calendar/Components/CalendarDay.tsx +105 -0
- package/src/components/Calendar/Components/CalendarDayGrid.tsx +53 -0
- package/src/components/Calendar/Components/CalendarHeader.tsx +39 -0
- package/src/components/Calendar/Components/Entries.test.tsx +81 -0
- package/src/components/Calendar/Components/Entries.tsx +163 -0
- package/src/components/Calendar/Helpers/CalendarMeasurement.tsx +10 -0
- package/src/components/Carousel/carousel.module.css +43 -0
- package/src/components/Carousel/carousel.module.css.map +1 -0
- package/src/components/Carousel/carousel.module.scss +46 -0
- package/src/components/Carousel/index.tsx +66 -0
- package/src/components/Common/forms/LicenseAuthor.tsx +19 -0
- package/src/components/Common/forms/LicenseAuthorUrl.tsx +20 -0
- package/src/components/Common/forms/LicenseDerivativeSourceUrl.tsx +20 -0
- package/src/components/Common/forms/LicenseObjectUrl.tsx +20 -0
- package/src/components/Common/forms/LicenseTitle.tsx +19 -0
- package/src/components/Common/forms/WgerTextField.tsx +27 -0
- package/src/components/Core/LoadingWidget/LoadingWidget.tsx +22 -0
- package/src/components/Core/Modals/DeleteConfirmationModal.test.tsx +57 -0
- package/src/components/Core/Modals/DeleteConfirmationModal.tsx +74 -0
- package/src/components/Core/Modals/WgerModal.test.tsx +45 -0
- package/src/components/Core/Modals/WgerModal.tsx +46 -0
- package/src/components/Core/Notifications/index.tsx +57 -0
- package/src/components/Core/Notifications/notifications.module.css +8 -0
- package/src/components/Core/Notifications/notifications.module.css.map +1 -0
- package/src/components/Core/Notifications/notifications.module.scss +6 -0
- package/src/components/Core/Tooltips/LightToolTip.tsx +14 -0
- package/src/components/Core/Widgets/Container.tsx +98 -0
- package/src/components/Core/Widgets/FormError.tsx +64 -0
- package/src/components/Core/Widgets/OverviewEmpty.tsx +26 -0
- package/src/components/Core/Widgets/RenderLoadingQuery.tsx +28 -0
- package/src/components/Core/queries/index.ts +2 -0
- package/src/components/Core/queries/languageCheck.ts +31 -0
- package/src/components/Dashboard/Dashboard.tsx +22 -0
- package/src/components/Dashboard/EmptyCard.tsx +56 -0
- package/src/components/Dashboard/NutritionCard.test.tsx +89 -0
- package/src/components/Dashboard/NutritionCard.tsx +178 -0
- package/src/components/Dashboard/RoutineCard.test.tsx +66 -0
- package/src/components/Dashboard/RoutineCard.tsx +107 -0
- package/src/components/Dashboard/WeightCard.test.tsx +81 -0
- package/src/components/Dashboard/WeightCard.tsx +72 -0
- package/src/components/Exercises/Add/AddExerciseStepper.test.tsx +26 -0
- package/src/components/Exercises/Add/AddExerciseStepper.tsx +97 -0
- package/src/components/Exercises/Add/NotEnoughRights.tsx +37 -0
- package/src/components/Exercises/Add/Step1Basics.test.tsx +133 -0
- package/src/components/Exercises/Add/Step1Basics.tsx +179 -0
- package/src/components/Exercises/Add/Step2Variations.test.tsx +149 -0
- package/src/components/Exercises/Add/Step2Variations.tsx +237 -0
- package/src/components/Exercises/Add/Step3Description.test.tsx +66 -0
- package/src/components/Exercises/Add/Step3Description.tsx +96 -0
- package/src/components/Exercises/Add/Step4Translation.test.tsx +119 -0
- package/src/components/Exercises/Add/Step4Translations.tsx +183 -0
- package/src/components/Exercises/Add/Step5Images.test.tsx +28 -0
- package/src/components/Exercises/Add/Step5Images.tsx +269 -0
- package/src/components/Exercises/Add/Step6Overview.test.tsx +128 -0
- package/src/components/Exercises/Add/Step6Overview.tsx +262 -0
- package/src/components/Exercises/Detail/ExerciseDetailEdit.test.tsx +248 -0
- package/src/components/Exercises/Detail/ExerciseDetailEdit.tsx +340 -0
- package/src/components/Exercises/Detail/ExerciseDetailView.test.tsx +96 -0
- package/src/components/Exercises/Detail/ExerciseDetailView.tsx +242 -0
- package/src/components/Exercises/Detail/ExerciseDetails.test.tsx +88 -0
- package/src/components/Exercises/Detail/ExerciseDetails.tsx +119 -0
- package/src/components/Exercises/Detail/ExerciseImageAvatar.tsx +20 -0
- package/src/components/Exercises/Detail/ExerciseImagePlaceholder.tsx +21 -0
- package/src/components/Exercises/Detail/Head/ExerciseDeleteDialog.test.tsx +125 -0
- package/src/components/Exercises/Detail/Head/ExerciseDeleteDialog.tsx +185 -0
- package/src/components/Exercises/Detail/Head/head.module.css +73 -0
- package/src/components/Exercises/Detail/Head/head.module.css.map +7 -0
- package/src/components/Exercises/Detail/Head/head.module.scss +111 -0
- package/src/components/Exercises/Detail/Head/index.tsx +175 -0
- package/src/components/Exercises/Detail/OverviewCard.test.tsx +98 -0
- package/src/components/Exercises/Detail/OverviewCard.tsx +68 -0
- package/src/components/Exercises/Detail/SideGallery/index.tsx +65 -0
- package/src/components/Exercises/Detail/SideGallery/side_gallery.module.css +26 -0
- package/src/components/Exercises/Detail/SideGallery/side_gallery.module.css.map +7 -0
- package/src/components/Exercises/Detail/SideGallery/side_gallery.module.scss +34 -0
- package/src/components/Exercises/ExerciseOverview.test.tsx +183 -0
- package/src/components/Exercises/ExerciseOverview.tsx +293 -0
- package/src/components/Exercises/Filter/CategoryFilter.test.tsx +57 -0
- package/src/components/Exercises/Filter/CategoryFilter.tsx +105 -0
- package/src/components/Exercises/Filter/EquipmentFilter.test.tsx +55 -0
- package/src/components/Exercises/Filter/EquipmentFilter.tsx +105 -0
- package/src/components/Exercises/Filter/ExerciseFiltersContext.tsx +16 -0
- package/src/components/Exercises/Filter/FilterDrawer.tsx +38 -0
- package/src/components/Exercises/Filter/MuscleFilter.test.tsx +50 -0
- package/src/components/Exercises/Filter/MuscleFilter.tsx +130 -0
- package/src/components/Exercises/Filter/NameAutcompleter.tsx +146 -0
- package/src/components/Exercises/Filter/NameAutocompleter.test.tsx +76 -0
- package/src/components/Exercises/Overview/ExerciseGrid.tsx +44 -0
- package/src/components/Exercises/Overview/ExerciseGridLoadingSkeleton.test.tsx +10 -0
- package/src/components/Exercises/Overview/ExerciseGridLoadingSkeleton.tsx +26 -0
- package/src/components/Exercises/forms/Category.test.tsx +49 -0
- package/src/components/Exercises/forms/Category.tsx +41 -0
- package/src/components/Exercises/forms/Equipment.test.tsx +84 -0
- package/src/components/Exercises/forms/Equipment.tsx +38 -0
- package/src/components/Exercises/forms/ExerciseAliases.tsx +37 -0
- package/src/components/Exercises/forms/ExerciseDescription.tsx +57 -0
- package/src/components/Exercises/forms/ExerciseEquipmentSelect.tsx +29 -0
- package/src/components/Exercises/forms/ExerciseName.tsx +19 -0
- package/src/components/Exercises/forms/ExerciseNotes.tsx +72 -0
- package/src/components/Exercises/forms/ExerciseSelect.tsx +28 -0
- package/src/components/Exercises/forms/ImageCard.tsx +101 -0
- package/src/components/Exercises/forms/ImageStyle.tsx +74 -0
- package/src/components/Exercises/forms/Muscle.test.tsx +74 -0
- package/src/components/Exercises/forms/Muscle.tsx +41 -0
- package/src/components/Exercises/forms/VideoCard.tsx +109 -0
- package/src/components/Exercises/forms/yupValidators.ts +46 -0
- package/src/components/Exercises/models/alias.ts +29 -0
- package/src/components/Exercises/models/category.ts +35 -0
- package/src/components/Exercises/models/equipment.ts +33 -0
- package/src/components/Exercises/models/exercise.test.ts +74 -0
- package/src/components/Exercises/models/exercise.ts +159 -0
- package/src/components/Exercises/models/image.ts +41 -0
- package/src/components/Exercises/models/language.ts +23 -0
- package/src/components/Exercises/models/muscle.test.ts +17 -0
- package/src/components/Exercises/models/muscle.ts +39 -0
- package/src/components/Exercises/models/note.ts +29 -0
- package/src/components/Exercises/models/translation.test.ts +68 -0
- package/src/components/Exercises/models/translation.ts +83 -0
- package/src/components/Exercises/models/video.ts +30 -0
- package/src/components/Exercises/queries/exercises.ts +29 -0
- package/src/components/Exercises/queries/index.ts +133 -0
- package/src/components/Exercises/queries/variations.ts +15 -0
- package/src/components/Header/SubMenus/BodyWeightSubMenu.tsx +27 -0
- package/src/components/Header/SubMenus/MeasurementsSubMenu.tsx +28 -0
- package/src/components/Header/SubMenus/NutritionSubMenu.tsx +28 -0
- package/src/components/Header/SubMenus/TrainingSubMenu.tsx +43 -0
- package/src/components/Header/SubMenus/WorkoutSubMenu.tsx +28 -0
- package/src/components/Header/index.tsx +27 -0
- package/src/components/Measurements/Screens/MeasurementCategoryDetail.test.tsx +67 -0
- package/src/components/Measurements/Screens/MeasurementCategoryDetail.tsx +37 -0
- package/src/components/Measurements/Screens/MeasurementCategoryOverview.test.tsx +59 -0
- package/src/components/Measurements/Screens/MeasurementCategoryOverview.tsx +64 -0
- package/src/components/Measurements/models/Category.ts +38 -0
- package/src/components/Measurements/models/Entry.ts +37 -0
- package/src/components/Measurements/queries/index.ts +121 -0
- package/src/components/Measurements/widgets/CategoryDetailDataGrid.tsx +209 -0
- package/src/components/Measurements/widgets/CategoryDetailDropdown.tsx +83 -0
- package/src/components/Measurements/widgets/CategoryForm.test.tsx +96 -0
- package/src/components/Measurements/widgets/CategoryForm.tsx +88 -0
- package/src/components/Measurements/widgets/EntryForm.test.tsx +120 -0
- package/src/components/Measurements/widgets/EntryForm.tsx +139 -0
- package/src/components/Measurements/widgets/MeasurementChart.tsx +52 -0
- package/src/components/Measurements/widgets/fab.tsx +65 -0
- package/src/components/Muscles/MuscleOverview.tsx +37 -0
- package/src/components/Nutrition/components/BmiCalculator.test.tsx +55 -0
- package/src/components/Nutrition/components/BmiCalculator.tsx +203 -0
- package/src/components/Nutrition/components/IngredientSearch.tsx +24 -0
- package/src/components/Nutrition/components/NutritionDiaryOverview.test.tsx +51 -0
- package/src/components/Nutrition/components/NutritionDiaryOverview.tsx +47 -0
- package/src/components/Nutrition/components/PlanDetail.test.tsx +58 -0
- package/src/components/Nutrition/components/PlanDetail.tsx +100 -0
- package/src/components/Nutrition/components/PlanOverview.test.tsx +37 -0
- package/src/components/Nutrition/components/PlansOverview.tsx +62 -0
- package/src/components/Nutrition/helpers/nutritionalValues.test.ts +108 -0
- package/src/components/Nutrition/helpers/nutritionalValues.ts +128 -0
- package/src/components/Nutrition/models/Ingredient.ts +84 -0
- package/src/components/Nutrition/models/IngredientImage.ts +57 -0
- package/src/components/Nutrition/models/IngredientImageThumbnails.ts +59 -0
- package/src/components/Nutrition/models/diaryEntry.ts +129 -0
- package/src/components/Nutrition/models/ingredient.test.ts +37 -0
- package/src/components/Nutrition/models/meal.test.ts +54 -0
- package/src/components/Nutrition/models/meal.ts +128 -0
- package/src/components/Nutrition/models/mealItem.test.ts +23 -0
- package/src/components/Nutrition/models/mealItem.ts +134 -0
- package/src/components/Nutrition/models/nutritionalPlan.test.ts +169 -0
- package/src/components/Nutrition/models/nutritionalPlan.ts +268 -0
- package/src/components/Nutrition/models/weightUnit.ts +24 -0
- package/src/components/Nutrition/queries/diary.ts +59 -0
- package/src/components/Nutrition/queries/index.ts +20 -0
- package/src/components/Nutrition/queries/ingredient.ts +12 -0
- package/src/components/Nutrition/queries/meal.ts +41 -0
- package/src/components/Nutrition/queries/mealItem.ts +43 -0
- package/src/components/Nutrition/queries/plan.ts +93 -0
- package/src/components/Nutrition/widgets/DiaryDetail.tsx +39 -0
- package/src/components/Nutrition/widgets/DiaryOverview.tsx +51 -0
- package/src/components/Nutrition/widgets/Fab.tsx +65 -0
- package/src/components/Nutrition/widgets/IngredientAutcompleter.tsx +140 -0
- package/src/components/Nutrition/widgets/IngredientAutocompleter.test.tsx +60 -0
- package/src/components/Nutrition/widgets/IngredientDetailTable.tsx +91 -0
- package/src/components/Nutrition/widgets/LoggedPlannedNutritionalValuesTable.tsx +138 -0
- package/src/components/Nutrition/widgets/MealDetail.tsx +170 -0
- package/src/components/Nutrition/widgets/MealDetailDropdown.tsx +117 -0
- package/src/components/Nutrition/widgets/NutritionalValuesTable.tsx +103 -0
- package/src/components/Nutrition/widgets/PlanDetailDropdown.tsx +82 -0
- package/src/components/Nutrition/widgets/PlanSidebar.tsx +44 -0
- package/src/components/Nutrition/widgets/charts/LinearPlannedLoggedChart.tsx +27 -0
- package/src/components/Nutrition/widgets/charts/MacrosPieChart.tsx +66 -0
- package/src/components/Nutrition/widgets/charts/NutritionDiaryChart.tsx +95 -0
- package/src/components/Nutrition/widgets/charts/NutritionalValuesDashboardChart.tsx +84 -0
- package/src/components/Nutrition/widgets/charts/NutritionalValuesPlannedLoggedChart.tsx +54 -0
- package/src/components/Nutrition/widgets/forms/MealForm.test.tsx +85 -0
- package/src/components/Nutrition/widgets/forms/MealForm.tsx +105 -0
- package/src/components/Nutrition/widgets/forms/MealItemForm.test.tsx +106 -0
- package/src/components/Nutrition/widgets/forms/MealItemForm.tsx +118 -0
- package/src/components/Nutrition/widgets/forms/NutritionDiaryEntryForm.test.tsx +165 -0
- package/src/components/Nutrition/widgets/forms/NutritionDiaryEntryForm.tsx +161 -0
- package/src/components/Nutrition/widgets/forms/PlanForm.test.tsx +101 -0
- package/src/components/Nutrition/widgets/forms/PlanForm.tsx +361 -0
- package/src/components/User/models/profile.ts +81 -0
- package/src/components/User/queries/contribute.test.ts +132 -0
- package/src/components/User/queries/contribute.ts +33 -0
- package/src/components/User/queries/permission.ts +11 -0
- package/src/components/User/queries/profile.ts +22 -0
- package/src/components/WorkoutRoutines/Detail/RoutineAdd.tsx +12 -0
- package/src/components/WorkoutRoutines/Detail/RoutineDetail.test.tsx +71 -0
- package/src/components/WorkoutRoutines/Detail/RoutineDetail.tsx +87 -0
- package/src/components/WorkoutRoutines/Detail/RoutineDetailsTable.test.tsx +83 -0
- package/src/components/WorkoutRoutines/Detail/RoutineDetailsTable.tsx +371 -0
- package/src/components/WorkoutRoutines/Detail/RoutineEdit.test.tsx +51 -0
- package/src/components/WorkoutRoutines/Detail/RoutineEdit.tsx +95 -0
- package/src/components/WorkoutRoutines/Detail/SessionAdd.test.tsx +43 -0
- package/src/components/WorkoutRoutines/Detail/SessionAdd.tsx +50 -0
- package/src/components/WorkoutRoutines/Detail/SlotProgressionEdit.test.tsx +41 -0
- package/src/components/WorkoutRoutines/Detail/SlotProgressionEdit.tsx +145 -0
- package/src/components/WorkoutRoutines/Detail/TemplateDetail.test.tsx +44 -0
- package/src/components/WorkoutRoutines/Detail/TemplateDetail.tsx +84 -0
- package/src/components/WorkoutRoutines/Detail/WorkoutLogs.test.tsx +64 -0
- package/src/components/WorkoutRoutines/Detail/WorkoutLogs.tsx +98 -0
- package/src/components/WorkoutRoutines/Detail/WorkoutStats.test.tsx +65 -0
- package/src/components/WorkoutRoutines/Detail/WorkoutStats.tsx +244 -0
- package/src/components/WorkoutRoutines/Overview/Fab.tsx +91 -0
- package/src/components/WorkoutRoutines/Overview/PrivateTemplateOverview.test.tsx +36 -0
- package/src/components/WorkoutRoutines/Overview/PrivateTemplateOverview.tsx +41 -0
- package/src/components/WorkoutRoutines/Overview/PublicTemplateOverview.test.tsx +36 -0
- package/src/components/WorkoutRoutines/Overview/PublicTemplateOverview.tsx +40 -0
- package/src/components/WorkoutRoutines/Overview/RoutineOverview.test.tsx +38 -0
- package/src/components/WorkoutRoutines/Overview/RoutineOverview.tsx +76 -0
- package/src/components/WorkoutRoutines/models/BaseConfig.ts +118 -0
- package/src/components/WorkoutRoutines/models/Day.test.ts +15 -0
- package/src/components/WorkoutRoutines/models/Day.ts +117 -0
- package/src/components/WorkoutRoutines/models/LogStats.test.ts +44 -0
- package/src/components/WorkoutRoutines/models/LogStats.ts +110 -0
- package/src/components/WorkoutRoutines/models/RepetitionUnit.ts +22 -0
- package/src/components/WorkoutRoutines/models/Routine.test.ts +113 -0
- package/src/components/WorkoutRoutines/models/Routine.ts +218 -0
- package/src/components/WorkoutRoutines/models/RoutineDayData.ts +38 -0
- package/src/components/WorkoutRoutines/models/RoutineLogData.ts +22 -0
- package/src/components/WorkoutRoutines/models/SetConfigData.ts +121 -0
- package/src/components/WorkoutRoutines/models/Slot.test.ts +19 -0
- package/src/components/WorkoutRoutines/models/Slot.ts +83 -0
- package/src/components/WorkoutRoutines/models/SlotData.ts +30 -0
- package/src/components/WorkoutRoutines/models/SlotEntry.test.ts +31 -0
- package/src/components/WorkoutRoutines/models/SlotEntry.ts +245 -0
- package/src/components/WorkoutRoutines/models/WeightUnit.ts +22 -0
- package/src/components/WorkoutRoutines/models/WorkoutLog.ts +159 -0
- package/src/components/WorkoutRoutines/models/WorkoutSession.ts +124 -0
- package/src/components/WorkoutRoutines/queries/configs.ts +393 -0
- package/src/components/WorkoutRoutines/queries/days.ts +42 -0
- package/src/components/WorkoutRoutines/queries/index.ts +64 -0
- package/src/components/WorkoutRoutines/queries/logs.ts +49 -0
- package/src/components/WorkoutRoutines/queries/routines.ts +121 -0
- package/src/components/WorkoutRoutines/queries/sessions.ts +41 -0
- package/src/components/WorkoutRoutines/queries/slot_entries.ts +33 -0
- package/src/components/WorkoutRoutines/queries/slots.ts +40 -0
- package/src/components/WorkoutRoutines/queries/units.ts +15 -0
- package/src/components/WorkoutRoutines/widgets/DayDetails.test.tsx +69 -0
- package/src/components/WorkoutRoutines/widgets/DayDetails.tsx +441 -0
- package/src/components/WorkoutRoutines/widgets/LogWidgets.test.tsx +91 -0
- package/src/components/WorkoutRoutines/widgets/LogWidgets.tsx +334 -0
- package/src/components/WorkoutRoutines/widgets/RoutineDetailDropdown.test.tsx +36 -0
- package/src/components/WorkoutRoutines/widgets/RoutineDetailDropdown.tsx +184 -0
- package/src/components/WorkoutRoutines/widgets/RoutineDetailsCard.test.tsx +42 -0
- package/src/components/WorkoutRoutines/widgets/RoutineDetailsCard.tsx +202 -0
- package/src/components/WorkoutRoutines/widgets/RoutineStatistics.test.tsx +364 -0
- package/src/components/WorkoutRoutines/widgets/RoutineStatistics.tsx +249 -0
- package/src/components/WorkoutRoutines/widgets/SlotDetails.test.tsx +72 -0
- package/src/components/WorkoutRoutines/widgets/SlotDetails.tsx +233 -0
- package/src/components/WorkoutRoutines/widgets/forms/BaseConfigForm.test.tsx +161 -0
- package/src/components/WorkoutRoutines/widgets/forms/BaseConfigForm.tsx +508 -0
- package/src/components/WorkoutRoutines/widgets/forms/DayForm.test.tsx +86 -0
- package/src/components/WorkoutRoutines/widgets/forms/DayForm.tsx +202 -0
- package/src/components/WorkoutRoutines/widgets/forms/ProgressionForm.test.tsx +176 -0
- package/src/components/WorkoutRoutines/widgets/forms/ProgressionForm.tsx +494 -0
- package/src/components/WorkoutRoutines/widgets/forms/RoutineForm.test.tsx +94 -0
- package/src/components/WorkoutRoutines/widgets/forms/RoutineForm.tsx +309 -0
- package/src/components/WorkoutRoutines/widgets/forms/RoutineTemplateForm.test.tsx +70 -0
- package/src/components/WorkoutRoutines/widgets/forms/RoutineTemplateForm.tsx +68 -0
- package/src/components/WorkoutRoutines/widgets/forms/SessionForm.test.tsx +164 -0
- package/src/components/WorkoutRoutines/widgets/forms/SessionForm.tsx +263 -0
- package/src/components/WorkoutRoutines/widgets/forms/SessionLogsForm.test.tsx +126 -0
- package/src/components/WorkoutRoutines/widgets/forms/SessionLogsForm.tsx +330 -0
- package/src/components/WorkoutRoutines/widgets/forms/SlotEntryForm.test.tsx +227 -0
- package/src/components/WorkoutRoutines/widgets/forms/SlotEntryForm.tsx +206 -0
- package/src/components/WorkoutRoutines/widgets/forms/SlotForm.test.tsx +44 -0
- package/src/components/WorkoutRoutines/widgets/forms/SlotForm.tsx +36 -0
- package/src/components/index.ts +3 -0
- package/src/config.ts +12 -0
- package/src/i18n.ts +63 -0
- package/src/i18n.tsx +52 -0
- package/src/index.css +13 -0
- package/src/index.tsx +184 -0
- package/src/locales/README.md +7 -0
- package/src/pages/About/index.tsx +9 -0
- package/src/pages/AddExercise/index.tsx +15 -0
- package/src/pages/AddWeight/index.tsx +9 -0
- package/src/pages/ApiPage/index.tsx +9 -0
- package/src/pages/Calendar/index.tsx +10 -0
- package/src/pages/CaloriesCalculator/index.tsx +9 -0
- package/src/pages/Equipments/index.tsx +9 -0
- package/src/pages/ExerciseDetails/index.tsx +6 -0
- package/src/pages/Ingrdedients/index.tsx +9 -0
- package/src/pages/Login/index.tsx +9 -0
- package/src/pages/Preferences/index.tsx +9 -0
- package/src/pages/PublicTemplate/index.tsx +9 -0
- package/src/pages/TemplatePage/index.tsx +9 -0
- package/src/pages/WeightOverview/index.tsx +6 -0
- package/src/pages/index.ts +14 -0
- package/src/permissions/index.ts +13 -0
- package/src/reportWebVitals.ts +15 -0
- package/src/routes.tsx +137 -0
- package/src/services/alias.test.ts +47 -0
- package/src/services/alias.ts +34 -0
- package/src/services/base_config.test.ts +48 -0
- package/src/services/base_config.ts +86 -0
- package/src/services/category.test.ts +44 -0
- package/src/services/category.ts +21 -0
- package/src/services/config.test.ts +213 -0
- package/src/services/config.ts +50 -0
- package/src/services/day.test.ts +118 -0
- package/src/services/day.ts +44 -0
- package/src/services/equipment.test.ts +46 -0
- package/src/services/equipment.ts +20 -0
- package/src/services/exercise.test.ts +98 -0
- package/src/services/exercise.ts +182 -0
- package/src/services/exerciseTranslation.test.ts +98 -0
- package/src/services/exerciseTranslation.ts +112 -0
- package/src/services/image.test.ts +77 -0
- package/src/services/image.ts +54 -0
- package/src/services/index.ts +104 -0
- package/src/services/ingredient.test.ts +81 -0
- package/src/services/ingredient.ts +70 -0
- package/src/services/ingredientweightunit.ts +29 -0
- package/src/services/language.test.ts +86 -0
- package/src/services/language.ts +35 -0
- package/src/services/languageCheck.ts +33 -0
- package/src/services/meal.ts +67 -0
- package/src/services/mealItem.ts +32 -0
- package/src/services/measurements.test.ts +106 -0
- package/src/services/measurements.ts +173 -0
- package/src/services/muscles.test.ts +46 -0
- package/src/services/muscles.ts +20 -0
- package/src/services/note.ts +39 -0
- package/src/services/nutritionalDiary.test.ts +35 -0
- package/src/services/nutritionalDiary.ts +70 -0
- package/src/services/nutritionalPlan.test.ts +74 -0
- package/src/services/nutritionalPlan.ts +104 -0
- package/src/services/permission.ts +26 -0
- package/src/services/permissions.test.ts +34 -0
- package/src/services/profile.test.ts +40 -0
- package/src/services/profile.ts +49 -0
- package/src/services/responseType.ts +35 -0
- package/src/services/routine.test.ts +195 -0
- package/src/services/routine.ts +250 -0
- package/src/services/session.test.ts +157 -0
- package/src/services/session.ts +99 -0
- package/src/services/slot.test.ts +68 -0
- package/src/services/slot.ts +43 -0
- package/src/services/slot_entry.ts +43 -0
- package/src/services/variation.test.ts +24 -0
- package/src/services/variation.ts +18 -0
- package/src/services/video.test.ts +65 -0
- package/src/services/video.ts +47 -0
- package/src/services/weight.test.ts +75 -0
- package/src/services/weight.ts +58 -0
- package/src/services/workoutLogs.test.ts +148 -0
- package/src/services/workoutLogs.ts +89 -0
- package/src/services/workoutUnits.ts +29 -0
- package/src/setupTests.ts +40 -0
- package/src/state/exerciseSubmissionReducer.ts +170 -0
- package/src/state/exerciseSubmissionState.tsx +75 -0
- package/src/state/index.ts +15 -0
- package/src/state/notificationReducer.ts +29 -0
- package/src/state/notificationState.tsx +32 -0
- package/src/state/stateTypes.ts +24 -0
- package/src/tests/api/ingredientInfoEndpoint.ts +72 -0
- package/src/tests/exerciseTestdata.ts +159 -0
- package/src/tests/exercises/searchResponse.ts +23 -0
- package/src/tests/ingredientTestdata.ts +76 -0
- package/src/tests/measurementsTestData.ts +40 -0
- package/src/tests/nutritionDiaryTestdata.ts +167 -0
- package/src/tests/nutritionTestdata.ts +200 -0
- package/src/tests/queryClient/index.ts +7 -0
- package/src/tests/responseApi.ts +197 -0
- package/src/tests/setup.ts +10 -0
- package/src/tests/slotEntryApiResponse.ts +144 -0
- package/src/tests/userTestdata.ts +43 -0
- package/src/tests/weight/testData.ts +7 -0
- package/src/tests/workoutLogsRoutinesTestData.ts +90 -0
- package/src/tests/workoutRoutinesTestData.ts +451 -0
- package/src/tests/workoutStatisticsTestData.ts +219 -0
- package/src/theme.ts +73 -0
- package/src/types.ts +144 -0
- package/src/utils/Adapter.ts +10 -0
- package/src/utils/colors.test.ts +38 -0
- package/src/utils/colors.ts +17 -0
- package/src/utils/consts.ts +160 -0
- package/src/utils/date.test.ts +56 -0
- package/src/utils/date.ts +145 -0
- package/src/utils/forms.test.ts +41 -0
- package/src/utils/forms.ts +54 -0
- package/src/utils/numbers.test.ts +55 -0
- package/src/utils/numbers.ts +42 -0
- package/src/utils/requests.test.ts +61 -0
- package/src/utils/requests.ts +22 -0
- package/src/utils/strings.test.ts +62 -0
- package/src/utils/strings.ts +28 -0
- package/src/utils/url.test.ts +127 -0
- package/src/utils/url.ts +237 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { EditProfileParams, Profile } from "components/User/models/profile";
|
|
3
|
+
import { ApiPath } from "utils/consts";
|
|
4
|
+
import { makeHeader, makeUrl } from "utils/url";
|
|
5
|
+
|
|
6
|
+
export const API_PROFILE_PATH = 'userprofile';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Loads the user's profile
|
|
11
|
+
*/
|
|
12
|
+
export const getProfile = async (): Promise<Profile | null> => {
|
|
13
|
+
const url = makeUrl(API_PROFILE_PATH);
|
|
14
|
+
|
|
15
|
+
// We need to manually catch the error, otherwise react-query will retry the
|
|
16
|
+
// query and report an error in the end
|
|
17
|
+
try {
|
|
18
|
+
const response = await axios.get(
|
|
19
|
+
url,
|
|
20
|
+
{ headers: makeHeader() }
|
|
21
|
+
);
|
|
22
|
+
return Profile.fromJson(response.data);
|
|
23
|
+
} catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* Edits the user's profile
|
|
30
|
+
*/
|
|
31
|
+
export const editProfile = async (data: Partial<EditProfileParams>): Promise<Profile> => {
|
|
32
|
+
|
|
33
|
+
const { weightRounding, repetitionsRounding, ...rest } = data;
|
|
34
|
+
const payload = {
|
|
35
|
+
...rest,
|
|
36
|
+
// eslint-disable-next-line camelcase
|
|
37
|
+
...(weightRounding !== undefined && { weight_rounding: weightRounding }),
|
|
38
|
+
// eslint-disable-next-line camelcase
|
|
39
|
+
...(repetitionsRounding !== undefined && { repetition_rounding: repetitionsRounding }),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const response = await axios.post(
|
|
43
|
+
makeUrl(ApiPath.API_PROFILE_PATH),
|
|
44
|
+
payload,
|
|
45
|
+
{ headers: makeHeader() }
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return Profile.fromJson(response.data);
|
|
49
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Exercise } from "components/Exercises/models/exercise";
|
|
2
|
+
|
|
3
|
+
export interface ResponseType<T> {
|
|
4
|
+
count: number,
|
|
5
|
+
next: number | null,
|
|
6
|
+
previous: number | null,
|
|
7
|
+
results: T[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ExerciseSearchResponse {
|
|
11
|
+
value: string,
|
|
12
|
+
data: {
|
|
13
|
+
id: number,
|
|
14
|
+
base_id: number,
|
|
15
|
+
name: string,
|
|
16
|
+
category: string,
|
|
17
|
+
image: string | null,
|
|
18
|
+
image_thumbnail: string | null,
|
|
19
|
+
},
|
|
20
|
+
exercise?: Exercise
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ExerciseSearchType {
|
|
24
|
+
suggestions: ExerciseSearchResponse[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface IngredientSearchResponse {
|
|
28
|
+
value: string,
|
|
29
|
+
data: {
|
|
30
|
+
id: number,
|
|
31
|
+
name: string,
|
|
32
|
+
image: string | null,
|
|
33
|
+
image_thumbnail: string | null,
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { Day } from "components/WorkoutRoutines/models/Day";
|
|
3
|
+
import { Routine } from "components/WorkoutRoutines/models/Routine";
|
|
4
|
+
import { SetConfigData } from "components/WorkoutRoutines/models/SetConfigData";
|
|
5
|
+
import { WorkoutLog } from "components/WorkoutRoutines/models/WorkoutLog";
|
|
6
|
+
import { getRoutinesShallow } from "services";
|
|
7
|
+
import { getRoutineDayDataAllIterations } from "services/routine";
|
|
8
|
+
import { getRoutineLogs } from "services/workoutLogs";
|
|
9
|
+
import { getRoutineRepUnits, getRoutineWeightUnits } from "services/workoutUnits";
|
|
10
|
+
import {
|
|
11
|
+
responseApiWorkoutRoutine,
|
|
12
|
+
responseRoutineDayData,
|
|
13
|
+
responseRoutineLogs,
|
|
14
|
+
testRepUnit1,
|
|
15
|
+
testRepUnit2,
|
|
16
|
+
testWeightUnit1,
|
|
17
|
+
testWeightUnit2
|
|
18
|
+
} from "tests/workoutRoutinesTestData";
|
|
19
|
+
|
|
20
|
+
jest.mock("axios");
|
|
21
|
+
jest.mock("services/workoutUnits");
|
|
22
|
+
jest.mock("services/exercise");
|
|
23
|
+
|
|
24
|
+
describe("workout routine service tests", () => {
|
|
25
|
+
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
jest.clearAllMocks();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
test('GET the routine data - shallow', async () => {
|
|
32
|
+
|
|
33
|
+
// Arrange
|
|
34
|
+
(axios.get as jest.Mock).mockImplementation(() => Promise.resolve({ data: responseApiWorkoutRoutine }));
|
|
35
|
+
|
|
36
|
+
// Act
|
|
37
|
+
const result = await getRoutinesShallow();
|
|
38
|
+
|
|
39
|
+
// Assert
|
|
40
|
+
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
41
|
+
expect(result).toStrictEqual([
|
|
42
|
+
new Routine({
|
|
43
|
+
id: 1,
|
|
44
|
+
name: 'My first routine!',
|
|
45
|
+
description: 'Well rounded full body routine',
|
|
46
|
+
created: new Date("2022-01-01T12:34:30+01:00"),
|
|
47
|
+
start: new Date("2024-03-01T00:00:00.000Z"),
|
|
48
|
+
end: new Date("2024-04-30T00:00:00.000Z"),
|
|
49
|
+
fitInWeek: false,
|
|
50
|
+
}),
|
|
51
|
+
new Routine({
|
|
52
|
+
id: 2,
|
|
53
|
+
name: 'Beach body',
|
|
54
|
+
description: 'Train only arms and chest, no legs!!!',
|
|
55
|
+
created: new Date("2023-01-01T17:22:22+02:00"),
|
|
56
|
+
start: new Date("2024-03-01T00:00:00.000Z"),
|
|
57
|
+
end: new Date("2024-04-30T00:00:00.000Z"),
|
|
58
|
+
fitInWeek: false,
|
|
59
|
+
}),
|
|
60
|
+
]);
|
|
61
|
+
expect(result[0].days.length).toEqual(0);
|
|
62
|
+
expect(result[1].days.length).toEqual(0);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
test('GET the routine logs', async () => {
|
|
67
|
+
|
|
68
|
+
// Arrange
|
|
69
|
+
(axios.get as jest.Mock).mockImplementation(() => Promise.resolve({ data: responseRoutineLogs }));
|
|
70
|
+
(getRoutineRepUnits as jest.Mock).mockImplementation(() => Promise.resolve([testRepUnit1, testRepUnit2]));
|
|
71
|
+
(getRoutineWeightUnits as jest.Mock).mockImplementation(() => Promise.resolve([testWeightUnit1, testWeightUnit2]));
|
|
72
|
+
|
|
73
|
+
// Act
|
|
74
|
+
const result = await getRoutineLogs(1);
|
|
75
|
+
|
|
76
|
+
// Assert
|
|
77
|
+
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
78
|
+
expect(result).toStrictEqual([
|
|
79
|
+
new WorkoutLog({
|
|
80
|
+
id: 2,
|
|
81
|
+
routineId: 1,
|
|
82
|
+
date: new Date("2023-05-10"),
|
|
83
|
+
iteration: 1,
|
|
84
|
+
exerciseId: 100,
|
|
85
|
+
slotEntryId: 2,
|
|
86
|
+
repetitionsUnitId: 1,
|
|
87
|
+
repetitions: 12,
|
|
88
|
+
repetitionsTarget: 12,
|
|
89
|
+
weight: 10.00,
|
|
90
|
+
weightUnitId: 1,
|
|
91
|
+
rir: null,
|
|
92
|
+
repetitionsUnit: testRepUnit1,
|
|
93
|
+
weightUnit: testWeightUnit1,
|
|
94
|
+
}),
|
|
95
|
+
|
|
96
|
+
new WorkoutLog({
|
|
97
|
+
id: 1,
|
|
98
|
+
routineId: 1,
|
|
99
|
+
date: new Date("2023-05-13"),
|
|
100
|
+
iteration: 1,
|
|
101
|
+
exerciseId: 100,
|
|
102
|
+
slotEntryId: 2,
|
|
103
|
+
repetitionsUnitId: 1,
|
|
104
|
+
repetitions: 10,
|
|
105
|
+
weight: 20,
|
|
106
|
+
weightTarget: 20,
|
|
107
|
+
weightUnitId: 1,
|
|
108
|
+
rir: 1.5,
|
|
109
|
+
rirTarget: 1,
|
|
110
|
+
repetitionsUnit: testRepUnit1,
|
|
111
|
+
weightUnit: testWeightUnit1,
|
|
112
|
+
}),
|
|
113
|
+
]);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('GET the routine day data', async () => {
|
|
117
|
+
// Arrange
|
|
118
|
+
(axios.get as jest.Mock).mockImplementation(() => Promise.resolve({ data: responseRoutineDayData }));
|
|
119
|
+
|
|
120
|
+
// Act
|
|
121
|
+
const result = await getRoutineDayDataAllIterations(1);
|
|
122
|
+
|
|
123
|
+
// Assert
|
|
124
|
+
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
125
|
+
|
|
126
|
+
expect(result[0].iteration).toStrictEqual(42);
|
|
127
|
+
expect(result[0].date).toStrictEqual(new Date('2024-04-01'));
|
|
128
|
+
expect(result[0].label).toStrictEqual('first label');
|
|
129
|
+
expect(result[0].day).toStrictEqual(
|
|
130
|
+
new Day({
|
|
131
|
+
id: 100,
|
|
132
|
+
routineId: null,
|
|
133
|
+
order: 5,
|
|
134
|
+
name: 'Push day',
|
|
135
|
+
description: '',
|
|
136
|
+
isRest: false,
|
|
137
|
+
needLogsToAdvance: false,
|
|
138
|
+
type: 'custom',
|
|
139
|
+
config: null
|
|
140
|
+
})
|
|
141
|
+
);
|
|
142
|
+
expect(result[0].slots[0].comment).toEqual('Push set 1');
|
|
143
|
+
expect(result[0].slots[0].isSuperset).toEqual(true);
|
|
144
|
+
expect(result[0].slots[0].exerciseIds).toEqual([9, 12]);
|
|
145
|
+
expect(result[0].slots[0].setConfigs[0]).toEqual(
|
|
146
|
+
new SetConfigData({
|
|
147
|
+
exerciseId: 9,
|
|
148
|
+
slotEntryId: 1000,
|
|
149
|
+
type: "dropset",
|
|
150
|
+
nrOfSets: 5,
|
|
151
|
+
maxNrOfSets: null,
|
|
152
|
+
weight: 100,
|
|
153
|
+
maxWeight: 120,
|
|
154
|
+
weightUnitId: 1,
|
|
155
|
+
weightRounding: 1.25,
|
|
156
|
+
repetitions: 10,
|
|
157
|
+
maxRepetitions: null,
|
|
158
|
+
repetitionsUnitId: 1,
|
|
159
|
+
repetitionsRounding: 1,
|
|
160
|
+
rir: 2,
|
|
161
|
+
maxRir: null,
|
|
162
|
+
rpe: 8,
|
|
163
|
+
restTime: 120,
|
|
164
|
+
maxRestTime: 180,
|
|
165
|
+
textRepr: "5 Sets, 10 × 100-120 kg @ 2 RiR",
|
|
166
|
+
comment: "foo"
|
|
167
|
+
},
|
|
168
|
+
)
|
|
169
|
+
);
|
|
170
|
+
expect(result[0].slots[0].setConfigs[1]).toEqual(
|
|
171
|
+
new SetConfigData({
|
|
172
|
+
exerciseId: 12,
|
|
173
|
+
slotEntryId: 1001,
|
|
174
|
+
type: "normal",
|
|
175
|
+
nrOfSets: 3,
|
|
176
|
+
maxNrOfSets: null,
|
|
177
|
+
weight: 90,
|
|
178
|
+
maxWeight: null,
|
|
179
|
+
weightUnitId: 1,
|
|
180
|
+
weightRounding: 1.25,
|
|
181
|
+
repetitions: 12,
|
|
182
|
+
maxRepetitions: null,
|
|
183
|
+
repetitionsUnitId: 1,
|
|
184
|
+
repetitionsRounding: 1,
|
|
185
|
+
rir: 2,
|
|
186
|
+
rpe: 8,
|
|
187
|
+
restTime: 120,
|
|
188
|
+
maxRestTime: null,
|
|
189
|
+
textRepr: "3 Sets, 12 × 90 kg @ 2 RiR",
|
|
190
|
+
comment: "bar"
|
|
191
|
+
},
|
|
192
|
+
)
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { Exercise } from "components/Exercises/models/exercise";
|
|
3
|
+
import { Day } from "components/WorkoutRoutines/models/Day";
|
|
4
|
+
import { RoutineStatsData, RoutineStatsDataAdapter } from "components/WorkoutRoutines/models/LogStats";
|
|
5
|
+
import { Routine } from "components/WorkoutRoutines/models/Routine";
|
|
6
|
+
import { RoutineDayData } from "components/WorkoutRoutines/models/RoutineDayData";
|
|
7
|
+
import { RoutineLogData, RoutineLogDataAdapter } from "components/WorkoutRoutines/models/RoutineLogData";
|
|
8
|
+
import { getExercise } from "services/exercise";
|
|
9
|
+
import { getRoutineRepUnits, getRoutineWeightUnits } from "services/workoutUnits";
|
|
10
|
+
import { ApiPath } from "utils/consts";
|
|
11
|
+
import { makeHeader, makeUrl } from "utils/url";
|
|
12
|
+
import { ResponseType } from "./responseType";
|
|
13
|
+
|
|
14
|
+
export const ROUTINE_API_STRUCTURE_PATH = 'structure';
|
|
15
|
+
export const ROUTINE_API_LOGS_PATH = 'logs';
|
|
16
|
+
export const ROUTINE_API_STATS_PATH = 'stats';
|
|
17
|
+
export const ROUTINE_API_ALL_ITERATION_DISPLAY = 'date-sequence-display';
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
* Processes a routine with all sub-objects
|
|
22
|
+
*/
|
|
23
|
+
const exerciseMap: { [id: number]: Exercise } = {};
|
|
24
|
+
|
|
25
|
+
export const processRoutine = async (id: number): Promise<Routine> => {
|
|
26
|
+
|
|
27
|
+
const response = await axios.get(
|
|
28
|
+
makeUrl(ApiPath.ROUTINE, { id: id }),
|
|
29
|
+
{ headers: makeHeader() }
|
|
30
|
+
);
|
|
31
|
+
const routine = Routine.fromJson(response.data);
|
|
32
|
+
|
|
33
|
+
const responses = await Promise.all([
|
|
34
|
+
getRoutineRepUnits(),
|
|
35
|
+
getRoutineWeightUnits(),
|
|
36
|
+
getRoutineDayDataAllIterations(id),
|
|
37
|
+
getRoutineStructure(id),
|
|
38
|
+
|
|
39
|
+
]);
|
|
40
|
+
const repsUnits = responses[0];
|
|
41
|
+
const weightUnits = responses[1];
|
|
42
|
+
const dayDataAllIterations = responses[2];
|
|
43
|
+
const dayStructure = responses[3];
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// Collect all unique exercise IDs and load the data in bulk
|
|
47
|
+
const exerciseIds = new Set<number>();
|
|
48
|
+
for (const dayData of dayDataAllIterations.filter(d => d.day !== null && d.iteration === 1)) {
|
|
49
|
+
for (const slotData of dayData.slots) {
|
|
50
|
+
for (const setData of slotData.setConfigs) {
|
|
51
|
+
exerciseIds.add(setData.exerciseId);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const exercisePromises = Array.from(exerciseIds).map(id => getExercise(id));
|
|
56
|
+
const exercises = await Promise.all(exercisePromises);
|
|
57
|
+
exercises.forEach(exercise => {
|
|
58
|
+
exerciseMap[exercise.id!] = exercise;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Collect and load all exercises for the workout
|
|
62
|
+
for (const dayData of dayDataAllIterations) {
|
|
63
|
+
for (const slotData of dayData.slots) {
|
|
64
|
+
for (const setData of slotData.setConfigs) {
|
|
65
|
+
setData.exercise = exerciseMap[setData.exerciseId];
|
|
66
|
+
if (setData.repetitionsUnitId !== null) {
|
|
67
|
+
setData.repetitionsUnit = repsUnits.find(r => r.id === setData.repetitionsUnitId) ?? null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (setData.weightUnitId !== null) {
|
|
71
|
+
setData.weightUnit = weightUnits.find(w => w.id === setData.weightUnitId) ?? null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
for (const exerciseId of slotData.exerciseIds) {
|
|
76
|
+
slotData.exercises?.push(exerciseMap[exerciseId]);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
for (const day of dayStructure) {
|
|
82
|
+
for (const slot of day.slots) {
|
|
83
|
+
for (const slotEntry of slot.entries) {
|
|
84
|
+
slotEntry.exercise = exerciseMap[slotEntry.exerciseId];
|
|
85
|
+
|
|
86
|
+
if (slotEntry.repetitionUnitId !== null) {
|
|
87
|
+
slotEntry.repetitionUnit = repsUnits.find(r => r.id === slotEntry.repetitionUnitId) ?? null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (slotEntry.weightUnitId !== null) {
|
|
91
|
+
slotEntry.weightUnit = weightUnits.find(w => w.id === slotEntry.weightUnitId) ?? null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
routine.dayData = dayDataAllIterations;
|
|
98
|
+
routine.days = dayStructure;
|
|
99
|
+
|
|
100
|
+
return routine;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
/*
|
|
105
|
+
* Retrieves all routines
|
|
106
|
+
*
|
|
107
|
+
* Note: this returns all the data, including all sub-objects
|
|
108
|
+
*/
|
|
109
|
+
export const getRoutines = async (): Promise<Routine[]> => {
|
|
110
|
+
const url = makeUrl(ApiPath.ROUTINE, { query: { 'is_public': false } });
|
|
111
|
+
const response = await axios.get<ResponseType<Routine>>(
|
|
112
|
+
url,
|
|
113
|
+
{ headers: makeHeader() }
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const out: Routine[] = [];
|
|
117
|
+
for (const routineData of response.data.results) {
|
|
118
|
+
out.push(await processRoutine(routineData.id!));
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/*
|
|
124
|
+
* Returns the current active routine
|
|
125
|
+
*
|
|
126
|
+
* Note that at the moment this is simply the newest one
|
|
127
|
+
*/
|
|
128
|
+
export const getActiveRoutine = async (): Promise<null | Routine> => {
|
|
129
|
+
const url = makeUrl(ApiPath.ROUTINE, { query: { 'limit': '1', 'is_template': false } });
|
|
130
|
+
|
|
131
|
+
const response = await axios.get<ResponseType<Routine>>(
|
|
132
|
+
url,
|
|
133
|
+
{ headers: makeHeader() }
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
if (response.data.count === 0) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return await processRoutine(response.data.results[0].id!);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const getRoutine = async (id: number): Promise<Routine> => {
|
|
144
|
+
return await processRoutine(id);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/*
|
|
148
|
+
* Retrieves all routines
|
|
149
|
+
*
|
|
150
|
+
* Note: strictly only the routine data, no days or any other sub-objects
|
|
151
|
+
*/
|
|
152
|
+
export const getRoutinesShallow = async (): Promise<Routine[]> => {
|
|
153
|
+
const url = makeUrl(ApiPath.ROUTINE, { query: { 'is_public': false } });
|
|
154
|
+
const response = await axios.get<ResponseType<Routine>>(
|
|
155
|
+
url,
|
|
156
|
+
{ headers: makeHeader() }
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
return response.data.results.map(routineData => Routine.fromJson(routineData)).filter(routine => routine.isNotTemplate);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export const getPrivateTemplatesShallow = async (): Promise<Routine[]> => {
|
|
163
|
+
const url = makeUrl(ApiPath.PRIVATE_TEMPLATE);
|
|
164
|
+
const response = await axios.get<ResponseType<Routine>>(
|
|
165
|
+
url,
|
|
166
|
+
{ headers: makeHeader() }
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
return response.data.results.map(routineData => Routine.fromJson(routineData));
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export const getPublicTemplatesShallow = async (): Promise<Routine[]> => {
|
|
173
|
+
const url = makeUrl(ApiPath.PUBLIC_TEMPLATE);
|
|
174
|
+
const response = await axios.get<ResponseType<Routine>>(
|
|
175
|
+
url,
|
|
176
|
+
{ headers: makeHeader() }
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
return response.data.results.map(routineData => Routine.fromJson(routineData));
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export const addRoutine = async (routine: Routine): Promise<Routine> => {
|
|
183
|
+
const response = await axios.post(
|
|
184
|
+
makeUrl(ApiPath.ROUTINE,),
|
|
185
|
+
routine.toJson(),
|
|
186
|
+
{ headers: makeHeader() }
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
return Routine.fromJson(response.data);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export const editRoutine = async (routine: Routine): Promise<Routine> => {
|
|
193
|
+
const response = await axios.patch(
|
|
194
|
+
makeUrl(ApiPath.ROUTINE, { id: routine.id! }),
|
|
195
|
+
routine.toJson(),
|
|
196
|
+
{ headers: makeHeader() }
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
return Routine.fromJson(response.data);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export const deleteRoutine = async (id: number): Promise<number> => {
|
|
203
|
+
const response = await axios.delete(
|
|
204
|
+
makeUrl(ApiPath.ROUTINE, { id: id }),
|
|
205
|
+
{ headers: makeHeader() }
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
return response.status;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
export const getRoutineDayDataAllIterations = async (routineId: number): Promise<RoutineDayData[]> => {
|
|
213
|
+
const response = await axios.get(
|
|
214
|
+
makeUrl(ApiPath.ROUTINE, { id: routineId, objectMethod: ROUTINE_API_ALL_ITERATION_DISPLAY }),
|
|
215
|
+
{ headers: makeHeader() }
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
219
|
+
return response.data.map((data: any) => RoutineDayData.fromJson(data));
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export const getRoutineStructure = async (routineId: number): Promise<Day[]> => {
|
|
223
|
+
const response = await axios.get(
|
|
224
|
+
makeUrl(ApiPath.ROUTINE, { id: routineId, objectMethod: ROUTINE_API_STRUCTURE_PATH }),
|
|
225
|
+
{ headers: makeHeader() }
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
|
+
return response.data.days.map((data: any) => Day.fromJson(data));
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export const getRoutineLogData = async (routineId: number): Promise<RoutineLogData[]> => {
|
|
233
|
+
const response = await axios.get(
|
|
234
|
+
makeUrl(ApiPath.ROUTINE, { id: routineId, objectMethod: ROUTINE_API_LOGS_PATH }),
|
|
235
|
+
{ headers: makeHeader() }
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
const adapter = new RoutineLogDataAdapter();
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
240
|
+
return response.data.map((data: any) => adapter.fromJson(data));
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export const getRoutineStatisticsData = async (routineId: number): Promise<RoutineStatsData> => {
|
|
244
|
+
const response = await axios.get(
|
|
245
|
+
makeUrl(ApiPath.ROUTINE, { id: routineId, objectMethod: ROUTINE_API_STATS_PATH }),
|
|
246
|
+
{ headers: makeHeader() }
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
return new RoutineStatsDataAdapter().fromJson(response.data);
|
|
250
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { getSessions } from "services";
|
|
3
|
+
import * as exerciseService from "services/exercise";
|
|
4
|
+
import { testExerciseBenchPress, testExerciseSquats } from "tests/exerciseTestdata";
|
|
5
|
+
|
|
6
|
+
jest.mock("axios");
|
|
7
|
+
jest.mock("services/exercise");
|
|
8
|
+
|
|
9
|
+
describe("Session service tests", () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
jest.resetAllMocks();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('Loads sessions with associated logs and exercises', async () => {
|
|
15
|
+
// Arrange
|
|
16
|
+
(axios.get as jest.Mock).mockImplementationOnce(() => {
|
|
17
|
+
return Promise.resolve({
|
|
18
|
+
data: {
|
|
19
|
+
count: 2,
|
|
20
|
+
next: null,
|
|
21
|
+
previous: null,
|
|
22
|
+
results: [
|
|
23
|
+
{
|
|
24
|
+
"id": 4072327,
|
|
25
|
+
"date": "2025-08-07T00:00:00+02:00",
|
|
26
|
+
"session": 24284,
|
|
27
|
+
"routine": 39764,
|
|
28
|
+
"iteration": 1,
|
|
29
|
+
"slot_entry": 316691,
|
|
30
|
+
"next_log": null,
|
|
31
|
+
"exercise": 200,
|
|
32
|
+
"repetitions_unit": 1,
|
|
33
|
+
"repetitions": "2.00",
|
|
34
|
+
"repetitions_target": "1.00",
|
|
35
|
+
"weight_unit": 1,
|
|
36
|
+
"weight": "33.00",
|
|
37
|
+
"weight_target": null,
|
|
38
|
+
"rir": "0.5",
|
|
39
|
+
"rir_target": null,
|
|
40
|
+
"rest": 167,
|
|
41
|
+
"rest_target": null
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": 4072329,
|
|
45
|
+
"date": "2025-08-07T00:00:00+02:00",
|
|
46
|
+
"session": 24284,
|
|
47
|
+
"routine": 39764,
|
|
48
|
+
"iteration": 1,
|
|
49
|
+
"slot_entry": 316693,
|
|
50
|
+
"next_log": null,
|
|
51
|
+
"exercise": 201,
|
|
52
|
+
"repetitions_unit": 1,
|
|
53
|
+
"repetitions": "2.00",
|
|
54
|
+
"repetitions_target": "3.00",
|
|
55
|
+
"weight_unit": 1,
|
|
56
|
+
"weight": "46.00",
|
|
57
|
+
"weight_target": null,
|
|
58
|
+
"rir": "1.0",
|
|
59
|
+
"rir_target": null,
|
|
60
|
+
"rest": 178,
|
|
61
|
+
"rest_target": null
|
|
62
|
+
},
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
(axios.get as jest.Mock).mockImplementationOnce(() => {
|
|
69
|
+
return Promise.resolve({
|
|
70
|
+
data: {
|
|
71
|
+
count: 1,
|
|
72
|
+
next: null,
|
|
73
|
+
previous: null,
|
|
74
|
+
results: [
|
|
75
|
+
{
|
|
76
|
+
"id": 24284,
|
|
77
|
+
"routine": 39764,
|
|
78
|
+
"day": null,
|
|
79
|
+
"date": "2025-08-07",
|
|
80
|
+
"notes": null,
|
|
81
|
+
"impression": "3",
|
|
82
|
+
"time_start": "20:10:58",
|
|
83
|
+
"time_end": "23:28:21"
|
|
84
|
+
},
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
(exerciseService.getExercise as jest.Mock).mockImplementation((id) => {
|
|
91
|
+
if (id === 200) {
|
|
92
|
+
return Promise.resolve(testExerciseSquats);
|
|
93
|
+
} else if (id === 201) {
|
|
94
|
+
return Promise.resolve(testExerciseBenchPress);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Act
|
|
99
|
+
const sessions = await getSessions();
|
|
100
|
+
|
|
101
|
+
// Assert
|
|
102
|
+
expect(sessions).toHaveLength(1);
|
|
103
|
+
expect(sessions[0].id).toBe(24284);
|
|
104
|
+
expect(sessions[0].logs).toHaveLength(2);
|
|
105
|
+
expect(sessions[0].logs[0].exerciseId).toBe(200);
|
|
106
|
+
expect(sessions[0].logs[0].exerciseObj).toBeDefined();
|
|
107
|
+
expect(sessions[0].logs[0].exerciseObj?.getTranslation().name).toBe('Squats');
|
|
108
|
+
expect(sessions[0].logs[1].exerciseId).toBe(201);
|
|
109
|
+
expect(sessions[0].logs[1].exerciseObj).toBeDefined();
|
|
110
|
+
expect(sessions[0].logs[1].exerciseObj?.getTranslation().name).toBe('Benchpress');
|
|
111
|
+
|
|
112
|
+
expect(exerciseService.getExercise).toHaveBeenCalledWith(200);
|
|
113
|
+
expect(exerciseService.getExercise).toHaveBeenCalledWith(201);
|
|
114
|
+
|
|
115
|
+
// Check that API calls were made correctly
|
|
116
|
+
expect(axios.get).toHaveBeenNthCalledWith(
|
|
117
|
+
1,
|
|
118
|
+
expect.stringContaining('/workoutlog/'),
|
|
119
|
+
expect.anything()
|
|
120
|
+
);
|
|
121
|
+
expect(axios.get).toHaveBeenNthCalledWith(
|
|
122
|
+
2,
|
|
123
|
+
expect.stringContaining('/workoutsession/'),
|
|
124
|
+
expect.anything()
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Keep the existing test
|
|
129
|
+
test('Correctly filters sessions and log entries', async () => {
|
|
130
|
+
(axios.get as jest.Mock).mockImplementation(() => {
|
|
131
|
+
return Promise.resolve({
|
|
132
|
+
data: {
|
|
133
|
+
count: 2,
|
|
134
|
+
next: null,
|
|
135
|
+
previous: null,
|
|
136
|
+
results: []
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
await getSessions({
|
|
142
|
+
filtersetQueryLogs: { foo: "bar" },
|
|
143
|
+
filtersetQuerySessions: { baz: 1234 }
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// No results, so no loading of ingredients or weight units
|
|
147
|
+
expect(axios.get).toHaveBeenCalledTimes(2);
|
|
148
|
+
expect(axios.get).toHaveBeenNthCalledWith(1,
|
|
149
|
+
expect.stringContaining('foo=bar'),
|
|
150
|
+
expect.anything()
|
|
151
|
+
);
|
|
152
|
+
expect(axios.get).toHaveBeenNthCalledWith(2,
|
|
153
|
+
expect.stringContaining('baz=1234'),
|
|
154
|
+
expect.anything()
|
|
155
|
+
);
|
|
156
|
+
});
|
|
157
|
+
});
|