@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,91 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { useDeleteRoutineLogQuery, useEditRoutineLogQuery } from 'components/WorkoutRoutines/queries';
|
|
4
|
+
import { ExerciseLog } from "components/WorkoutRoutines/widgets/LogWidgets";
|
|
5
|
+
import { testExerciseBenchPress } from "tests/exerciseTestdata";
|
|
6
|
+
import { testWorkoutLogs } from "tests/workoutLogsRoutinesTestData";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const { ResizeObserver } = window;
|
|
10
|
+
|
|
11
|
+
jest.mock('components/WorkoutRoutines/queries', () => ({
|
|
12
|
+
useDeleteRoutineLogQuery: jest.fn(),
|
|
13
|
+
useEditRoutineLogQuery: jest.fn()
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
describe('ExerciseLog', () => {
|
|
17
|
+
let mockDeleteMutate: jest.Mock;
|
|
18
|
+
let mockEditMutate: jest.Mock;
|
|
19
|
+
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
jest.clearAllMocks();
|
|
22
|
+
|
|
23
|
+
mockDeleteMutate = jest.fn();
|
|
24
|
+
mockEditMutate = jest.fn();
|
|
25
|
+
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
delete window.ResizeObserver;
|
|
28
|
+
window.ResizeObserver = jest.fn().mockImplementation(() => ({
|
|
29
|
+
observe: jest.fn(),
|
|
30
|
+
unobserve: jest.fn(),
|
|
31
|
+
disconnect: jest.fn()
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
(useDeleteRoutineLogQuery as jest.Mock).mockReturnValue({ mutate: mockDeleteMutate });
|
|
35
|
+
(useEditRoutineLogQuery as jest.Mock).mockReturnValue({ mutate: mockEditMutate });
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
afterEach(() => {
|
|
39
|
+
window.ResizeObserver = ResizeObserver;
|
|
40
|
+
jest.restoreAllMocks();
|
|
41
|
+
});
|
|
42
|
+
const mockRoutineId = 123;
|
|
43
|
+
const user = userEvent.setup();
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
test('renders the DataGrid table correctly', () => {
|
|
47
|
+
render(
|
|
48
|
+
<ExerciseLog
|
|
49
|
+
exercise={testExerciseBenchPress}
|
|
50
|
+
routineId={mockRoutineId}
|
|
51
|
+
logEntries={testWorkoutLogs}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
expect(screen.getByRole('grid')).toBeInTheDocument();
|
|
56
|
+
expect(screen.getByText('Benchpress')).toBeInTheDocument();
|
|
57
|
+
expect(mockDeleteMutate).not.toHaveBeenCalled();
|
|
58
|
+
expect(mockEditMutate).not.toHaveBeenCalled();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('calls deleteLogQuery when DeleteIcon is clicked', async () => {
|
|
62
|
+
render(
|
|
63
|
+
<ExerciseLog
|
|
64
|
+
exercise={testExerciseBenchPress}
|
|
65
|
+
routineId={mockRoutineId}
|
|
66
|
+
logEntries={testWorkoutLogs}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
await user.click(screen.getAllByRole('menuitem', { name: /delete/i })[0]);
|
|
71
|
+
expect(mockDeleteMutate).toHaveBeenCalledWith(5);
|
|
72
|
+
expect(mockEditMutate).not.toHaveBeenCalled();
|
|
73
|
+
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('calls editLogQuery when SaveIcon is clicked', async () => {
|
|
77
|
+
render(
|
|
78
|
+
<ExerciseLog
|
|
79
|
+
exercise={testExerciseBenchPress}
|
|
80
|
+
routineId={mockRoutineId}
|
|
81
|
+
logEntries={testWorkoutLogs}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
await user.click(screen.getAllByRole('menuitem', { name: /edit/i })[0]);
|
|
86
|
+
await user.click(screen.getAllByRole('menuitem', { name: /save/i })[0]);
|
|
87
|
+
|
|
88
|
+
expect(mockDeleteMutate).not.toHaveBeenCalled();
|
|
89
|
+
expect(mockEditMutate).toHaveBeenCalled();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import CancelIcon from "@mui/icons-material/Cancel";
|
|
2
|
+
import DeleteIcon from "@mui/icons-material/DeleteOutlined";
|
|
3
|
+
import EditIcon from "@mui/icons-material/Edit";
|
|
4
|
+
import SaveIcon from "@mui/icons-material/Save";
|
|
5
|
+
import { Box, Card, CardContent, Typography } from '@mui/material';
|
|
6
|
+
import Grid from "@mui/material/Grid";
|
|
7
|
+
import {
|
|
8
|
+
DataGrid,
|
|
9
|
+
GridActionsCellItem,
|
|
10
|
+
GridColDef,
|
|
11
|
+
GridEventListener,
|
|
12
|
+
GridRowEditStopReasons,
|
|
13
|
+
GridRowId,
|
|
14
|
+
GridRowModel,
|
|
15
|
+
GridRowModes,
|
|
16
|
+
GridRowModesModel,
|
|
17
|
+
GridRowsProp
|
|
18
|
+
} from "@mui/x-data-grid";
|
|
19
|
+
import { FormQueryErrors } from "components/Core/Widgets/FormError";
|
|
20
|
+
import { Exercise } from "components/Exercises/models/exercise";
|
|
21
|
+
import { RIR_VALUES_SELECT_LIST } from "components/WorkoutRoutines/models/BaseConfig";
|
|
22
|
+
import { WorkoutLog } from "components/WorkoutRoutines/models/WorkoutLog";
|
|
23
|
+
import { useDeleteRoutineLogQuery, useEditRoutineLogQuery } from "components/WorkoutRoutines/queries";
|
|
24
|
+
import { DateTime } from "luxon";
|
|
25
|
+
import React from "react";
|
|
26
|
+
import { useTranslation } from "react-i18next";
|
|
27
|
+
import {
|
|
28
|
+
CartesianGrid,
|
|
29
|
+
Legend,
|
|
30
|
+
ResponsiveContainer,
|
|
31
|
+
Scatter,
|
|
32
|
+
ScatterChart,
|
|
33
|
+
Tooltip,
|
|
34
|
+
TooltipProps,
|
|
35
|
+
XAxis,
|
|
36
|
+
YAxis
|
|
37
|
+
} from "recharts";
|
|
38
|
+
import { NameType, ValueType } from "recharts/types/component/DefaultTooltipContent";
|
|
39
|
+
import { generateChartColors } from "utils/colors";
|
|
40
|
+
import { PAGINATION_OPTIONS } from "utils/consts";
|
|
41
|
+
import { dateToLocale, luxonDateTimeToLocale } from "utils/date";
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
export const ExerciseLog = (props: { exercise: Exercise, routineId: number, logEntries: WorkoutLog[] | undefined }) => {
|
|
45
|
+
const { t } = useTranslation();
|
|
46
|
+
const logEntries = props.logEntries ?? [];
|
|
47
|
+
const deleteLogQuery = useDeleteRoutineLogQuery(props.routineId);
|
|
48
|
+
const editLogQuery = useEditRoutineLogQuery(props.routineId);
|
|
49
|
+
|
|
50
|
+
const initialRows: GridRowsProp = logEntries.map((logEntry: WorkoutLog) => ({
|
|
51
|
+
id: logEntry.id,
|
|
52
|
+
date: logEntry.date,
|
|
53
|
+
repetitions: logEntry.repetitions,
|
|
54
|
+
weight: logEntry.weight,
|
|
55
|
+
rir: logEntry.rir,
|
|
56
|
+
entry: logEntry
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
const [rows, setRows] = React.useState(initialRows);
|
|
61
|
+
const [rowModesModel, setRowModesModel] = React.useState<GridRowModesModel>({});
|
|
62
|
+
|
|
63
|
+
const handleRowEditStop: GridEventListener<'rowEditStop'> = (params, event) => {
|
|
64
|
+
if (params.reason === GridRowEditStopReasons.rowFocusOut) {
|
|
65
|
+
event.defaultMuiPrevented = true;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const handleEditClick = (id: GridRowId) => () => {
|
|
70
|
+
setRowModesModel({ ...rowModesModel, [id]: { mode: GridRowModes.Edit } });
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const handleSaveClick = (id: GridRowId) => () => {
|
|
74
|
+
setRowModesModel({ ...rowModesModel, [id]: { mode: GridRowModes.View } });
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const handleDeleteClick = (id: GridRowId) => () => {
|
|
78
|
+
deleteLogQuery.mutate(id as number);
|
|
79
|
+
setRows(rows.filter((row) => row.id !== id));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const handleCancelClick = (id: GridRowId) => () => {
|
|
83
|
+
setRowModesModel({
|
|
84
|
+
...rowModesModel,
|
|
85
|
+
[id]: { mode: GridRowModes.View, ignoreModifications: true },
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const editedRow = rows.find((row) => row.id === id);
|
|
89
|
+
if (editedRow!.isNew) {
|
|
90
|
+
setRows(rows.filter((row) => row.id !== id));
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const processRowUpdate = (newRow: GridRowModel) => {
|
|
95
|
+
|
|
96
|
+
const log = newRow.entry;
|
|
97
|
+
if (log !== undefined) {
|
|
98
|
+
log.date = newRow.date;
|
|
99
|
+
log.repetitions = newRow.repetitions;
|
|
100
|
+
log.weight = newRow.weight;
|
|
101
|
+
log.rir = newRow.rir;
|
|
102
|
+
|
|
103
|
+
editLogQuery.mutate(log);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const updatedRow = { ...newRow, isNew: false };
|
|
107
|
+
setRows(rows.map((row) => (row.id === newRow.id ? updatedRow : row)));
|
|
108
|
+
return updatedRow;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const handleRowModesModelChange = (newRowModesModel: GridRowModesModel) => {
|
|
112
|
+
setRowModesModel(newRowModesModel);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const columns: GridColDef[] = [
|
|
116
|
+
{
|
|
117
|
+
field: 'date',
|
|
118
|
+
type: 'dateTime',
|
|
119
|
+
flex: 1,
|
|
120
|
+
editable: true,
|
|
121
|
+
disableColumnMenu: true,
|
|
122
|
+
headerName: t('date'),
|
|
123
|
+
valueFormatter: (value?: Date) => {
|
|
124
|
+
if (value == null) {
|
|
125
|
+
return '';
|
|
126
|
+
}
|
|
127
|
+
return `${dateToLocale(value)}`;
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
field: 'repetitions',
|
|
132
|
+
type: 'number',
|
|
133
|
+
disableColumnMenu: true,
|
|
134
|
+
editable: true,
|
|
135
|
+
headerName: t('routines.reps'),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
field: 'weight',
|
|
139
|
+
type: 'number',
|
|
140
|
+
disableColumnMenu: true,
|
|
141
|
+
editable: true,
|
|
142
|
+
headerName: t('weight'),
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
field: 'rir',
|
|
146
|
+
type: 'singleSelect',
|
|
147
|
+
disableColumnMenu: true,
|
|
148
|
+
|
|
149
|
+
editable: true,
|
|
150
|
+
headerName: t('routines.rir'),
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
152
|
+
getOptionValue: (value: any) => value.value,
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
154
|
+
getOptionLabel: (value: any) => value.label,
|
|
155
|
+
valueOptions: RIR_VALUES_SELECT_LIST,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
field: 'actions',
|
|
159
|
+
type: 'actions',
|
|
160
|
+
headerName: 'Actions',
|
|
161
|
+
width: 100,
|
|
162
|
+
cellClassName: 'actions',
|
|
163
|
+
getActions: ({ id }) => {
|
|
164
|
+
const isInEditMode = rowModesModel[id]?.mode === GridRowModes.Edit;
|
|
165
|
+
|
|
166
|
+
if (isInEditMode) {
|
|
167
|
+
return [
|
|
168
|
+
<GridActionsCellItem
|
|
169
|
+
icon={<SaveIcon />}
|
|
170
|
+
sx={{ color: 'primary.main' }}
|
|
171
|
+
label={t('save')}
|
|
172
|
+
onClick={handleSaveClick(id)}
|
|
173
|
+
/>,
|
|
174
|
+
<GridActionsCellItem
|
|
175
|
+
icon={<CancelIcon />}
|
|
176
|
+
label={t('cancel')}
|
|
177
|
+
className="textPrimary"
|
|
178
|
+
onClick={handleCancelClick(id)}
|
|
179
|
+
color="inherit"
|
|
180
|
+
/>,
|
|
181
|
+
];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return [
|
|
185
|
+
<GridActionsCellItem
|
|
186
|
+
icon={<EditIcon />}
|
|
187
|
+
label={t('edit')}
|
|
188
|
+
className="textPrimary"
|
|
189
|
+
onClick={handleEditClick(id)}
|
|
190
|
+
color="inherit"
|
|
191
|
+
/>,
|
|
192
|
+
<GridActionsCellItem
|
|
193
|
+
icon={<DeleteIcon />}
|
|
194
|
+
label={t('delete')}
|
|
195
|
+
onClick={handleDeleteClick(id)}
|
|
196
|
+
color="inherit"
|
|
197
|
+
/>,
|
|
198
|
+
];
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
|
|
203
|
+
const initialState = {
|
|
204
|
+
pagination: {
|
|
205
|
+
paginationModel: {
|
|
206
|
+
pageSize: 5,
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
return <>
|
|
212
|
+
<Typography variant={"h6"} sx={{ mt: 4 }}>
|
|
213
|
+
{props.exercise.getTranslation().name}
|
|
214
|
+
</Typography>
|
|
215
|
+
|
|
216
|
+
<Grid container spacing={2}>
|
|
217
|
+
<Grid size={{ xs: 12, md: 6 }}>
|
|
218
|
+
<FormQueryErrors mutationQuery={editLogQuery} />
|
|
219
|
+
|
|
220
|
+
<DataGrid
|
|
221
|
+
initialState={initialState}
|
|
222
|
+
pageSizeOptions={PAGINATION_OPTIONS.pageSizeOptions}
|
|
223
|
+
disableRowSelectionOnClick
|
|
224
|
+
rows={rows}
|
|
225
|
+
columns={columns}
|
|
226
|
+
editMode="row"
|
|
227
|
+
rowModesModel={rowModesModel}
|
|
228
|
+
onRowModesModelChange={handleRowModesModelChange}
|
|
229
|
+
onRowEditStop={handleRowEditStop}
|
|
230
|
+
processRowUpdate={processRowUpdate}
|
|
231
|
+
/>
|
|
232
|
+
|
|
233
|
+
</Grid>
|
|
234
|
+
<Grid size={{ xs: 12, md: 6 }}>
|
|
235
|
+
<TimeSeriesChart data={logEntries} key={props.exercise.id} />
|
|
236
|
+
</Grid>
|
|
237
|
+
</Grid>
|
|
238
|
+
</>;
|
|
239
|
+
};
|
|
240
|
+
/*
|
|
241
|
+
* Format the log entries so that they can be passed to the chart
|
|
242
|
+
*
|
|
243
|
+
* This is mostly due to the time, which needs to be a number to be shown
|
|
244
|
+
* in the scatter plot
|
|
245
|
+
*/
|
|
246
|
+
const formatData = (data: WorkoutLog[]) =>
|
|
247
|
+
data.map((log) => {
|
|
248
|
+
return {
|
|
249
|
+
id: log.id,
|
|
250
|
+
value: log.weight,
|
|
251
|
+
time: log.date.getTime(),
|
|
252
|
+
entry: log,
|
|
253
|
+
};
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
const ExerciseLogTooltip = ({ active, payload }: TooltipProps<ValueType, NameType>) => {
|
|
257
|
+
if (active) {
|
|
258
|
+
// TODO: translate rir
|
|
259
|
+
let rir = '';
|
|
260
|
+
if (payload?.[1].payload?.entry.rir) {
|
|
261
|
+
rir = `, ${payload?.[1].payload?.entry.rir} RiR`;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return <Card>
|
|
265
|
+
<CardContent>
|
|
266
|
+
<Typography variant="body1">
|
|
267
|
+
{luxonDateTimeToLocale(DateTime.fromMillis(payload?.[0].value as number))}
|
|
268
|
+
</Typography>
|
|
269
|
+
|
|
270
|
+
<Typography variant="body2">
|
|
271
|
+
{payload?.[1].payload?.entry.repetitions} × {payload?.[1].value}{payload?.[1].unit}{rir}
|
|
272
|
+
</Typography>
|
|
273
|
+
</CardContent>
|
|
274
|
+
</Card>;
|
|
275
|
+
}
|
|
276
|
+
return null;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export const TimeSeriesChart = (props: { data: WorkoutLog[] }) => {
|
|
280
|
+
|
|
281
|
+
// Group by rep count
|
|
282
|
+
//
|
|
283
|
+
// We draw series based on the same reps, as otherwise the chart wouldn't
|
|
284
|
+
// make much sense
|
|
285
|
+
const result: Map<number, WorkoutLog[]> = props.data.reduce(function (r, a) {
|
|
286
|
+
r.set(a.repetitions, r.get(a.repetitions) || []);
|
|
287
|
+
r.get(a.repetitions)!.push(a);
|
|
288
|
+
return r;
|
|
289
|
+
}, new Map());
|
|
290
|
+
|
|
291
|
+
const colorGenerator = generateChartColors(result.size);
|
|
292
|
+
|
|
293
|
+
return (
|
|
294
|
+
<Box>
|
|
295
|
+
<ResponsiveContainer width={"100%"} height={250}>
|
|
296
|
+
<ScatterChart>
|
|
297
|
+
<XAxis
|
|
298
|
+
dataKey="time"
|
|
299
|
+
domain={["auto", "auto"]}
|
|
300
|
+
name="Time"
|
|
301
|
+
tickFormatter={unixTime => luxonDateTimeToLocale(DateTime.fromMillis(unixTime))}
|
|
302
|
+
type="number"
|
|
303
|
+
/>
|
|
304
|
+
<YAxis
|
|
305
|
+
domain={["auto", "auto"]}
|
|
306
|
+
dataKey="value"
|
|
307
|
+
name="Value"
|
|
308
|
+
unit="kg"
|
|
309
|
+
/>
|
|
310
|
+
|
|
311
|
+
{Array.from(result).map(([key, value]) => {
|
|
312
|
+
const color = colorGenerator.next().value!;
|
|
313
|
+
const formattedData = formatData(value);
|
|
314
|
+
|
|
315
|
+
return <Scatter
|
|
316
|
+
key={key}
|
|
317
|
+
data={formattedData}
|
|
318
|
+
fill={color}
|
|
319
|
+
line={{ stroke: color }}
|
|
320
|
+
lineType="joint"
|
|
321
|
+
lineJointType="monotoneX"
|
|
322
|
+
name={key?.toString()}
|
|
323
|
+
/>;
|
|
324
|
+
}
|
|
325
|
+
)}
|
|
326
|
+
|
|
327
|
+
<Tooltip content={<ExerciseLogTooltip />} />
|
|
328
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
329
|
+
<Legend />
|
|
330
|
+
</ScatterChart>
|
|
331
|
+
</ResponsiveContainer>
|
|
332
|
+
</Box>
|
|
333
|
+
);
|
|
334
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { QueryClientProvider } from "@tanstack/react-query";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { RoutineDetailDropdown } from "components/WorkoutRoutines/widgets/RoutineDetailDropdown";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { MemoryRouter } from "react-router-dom";
|
|
7
|
+
import { testQueryClient } from "tests/queryClient";
|
|
8
|
+
import { testRoutine1 } from "tests/workoutRoutinesTestData";
|
|
9
|
+
|
|
10
|
+
describe("Test the RoutineDetailDropdown component", () => {
|
|
11
|
+
|
|
12
|
+
let user: ReturnType<typeof userEvent.setup>;
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
user = userEvent.setup();
|
|
16
|
+
jest.resetAllMocks();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('Edit entry is enabled for routines', async () => {
|
|
20
|
+
|
|
21
|
+
// Act
|
|
22
|
+
render(
|
|
23
|
+
<QueryClientProvider client={testQueryClient}>
|
|
24
|
+
<MemoryRouter>
|
|
25
|
+
<RoutineDetailDropdown routine={testRoutine1} />
|
|
26
|
+
</MemoryRouter>
|
|
27
|
+
</QueryClientProvider>
|
|
28
|
+
);
|
|
29
|
+
const menuButton = screen.getByRole('button');
|
|
30
|
+
await user.click(menuButton);
|
|
31
|
+
|
|
32
|
+
// Assert
|
|
33
|
+
const editMenuItem = screen.getByText('edit').closest('li');
|
|
34
|
+
expect(editMenuItem).not.toHaveAttribute('aria-disabled');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import MenuIcon from '@mui/icons-material/Menu';
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
Dialog,
|
|
5
|
+
DialogActions,
|
|
6
|
+
DialogContent,
|
|
7
|
+
DialogContentText,
|
|
8
|
+
DialogTitle,
|
|
9
|
+
Divider,
|
|
10
|
+
Menu,
|
|
11
|
+
MenuItem
|
|
12
|
+
} from "@mui/material";
|
|
13
|
+
import { Routine } from "components/WorkoutRoutines/models/Routine";
|
|
14
|
+
import { useDeleteRoutineQuery } from "components/WorkoutRoutines/queries";
|
|
15
|
+
import { RoutineTemplateForm } from "components/WorkoutRoutines/widgets/forms/RoutineTemplateForm";
|
|
16
|
+
import React, { useState } from "react";
|
|
17
|
+
import { useTranslation } from "react-i18next";
|
|
18
|
+
import { Link, useNavigate } from "react-router-dom";
|
|
19
|
+
import { makeLink, WgerLink } from "utils/url";
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export enum DialogToOpen {
|
|
23
|
+
NONE,
|
|
24
|
+
DELETE_CONFIRMATION,
|
|
25
|
+
EDIT_TEMPLATE
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const RoutineDetailDropdown = (props: { routine: Routine }) => {
|
|
29
|
+
|
|
30
|
+
const navigate = useNavigate();
|
|
31
|
+
const useDeleteQuery = useDeleteRoutineQuery(props.routine.id!);
|
|
32
|
+
|
|
33
|
+
const [t, i18n] = useTranslation();
|
|
34
|
+
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
35
|
+
const [deleteConfirmationOpen, setConfirmationOpen] = useState<DialogToOpen>(DialogToOpen.NONE);
|
|
36
|
+
|
|
37
|
+
const open = Boolean(anchorEl);
|
|
38
|
+
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
39
|
+
setAnchorEl(event.currentTarget);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const handleDelete = () => {
|
|
43
|
+
setConfirmationOpen(DialogToOpen.DELETE_CONFIRMATION);
|
|
44
|
+
handleClose(); // Close the dropdown menu
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const handleTemplate = () => {
|
|
48
|
+
setConfirmationOpen(DialogToOpen.EDIT_TEMPLATE);
|
|
49
|
+
handleClose();
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleConfirmDelete = async () => {
|
|
53
|
+
await useDeleteQuery.mutateAsync();
|
|
54
|
+
navigate(makeLink(WgerLink.ROUTINE_OVERVIEW, i18n.language));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const handleCloseDialogs = () => {
|
|
58
|
+
setConfirmationOpen(DialogToOpen.NONE);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const handleClose = () => {
|
|
62
|
+
setAnchorEl(null);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
* Note: this is a workaround. Instead of just using the navigate function we need to
|
|
67
|
+
* force a reload of the page, otherwise the drag-and-drop doesn't work properly
|
|
68
|
+
* when loaded from within the django application. This has probably to do with
|
|
69
|
+
* the way we add the components there. If we find a solution for that one day,
|
|
70
|
+
* this can be removed.
|
|
71
|
+
*
|
|
72
|
+
* See also: https://github.com/wger-project/wger/issues/1943
|
|
73
|
+
*/
|
|
74
|
+
const navigateEdit = () => window.location.href = makeLink(
|
|
75
|
+
WgerLink.ROUTINE_EDIT,
|
|
76
|
+
i18n.language,
|
|
77
|
+
{ id: props.routine.id! }
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div>
|
|
83
|
+
<Button onClick={handleClick}>
|
|
84
|
+
<MenuIcon />
|
|
85
|
+
</Button>
|
|
86
|
+
<Menu
|
|
87
|
+
anchorEl={anchorEl}
|
|
88
|
+
open={open}
|
|
89
|
+
onClose={handleClose}
|
|
90
|
+
>
|
|
91
|
+
<MenuItem
|
|
92
|
+
// disabled={props.routine.isTemplate}
|
|
93
|
+
onClick={navigateEdit}>
|
|
94
|
+
{t("edit")}
|
|
95
|
+
</MenuItem>
|
|
96
|
+
<MenuItem
|
|
97
|
+
component={Link}
|
|
98
|
+
to={makeLink(WgerLink.ROUTINE_DETAIL_TABLE, i18n.language, { id: props.routine.id! })}>
|
|
99
|
+
Table view
|
|
100
|
+
</MenuItem>
|
|
101
|
+
{props.routine.isNotTemplate && <MenuItem
|
|
102
|
+
component={Link}
|
|
103
|
+
to={makeLink(WgerLink.ROUTINE_LOGS_OVERVIEW, i18n.language, { id: props.routine.id! })}>
|
|
104
|
+
{t("routines.logsOverview")}
|
|
105
|
+
</MenuItem>}
|
|
106
|
+
{props.routine.isNotTemplate && <MenuItem
|
|
107
|
+
component={Link}
|
|
108
|
+
to={makeLink(WgerLink.ROUTINE_STATS_OVERVIEW, i18n.language, { id: props.routine.id! })}>
|
|
109
|
+
{t("routines.statsOverview")}
|
|
110
|
+
</MenuItem>}
|
|
111
|
+
<MenuItem
|
|
112
|
+
component="a"
|
|
113
|
+
href={makeLink(WgerLink.ROUTINE_COPY, i18n.language, { id: props.routine.id! })}
|
|
114
|
+
>
|
|
115
|
+
{t("routines.duplicate")}
|
|
116
|
+
</MenuItem>
|
|
117
|
+
<MenuItem onClick={handleTemplate}>
|
|
118
|
+
{t("routines.markAsTemplate")}
|
|
119
|
+
</MenuItem>
|
|
120
|
+
<MenuItem
|
|
121
|
+
component="a"
|
|
122
|
+
href={makeLink(WgerLink.ROUTINE_PDF_TABLE, i18n.language, { id: props.routine.id! })}
|
|
123
|
+
download={`Routine-${props.routine.id}-table.pdf`}>
|
|
124
|
+
{t("routines.downloadPdfTable")}
|
|
125
|
+
</MenuItem>
|
|
126
|
+
<MenuItem
|
|
127
|
+
component="a"
|
|
128
|
+
href={makeLink(WgerLink.ROUTINE_PDF_LOGS, i18n.language, { id: props.routine.id! })}
|
|
129
|
+
download={`Routine-${props.routine.id}-logs.pdf`}>
|
|
130
|
+
{t("routines.downloadPdfLogs")}
|
|
131
|
+
</MenuItem>
|
|
132
|
+
<MenuItem
|
|
133
|
+
component="a"
|
|
134
|
+
href={makeLink(WgerLink.ROUTINE_ICAL, i18n.language, { id: props.routine.id! })}
|
|
135
|
+
download={`Routine-${props.routine.id}-calendar.ics`}>
|
|
136
|
+
{t("routines.downloadIcal")}
|
|
137
|
+
</MenuItem>
|
|
138
|
+
<Divider />
|
|
139
|
+
<MenuItem onClick={handleDelete}>{t("delete")}</MenuItem>
|
|
140
|
+
</Menu>
|
|
141
|
+
|
|
142
|
+
<Dialog
|
|
143
|
+
open={deleteConfirmationOpen === DialogToOpen.DELETE_CONFIRMATION}
|
|
144
|
+
onClose={handleCloseDialogs}
|
|
145
|
+
>
|
|
146
|
+
<DialogTitle id="alert-dialog-title">
|
|
147
|
+
{t('delete')}
|
|
148
|
+
</DialogTitle>
|
|
149
|
+
<DialogContent>
|
|
150
|
+
<DialogContentText id="alert-dialog-description">
|
|
151
|
+
{t('deleteConfirmation', { name: props.routine.name })}
|
|
152
|
+
</DialogContentText>
|
|
153
|
+
</DialogContent>
|
|
154
|
+
<DialogActions>
|
|
155
|
+
<Button onClick={handleCloseDialogs}>
|
|
156
|
+
{t("cancel")}
|
|
157
|
+
</Button>
|
|
158
|
+
<Button onClick={handleConfirmDelete} color="error" autoFocus>
|
|
159
|
+
{t("delete")}
|
|
160
|
+
</Button>
|
|
161
|
+
</DialogActions>
|
|
162
|
+
</Dialog>
|
|
163
|
+
|
|
164
|
+
<Dialog
|
|
165
|
+
open={deleteConfirmationOpen === DialogToOpen.EDIT_TEMPLATE}
|
|
166
|
+
onClose={handleCloseDialogs}
|
|
167
|
+
>
|
|
168
|
+
<DialogTitle>
|
|
169
|
+
{t("routines.markAsTemplate")}
|
|
170
|
+
</DialogTitle>
|
|
171
|
+
<DialogContent>
|
|
172
|
+
<DialogContentText>
|
|
173
|
+
<RoutineTemplateForm routine={props.routine} />
|
|
174
|
+
</DialogContentText>
|
|
175
|
+
</DialogContent>
|
|
176
|
+
<DialogActions>
|
|
177
|
+
<Button onClick={handleCloseDialogs}>
|
|
178
|
+
{t("close")}
|
|
179
|
+
</Button>
|
|
180
|
+
</DialogActions>
|
|
181
|
+
</Dialog>
|
|
182
|
+
</div>
|
|
183
|
+
);
|
|
184
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { useRoutineDetailQuery } from "components/WorkoutRoutines/queries";
|
|
4
|
+
import { RoutineDetailsCard } from "components/WorkoutRoutines/widgets/RoutineDetailsCard";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { MemoryRouter, Route, Routes } from "react-router";
|
|
7
|
+
import { testRoutine1 } from "tests/workoutRoutinesTestData";
|
|
8
|
+
|
|
9
|
+
jest.mock("components/WorkoutRoutines/queries");
|
|
10
|
+
|
|
11
|
+
const queryClient = new QueryClient();
|
|
12
|
+
|
|
13
|
+
describe("Test the RoutineDetail component", () => {
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
(useRoutineDetailQuery as jest.Mock).mockImplementation(() => ({
|
|
17
|
+
isSuccess: true,
|
|
18
|
+
isLoading: false,
|
|
19
|
+
data: testRoutine1
|
|
20
|
+
}));
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('renders a specific routine', async () => {
|
|
24
|
+
|
|
25
|
+
// Act
|
|
26
|
+
render(
|
|
27
|
+
<QueryClientProvider client={queryClient}>
|
|
28
|
+
<MemoryRouter initialEntries={['/routine/101']}>
|
|
29
|
+
<Routes>
|
|
30
|
+
<Route path="routine/:routineId" element={<RoutineDetailsCard />} />
|
|
31
|
+
</Routes>
|
|
32
|
+
</MemoryRouter>
|
|
33
|
+
</QueryClientProvider>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// Assert
|
|
37
|
+
expect(useRoutineDetailQuery).toHaveBeenCalledWith(101);
|
|
38
|
+
expect(screen.getByText('Full body routine')).toBeInTheDocument();
|
|
39
|
+
expect(screen.getByText('Every day is leg day 🦵🏻')).toBeInTheDocument();
|
|
40
|
+
expect(screen.getByText('Squats')).toBeInTheDocument();
|
|
41
|
+
});
|
|
42
|
+
});
|