Skip to content

Commit 59c64cc

Browse files
authored
Merge pull request #27 from canopas/change-menus-flow
Refactor UI in restaurant detail page
2 parents 265f285 + cb1ee25 commit 59c64cc

File tree

8 files changed

+45
-24
lines changed

8 files changed

+45
-24
lines changed

admin/pages/admins/index.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const AdminsPage = () => {
2323
const { data, error } = await supabase
2424
.from("admins_roles_restaurants")
2525
.select("*, admins(id, name, email), roles(name)")
26-
.order('id', { ascending: false })
26+
.order("id", { ascending: false })
2727
.range((page - 1) * pageSize, pageSize * page - 1)
2828
.eq("restaurant_id", user.split("/")[2])
2929
.neq("admin_id", user.split("/")[0]);
@@ -71,13 +71,12 @@ const AdminsPage = () => {
7171
fetchAdmins(currentPage);
7272
}, [currentPage]);
7373

74-
const deleteRecord = async (id: number, relativeId: number) => {
74+
const deleteRecord = async (id: number) => {
7575
try {
76-
await supabase.from("admins").delete().eq("id", id).throwOnError();
7776
await supabase
7877
.from("admins_roles_restaurants")
7978
.delete()
80-
.eq("id", relativeId)
79+
.eq("id", id)
8180
.throwOnError();
8281
setAdminsData(adminsData.filter((x) => x.id != id));
8382
fetchCountAdmins();
@@ -188,7 +187,7 @@ const AdminsPage = () => {
188187
className="text-red"
189188
onClick={() =>
190189
confirm("Are you sure you want to delete this admin?")
191-
? deleteRecord(admin.admins.id, admin.id)
190+
? deleteRecord(admin.id)
192191
: ""
193192
}
194193
>

admin/pages/invited-members/add/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const InvitedMemberPage = () => {
9696

9797
await sendEmail({
9898
to: email,
99-
subject: "Bite Space - Invitation To Join Space",
99+
subject: "Invitation To Join Space",
100100
message: render(
101101
InviteMemberEmail({
102102
invited_by: data.admins.name,

website/components/BottomSheet/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,31 @@ const BottomSheet = ({
3131
};
3232
}, [isOpen, onClose]);
3333

34+
const handleClose = () => {
35+
if (window.history.state?.bottomSheetOpen) {
36+
window.history.back();
37+
} else {
38+
onClose();
39+
}
40+
};
41+
3442
return (
3543
<div
3644
className={`fixed inset-0 z-[100] flex items-end ${
3745
isOpen ? "block" : "hidden"
3846
}`}
3947
>
40-
<div className="fixed inset-0" onClick={onClose}></div>
48+
{/* <div className="fixed inset-0" onClick={onClose}></div> */}
4149
<header className="select-none header left-0 top-0 z-40 w-full items-center absolute p-3 flex gap-2 text-white">
4250
<button
43-
onClick={onClose}
51+
onClick={handleClose}
4452
className="flex gap-2 items-center bg-primary bg-opacity-50 dark:bg-opacity-30 border-b border-primary dark:border-opacity-50 px-3 py-1 text-sm font-semibold rounded-lg"
4553
>
4654
<span>{"<"}</span>
4755
Back
4856
</button>
4957
<span>|</span>
50-
<p className="font-bold text-sm">{name} dishes</p>
58+
<p className="font-bold text-sm">{name}</p>
5159
</header>
5260
<div className="h-full w-full bg-white dark:bg-black">
5361
<Reels dishesData={items} />

website/components/Reel/index.tsx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,16 @@ const Reels = ({ dishesData }: ReelProps) => {
8383

8484
return (
8585
<section className="select-none">
86-
{isLoading ? <MenuDishSkeleton classes="reel" /> : ""}
86+
{isLoading ? (
87+
<MenuDishSkeleton
88+
classes="reel"
89+
style={{
90+
height: screenHeight != 0 ? screenHeight + "px" : "100vh",
91+
}}
92+
/>
93+
) : (
94+
""
95+
)}
8796
<div
8897
ref={carouselRef}
8998
className="reelsContainer scrollbar-hidden w-full"
@@ -106,11 +115,18 @@ const Reels = ({ dishesData }: ReelProps) => {
106115
{!isLoading ? (
107116
<div className="animated-fade">
108117
{data.video ? (
109-
<VideoPlayer
110-
src={data.video}
111-
poster={data.video_thumbnail}
112-
classes={"h-full w-full object-cover"}
113-
/>
118+
<div
119+
style={{
120+
height:
121+
screenHeight != 0 ? screenHeight + "px" : "100vh",
122+
}}
123+
>
124+
<VideoPlayer
125+
src={data.video}
126+
poster={data.video_thumbnail}
127+
classes={"h-full w-full object-cover"}
128+
/>
129+
</div>
114130
) : (
115131
<SwiperComponent images={data.images}></SwiperComponent>
116132
)}

website/components/SkeletonPlaceholders/MenuDish.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const MenuDishSkeleton = ({ classes }: any) => {
1+
const MenuDishSkeleton = ({ classes, style }: any) => {
22
return (
33
<div
44
className={`${classes} relative animate-pulse w-full bg-gray-200 dark:bg-black rounded-xl`}
5+
style={style}
56
>
67
<div className="absolute flex h-full w-full flex-col gap-3 p-5 pb-10">
78
<div className="flex flex-col justify-end h-full gap-5">

website/pages/category/restaurant.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import BottomSheet from "@/components/BottomSheet";
44
import NoDataFound from "@/components/NoDataFound";
5-
import { useAppDispatch, useAppSelector } from "@/store/store";
5+
import { useAppDispatch } from "@/store/store";
66
import { RestaurantData } from "@/types/category-by-id";
77
import Image from "next/image";
88
import Link from "next/link";
@@ -12,7 +12,6 @@ import { Swiper, SwiperSlide } from "swiper/react";
1212
import "swiper/css";
1313
import "swiper/css/pagination";
1414

15-
import { Autoplay, Pagination } from "swiper/modules";
1615
import { setScreenHeightState } from "@/store/slice";
1716

1817
const Restaurant = ({
@@ -49,7 +48,7 @@ const Restaurant = ({
4948
);
5049
}, [dispatch]);
5150

52-
return (
51+
return (
5352
<>
5453
{restaurantsData && restaurantsData.length > 0 ? (
5554
<div className="flex flex-col gap-5">
@@ -82,8 +81,6 @@ const Restaurant = ({
8281
<Swiper
8382
slidesPerView={"auto"}
8483
spaceBetween={20}
85-
autoplay={true}
86-
modules={[Autoplay]}
8784
className="h-full w-full mt-6"
8885
>
8986
{item.menu.map((data, index) => (
@@ -134,7 +131,7 @@ const Restaurant = ({
134131
width={100}
135132
/>
136133
</div>
137-
<p className="mt-1 w-full font-extrabold capitalize sm:text-xl text-center">
134+
<p className="mt-1 w-full sm:w-96 font-extrabold capitalize sm:text-xl text-center">
138135
{data.name}
139136
</p>
140137
</SwiperSlide>

website/pages/restaurants/[restaurant]/categories/[category].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ const RestaurantCategory = ({
212212
Back
213213
</button>
214214
<span>|</span>
215-
<p className="font-bold text-sm">{categoryData.name} dishes</p>
215+
<p className="font-bold text-sm">{categoryData.name}</p>
216216
</header>
217217
<Reels
218218
dishesData={dishesData}

website/pages/restaurants/[restaurant]/menus/[menu].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ const RestaurantMenu = ({ name, menus }: { name: string; menus: any }) => {
230230
Back
231231
</button>
232232
<span>|</span>
233-
<p className="font-bold text-sm">{menuName} dishes</p>
233+
<p className="font-bold text-sm">{menuName}</p>
234234
</header>
235235
<Reels dishesData={menusData} />
236236
</NoHeaderFooterLayout>

0 commit comments

Comments
 (0)