Skip to content

Commit

Permalink
feat: added go to buttons to home page
Browse files Browse the repository at this point in the history
  • Loading branch information
wreshi committed Nov 5, 2024
1 parent 748d0cb commit b3a81c3
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/app/app/home/_components/GoToPageButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"use client";
import { Button } from "@/components/ui/button";
import { useRouter } from "@/hooks/use-performance-router";
import {
ArrowUpRight,
Building,
Handshake,
LucideIcon,
SquareUserRound,
} from "lucide-react";
import React from "react";

interface GoToPageButtonProps {
label: string;
href: string;
}

export function GoToPageButton(props: GoToPageButtonProps) {
let IconComponent;

const router = useRouter({
fancy: true,
});

const handleClick = () => {
router.push(props.href);
};

switch (props.href) {
case "/app/leads":
IconComponent = <Building className="mr-1.5" size={12} />;
break;
case "/app/clients":
IconComponent = <SquareUserRound className="mr-1.5" size={12} />;
break;
case "/app/deals":
IconComponent = <Handshake className="mr-1.5" size={12} />;
break;
default:
IconComponent = <ArrowUpRight className="mr-1.5" size={12} />;
break;
}

return (
<Button onClick={handleClick} variant={"outline"} className="h-7 px-1.5">
{IconComponent}
{props.label}
</Button>
);
}
7 changes: 7 additions & 0 deletions src/app/app/home/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { PageTitle } from "@/components/PageTitle";
import { Button } from "@/components/ui/button";
import { Building } from "lucide-react";
import { redirect } from "next/navigation";
import React from "react";
import { GoToPageButton } from "./_components/GoToPageButton";
export default async function HomePage() {
return (
<section className="flex h-screen flex-col gap-3 px-5 py-4">
Expand All @@ -13,6 +15,11 @@ export default async function HomePage() {
</Button>
</div>
</div>
<div className="flex h-full items-center justify-center gap-2">
Go to <GoToPageButton label="Leads" href="/app/leads" />
or <GoToPageButton label="Deals" href="/app/deals" />
or <GoToPageButton label="Clients" href="/app/clients" />
</div>
</section>
);
}

0 comments on commit b3a81c3

Please sign in to comment.