diff --git a/apps/web/src/modules/nutrition/NutritionApp.tsx b/apps/web/src/modules/nutrition/NutritionApp.tsx index b9440ea26..d7563a915 100644 --- a/apps/web/src/modules/nutrition/NutritionApp.tsx +++ b/apps/web/src/modules/nutrition/NutritionApp.tsx @@ -5,6 +5,11 @@ import { SkeletonText, Skeleton, } from "@shared/components/ui/Skeleton"; +import { + DataState, + type DataStateQueryLike, +} from "@shared/components/ui/DataState"; +import type { NutritionDayPlan } from "./hooks/useNutritionUiState"; import { NutritionHeader } from "./components/NutritionHeader"; import { NutritionBottomNav } from "./components/NutritionBottomNav"; import { SubTabs } from "./components/SubTabs"; @@ -413,6 +418,27 @@ export default function NutritionApp({ toast.error("Не вдалося оновити дані. Перевір з'єднання."); }, [toast]); + const dayPlanQuery: DataStateQueryLike = { + data: dayPlanBusy ? undefined : dayPlan, + isLoading: dayPlanBusy, + }; + + const dayPlanLoadingSkeleton = ( +
+
+ + +
+ {[0, 1, 2].map((i) => ( + + ))} +
+ ); + return ( @@ -624,36 +650,29 @@ export default function NutritionApp({ { id: "recipes", label: "Рецепти" }, ]} /> - {menuSubTab === "plan" && dayPlanBusy ? ( -
-
- - -
- {[0, 1, 2].map((i) => ( - + {() => ( + fetchDayPlan(null)} + regenMeal={(mealType) => fetchDayPlan(mealType)} + addMealToLog={addMealFromPlan} + weekPlan={weekPlan} + weekPlanRaw={weekPlanRaw} + weekPlanBusy={weekPlanBusy} + fetchWeekPlan={fetchWeekPlan} /> - ))} -
- ) : menuSubTab === "plan" ? ( - fetchDayPlan(null)} - regenMeal={(mealType) => fetchDayPlan(mealType)} - addMealToLog={addMealFromPlan} - weekPlan={weekPlan} - weekPlanRaw={weekPlanRaw} - weekPlanBusy={weekPlanBusy} - fetchWeekPlan={fetchWeekPlan} - /> + )} + ) : (