Skip to content

Commit

Permalink
Merge pull request #154 from Kevin-Umali/bugfix/TL-DYS-107
Browse files Browse the repository at this point in the history
[TL-DYS-107]
  • Loading branch information
Kevin-Umali authored Jun 7, 2024
2 parents 003e18a + 0fb7fc0 commit 7a07a0c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const ProjectTabs: React.FC<ProjectTabsProps> = ({ projects, className }) => {
<Separator className="my-2 md:block" />
<div className="mt-3 flex flex-col items-start space-y-2 md:flex-row md:items-center md:space-x-2 md:space-y-0">
<Label className="sm:text-md mb-2 text-lg md:mb-0">Like this idea?</Label>
<Link href={{ pathname: "/project-detail", query: { ...project } }} as={`/project-detail/${project.title}`} passHref>
<Link href={{ pathname: "/project-detail", query: { ...project } }} passHref>
<Button className="flex w-full items-center justify-center space-x-1 text-xs md:w-auto md:text-sm">
<BookOpen className="size-4" aria-label="Book icon" />
<span>Provide Detailed Steps</span>
Expand Down
5 changes: 4 additions & 1 deletion client/app/(account)/_components/avatar-control.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useRouter } from "next/navigation";
import { HelpCircle, LogOut, Settings } from "lucide-react";

import { Avatar, AvatarFallback } from "@/components/ui/avatar";
Expand All @@ -8,6 +9,8 @@ interface AvatarControlProps {
}

const AvatarControl: React.FC<AvatarControlProps> = ({ logout }) => {
const router = useRouter();

return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
Expand All @@ -18,7 +21,7 @@ const AvatarControl: React.FC<AvatarControlProps> = ({ logout }) => {
<DropdownMenuContent className="w-50">
<DropdownMenuLabel>My Account</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem disabled>
<DropdownMenuItem onClick={() => router.push("/settings")}>
<span className="flex items-center space-x-2">
<Settings size={20} />
<span>Settings</span>
Expand Down
25 changes: 16 additions & 9 deletions client/app/(account)/_components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { useMemo, useState } from "react";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useAuth } from "@/context/authContext";
import { useCurrency } from "@/context/currencyContext";
import { useRoutes } from "@/context/routesContext";
Expand All @@ -21,6 +22,7 @@ import AvatarControl from "./avatar-control";
const Navbar: React.FC = () => {
const [open, setOpen] = useState(false);

const router = useRouter(); // Get the router instance
const { theme, setTheme } = useTheme();
const { currency, setCurrency, currencyList } = useCurrency();
const { routes, activePath } = useRoutes();
Expand All @@ -31,14 +33,19 @@ const Navbar: React.FC = () => {
setTheme(theme === "light" ? "dark" : "light");
};

const handleNavigation = (path: string) => {
setOpen(!open);
router.push(path);
};

const currencyItems = useMemo(
() =>
currencyList.map((value) => (
<SelectItem key={value} value={value}>
{value}
</SelectItem>
)),
[],
[currencyList],
);

return (
Expand All @@ -52,21 +59,21 @@ const Navbar: React.FC = () => {
</SheetTrigger>
<SheetContent side="left" className="flex flex-col">
<nav className="grid gap-2 text-lg font-medium">
<Link href="#" as={"/"} className="flex items-center gap-2 text-lg font-semibold">
<Button variant="ghost" onClick={() => handleNavigation("#")} className="flex items-center gap-2 text-lg font-semibold">
<Image src="/android-chrome-512x512.png" alt="Logo" width={32} height={32} priority={true} />
<span className="text-md sm:text-xl lg:text-xl">DIYspire</span>
</Link>
{routes?.map(({ label, path, icon: IconComponent }, index) => (
<Link
</Button>
{routes?.map(({ label, path, icon: IconComponent, disabled }, index) => (
<Button
disabled={disabled}
variant="ghost"
key={index + path}
href={path}
as={path}
className={cn("mx-[-0.65rem] flex items-center gap-4 rounded-xl px-3 py-2 hover:text-foreground", activePath && path.includes(activePath) ? "text-primary" : "text-muted-foreground")}
onClick={() => setOpen(!open)}
onClick={() => handleNavigation(path)}
>
{IconComponent && <IconComponent size={20} />}
<span className="text-md sm:text-xl lg:text-xl">{label}</span>
</Link>
</Button>
))}
</nav>
<div className="mt-auto">
Expand Down
20 changes: 11 additions & 9 deletions client/app/(landing)/(routes)/community/community.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,24 @@ export default function CommunityGeneratedIdeaList() {
</Label>
</div>
{isLoading ? renderLoadingSkeleton() : isSuccess && communityData.data.totalCount > 0 ? renderProjectCards() : renderNoDataDisplay()}
{isSuccess && (
{isSuccess && totalPages > 1 && (
<Pagination className="mt-8 flex items-center justify-center">
<PaginationContent>
<PaginationItem>
<PaginationPrevious onClick={() => setCurrentPage((prev) => (prev > 1 ? prev - 1 : prev))} aria-disabled={currentPage === 1} />
</PaginationItem>

<PaginationItem>
<PaginationLink isActive={currentPage === 1} onClick={() => setCurrentPage(1)}>
1
</PaginationLink>
</PaginationItem>

{currentPage > 3 && (
<PaginationItem>
<PaginationEllipsis />
</PaginationItem>
)}

{Array.from({ length: Math.min(5, totalPages) }, (_, i) => {
const page = currentPage - 2 + i;
if (page > 1 && page < totalPages) {
Expand All @@ -109,18 +110,19 @@ export default function CommunityGeneratedIdeaList() {
}
return null;
}).filter(Boolean)}

{currentPage < totalPages - 2 && (
<PaginationItem>
<PaginationEllipsis />
</PaginationItem>
)}
{totalPages > 1 && (
<PaginationItem>
<PaginationLink isActive={currentPage === totalPages} onClick={() => setCurrentPage(totalPages)}>
{totalPages}
</PaginationLink>
</PaginationItem>
)}

<PaginationItem>
<PaginationLink isActive={currentPage === totalPages} onClick={() => setCurrentPage(totalPages)}>
{totalPages}
</PaginationLink>
</PaginationItem>

<PaginationItem>
<PaginationNext onClick={() => setCurrentPage((prevPage) => Math.min(prevPage + 1, totalPages))} aria-disabled={currentPage === totalPages} />
</PaginationItem>
Expand Down

1 comment on commit 7a07a0c

@vercel
Copy link

@vercel vercel bot commented on 7a07a0c Jun 7, 2024

Choose a reason for hiding this comment

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

Please sign in to comment.