Skip to content

Commit 81a28d4

Browse files
committed
fix types
1 parent 61758d9 commit 81a28d4

File tree

7 files changed

+42
-24
lines changed

7 files changed

+42
-24
lines changed

components/modals/AddExerciseModal.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import { Button } from '../theme/Button';
1414
import { StepperInlineInput } from '../theme/StepperInlineInput';
1515
import { TextInput } from '../theme/TextInput';
1616
import { FullScreenModal } from './FullScreenModal';
17-
import { type MuscleGroup } from '../../database/models';
17+
import {
18+
type EquipmentType,
19+
type MechanicType,
20+
type MuscleGroup,
21+
} from '../../database/models';
1822

1923
// UI-specific muscle group filter type (subset of MuscleGroup + 'all')
2024
type MuscleGroupFilter = 'all' | 'chest' | 'back' | 'legs' | 'arms';
@@ -23,7 +27,7 @@ type ExerciseId = string;
2327

2428
type ExerciseOption = SelectorOption<ExerciseId> & {
2529
category: string;
26-
type: 'compound' | 'isolation' | 'bodyweight' | 'machine';
30+
type: MechanicType | EquipmentType;
2731
};
2832

2933
type AddExerciseModalProps = {
@@ -66,20 +70,20 @@ const normalizeMuscleGroup = (muscleGroup: MuscleGroup | string): MuscleGroupFil
6670
const getExerciseType = (
6771
mechanicType: string,
6872
equipmentType: string
69-
): 'compound' | 'isolation' | 'bodyweight' | 'machine' => {
73+
): MechanicType | EquipmentType => {
7074
const mechanic = mechanicType?.toLowerCase() || '';
7175
const equipment = equipmentType?.toLowerCase() || '';
7276

7377
if (equipment.includes('bodyweight') || equipment.includes('body weight')) {
74-
return 'bodyweight';
78+
return 'bodyweight' as EquipmentType;
7579
}
7680
if (mechanic.includes('compound')) {
77-
return 'compound';
81+
return 'compound' as MechanicType;
7882
}
7983
if (equipment.includes('machine')) {
80-
return 'machine';
84+
return 'machine' as EquipmentType;
8185
}
82-
return 'isolation';
86+
return 'isolation' as MechanicType;
8387
};
8488

8589
// Helper function to get icon for exercise type

components/modals/CreateExerciseModal.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useState } from 'react';
33
import { useTranslation } from 'react-i18next';
44
import { Pressable, ScrollView, Text, View } from 'react-native';
55

6+
import { type MuscleGroup } from '../../database/models';
67
import { useTheme } from '../../hooks/useTheme';
78
import { BottomPopUpMenu } from '../BottomPopUpMenu';
89
import { Button } from '../theme/Button';
@@ -11,8 +12,23 @@ import { ToggleInput } from '../theme/ToggleInput';
1112
import { FullScreenModal } from './FullScreenModal';
1213

1314
// Muscle groups will be translated using useTranslation hook
14-
const PRIMARY_MUSCLES_KEYS = ['chest', 'shoulders', 'back', 'legs', 'arms', 'core'];
15-
const SECONDARY_MUSCLES_KEYS = ['triceps', 'biceps', 'abs', 'forearms', 'traps', 'glutes'];
15+
// Using string arrays for translation keys, but values should match MuscleGroup where possible
16+
const PRIMARY_MUSCLES_KEYS: (MuscleGroup | 'legs' | 'arms' | 'core')[] = [
17+
'chest',
18+
'shoulders',
19+
'back',
20+
'legs',
21+
'arms',
22+
'core',
23+
];
24+
const SECONDARY_MUSCLES_KEYS: (MuscleGroup | 'abs' | 'forearms' | 'traps' | 'glutes')[] = [
25+
'triceps',
26+
'biceps',
27+
'abs',
28+
'forearms',
29+
'traps',
30+
'glutes',
31+
];
1632

1733
type CreateExerciseModalProps = {
1834
visible: boolean;

components/modals/FilterWorkoutsModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { FullScreenModal } from './FullScreenModal';
1111

1212
type WorkoutType = 'strength' | 'cardio' | 'flexibility';
1313

14+
// UI-specific muscle group type for filtering (aggregated categories)
1415
type TargetMuscle = 'full-body' | 'chest' | 'back' | 'legs' | 'shoulders' | 'arms' | 'core';
1516

1617
type FilterWorkoutsModalProps = {

components/modals/PastWorkoutsHistoryFilterMenu.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import { Slider } from '../theme/Slider';
1212

1313
type WorkoutType = 'all' | 'strength' | 'cardio' | 'hiit' | 'yoga';
1414
type DateRange = '30' | '90' | 'custom';
15-
type MuscleGroup = 'chest' | 'back' | 'legs' | 'shoulders' | 'arms' | 'core' | 'full-body';
15+
// UI-specific muscle group type for filtering (aggregated categories)
16+
type MuscleGroup = 'full-body' | 'chest' | 'back' | 'legs' | 'shoulders' | 'arms' | 'core';
1617

1718
type PastWorkoutsHistoryFilterMenuProps = {
1819
visible: boolean;

components/modals/PastWorkoutsHistoryModal.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -417,15 +417,9 @@ export default function PastWorkoutsHistoryModal({ visible, onClose }: WorkoutHi
417417
initialFilters={{
418418
workoutType: filters.workoutType,
419419
dateRange: filters.dateRange,
420-
muscleGroups: filters.muscleGroups as (
421-
| 'chest'
422-
| 'back'
423-
| 'legs'
424-
| 'shoulders'
425-
| 'arms'
426-
| 'core'
427-
| 'full-body'
428-
)[],
420+
muscleGroups: filters.muscleGroups as Array<
421+
'chest' | 'back' | 'legs' | 'shoulders' | 'arms' | 'core' | 'full-body'
422+
>,
429423
minDuration: filters.minDuration,
430424
}}
431425
onApplyFilters={handleApplyFilters}

types/EatingPhaseUI.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { type EatingPhase } from '../database/models';
2+
13
/**
24
* UI-specific eating phase types for display purposes.
35
* These map to the database EatingPhase types ('cut' | 'maintain' | 'bulk')
@@ -8,7 +10,7 @@ export type EatingPhaseUI = 'cutting' | 'maintenance' | 'bulking' | 'lean-bulk';
810
/**
911
* Converts database EatingPhase to UI EatingPhaseUI
1012
*/
11-
export function convertEatingPhaseToUI(dbPhase: string): EatingPhaseUI {
13+
export function convertEatingPhaseToUI(dbPhase: EatingPhase | string): EatingPhaseUI {
1214
switch (dbPhase) {
1315
case 'cut':
1416
return 'cutting';
@@ -24,7 +26,7 @@ export function convertEatingPhaseToUI(dbPhase: string): EatingPhaseUI {
2426
/**
2527
* Converts UI EatingPhaseUI to database EatingPhase
2628
*/
27-
export function convertEatingPhaseToDB(uiPhase: EatingPhaseUI): 'cut' | 'maintain' | 'bulk' {
29+
export function convertEatingPhaseToDB(uiPhase: EatingPhaseUI): EatingPhase {
2830
switch (uiPhase) {
2931
case 'cutting':
3032
return 'cut';

utils/workout.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const WEEKDAY_LABELS = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
1616

1717
// Day names mapping for database: WeekdayPicker index -> Day name
1818
// WeekdayPicker uses: 0 = Monday, 1 = Tuesday, ..., 6 = Sunday
19-
export const WEEKDAY_NAMES = [
19+
export const WEEKDAY_NAMES: DayOfWeek[] = [
2020
'Monday',
2121
'Tuesday',
2222
'Wednesday',
@@ -29,8 +29,8 @@ export const WEEKDAY_NAMES = [
2929
/**
3030
* Convert day name from database to WeekdayPicker index
3131
*/
32-
export function dayNameToIndex(dayName: string): number {
33-
return WEEKDAY_NAMES.indexOf(dayName);
32+
export function dayNameToIndex(dayName: DayOfWeek | string): number {
33+
return WEEKDAY_NAMES.indexOf(dayName as DayOfWeek);
3434
}
3535

3636
/**

0 commit comments

Comments
 (0)