import React from "react" import Link from "next/link" import { usePathname, useRouter } from "next/navigation" import { useAccount } from "@/lib/providers/jazz-provider" import { cn } from "@/lib/utils" import { PersonalLinkLists } from "@/lib/schema/personal-link" import { useQueryState, parseAsStringLiteral } from "nuqs" import { LEARNING_STATES } from "@/lib/constants" export const LinkSection: React.FC<{ pathname: string }> = ({ pathname }) => { const { me } = useAccount({ root: { personalLinks: [] } }) const linkCount = me?.root.personalLinks?.length || 0 const isActive = pathname === "/links" if (!me) return null return (
) } interface LinkSectionHeaderProps { linkCount: number isActive: boolean } const LinkSectionHeader: React.FC = ({ linkCount, isActive }) => { const pathname = usePathname() const [state] = useQueryState("state", parseAsStringLiteral(LEARNING_STATES.map(ls => ls.value))) const isLinksActive = pathname.startsWith("/links") && !state return (

Links {linkCount > 0 && {linkCount}}

) } const ALL_STATES = ["all", ...LEARNING_STATES.map(ls => ls.value)] interface ListProps { personalLinks: PersonalLinkLists } const List: React.FC = ({ personalLinks }) => { const pathname = usePathname() const [state] = useQueryState("state", parseAsStringLiteral(LEARNING_STATES.map(ls => ls.value))) const toLearnCount = personalLinks.filter(link => link?.learningState === "wantToLearn").length const learningCount = personalLinks.filter(link => link?.learningState === "learning").length const learnedCount = personalLinks.filter(link => link?.learningState === "learned").length const isActive = (checkState: string) => { return pathname === "/links" && state === checkState } return (
) } interface ListItemProps { label: string href: string count: number isActive: boolean } const ListItem: React.FC = ({ label, href, count, isActive }) => { return (

{label}

{count > 0 && ( {count} )}
) }