Add Workout Library feature with browse, create, and favorites
This commit is contained in:
74
src/services/workoutLibraryApi.js
Normal file
74
src/services/workoutLibraryApi.js
Normal file
@@ -0,0 +1,74 @@
|
||||
import api from './api'
|
||||
|
||||
export const workoutLibraryApi = {
|
||||
// Browse & Search
|
||||
async getWorkouts(params = {}) {
|
||||
const { data } = await api.get('/api/protected/workout-library', { params })
|
||||
return data
|
||||
},
|
||||
|
||||
async getWorkout(workoutId) {
|
||||
const { data } = await api.get(`/api/protected/workout-library/${workoutId}`)
|
||||
return data
|
||||
},
|
||||
|
||||
async getWorkoutIntervals(workoutId) {
|
||||
const { data } = await api.get(`/api/protected/workout-library/${workoutId}/intervals`)
|
||||
return data
|
||||
},
|
||||
|
||||
// User's Workouts
|
||||
async getUserWorkouts() {
|
||||
const { data } = await api.get('/api/protected/workouts')
|
||||
return data
|
||||
},
|
||||
|
||||
async createWorkout(workout) {
|
||||
const { data } = await api.post('/api/protected/workouts', workout)
|
||||
return data
|
||||
},
|
||||
|
||||
async updateWorkout(workoutId, workout) {
|
||||
const { data } = await api.put(`/api/protected/workouts/${workoutId}`, workout)
|
||||
return data
|
||||
},
|
||||
|
||||
async deleteWorkout(workoutId) {
|
||||
const { data } = await api.delete(`/api/protected/workouts/${workoutId}`)
|
||||
return data
|
||||
},
|
||||
|
||||
async publishWorkout(workoutId) {
|
||||
const { data } = await api.post(`/api/protected/workouts/${workoutId}/publish`)
|
||||
return data
|
||||
},
|
||||
|
||||
// Favorites
|
||||
async getFavorites() {
|
||||
const { data } = await api.get('/api/protected/workout-favorites')
|
||||
return data
|
||||
},
|
||||
|
||||
async addFavorite(workoutId) {
|
||||
const { data } = await api.post(`/api/protected/workout-favorites/${workoutId}`)
|
||||
return data
|
||||
},
|
||||
|
||||
async removeFavorite(workoutId) {
|
||||
const { data } = await api.delete(`/api/protected/workout-favorites/${workoutId}`)
|
||||
return data
|
||||
},
|
||||
|
||||
// Usage & Ratings
|
||||
async recordUsage(workoutId) {
|
||||
const { data } = await api.post(`/api/protected/workout-library/${workoutId}/use`)
|
||||
return data
|
||||
},
|
||||
|
||||
async rateWorkout(workoutId, rating) {
|
||||
const { data } = await api.post(`/api/protected/workout-library/${workoutId}/rate`, { rating })
|
||||
return data
|
||||
}
|
||||
}
|
||||
|
||||
export default workoutLibraryApi
|
||||
Reference in New Issue
Block a user