diff --git a/amplify-migration-apps/app-4/src/App.tsx b/amplify-migration-apps/app-4/src/App.tsx index 527cbbd0cd..3e16ce0fab 100644 --- a/amplify-migration-apps/app-4/src/App.tsx +++ b/amplify-migration-apps/app-4/src/App.tsx @@ -510,15 +510,15 @@ const FoodSearch: React.FC<{ user?: AuthUser; onFoodSelect: (food: any) => void async function searchFood() { if (!searchTerm.trim() || !user) return; - + try { setLoading(true); const response = await get({ apiName: 'nutritionapi', - path: `/nutrition/search/${encodeURIComponent(searchTerm)}` + path: `/nutrition/search/${encodeURIComponent(searchTerm)}`, }).response; - - const data = await response.body.json() as any; + + const data = (await response.body.json()) as any; if (data && data.success) { setSearchResults(data.results); } @@ -541,17 +541,20 @@ const FoodSearch: React.FC<{ user?: AuthUser; onFoodSelect: (food: any) => void style={{ ...themedStyles.input, marginBottom: 0, flex: 1 }} placeholder="Search foods (apple, chicken, etc.)" /> - - + {searchResults.length > 0 && ( -
+
{searchResults.map((food) => (
void padding: 8, borderBottom: theme === 'dark' ? '1px solid #4a5568' : '1px solid #e1e8ed', cursor: 'pointer', - backgroundColor: theme === 'dark' ? '#2d3748' : 'white' + backgroundColor: theme === 'dark' ? '#2d3748' : 'white', }} onClick={() => onFoodSelect(food)} > @@ -586,7 +589,7 @@ const MealLogger: React.FC<{ user?: AuthUser; onMealLogged: () => void }> = ({ u async function logMeal() { if (!selectedFood || !user) return; - + try { setLogging(true); const response = await post({ @@ -596,12 +599,12 @@ const MealLogger: React.FC<{ user?: AuthUser; onMealLogged: () => void }> = ({ u body: { foodId: selectedFood.id, quantity, - mealType - } - } + mealType, + }, + }, }).response; - - const data = await response.body.json() as any; + + const data = (await response.body.json()) as any; if (data && data.success) { setSelectedFood(null); setQuantity(1); @@ -619,7 +622,7 @@ const MealLogger: React.FC<{ user?: AuthUser; onMealLogged: () => void }> = ({ u return (
- + {selectedFood && (

Log: {selectedFood.name}

@@ -637,11 +640,7 @@ const MealLogger: React.FC<{ user?: AuthUser; onMealLogged: () => void }> = ({ u
- setMealType(e.target.value)} style={{ ...themedStyles.input, marginBottom: 0 }}> @@ -653,17 +652,10 @@ const MealLogger: React.FC<{ user?: AuthUser; onMealLogged: () => void }> = ({ u Total: {Math.round(selectedFood.calories * quantity)} calories
- -
@@ -681,16 +673,16 @@ const NutritionSummary: React.FC<{ user?: AuthUser; refreshTrigger: number }> = async function fetchNutritionSummary() { if (!user) return; - + try { setLoading(true); const today = new Date().toISOString().split('T')[0]; const response = await get({ apiName: 'nutritionapi', - path: `/nutrition/daily/${today}` + path: `/nutrition/daily/${today}`, }).response; - - const data = await response.body.json() as any; + + const data = (await response.body.json()) as any; if (data && data.success) { setNutritionData(data.summary); } @@ -711,15 +703,11 @@ const NutritionSummary: React.FC<{ user?: AuthUser; refreshTrigger: number }> =

🍎 Today's Nutrition

-
- + {nutritionData ? (
@@ -740,12 +728,20 @@ const NutritionSummary: React.FC<{ user?: AuthUser; refreshTrigger: number }> =
Fat
- +
-

🍳 Breakfast: {nutritionData.meals.breakfast.calories} cal ({nutritionData.meals.breakfast.items} items)

-

🥗 Lunch: {nutritionData.meals.lunch.calories} cal ({nutritionData.meals.lunch.items} items)

-

🍽️ Dinner: {nutritionData.meals.dinner.calories} cal ({nutritionData.meals.dinner.items} items)

-

🍿 Snacks: {nutritionData.meals.snacks.calories} cal ({nutritionData.meals.snacks.items} items)

+

+ 🍳 Breakfast: {nutritionData.meals.breakfast.calories} cal ({nutritionData.meals.breakfast.items} items) +

+

+ 🥗 Lunch: {nutritionData.meals.lunch.calories} cal ({nutritionData.meals.lunch.items} items) +

+

+ 🍽️ Dinner: {nutritionData.meals.dinner.calories} cal ({nutritionData.meals.dinner.items} items) +

+

+ 🍿 Snacks: {nutritionData.meals.snacks.calories} cal ({nutritionData.meals.snacks.items} items) +

) : ( @@ -1623,12 +1619,12 @@ const AuthenticatedApp: React.FC = ({ signOut, user }) => { ) : showNutritionForm ? (

Log Food

- { - setNutritionRefresh(prev => prev + 1); + setNutritionRefresh((prev) => prev + 1); setShowNutritionForm(false); - }} + }} />