Skip to content

Commit f57111f

Browse files
authored
Merge pull request #3 from sinfo/bottomNavBar
Fixed navbar. Now behaves depending on the path the user is in
2 parents 31e6a5f + 37bd88c commit f57111f

File tree

2 files changed

+78
-74
lines changed

2 files changed

+78
-74
lines changed

src/components/BottomNavbar.tsx

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,20 @@
1-
import Link from "next/link";
2-
import Image from "next/image";
31
import { redirect } from "next/navigation";
42
import { getServerSession } from "next-auth/next";
5-
import { headers } from 'next/headers';
63

74
import UserSignOut from "@/components/UserSignOut";
85
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
96
import { UserService } from "@/services/UserService";
107

11-
import qrCodeIcon from "@/assets/icons/qr-code.png";
12-
import cameraIconWhite from "@/assets/icons/camera.png";
13-
import cameraIconBlue from "@/assets/icons/blueCamera.png";
14-
15-
import giftBoxIcon from "@/assets/icons/gift-box.png";
16-
import attendeeLink from "@/assets/icons/link_card_attendee.png"
17-
import companyLink from "@/assets/icons/link_card_company.png"
18-
19-
//TODO: add redirects
20-
21-
function RightIcon({ role } : { role: string}) {
22-
console.log(role)
23-
switch (role) {
24-
case "team":
25-
case "admin":
26-
return(
27-
<button className="flex gap-1">
28-
<Link href="/">
29-
<Image width={25} src={giftBoxIcon} alt="Gift Box Icon" />
30-
</Link>
31-
</button>
32-
);
33-
34-
case "user":
35-
return(
36-
<button className="flex gap-1">
37-
<Link href="/">
38-
<Image width={30} src={attendeeLink} alt="Attendee Link Icon" />
39-
</Link>
40-
</button>
41-
);
42-
43-
case "company":
44-
return(
45-
<button className="flex gap-1">
46-
<Link href="/">
47-
<Image width={30} src={companyLink} alt="Company Link Icon" />
48-
</Link>
49-
</button>
50-
);
51-
52-
default:
53-
break;
54-
}
55-
}
8+
import ClientBottomNavbar from "./ClientBottomNavbar";
569

5710
export default async function BottomNavbar() {
5811
const session = await getServerSession(authOptions);
5912
if (!session) redirect("/login");
6013

6114
const user: User = await UserService.getMe(session.cannonToken);
6215
if (!user) return <UserSignOut />;
63-
64-
let headersList = headers();
65-
let fullUrl = headersList.get('referer') || "";
66-
let urlObject = new URL(fullUrl);
67-
let path = urlObject.pathname;
68-
console.log(path)
6916

7017
return (
71-
<div className="flex flex-col items-center">
72-
<div className={`cameraIcon ${path == "/camera" ? "bg-white" : "bg-dark-blue"}`}>
73-
<Link className="flex gap-1" href="/camera">
74-
<Image width={35} src={path == "/camera" ? cameraIconBlue : cameraIconWhite} alt="Camera Icon" />
75-
</Link>
76-
</div>
77-
<div className="baseNav">
78-
<div className="baseNavIcons">
79-
<Link className={`flex gap-1 ${
80-
path == "/"
81-
? ""
82-
: "border-dark-blue"
83-
} border-b-2 pb-1`} href="/">
84-
<Image width={30} src={qrCodeIcon} alt="QR Code Icon" />
85-
</Link>
86-
<RightIcon role={user.role}/>
87-
</div>
88-
</div>
89-
</div>
90-
18+
<ClientBottomNavbar user={user} ></ClientBottomNavbar>
9119
);
9220
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
'use client'
2+
3+
import Link from "next/link";
4+
import Image from "next/image";
5+
import { usePathname } from "next/navigation";
6+
7+
import qrCodeIcon from "@/assets/icons/qr-code.png";
8+
import cameraIconWhite from "@/assets/icons/camera.png";
9+
import cameraIconBlue from "@/assets/icons/blueCamera.png";
10+
11+
import giftBoxIcon from "@/assets/icons/gift-box.png";
12+
import attendeeLink from "@/assets/icons/link_card_attendee.png"
13+
import companyLink from "@/assets/icons/link_card_company.png"
14+
15+
//TODO: add the redirects on the buttons to the corresponding pages once the pages are implemented
16+
17+
function RightIcon({ role } : { role: string}) {
18+
switch (role) {
19+
case "team":
20+
case "admin":
21+
return(
22+
<button className="flex gap-1">
23+
<Link href="/">
24+
<Image width={25} src={giftBoxIcon} alt="Gift Box Icon" />
25+
</Link>
26+
</button>
27+
);
28+
29+
case "user":
30+
return(
31+
<button className="flex gap-1">
32+
<Link href="/">
33+
<Image width={30} src={attendeeLink} alt="Attendee Link Icon" />
34+
</Link>
35+
</button>
36+
);
37+
38+
case "company":
39+
return(
40+
<button className="flex gap-1">
41+
<Link href="/">
42+
<Image width={30} src={companyLink} alt="Company Link Icon" />
43+
</Link>
44+
</button>
45+
);
46+
47+
default:
48+
break;
49+
}
50+
}
51+
52+
export default function ClientBottomNavbar({ user } : { user: User}) {
53+
const path = usePathname()
54+
return (
55+
<div className="flex flex-col items-center">
56+
<div className={`cameraIcon ${path == "/camera" ? "bg-white" : "bg-dark-blue"}`}>
57+
<Link className="flex gap-1" href="/camera">
58+
<Image width={35} src={path == "/camera" ? cameraIconBlue : cameraIconWhite} alt="Camera Icon" />
59+
</Link>
60+
</div>
61+
<div className="baseNav">
62+
<div className="baseNavIcons">
63+
<Link className={`flex gap-1 ${
64+
path == "/"
65+
? ""
66+
: "border-dark-blue"
67+
} border-b-2 pb-1`} href="/">
68+
<Image width={30} src={qrCodeIcon} alt="QR Code Icon" />
69+
</Link>
70+
<RightIcon role={user.role}/>
71+
</div>
72+
</div>
73+
</div>
74+
75+
);
76+
}

0 commit comments

Comments
 (0)