From 39c37238b5032c858c457e0437ce7918243e7dc8 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Tue, 23 Dec 2025 15:55:29 +0330 Subject: [PATCH] skeleton home page --- .../[name]/(Main)/components/MenuSkeleton.tsx | 55 +++++++++++++++++++ src/app/[name]/(Main)/page.tsx | 12 +++- 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 src/app/[name]/(Main)/components/MenuSkeleton.tsx diff --git a/src/app/[name]/(Main)/components/MenuSkeleton.tsx b/src/app/[name]/(Main)/components/MenuSkeleton.tsx new file mode 100644 index 0000000..1c81441 --- /dev/null +++ b/src/app/[name]/(Main)/components/MenuSkeleton.tsx @@ -0,0 +1,55 @@ +'use client'; + +import { Skeleton } from "@/components/ui/skeleton"; +import VerticalScrollView from "@/components/listview/VerticalScrollView"; +import MenuItemRenderer from "@/components/listview/MenuItemRenderer"; + +const MenuSkeleton = () => { + return ( +
+
+ +
+ {[...Array(5)].map((_, index) => ( + + ))} +
+
+ +
+
+ +
+ + +
+
+ + + {[...Array(6)].map((_, index) => ( + +
+ +
+
+ + + +
+
+
+ +
+ +
+
+
+
+ ))} +
+
+
+ ); +}; + +export default MenuSkeleton; diff --git a/src/app/[name]/(Main)/page.tsx b/src/app/[name]/(Main)/page.tsx index 233d43b..64948a9 100644 --- a/src/app/[name]/(Main)/page.tsx +++ b/src/app/[name]/(Main)/page.tsx @@ -14,16 +14,19 @@ import useToggle from "@/hooks/helpers/useToggle"; import CategoryScroll from "@/app/[name]/(Main)/components/CategoryScroll"; import MenuFilterDrawer from "@/app/[name]/(Main)/components/MenuFilterDrawer"; import MenuSortingDrawer from "@/app/[name]/(Main)/components/MenuSortingDrawer"; +import MenuSkeleton from "@/app/[name]/(Main)/components/MenuSkeleton"; import { useGetCategories, useGetFoods } from "./hooks/useMenuData"; import type { Food, Category } from "./types/Types"; const sortings = ["PopularityDescending", "RateDescending", "PriceAscending", "PriceDescending"] as const; const MenuIndex = () => { - const { data: foodsData } = useGetFoods(); - const { data: categoriesData } = useGetCategories(); + const { data: foodsData, isLoading: foodsLoading } = useGetFoods(); + const { data: categoriesData, isLoading: categoriesLoading } = useGetCategories(); const foods = useMemo(() => foodsData?.data || [], [foodsData?.data]); const categories = useMemo(() => categoriesData?.data || [], [categoriesData?.data]); + + const isLoading = foodsLoading || categoriesLoading; const { t: tCommon } = useTranslation('common'); const { t: tMenu } = useTranslation('menu', { keyPrefix: "Menu" }); const { state: filterModal, toggle: toggleFilterModal } = useToggle(); @@ -143,6 +146,11 @@ const MenuIndex = () => { } }); }, [selectedCategory, search, selectedIngredients, selectedDeliveryId, foods, categories, sorting]); + + if (isLoading) { + return ; + } + return (