Skip to content

Commit c549305

Browse files
author
Simon
committed
revert '' to null
1 parent 136db4a commit c549305

14 files changed

Lines changed: 48 additions & 40 deletions

File tree

SparkyFitnessFrontend/src/api/Exercises/exerciseEntryService.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ export const createExerciseEntry = async (payload: {
115115
sets: WorkoutPresetSet[];
116116
image_url?: string;
117117
calories_burned?: number;
118-
distance?: number;
119-
avg_heart_rate?: number;
118+
distance?: number | null;
119+
avg_heart_rate?: number | null;
120120
imageFile?: File | null;
121121
activity_details?: {
122122
provider_name?: string;
@@ -192,9 +192,9 @@ export interface UpdateExerciseEntryPayload {
192192
calories_burned?: number;
193193
notes?: string;
194194
sets?: WorkoutPresetSet[];
195-
image_url?: string;
196-
distance?: number;
197-
avg_heart_rate?: number;
195+
image_url?: string | null;
196+
distance?: number | null;
197+
avg_heart_rate?: number | null;
198198
imageFile?: File | null;
199199
activity_details?: {
200200
id?: string;

SparkyFitnessFrontend/src/api/Foods/nutrionix.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export const getNutritionixBrandedNutrients = async (
271271
}
272272
return {
273273
name: food.food_name,
274-
brand: food.brand_name || '',
274+
brand: food.brand_name || null,
275275
calories: food.nf_calories,
276276
protein: food.nf_protein,
277277
carbs: food.nf_total_carbohydrate,

SparkyFitnessFrontend/src/api/Settings/aiServiceSettingsService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const getAIServices = async (): Promise<AIService[]> => {
2020
}
2121
};
2222

23-
export const getPreferences = async (): Promise<UserPreferencesChat> => {
23+
export const getPreferences = async (): Promise<UserPreferencesChat | null> => {
2424
try {
2525
const preferences = await apiCall(`/user-preferences`, {
2626
method: 'GET',
@@ -32,7 +32,7 @@ export const getPreferences = async (): Promise<UserPreferencesChat> => {
3232
// If it's a 404, it means no preferences are found, which is a valid scenario.
3333
// We return null in this case, and the calling function will handle it.
3434
if (message && message.includes('404')) {
35-
return { auto_clear_history: '' };
35+
return null;
3636
}
3737
throw err;
3838
}

SparkyFitnessFrontend/src/components/FoodSearch/FoodSearch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export interface NutritionixItem {
9191
id?: string;
9292
name: string;
9393
food_name?: string;
94-
brand?: string;
94+
brand?: string | null;
9595
brand_name?: string;
9696
image?: string;
9797
serving_size?: number;

SparkyFitnessFrontend/src/pages/Admin/GlobalAISettings.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ const GlobalAISettings = () => {
127127
service_name: newService.service_name,
128128
service_type: newService.service_type,
129129
api_key: newService.api_key,
130-
custom_url: newService.custom_url || '',
130+
custom_url: newService.custom_url || null,
131131
system_prompt: newService.system_prompt || '',
132132
is_active: newService.is_active,
133133
model_name: newService.showCustomModelInput
134134
? newService.custom_model_name
135-
: newService.model_name || '',
135+
: newService.model_name || null,
136136
};
137137
await createService(serviceData);
138138
// Reset form

SparkyFitnessFrontend/src/pages/Diary/EditExerciseEntryDialog.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ const EditExerciseEntryDialog = ({
7676
}));
7777
});
7878
const [notes, setNotes] = useState(entry.notes || '');
79-
const [imageUrl, setImageUrl] = useState<string>(entry.image_url || '');
79+
const [imageUrl, setImageUrl] = useState<string | null>(
80+
entry.image_url || null
81+
);
8082
const [imageFile, setImageFile] = useState<File | null>(null);
8183
const [caloriesBurnedInput, setCaloriesBurnedInput] = useState<number | ''>(
8284
entry.calories_burned || ''
@@ -129,7 +131,7 @@ const EditExerciseEntryDialog = ({
129131

130132
const handleClearImage = () => {
131133
setImageFile(null);
132-
setImageUrl('');
134+
setImageUrl(null);
133135
};
134136

135137
const handleSetChange = (
@@ -269,7 +271,7 @@ const EditExerciseEntryDialog = ({
269271
image_url: imageUrl,
270272
distance:
271273
distanceInput === ''
272-
? 0
274+
? null
273275
: convertDistance(Number(distanceInput), distanceUnit, 'km'),
274276
avg_heart_rate:
275277
avgHeartRateInput === '' ? 0 : Number(avgHeartRateInput),

SparkyFitnessFrontend/src/pages/Diary/LogExerciseEntryDialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,10 @@ const LogExerciseEntryDialog: React.FC<LogExerciseEntryDialogProps> = ({
240240
imageFile: imageFile,
241241
distance:
242242
distanceInput === ''
243-
? 0
243+
? null
244244
: convertDistance(Number(distanceInput), distanceUnit, 'km'),
245245
avg_heart_rate:
246-
avgHeartRateInput === '' ? 0 : Number(avgHeartRateInput),
246+
avgHeartRateInput === '' ? null : Number(avgHeartRateInput),
247247
...(mappedDetails.length > 0 && { activity_details: mappedDetails }),
248248
};
249249

SparkyFitnessFrontend/src/pages/Exercises/AddWorkoutPlanDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ const AddWorkoutPlanDialog: React.FC<AddWorkoutPlanDialogProps> = ({
871871
plan_name: planName,
872872
description: description,
873873
start_date: startDate,
874-
end_date: endDate || '',
874+
end_date: endDate || null,
875875
is_active: isActive,
876876
assignments: assignmentsToSave.map((a) => {
877877
// Calculate sort_order within its day

SparkyFitnessFrontend/src/pages/Settings/ExternalProviderList.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,33 @@ const ExternalProviderList = ({ showAddForm }: ExternalProviderListProps) => {
5555
withings_last_sync_at:
5656
editData.provider_type === 'withings'
5757
? editData.withings_last_sync_at
58-
: '',
58+
: null,
5959
withings_token_expires:
6060
editData.provider_type === 'withings'
6161
? editData.withings_token_expires
62-
: '',
62+
: null,
6363
fitbit_last_sync_at:
64-
editData.provider_type === 'fitbit' ? editData.fitbit_last_sync_at : '',
64+
editData.provider_type === 'fitbit'
65+
? editData.fitbit_last_sync_at
66+
: null,
6567
fitbit_token_expires:
6668
editData.provider_type === 'fitbit'
6769
? editData.fitbit_token_expires
68-
: '',
70+
: null,
6971
polar_last_sync_at:
70-
editData.provider_type === 'polar' ? editData.polar_last_sync_at : '',
72+
editData.provider_type === 'polar' ? editData.polar_last_sync_at : null,
7173
polar_token_expires:
72-
editData.provider_type === 'polar' ? editData.polar_token_expires : '',
74+
editData.provider_type === 'polar'
75+
? editData.polar_token_expires
76+
: null,
7377
strava_last_sync_at:
74-
editData.provider_type === 'strava' ? editData.strava_last_sync_at : '',
78+
editData.provider_type === 'strava'
79+
? editData.strava_last_sync_at
80+
: null,
7581
strava_token_expires:
7682
editData.provider_type === 'strava'
7783
? editData.strava_token_expires
78-
: '',
84+
: null,
7985
sync_frequency:
8086
editData.provider_type === 'withings' ||
8187
editData.provider_type === 'garmin' ||
@@ -120,7 +126,7 @@ const ExternalProviderList = ({ showAddForm }: ExternalProviderListProps) => {
120126
setEditData({
121127
provider_name: provider.provider_name,
122128
provider_type: provider.provider_type,
123-
app_id: provider.app_id || '',
129+
app_id: provider.app_id || null,
124130
// Never pre-fill API keys when editing for security/privacy
125131
app_key: '',
126132
is_active: provider.is_active,

SparkyFitnessFrontend/src/pages/Settings/ExternalProviderSettings.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ export interface ExternalDataProvider {
4949
garmin_connect_status?: 'linked' | 'connected' | 'disconnected';
5050
garmin_last_status_check?: string;
5151
garmin_token_expires?: string;
52-
withings_last_sync_at?: string;
53-
withings_token_expires?: string;
54-
fitbit_last_sync_at?: string;
55-
fitbit_token_expires?: string;
56-
polar_last_sync_at?: string;
57-
polar_token_expires?: string;
58-
hevy_last_sync_at?: string;
52+
withings_last_sync_at?: string | null;
53+
withings_token_expires?: string | null;
54+
fitbit_last_sync_at?: string | null;
55+
fitbit_token_expires?: string | null;
56+
polar_last_sync_at?: string | null;
57+
polar_token_expires?: string | null;
58+
hevy_last_sync_at?: string | null;
5959
hevy_connect_status?: 'connected' | 'disconnected';
60-
strava_last_sync_at?: string;
61-
strava_token_expires?: string;
62-
is_strictly_private?: boolean;
60+
strava_last_sync_at?: string | null;
61+
strava_token_expires?: string | null;
62+
is_strictly_private?: boolean | null;
6363
}
6464

6565
const BARCODE_PROVIDER_TYPES = ['openfoodfacts', 'usda'];

0 commit comments

Comments
 (0)