diff --git a/src/pages/workouts/WorkoutList.vue b/src/pages/workouts/WorkoutList.vue
index 2f96ee2..10a6441 100644
--- a/src/pages/workouts/WorkoutList.vue
+++ b/src/pages/workouts/WorkoutList.vue
@@ -3,19 +3,22 @@
Тренировки
-
+
Тренировки не найдены
-
+
+
@@ -28,14 +31,39 @@ import { AxiosResponse, AxiosInstance } from "axios";
import { ref, inject } from 'vue';
import { useToast } from "vuestic-ui/web-components";
+const deleteItem = (id: string) => {
+ axiosAuth
+ .delete(`/api/v0/workouts/${id}`)
+ .then((_: AxiosResponse) => {
+ init({
+ message: "Тренировка успешно удалена.",
+ color: "success",
+ });
+ initWorkouts();
+ })
+ .catch((error: any) => {
+ console.log(error);
+ init({
+ message: "Что-то пошло не так.",
+ color: "error",
+ });
+ });
+};
-
-function secondsToDuration(seconds: number) : string {
+const secondsToDuration = (seconds: number) => {
var hours = Math.floor(seconds / 3600);
var minutes = Math.floor((seconds % 3600) / 60);
return `${hours} ч. ${minutes} мин.`;
}
+const distConvert = (speed: number) => {
+ return Math.round(speed/1000)
+}
+
+const speedConvert = (speed: number) => {
+ return Math.round(speed*3.6)
+}
+
type WorkoutItem = {
id: string;
@@ -50,24 +78,28 @@ type WorkoutItem = {
speed: number;
power: number;
duraion_sec: number;
+ distantion: number;
};
const axiosAuth= inject('axiosAuth') as AxiosInstance;
let workoutItems = ref>([]);
const { init } = useToast();
-axiosAuth
- .get(`/api/v0/workouts`)
- .then((response: AxiosResponse) => {
- workoutItems.value = response.data.results;
- })
- .catch((error: any) => {
- console.log(error);
- init({
- message: "Что-то пошло не так.",
- color: "error",
- });
- });
+const initWorkouts = () => {
+ axiosAuth
+ .get(`/api/v0/workouts`)
+ .then((response: AxiosResponse) => {
+ workoutItems.value = response.data.results;
+ })
+ .catch((error: any) => {
+ console.log(error);
+ init({
+ message: "Что-то пошло не так.",
+ color: "error",
+ });
+ });
+}
+initWorkouts();