diff --git a/src/shared/hooks/useTimer.ts b/src/shared/hooks/useTimer.ts index 4273a6c..c77ae76 100644 --- a/src/shared/hooks/useTimer.ts +++ b/src/shared/hooks/useTimer.ts @@ -5,6 +5,7 @@ import { useRef, useEffect, useCallback } from 'react' import { usePlayerStore } from '../stores' +import i18n from '@/src/shared/i18n' import type { Workout } from '../types' export type TimerPhase = 'PREP' | 'WORK' | 'REST' | 'COMPLETE' @@ -47,7 +48,7 @@ export function useTimer(workout: Workout | null): UseTimerReturn { workTime: 20, restTime: 10, rounds: 8, - exercises: [{ name: 'Ready', duration: 20 }], + exercises: [{ name: i18n.t('screens:player.phases.prep'), duration: 20 }], } // Calculate phase duration @@ -75,7 +76,7 @@ export function useTimer(workout: Workout | null): UseTimerReturn { intervalRef.current = setInterval(() => { const s = usePlayerStore.getState() - if (s.timeRemaining <= 1) { + if (s.timeRemaining <= 0) { // Phase transition if (s.phase === 'PREP') { store.setPhase('WORK') diff --git a/src/shared/stores/activityStore.ts b/src/shared/stores/activityStore.ts index 7cf156e..414ba99 100644 --- a/src/shared/stores/activityStore.ts +++ b/src/shared/stores/activityStore.ts @@ -87,7 +87,6 @@ export const useActivityStore = create()( // Standalone helper functions (use outside selectors) export function getWeeklyActivity(history: WorkoutResult[]): DayActivity[] { const days: DayActivity[] = [] - const dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] const today = new Date() const startOfWeek = new Date(today) startOfWeek.setDate(today.getDate() - today.getDay()) @@ -100,7 +99,7 @@ export function getWeeklyActivity(history: WorkoutResult[]): DayActivity[] { r => getDateString(r.completedAt) === dateStr ) days.push({ - date: dayNames[i], + date: String(i), completed: workoutsOnDay.length > 0, workoutCount: workoutsOnDay.length, }) diff --git a/src/shared/stores/userStore.ts b/src/shared/stores/userStore.ts index 090d5c0..6cd1883 100644 --- a/src/shared/stores/userStore.ts +++ b/src/shared/stores/userStore.ts @@ -6,7 +6,16 @@ import { create } from 'zustand' import { persist, createJSONStorage } from 'zustand/middleware' import AsyncStorage from '@react-native-async-storage/async-storage' -import type { UserProfile, UserSettings, SubscriptionPlan } from '../types' +import { getLocales } from 'expo-localization' +import type { UserProfile, UserSettings, SubscriptionPlan, FitnessLevel, FitnessGoal, WeeklyFrequency } from '../types' + +interface OnboardingData { + name: string + fitnessLevel: FitnessLevel + goal: FitnessGoal + weeklyFrequency: WeeklyFrequency + barriers: string[] +} interface UserState { profile: UserProfile @@ -15,16 +24,22 @@ interface UserState { updateProfile: (updates: Partial) => void updateSettings: (updates: Partial) => void setSubscription: (plan: SubscriptionPlan) => void + completeOnboarding: (data: OnboardingData) => void } export const useUserStore = create()( persist( (set) => ({ profile: { - name: 'Alex', - email: 'alex@example.com', - joinDate: 'January 2026', - subscription: 'premium-monthly', + name: '', + email: '', + joinDate: new Date().toLocaleDateString(getLocales()[0]?.languageTag ?? 'en-US', { month: 'long', year: 'numeric' }), + subscription: 'free', + onboardingCompleted: false, + fitnessLevel: 'beginner', + goal: 'cardio', + weeklyFrequency: 3, + barriers: [], }, settings: { haptics: true, @@ -48,6 +63,19 @@ export const useUserStore = create()( set((state) => ({ profile: { ...state.profile, subscription: plan }, })), + + completeOnboarding: (data) => + set((state) => ({ + profile: { + ...state.profile, + name: data.name, + fitnessLevel: data.fitnessLevel, + goal: data.goal, + weeklyFrequency: data.weeklyFrequency, + barriers: data.barriers, + onboardingCompleted: true, + }, + })), }), { name: 'tabatafit-user', diff --git a/src/shared/types/user.ts b/src/shared/types/user.ts index 1ae8f48..90a6a77 100644 --- a/src/shared/types/user.ts +++ b/src/shared/types/user.ts @@ -12,11 +12,20 @@ export interface UserSettings { reminderTime: string } +export type FitnessLevel = 'beginner' | 'intermediate' | 'advanced' +export type FitnessGoal = 'weight-loss' | 'cardio' | 'strength' | 'wellness' +export type WeeklyFrequency = 2 | 3 | 5 + export interface UserProfile { name: string email: string joinDate: string subscription: SubscriptionPlan + onboardingCompleted: boolean + fitnessLevel: FitnessLevel + goal: FitnessGoal + weeklyFrequency: WeeklyFrequency + barriers: string[] } export interface Achievement {