Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions components/Nav/Nav.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";
import { api } from "@/server/trpc/react";
import { usePathname } from "next/navigation";
import {
Disclosure,
DisclosureButton,
Expand Down Expand Up @@ -40,6 +41,8 @@ const Nav = ({
enabled: session ? true : false,
});

const pathname = usePathname();

const userNavigation = [
{
name: "Your Profile",
Expand All @@ -55,6 +58,18 @@ const Nav = ({

const hasNotifications = !!count && count > 0;

const handleSignInPageNavigation = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This is very much a minor issue but it annoyed me and means we need to add guards in E2E tests. This will remove that need

Copy link
Contributor Author

@IdrisGit IdrisGit Oct 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I am happy to help :)

Helping maintainers to solve these minor but time consuming issues is my goal for this Hacktoberfest.

/**
* * NextAuth.js automatically adds current url to the callbackurl prop in the singin() method.
* * As Navbar is always present, spamming SignIn button causes login page url getting appended in the url bar.
*/
if (pathname === "/get-started") {
return;
}

signIn();
};

return (
<Disclosure as="nav" className="bg-neutral-100 dark:bg-black">
{({ close, open }) => (
Expand Down Expand Up @@ -117,12 +132,15 @@ const Nav = ({
</>
) : (
<>
<button className="nav-button" onClick={() => signIn()}>
<button
className="nav-button"
onClick={handleSignInPageNavigation}
>
Sign in
</button>
<button
className="primary-button"
onClick={() => signIn()}
onClick={handleSignInPageNavigation}
>
Sign up for free
</button>
Expand Down