import {
faChevronLeft,
faCirclePlay,
faLayerGroup,
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useAtomValue } from "jotai";
import { Suspense } from "react";
import { Link, useParams } from "wouter";
import { getEndOfStudyDayBoundary } from "../../shared/date";
import { cardsByDeckAtomFamily, deckByIdAtomFamily } from "../atoms";
import { ErrorBoundary } from "../components/ErrorBoundary";
import { LoadingSpinner } from "../components/LoadingSpinner";
function DeckHeader({ deckId }: { deckId: string }) {
const { data: deck } = useAtomValue(deckByIdAtomFamily(deckId));
return (
{deck.name}
{deck.description &&
{deck.description}
}
);
}
// CardState values from FSRS
const CardState = {
New: 0,
Learning: 1,
Review: 2,
Relearning: 3,
} as const;
function DeckStats({ deckId }: { deckId: string }) {
const { data: cards } = useAtomValue(cardsByDeckAtomFamily(deckId));
// Count cards due today (study day boundary is 3:00 AM)
const boundary = getEndOfStudyDayBoundary();
const dueCards = cards.filter((card) => new Date(card.due) < boundary);
// Count by card state
const newCards = dueCards.filter((card) => card.state === CardState.New);
const learningCards = dueCards.filter(
(card) =>
card.state === CardState.Learning || card.state === CardState.Relearning,
);
const reviewCards = dueCards.filter(
(card) => card.state === CardState.Review,
);
return (
Learning
{learningCards.length}
Review
{reviewCards.length}
);
}
function DeckContent({ deckId }: { deckId: string }) {
return (
}
>
{/* Deck Stats */}
}
>
{/* Action Buttons */}
{/* Study Button */}
Study Now
{/* View Cards Link */}
View Cards
);
}
export function DeckDetailPage() {
const { deckId } = useParams<{ deckId: string }>();
if (!deckId) {
return (
Invalid deck ID
Back to decks
);
}
return (
{/* Header */}
{/* Main Content */}
}>
);
}