Switch to version 1: remove src/hooks/useWorkoutData.ts
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import {
|
||||
UserMetrics,
|
||||
WorkoutSession,
|
||||
saveWorkoutSession,
|
||||
getWorkoutSessions,
|
||||
updateWorkoutSession,
|
||||
deleteWorkoutSession,
|
||||
getWorkoutsByType,
|
||||
getWorkoutsByDateRange,
|
||||
saveUserMetrics,
|
||||
getUserMetrics,
|
||||
updateUserMetrics,
|
||||
calculateMetricsFromSessions,
|
||||
} from '@/lib/storage/workoutStorage';
|
||||
|
||||
export function useWorkoutData() {
|
||||
const [workouts, setWorkouts] = useState<WorkoutSession[]>([]);
|
||||
const [metrics, setMetrics] = useState<UserMetrics | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
const loadData = async () => {
|
||||
try {
|
||||
const [workoutList, userMetrics] = await Promise.all([
|
||||
getWorkoutSessions(),
|
||||
getUserMetrics(),
|
||||
]);
|
||||
setWorkouts(workoutList);
|
||||
setMetrics(userMetrics);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
loadData();
|
||||
}, []);
|
||||
|
||||
return {
|
||||
workouts,
|
||||
metrics,
|
||||
loading,
|
||||
saveWorkoutSession,
|
||||
updateWorkoutSession,
|
||||
deleteWorkoutSession,
|
||||
getWorkoutsByType,
|
||||
getWorkoutsByDateRange,
|
||||
saveUserMetrics,
|
||||
updateUserMetrics,
|
||||
calculateMetricsFromSessions,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user