mirror of
https://github.com/DocNR/POWR.git
synced 2025-04-23 01:01:27 +00:00
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
// lib/hooks/useNostrWorkoutHistory.ts
|
|
import { useMemo } from 'react';
|
|
import { useSQLiteContext } from 'expo-sqlite';
|
|
import { UnifiedWorkoutHistoryService } from '@/lib/db/services/UnifiedWorkoutHistoryService';
|
|
import { Workout } from '@/types/workout';
|
|
|
|
/**
|
|
* @deprecated This hook is deprecated. Please use useWorkoutHistory instead.
|
|
* See docs/design/WorkoutHistory/MigrationGuide.md for migration instructions.
|
|
*/
|
|
export function useNostrWorkoutHistory() {
|
|
console.warn(
|
|
'useNostrWorkoutHistory is deprecated. ' +
|
|
'Please use useWorkoutHistory instead. ' +
|
|
'See docs/design/WorkoutHistory/MigrationGuide.md for migration instructions.'
|
|
);
|
|
|
|
const db = useSQLiteContext();
|
|
|
|
// Create UnifiedWorkoutHistoryService instance
|
|
const unifiedWorkoutHistoryService = useMemo(() => {
|
|
return new UnifiedWorkoutHistoryService(db);
|
|
}, [db]);
|
|
|
|
// Return a compatibility layer that mimics the old API
|
|
return {
|
|
getAllWorkouts: (options?: {
|
|
limit?: number;
|
|
offset?: number;
|
|
includeNostr?: boolean;
|
|
isAuthenticated?: boolean;
|
|
}): Promise<Workout[]> => {
|
|
return unifiedWorkoutHistoryService.getAllWorkouts(options);
|
|
},
|
|
|
|
getWorkoutsByDate: (date: Date): Promise<Workout[]> => {
|
|
return unifiedWorkoutHistoryService.getWorkoutsByDate(date);
|
|
},
|
|
|
|
getWorkoutDatesInMonth: (year: number, month: number): Promise<Date[]> => {
|
|
return unifiedWorkoutHistoryService.getWorkoutDatesInMonth(year, month);
|
|
},
|
|
|
|
getWorkoutDetails: (workoutId: string): Promise<Workout | null> => {
|
|
return unifiedWorkoutHistoryService.getWorkoutDetails(workoutId);
|
|
}
|
|
};
|
|
}
|