Skip to content

Commit

Permalink
fix : Bug title not change on first click
Browse files Browse the repository at this point in the history
  • Loading branch information
PriyansuMaurya committed Nov 5, 2023
1 parent eabc866 commit 4be326b
Showing 1 changed file with 22 additions and 30 deletions.
52 changes: 22 additions & 30 deletions components/NavigationLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useMediaQuery from "@mui/material/useMediaQuery";
export default function NavigationLinks() {
const [activeSection, setActiveSection] = useState("");

const handleSectionClick = (section) => {
const handleSectionClick = (section: string) => {
setActiveSection(section);
};

Expand All @@ -23,16 +23,11 @@ export default function NavigationLinks() {
},
};

const handleToolsClick = () => {
document.title = "AI Fusion - Tools";
};

const handlePromptsClick = () => {
document.title = "AI Fusion - Prompts";
};
const handleClick = (event: React.MouseEvent<HTMLAnchorElement>, title: string) => {
event.preventDefault();

const handleDatasetsClick = () => {
document.title = "AI Fusion - Datasets";
document.title = `AI Fusion | ${title}`;
};

return (
Expand All @@ -43,43 +38,40 @@ export default function NavigationLinks() {
>
<div className="w-50 border border-[--dark-bg] dark:border-[--light-bg] rounded-3xl flex flex-row justify-evenly items-center">
<Link
className={`w-24 text-center font-semibold ${
activeSection === "tools"
? "bg-green-500 text-white"
: "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]"
} rounded-l-3xl transition px-4 py-2`}
className={`w-24 text-center font-semibold ${activeSection === "tools"
? "bg-green-500 text-white"
: "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]"
} rounded-l-3xl transition px-4 py-2`}
href="/tools"
onClick={() => {
onClick={(event) => {
handleSectionClick("tools");
handleToolsClick();
handleClick(event, "Tools");
}}
>
Tools
</Link>
<Link
className={`w-24 text-center font-semibold ${
activeSection === "prompts"
? "bg-green-500 text-white"
: "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]"
} transition px-4 py-2`}
className={`w-24 text-center font-semibold ${activeSection === "prompts"
? "bg-green-500 text-white"
: "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]"
} transition px-4 py-2`}
href="/prompts"
onClick={() => {
onClick={(event) => {
handleSectionClick("prompts");
handlePromptsClick();
handleClick(event, "Prompts");
}}
>
Prompts
</Link>
<Link
className={`w-24 text-center font-semibold ${
activeSection === "datasets"
? "bg-green-500 text-white"
: "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]"
} rounded-r-3xl transition px-4 py-2`}
className={`w-24 text-center font-semibold ${activeSection === "datasets"
? "bg-green-500 text-white"
: "hover:bg-[color:var(--primary-color)] hover:text-white focus:bg-[--primary-color]"
} rounded-r-3xl transition px-4 py-2`}
href="/datasets"
onClick={() => {
onClick={(event) => {
handleSectionClick("datasets");
handleDatasetsClick();
handleClick(event, "Datasets");
}}
>
Datasets
Expand Down

1 comment on commit 4be326b

@vercel
Copy link

@vercel vercel bot commented on 4be326b Nov 5, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

aifusion – ./

aifusion-priyansu.vercel.app
aifusion-git-main-priyansu.vercel.app
aifusion.vercel.app

Please sign in to comment.