"use client"
import { ReviewMemoriesModal } from "@/components/review-memories-modal"
import { useInferredMemories } from "@/hooks/use-inferred-memories"
import { dmSansClassName } from "@/lib/fonts"
import { cn } from "@lib/utils"
import { ArrowRight } from "lucide-react"
import { useEffect, useState } from "react"
// "Suggested for you" entry point — opens the swipe-review modal. The trigger
// hides when there's nothing to review, but the modal stays mounted while open
// (even after the last card) so it can show its "all caught up" summary.
// Styled to match the Weekly digest box above it.
export function ReviewMemoriesCard({
containerTag,
className,
}: {
containerTag: string | undefined
className?: string
}) {
const [open, setOpen] = useState(false)
const { data: memories = [] } = useInferredMemories(containerTag)
const liveCount = memories.length
// While the modal is open, freeze the count shown on the trigger so the
// background button stays put (doesn't tick down or vanish) until it closes.
const [frozenCount, setFrozenCount] = useState(0)
const count = open ? frozenCount : liveCount
const handleOpenChange = (next: boolean) => {
if (next) setFrozenCount(liveCount)
setOpen(next)
}
// Switching spaces shouldn't carry an open modal over to the new space.
// biome-ignore lint/correctness/useExhaustiveDependencies: reset on space switch
useEffect(() => {
setOpen(false)
}, [containerTag])
return (
<>
{count > 0 && (
)}
{(open || liveCount > 0) && (
)}
>
)
}