2021-09-24 12:11:38 +02:00
|
|
|
<template>
|
|
|
|
<div class="workout-detail">
|
|
|
|
<Card :without-title="false">
|
|
|
|
<template #title>
|
2021-09-24 15:03:40 +02:00
|
|
|
<div
|
|
|
|
class="workout-previous workout-arrow"
|
|
|
|
:class="{ inactive: !workout.workout.previous_workout }"
|
|
|
|
:title="
|
|
|
|
workout.workout.previous_workout
|
|
|
|
? t('workouts.PREVIOUS_WORKOUT')
|
|
|
|
: t('workouts.NO_PREVIOUS_WORKOUT')
|
|
|
|
"
|
|
|
|
@click="
|
|
|
|
workout.workout.previous_workout
|
|
|
|
? $router.push({
|
|
|
|
name: 'Workout',
|
|
|
|
params: { workoutId: workout.workout.previous_workout },
|
|
|
|
})
|
|
|
|
: null
|
|
|
|
"
|
|
|
|
>
|
2021-09-24 12:11:38 +02:00
|
|
|
<i class="fa fa-chevron-left" aria-hidden="true" />
|
|
|
|
</div>
|
|
|
|
<div class="workout-card-title">
|
|
|
|
<div class="sport-img">
|
|
|
|
<img alt="workout sport logo" :src="sport.img" />
|
|
|
|
</div>
|
|
|
|
<div class="workout-title-date">
|
|
|
|
<div class="workout-title">{{ workout.workout.title }}</div>
|
|
|
|
<div class="workout-date">
|
|
|
|
{{ workoutDate.workout_date }} - {{ workoutDate.workout_time }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-09-24 15:03:40 +02:00
|
|
|
<div
|
|
|
|
class="workout-next workout-arrow"
|
|
|
|
:class="{ inactive: !workout.workout.next_workout }"
|
|
|
|
:title="
|
|
|
|
workout.workout.next_workout
|
|
|
|
? t('workouts.NEXT_WORKOUT')
|
|
|
|
: t('workouts.NO_NEXT_WORKOUT')
|
|
|
|
"
|
|
|
|
@click="
|
|
|
|
workout.workout.next_workout
|
|
|
|
? $router.push({
|
|
|
|
name: 'Workout',
|
|
|
|
params: { workoutId: workout.workout.next_workout },
|
|
|
|
})
|
|
|
|
: null
|
|
|
|
"
|
|
|
|
>
|
2021-09-24 12:11:38 +02:00
|
|
|
<i class="fa fa-chevron-right" aria-hidden="true" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template #content>
|
|
|
|
<WorkoutMap :workout="workout" />
|
2021-09-24 19:51:04 +02:00
|
|
|
<WorkoutData :workout="workout.workout" />
|
2021-09-24 12:11:38 +02:00
|
|
|
</template>
|
|
|
|
</Card>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-09-24 15:03:40 +02:00
|
|
|
import { PropType, defineComponent, computed, watch } from 'vue'
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
import { useRoute } from 'vue-router'
|
2021-09-24 12:11:38 +02:00
|
|
|
|
|
|
|
import Card from '@/components/Common/Card.vue'
|
2021-09-24 19:51:04 +02:00
|
|
|
import WorkoutData from '@/components/Workout/WorkoutDetail/WorkoutData.vue'
|
2021-09-24 12:11:38 +02:00
|
|
|
import WorkoutMap from '@/components/Workout/WorkoutDetail/WorkoutMap.vue'
|
2021-09-24 15:03:40 +02:00
|
|
|
import { WORKOUTS_STORE } from '@/store/constants'
|
2021-09-24 12:11:38 +02:00
|
|
|
import { ISport } from '@/types/sports'
|
|
|
|
import { IAuthUserProfile } from '@/types/user'
|
|
|
|
import { IWorkoutState } from '@/types/workouts'
|
2021-09-24 15:03:40 +02:00
|
|
|
import { useStore } from '@/use/useStore'
|
2021-09-24 12:11:38 +02:00
|
|
|
import { formatWorkoutDate, getDateWithTZ } from '@/utils/dates'
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: 'WorkoutDetail',
|
|
|
|
components: {
|
|
|
|
Card,
|
2021-09-24 19:51:04 +02:00
|
|
|
WorkoutData,
|
2021-09-24 12:11:38 +02:00
|
|
|
WorkoutMap,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
authUser: {
|
|
|
|
type: Object as PropType<IAuthUserProfile>,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
sports: {
|
|
|
|
type: Object as PropType<ISport[]>,
|
|
|
|
},
|
|
|
|
workout: {
|
|
|
|
type: Object as PropType<IWorkoutState>,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
setup(props) {
|
2021-09-24 15:03:40 +02:00
|
|
|
const route = useRoute()
|
|
|
|
const store = useStore()
|
|
|
|
const { t } = useI18n()
|
|
|
|
watch(
|
|
|
|
() => route.params.workoutId,
|
|
|
|
async (newWorkoutId) => {
|
|
|
|
store.dispatch(WORKOUTS_STORE.ACTIONS.GET_WORKOUT, newWorkoutId)
|
|
|
|
}
|
|
|
|
)
|
2021-09-24 12:11:38 +02:00
|
|
|
return {
|
|
|
|
sport: computed(() =>
|
|
|
|
props.sports
|
|
|
|
? props.sports.find(
|
|
|
|
(sport) => sport.id === props.workout.workout.sport_id
|
|
|
|
)
|
|
|
|
: {}
|
|
|
|
),
|
|
|
|
workoutDate: computed(() =>
|
|
|
|
formatWorkoutDate(
|
|
|
|
getDateWithTZ(
|
|
|
|
props.workout.workout.workout_date,
|
|
|
|
props.authUser.timezone
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
2021-09-24 15:03:40 +02:00
|
|
|
t,
|
2021-09-24 12:11:38 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import '~@/scss/base';
|
|
|
|
.workout-detail {
|
2021-09-24 14:10:20 +02:00
|
|
|
display: flex;
|
2021-09-24 12:11:38 +02:00
|
|
|
::v-deep(.card) {
|
2021-09-24 14:10:20 +02:00
|
|
|
width: 100%;
|
2021-09-24 12:11:38 +02:00
|
|
|
.card-title {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
2021-09-24 15:03:40 +02:00
|
|
|
.workout-arrow {
|
|
|
|
cursor: pointer;
|
|
|
|
&.inactive {
|
|
|
|
color: var(--disabled-color);
|
|
|
|
cursor: default;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-24 12:11:38 +02:00
|
|
|
.workout-card-title {
|
|
|
|
display: flex;
|
|
|
|
flex-grow: 1;
|
|
|
|
.sport-img {
|
|
|
|
img {
|
|
|
|
height: 35px;
|
|
|
|
width: 35px;
|
|
|
|
padding: 0 $default-padding;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.workout-date {
|
|
|
|
font-size: 0.8em;
|
|
|
|
font-weight: normal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-24 19:51:04 +02:00
|
|
|
.card-content {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
@media screen and (max-width: $small-limit) {
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
}
|
2021-09-24 12:11:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|