@wger-project/react-components 25.11.22 → 25.12.5

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/src/routes.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { Dashboard } from "components/Dashboard/Dashboard";
1
+ import { ConfigurableDashboard } from "components/Dashboard/ConfigurableDashboard";
2
2
  import { ExerciseOverview } from "components/Exercises/ExerciseOverview";
3
3
  import { MeasurementCategoryDetail } from "components/Measurements/Screens/MeasurementCategoryDetail";
4
4
  import { MeasurementCategoryOverview } from "components/Measurements/Screens/MeasurementCategoryOverview";
@@ -42,96 +42,99 @@ import { Route, Routes } from "react-router-dom";
42
42
  * See also src/utils/url.ts
43
43
  */
44
44
  export const WgerRoutes = () => {
45
- return <Routes>
46
- <Route path="/:lang">
45
+ return (
46
+ <Routes>
47
+ <Route path="/:lang">
48
+ <Route path="routine">
49
+ <Route index element={<RoutineOverview />} />
50
+ <Route path="overview" element={<RoutineOverview />} />
51
+ <Route path="calendar" element={<Calendar />} />
52
+ <Route path="add" element={<RoutineAdd />} />
47
53
 
48
- <Route path="routine">
49
- <Route index element={<RoutineOverview />} />
50
- <Route path="overview" element={<RoutineOverview />} />
51
- <Route path="calendar" element={<Calendar />} />
52
- <Route path="add" element={<RoutineAdd />} />
54
+ <Route path=":routineId">
55
+ <Route path="day/:dayId">
56
+ <Route path="add-logs" element={<SessionAdd />} />
57
+ </Route>
58
+ <Route path="edit">
59
+ <Route index element={<RoutineEdit />} />
60
+ <Route path="progression/:slotId" element={<SlotProgressionEdit />} />
61
+ </Route>
53
62
 
54
- <Route path=":routineId">
55
- <Route path="day/:dayId">
56
- <Route path="add-logs" element={<SessionAdd />} />
57
- </Route>
58
- <Route path="edit">
59
- <Route index element={<RoutineEdit />} />
60
- <Route path="progression/:slotId" element={<SlotProgressionEdit />} />
63
+ <Route path="view" element={<RoutineDetail />} />
64
+ <Route path="table" element={<RoutineDetailsTable />} />
65
+ <Route path="logs" element={<WorkoutLogs />} />
66
+ <Route path="statistics" element={<WorkoutStats />} />
61
67
  </Route>
62
68
 
63
- <Route path="view" element={<RoutineDetail />} />
64
- <Route path="table" element={<RoutineDetailsTable />} />
65
- <Route path="logs" element={<WorkoutLogs />} />
66
- <Route path="statistics" element={<WorkoutStats />} />
67
- </Route>
68
-
69
- <Route path="templates">
70
- <Route path=":routineId">
71
- <Route path="view" element={<TemplateDetail />} />
69
+ <Route path="templates">
70
+ <Route path=":routineId">
71
+ <Route path="view" element={<TemplateDetail />} />
72
+ </Route>
73
+ <Route path="overview">
74
+ <Route path="private" element={<PrivateTemplateOverview />} />
75
+ <Route path="public" element={<PublicTemplateOverview />} />
76
+ </Route>
72
77
  </Route>
73
- <Route path="overview">
74
- <Route path="private" element={<PrivateTemplateOverview />} />
75
- <Route path="public" element={<PublicTemplateOverview />} />
78
+ </Route>
79
+ <Route path="measurement">
80
+ <Route index element={<MeasurementCategoryOverview />} />
81
+ <Route path="overview" element={<MeasurementCategoryOverview />} />
82
+ <Route path="category/:categoryId" element={<MeasurementCategoryDetail />}></Route>
83
+ </Route>
84
+ <Route path="exercise">
85
+ <Route index element={<ExerciseOverview />} />
86
+ <Route path="overview" element={<ExerciseOverview />} />
87
+ <Route path=":exerciseId" element={<ExerciseDetailPage />}>
88
+ <Route path="view" element={<ExerciseDetailPage />}>
89
+ <Route path=":slug" element={<ExerciseDetailPage />} />
90
+ </Route>
76
91
  </Route>
92
+ <Route path="contribute" element={<AddExercise />} />
77
93
  </Route>
78
-
79
- </Route>
80
- <Route path="measurement">
81
- <Route index element={<MeasurementCategoryOverview />} />
82
- <Route path="overview" element={<MeasurementCategoryOverview />} />
83
- <Route path="category/:categoryId" element={<MeasurementCategoryDetail />}>
94
+ <Route path="weight">
95
+ <Route path="overview" element={<WeightOverview />} />
96
+ <Route path="add" element={<AddWeight />} />
84
97
  </Route>
85
- </Route>
86
- <Route path="exercise">
87
- <Route index element={<ExerciseOverview />} />
88
- <Route path="overview" element={<ExerciseOverview />} />
89
- <Route path=":exerciseId" element={<ExerciseDetailPage />}>
90
- <Route path="view" element={<ExerciseDetailPage />}>
91
- <Route path=":slug" element={<ExerciseDetailPage />} />
98
+ <Route path="nutrition">
99
+ <Route path="overview" element={<PlansOverview />} />
100
+ <Route path=":planId">
101
+ <Route path="view" element={<PlanDetail />} />
102
+ <Route path=":date" element={<NutritionDiaryOverview />} />
103
+ <Route path="diary" element={<NutritionDiaryOverview />} />
104
+ </Route>
105
+ <Route path="calculator">
106
+ <Route path="bmi" element={<BmiCalculator />} />
107
+ <Route path="calories" element={<CaloriesCalculator />} />
108
+ </Route>
109
+ <Route path="ingredient">
110
+ <Route path="overview" element={<Ingredients />} />
92
111
  </Route>
93
112
  </Route>
94
- <Route path="contribute" element={<AddExercise />} />
95
- </Route>
96
- <Route path="weight">
97
- <Route path="overview" element={<WeightOverview />} />
98
- <Route path="add" element={<AddWeight />} />
99
- </Route>
100
- <Route path="nutrition">
101
- <Route path="overview" element={<PlansOverview />} />
102
- <Route path=":planId">
103
- <Route path="view" element={<PlanDetail />} />
104
- <Route path=":date" element={<NutritionDiaryOverview />} />
105
- <Route path="diary" element={<NutritionDiaryOverview />} />
113
+ <Route path="software">
114
+ <Route path="about-us" element={<About />} />
115
+ <Route path="api" element={<ApiPage />} />
116
+ <Route path="equipment" element={<Equipments />} />
106
117
  </Route>
107
- <Route path="calculator">
108
- <Route path="bmi" element={<BmiCalculator />} />
109
- <Route path="calories" element={<CaloriesCalculator />} />
118
+ <Route path="login" element={<Login />} />
119
+ <Route path="user">
120
+ <Route path="preferences" element={<Preferences />} />
110
121
  </Route>
111
- <Route path="ingredient">
112
- <Route path="overview" element={<Ingredients />} />
122
+ <Route path="dashboard">
123
+ <Route index element={<ConfigurableDashboard />} />
124
+ <Route path="" element={<ConfigurableDashboard />} />
113
125
  </Route>
114
126
  </Route>
115
- <Route path="software">
116
- <Route path="about-us" element={<About />} />
117
- <Route path="api" element={<ApiPage />} />
118
- <Route path="equipment" element={<Equipments />} />
119
- </Route>
120
- <Route path="login" element={<Login />} />
121
- <Route path="user">
122
- <Route path="preferences" element={<Preferences />} />
123
- </Route>
124
- </Route>
125
- <Route path="/" element={<Dashboard />} />
127
+ <Route path="/" element={<ConfigurableDashboard />} />
126
128
 
127
- {/* This route matches when no other route match, so a 404 */}
128
- <Route
129
- path="*"
130
- element={
131
- <main style={{ padding: "1rem" }}>
132
- <p>404, Page NOT FOUND</p>
133
- </main>
134
- }
135
- />
136
- </Routes>;
137
- };
129
+ {/* This route matches when no other route match, so a 404 */}
130
+ <Route
131
+ path="*"
132
+ element={
133
+ <main style={{ padding: "1rem" }}>
134
+ <p>404, Page NOT FOUND</p>
135
+ </main>
136
+ }
137
+ />
138
+ </Routes>
139
+ );
140
+ };
@@ -14,7 +14,6 @@ export const EXERCISE_TRANSLATION_PATH = 'exercise-translation';
14
14
  */
15
15
  export const getExerciseTranslations = async (id: number): Promise<Translation[]> => {
16
16
  const url = makeUrl(EXERCISE_PATH, { query: { exercise: id } });
17
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
17
  const { data } = await axios.get<ResponseType<Translation>>(url, {
19
18
  headers: makeHeader(),
20
19
  });
@@ -26,7 +25,7 @@ export const getExerciseTranslations = async (id: number): Promise<Translation[]
26
25
  /*
27
26
  * Search for exercises by name using the exerciseinfo endpoint
28
27
  */
29
- export const searchExerciseTranslations = async (name: string,languageCode: string = ENGLISH_LANGUAGE_CODE,searchEnglish: boolean = true): Promise<Exercise[]> => {
28
+ export const searchExerciseTranslations = async (name: string, languageCode: string = ENGLISH_LANGUAGE_CODE, searchEnglish: boolean = true): Promise<Exercise[]> => {
30
29
  const languages = [languageCode];
31
30
  if (languageCode !== LANGUAGE_SHORT_ENGLISH && searchEnglish) {
32
31
  languages.push(LANGUAGE_SHORT_ENGLISH);
@@ -34,19 +33,19 @@ export const searchExerciseTranslations = async (name: string,languageCode: stri
34
33
 
35
34
  const url = makeUrl('exerciseinfo', {
36
35
  query: {
37
- name__search: name,
38
- language__code: languages.join(','),
36
+ "name__search": name,
37
+ "language__code": languages.join(','),
39
38
  limit: 50,
40
39
  }
41
40
  });
42
41
 
43
42
  try {
44
43
  const { data } = await axios.get<ResponseType<Exercise>>(url);
45
-
44
+
46
45
  if (!data || !data.results || !Array.isArray(data.results)) {
47
46
  return [];
48
47
  }
49
-
48
+
50
49
  const adapter = new ExerciseAdapter();
51
50
  return data.results.map((item: unknown) => adapter.fromJson(item));
52
51
  } catch {
@@ -11,17 +11,17 @@ describe("Exercise video service API tests", () => {
11
11
  id: 1,
12
12
  uuid: "b1c934fa-c4f8-4d84-8cb4-7802be0d284c",
13
13
  exercise: 258,
14
- exercise_uuid: "6260e3aa-e46b-4b4b-8ada-58bfd0922d3a",
14
+ "exercise_uuid": "6260e3aa-e46b-4b4b-8ada-58bfd0922d3a",
15
15
  video: "http://localhost:8000/media/exercise-video/258/b1c934fa-c4f8-4d84-8cb4-7802be0d284c.mp4",
16
- is_main: false,
16
+ "is_main": false,
17
17
  size: 0,
18
18
  duration: "0.00",
19
19
  width: 0,
20
20
  height: 0,
21
21
  codec: "",
22
- codec_long: "",
22
+ "codec_long": "",
23
23
  license: 2,
24
- license_author: null,
24
+ "license_author": null,
25
25
  };
26
26
 
27
27
  const video = new ExerciseVideo(
@@ -1,22 +0,0 @@
1
- import Grid from '@mui/material/Grid';
2
- import { NutritionCard } from "components/Dashboard/NutritionCard";
3
- import { RoutineCard } from "components/Dashboard/RoutineCard";
4
- import { WeightCard } from "components/Dashboard/WeightCard";
5
- import React from 'react';
6
-
7
- export const Dashboard = () => {
8
-
9
- return (
10
- <Grid container spacing={2}>
11
- <Grid size={{ xs: 12, sm: 4 }}>
12
- <RoutineCard />
13
- </Grid>
14
- <Grid size={{ xs: 12, sm: 4 }}>
15
- <NutritionCard />
16
- </Grid>
17
- <Grid size={{ xs: 12, sm: 4 }}>
18
- <WeightCard />
19
- </Grid>
20
- </Grid>
21
- );
22
- };