import React, { useEffect, useState } from "react"; import Markdown from "react-markdown"; import { useNavigate } from "@remix-run/react"; import image from "./gradients/gradient1.png"; import { AddMemoryModal } from "./memories/AddMemory"; import { Button } from "./ui/button"; import { MemoryIcon, SpaceIcon } from "@supermemory/shared/icons"; import { motion } from "framer-motion"; import { BookIcon, BookOpen, ChevronDownIcon, SparkleIcon } from "lucide-react"; import { Theme, useTheme } from "~/lib/theme-provider"; function Reminder({ content, contentId }: { content: string; contentId: string }) { const [theme] = useTheme(); const navigate = useNavigate(); const [isExpanded, setIsExpanded] = useState(false); const [isOverflowing, setIsOverflowing] = useState(false); const contentRef = React.useRef(null); useEffect(() => { if (contentRef.current) { setIsOverflowing(contentRef.current.scrollHeight > contentRef.current.clientHeight); } }, [content]); if (typeof window === "undefined") return null; return (

Remember this? A topic you forgot.

{content}
{!isExpanded && isOverflowing && (
)}
{isOverflowing && ( )}
); } function LoadingReminder() { return (
); } function Reminders() { const [suggestedLearnings, setSuggestedLearnings] = useState>>([]); const [currentIndex, setCurrentIndex] = useState(0); const [isLoading, setIsLoading] = useState(true); const navigate = useNavigate(); useEffect(() => { fetch(`/backend/v1/suggested-learnings`, { credentials: "include", }) .then((res) => res.json() as Promise<{ suggestedLearnings: Array> }>) .then((data) => { setSuggestedLearnings(data.suggestedLearnings); setIsLoading(false); }) .catch((err) => { console.error("Failed to fetch suggested learnings:", err); setIsLoading(false); }); }, []); if (typeof window === "undefined") return null; const handleDragEnd = (event: any, info: any) => { const DRAG_THRESHOLD = window?.innerWidth * 0.15; if (Math.abs(info.offset.x) > DRAG_THRESHOLD) { const direction = info.offset.x > 0 ? -1 : 1; handleNavigate(direction); } }; const handleNavigate = (direction: number) => { setCurrentIndex((prevIndex) => { const newIndex = prevIndex + direction; if (newIndex < 0) return suggestedLearnings.length - 1; if (newIndex >= suggestedLearnings.length) return 0; return newIndex; }); }; if (!isLoading && (!suggestedLearnings || suggestedLearnings.length === 0)) { return (

Your Memory Hub Awaits

Start saving content to get bite-sized memory snippets that keep you on top of your game. We'll transform your notes into smart reminders that help you retain knowledge effortlessly.

); } return (
{isLoading ? // Show 3 loading cards when loading [...Array(3)]?.map((_, index) => { const xOffset = index * (window?.innerWidth < 768 ? 12 : 16); const yOffset = index * (window?.innerWidth < 768 ? 12 : 16); const opacity = Math.max(1 - index * 0.15, 0.4); const scale = 1 - index * (window?.innerWidth < 768 ? 0.02 : 0.03); return ( ); }) : suggestedLearnings?.map((learning, index) => { const position = (index - currentIndex + suggestedLearnings.length) % suggestedLearnings.length; if (position >= 3) return null; if (typeof window === "undefined") return null; const contentId = Object.keys(learning)[0]; const content = learning[contentId]; const zIndex = suggestedLearnings.length - position; const xOffset = position * (window?.innerWidth < 768 ? 12 : 16); const yOffset = position * (window?.innerWidth < 768 ? 12 : 16); const opacity = Math.max(1 - position * 0.15, 0.4); const scale = 1 - position * (window?.innerWidth < 768 ? 0.02 : 0.03); return ( = 768 ? { transition: { duration: 0.3, ease: [0.4, 0, 0.2, 1], }, } : undefined } role="group" aria-label={`Memory card ${index + 1} of ${suggestedLearnings.length}`} > ); })}
{/* Navigation controls - Hidden on mobile since we use swipe */} {!isLoading && suggestedLearnings.length > 0 && (
handleNavigate(-1)} className="p-2 rounded-full bg-gray-200 hover:bg-gray-300 dark:bg-gray-800 dark:hover:bg-gray-700" aria-label="Previous card" >
{suggestedLearnings?.map((_, index) => ( handleNavigate(index - currentIndex)} className={`w-1.5 h-1.5 rounded-full transition-colors ${ index === currentIndex ? "bg-blue-500" : "bg-gray-300" } hover:bg-blue-400`} aria-label={`Go to card ${index + 1}`} /> ))}
handleNavigate(1)} className="p-2 rounded-full bg-gray-200 hover:bg-gray-300 dark:bg-gray-800 dark:hover:bg-gray-700" aria-label="Next card" >
)} {/* Mobile swipe indicator */} {!isLoading && suggestedLearnings.length > 0 && (
Swipe to navigate • {currentIndex + 1}/{suggestedLearnings.length}
)}
); } export default Reminders;