import * as React from "react"
import { Link } from "@tanstack/react-router"
import { useAccount } from "@/lib/providers/jazz-provider"
import { cn } from "@/lib/utils"
import { PersonalLinkLists } from "@/lib/schema/personal-link"
import { LearningStateValue } from "~/lib/constants"
import { LaIcon } from "~/components/custom/la-icon"
export const LinkSection: React.FC = () => {
const { me } = useAccount({ root: { personalLinks: [] } })
if (!me) return null
const linkCount = me.root.personalLinks?.length || 0
return (
)
}
interface LinkSectionHeaderProps {
linkCount: number
}
const LinkSectionHeader: React.FC = ({ linkCount }) => {
return (
{({ isActive }) => {
return (
<>
Links
{linkCount > 0 && (
{linkCount}
)}
>
)
}}
)
}
interface LinkListProps {
personalLinks: PersonalLinkLists
}
const LinkList: React.FC = ({ personalLinks }) => {
const linkStates: LearningStateValue[] = [
"wantToLearn",
"learning",
"learned",
]
const linkLabels: Record = {
wantToLearn: "To Learn",
learning: "Learning",
learned: "Learned",
}
const linkCounts = linkStates.reduce(
(acc, state) => ({
...acc,
[state]: personalLinks.filter((link) => link?.learningState === state)
.length,
}),
{} as Record,
)
return (
{linkStates.map((state) => (
))}
)
}
interface LinkListItemProps {
label: string
state: LearningStateValue
count: number
}
const LinkListItem: React.FC = ({ label, state, count }) => (
{({ isActive }) => (
<>
{count > 0 && (
{count}
)}
>
)}
)