From 56f1e74cc02bc51731c1f0d63eaf673e47aeecc7 Mon Sep 17 00:00:00 2001 From: cp-dharti-r Date: Thu, 23 May 2024 11:21:41 +0530 Subject: [PATCH] Refactor some UI of restaurant page --- admin/pages/dishes/add/index.tsx | 5 - admin/pages/dishes/edit/[id].tsx | 7 +- admin/pages/menus/index.tsx | 4 +- website/components/Reel/index.tsx | 12 +- website/components/YouMayLike/index.tsx | 2 +- .../pages/restaurants/[restaurant]/index.tsx | 157 +++++++++--------- 6 files changed, 95 insertions(+), 92 deletions(-) diff --git a/admin/pages/dishes/add/index.tsx b/admin/pages/dishes/add/index.tsx index 28afe4a..279350a 100644 --- a/admin/pages/dishes/add/index.tsx +++ b/admin/pages/dishes/add/index.tsx @@ -71,7 +71,6 @@ const AddDishPage = () => { try { const mySchema = z.object({ name: z.string().min(3), - description: z.string().min(3), menu_id: z.number().positive({ message: "Select menu from list" }), tags: z.array(z.string().min(2)).min(1), price: z.number().positive(), @@ -150,7 +149,6 @@ const AddDishPage = () => { const response = mySchema.safeParse({ name: name, - description: description, menu_id: menuId, tags: tags, price: price, @@ -317,9 +315,6 @@ const AddDishPage = () => { onChange={(e) => setDescription(e.target.value)} > -
- {errors.find((error) => error.for === "description")?.message} -
diff --git a/admin/pages/dishes/edit/[id].tsx b/admin/pages/dishes/edit/[id].tsx index 8c2d6c1..6881eec 100644 --- a/admin/pages/dishes/edit/[id].tsx +++ b/admin/pages/dishes/edit/[id].tsx @@ -34,7 +34,7 @@ const EditDishPage = () => { const [isVideoChecked, setIsVideoChecked] = useState(false); const [name, setName] = useState(""); - const [description, setDescription] = useState(""); + const [description, setDescription] = useState(""); const [menuId, setMenuOption] = useState(0); const [categoryId, setCategoryOption] = useState(null); const [tags, setTags] = useState([]); @@ -72,7 +72,6 @@ const EditDishPage = () => { const mySchema = z.object({ name: z.string().min(3), - description: z.string().min(3), menu_id: z.number().positive({ message: "Select menu from list" }), tags: z.array(z.string().min(2)).min(1), price: z.number().positive(), @@ -220,7 +219,6 @@ const EditDishPage = () => { const response = mySchema.safeParse({ name: name, - description: description, menu_id: menuId, tags: tags, price: price, @@ -410,9 +408,6 @@ const EditDishPage = () => { defaultValue={description} >
-
- {errors.find((error) => error.for === "description")?.message} -
diff --git a/admin/pages/menus/index.tsx b/admin/pages/menus/index.tsx index 56838f3..912a0ac 100644 --- a/admin/pages/menus/index.tsx +++ b/admin/pages/menus/index.tsx @@ -15,7 +15,7 @@ const MenusPage = () => { const [menusCount, setMenusCount] = useState(0); const [currentPage, setCurrentPage] = useState(1); - const pageSize = 5; + const pageSize = 10; const fetchMenus = async (page: number) => { try { @@ -23,7 +23,7 @@ const MenusPage = () => { const { data, error } = await supabase .from("menus") .select("id, restaurant_id, name") - .order('id', { ascending: false }) + .order("id", { ascending: false }) .range((page - 1) * pageSize, pageSize * page - 1) .eq("restaurant_id", user.split("/")[2]) .neq("restaurant_id", 0); diff --git a/website/components/Reel/index.tsx b/website/components/Reel/index.tsx index f3f55ac..00248bb 100644 --- a/website/components/Reel/index.tsx +++ b/website/components/Reel/index.tsx @@ -104,12 +104,18 @@ const Reels = ({ dishesData, isDishesLoading }: ReelProps) => { ) : ( )} -
-
+
+

{data.name}

₹{data.price}

-

{data.description}

+ {data.description && data.description != "" ? ( +

+ {data.description} +

+ ) : ( + "" + )}
))} diff --git a/website/components/YouMayLike/index.tsx b/website/components/YouMayLike/index.tsx index 19e3c9d..b74b2b7 100644 --- a/website/components/YouMayLike/index.tsx +++ b/website/components/YouMayLike/index.tsx @@ -83,7 +83,7 @@ const YouMayLike = ({ restaurants }: { restaurants: any }) => { loop={true} autoplay={true} effect="fade" - className="sm:h-[25rem]" + className="sm:h-[25rem] h-[19rem]" > {item.images.map((data: any, index: any) => ( diff --git a/website/pages/restaurants/[restaurant]/index.tsx b/website/pages/restaurants/[restaurant]/index.tsx index 938f843..a286ff0 100644 --- a/website/pages/restaurants/[restaurant]/index.tsx +++ b/website/pages/restaurants/[restaurant]/index.tsx @@ -153,7 +153,7 @@ const RestaurantMenu = ({ ); setIsDishesLoading(false); } else { - restaurantData(); + fetchRestaurantData(); fetchCategoriesData(); fetchDishes(); } @@ -292,16 +292,16 @@ const RestaurantMenu = ({
- {categoriesData ? ( -
-

Categories

- {isCategoriesLoading ? ( -
-
-
-
-
- ) : ( +
+ {isCategoriesLoading ? ( +
+
+
+
+
+ ) : categoriesData && categoriesData.length > 0 ? ( + <> +

Categories

{categoriesData.map((item: any, index: any) => ( ))}
- )} -
- ) : ( - "" - )} - {menusData ? ( -
- {menusData.map((item: any, index: any) => - item.dishes.length > 0 ? ( -
- - {({ inView, ref, entry }) => ( -
+ ) : ( + "" + )} +
+
+ {isDishesLoading ? ( +
+ {Array.from({ length: 4 }).map((_, index) => ( + + ))} +
+ ) : menusData && menusData.length > 0 ? ( + <> + {menusData.map((item: any, index: any) => + item.dishes.length > 0 ? ( +
+ + {({ inView, ref, entry }) => ( +
-

- {item.name} -

- {isDishesLoading ? ( -
- {Array.from({ length: 4 }).map((_, index) => ( - - ))} -
- ) : ( + }`} + > +

+ {item.name} +

{item.dishes.map((data: any) => (
))}
- )} -
- )} - -
- ) : ( - "" - ) - )} -
- ) : ( - "" - )} +
+ )} +
+
+ ) : ( + "" + ) + )} + + ) : ( + "" + )} +
-
+
-
-

- Categories -

- {isCategoriesLoading ? ( + {isCategoriesLoading ? ( +
- ) : categoriesData ? ( +
+ ) : categoriesData && categoriesData.length > 0 ? ( +
+

+ Categories +

{categoriesData.map((item: any, index: any) => ( ))}
- ) : ( - "" - )} -
- {menusData ? ( -
+
+ ) : ( + "" + )} + {isDishesLoading ? ( +
+
+
+
+ ) : menusData && menusData.length > 0 ? ( +

Menus