feat: add API services for templates, stats, integrations, and calendar
This commit is contained in:
@@ -3,19 +3,19 @@ import api from './api'
|
||||
export const workoutLibraryApi = {
|
||||
// Get workout types, categories, and difficulties
|
||||
async getTypes() {
|
||||
const { data } = await api.get('/protected/library/types')
|
||||
const { data } = await api.get('/api/protected/library/types')
|
||||
return data
|
||||
},
|
||||
|
||||
// Get system-provided workouts
|
||||
async getSystemWorkouts() {
|
||||
const { data } = await api.get('/protected/library/system')
|
||||
const { data } = await api.get('/api/protected/library/system')
|
||||
return data
|
||||
},
|
||||
|
||||
// Browse public workouts (paginated)
|
||||
async browseWorkouts(page = 1, pageSize = 20) {
|
||||
const { data } = await api.get('/protected/library/browse', {
|
||||
const { data } = await api.get('/api/protected/library/browse', {
|
||||
params: { page, page_size: pageSize }
|
||||
})
|
||||
return data
|
||||
@@ -23,7 +23,7 @@ export const workoutLibraryApi = {
|
||||
|
||||
// Search/filter workouts
|
||||
async searchWorkouts(params = {}) {
|
||||
const { data } = await api.get('/protected/library/search', {
|
||||
const { data } = await api.get('/api/protected/library/search', {
|
||||
params: {
|
||||
q: params.search || undefined,
|
||||
type: params.type || undefined,
|
||||
@@ -38,73 +38,73 @@ export const workoutLibraryApi = {
|
||||
|
||||
// Get workouts by type
|
||||
async getWorkoutsByType(type) {
|
||||
const { data } = await api.get(`/protected/library/type/${type}`)
|
||||
const { data } = await api.get(`/api/protected/library/type/${type}`)
|
||||
return data
|
||||
},
|
||||
|
||||
// Get workouts by category
|
||||
async getWorkoutsByCategory(category) {
|
||||
const { data } = await api.get(`/protected/library/category/${category}`)
|
||||
const { data } = await api.get(`/api/protected/library/category/${category}`)
|
||||
return data
|
||||
},
|
||||
|
||||
// Get single workout details
|
||||
async getWorkout(workoutId) {
|
||||
const { data } = await api.get(`/protected/library/${workoutId}`)
|
||||
const { data } = await api.get(`/api/protected/library/${workoutId}`)
|
||||
return data
|
||||
},
|
||||
|
||||
// Get current user's custom workouts
|
||||
async getUserWorkouts() {
|
||||
const { data } = await api.get('/protected/library/mine')
|
||||
const { data } = await api.get('/api/protected/library/mine')
|
||||
return data
|
||||
},
|
||||
|
||||
// Get user's favorited workouts
|
||||
async getFavorites() {
|
||||
const { data } = await api.get('/protected/library/favorites')
|
||||
const { data } = await api.get('/api/protected/library/favorites')
|
||||
return data
|
||||
},
|
||||
|
||||
// Create custom workout
|
||||
async createWorkout(workout) {
|
||||
const { data } = await api.post('/protected/library', workout)
|
||||
const { data } = await api.post('/api/protected/library', workout)
|
||||
return data
|
||||
},
|
||||
|
||||
// Update user's workout
|
||||
async updateWorkout(workoutId, workout) {
|
||||
const { data } = await api.put(`/protected/library/${workoutId}`, workout)
|
||||
const { data } = await api.put(`/api/protected/library/${workoutId}`, workout)
|
||||
return data
|
||||
},
|
||||
|
||||
// Delete user's workout
|
||||
async deleteWorkout(workoutId) {
|
||||
const { data } = await api.delete(`/protected/library/${workoutId}`)
|
||||
const { data } = await api.delete(`/api/protected/library/${workoutId}`)
|
||||
return data
|
||||
},
|
||||
|
||||
// Mark workout as used
|
||||
async recordUsage(workoutId) {
|
||||
const { data } = await api.post(`/protected/library/${workoutId}/use`)
|
||||
const { data } = await api.post(`/api/protected/library/${workoutId}/use`)
|
||||
return data
|
||||
},
|
||||
|
||||
// Add to favorites
|
||||
async addFavorite(workoutId) {
|
||||
const { data } = await api.post(`/protected/library/${workoutId}/favorite`)
|
||||
const { data } = await api.post(`/api/protected/library/${workoutId}/favorite`)
|
||||
return data
|
||||
},
|
||||
|
||||
// Remove from favorites
|
||||
async removeFavorite(workoutId) {
|
||||
const { data } = await api.delete(`/protected/library/${workoutId}/favorite`)
|
||||
const { data } = await api.delete(`/api/protected/library/${workoutId}/favorite`)
|
||||
return data
|
||||
},
|
||||
|
||||
// Rate workout (1-5 stars + optional comment)
|
||||
async rateWorkout(workoutId, rating, comment = null) {
|
||||
const { data } = await api.post(`/protected/library/${workoutId}/rate`, {
|
||||
const { data } = await api.post(`/api/protected/library/${workoutId}/rate`, {
|
||||
rating,
|
||||
comment: comment || undefined
|
||||
})
|
||||
@@ -113,7 +113,7 @@ export const workoutLibraryApi = {
|
||||
|
||||
// Schedule a library workout to a specific date
|
||||
async scheduleToCalendar(workout, scheduledDate) {
|
||||
const { data } = await api.post('/protected/workouts/schedule-template', {
|
||||
const { data } = await api.post('/api/protected/workouts/schedule-template', {
|
||||
template_id: workout.id,
|
||||
template_name: workout.name,
|
||||
template_type: workout.type,
|
||||
|
||||
Reference in New Issue
Block a user