import { ClientOnly } from 'remix-utils/client-only'; import { Header } from '~/components/header/Header'; import { Menu } from '~/components/sidebar/Menu.client'; import BackgroundRays from '~/components/ui/BackgroundRays'; import { TooltipProvider } from '@radix-ui/react-tooltip'; import { cssTransition, ToastContainer } from 'react-toastify'; import { Suspense, useEffect, useState } from 'react'; import { listAllProblems, BoltProblemStatus } from '~/lib/replay/Problems'; import type { BoltProblemDescription } from '~/lib/replay/Problems'; const toastAnimation = cssTransition({ enter: 'animated fadeInRight', exit: 'animated fadeOutRight', }); export function ToastContainerWrapper() { return ( { return ( ); }} icon={({ type }) => { /** * @todo Handle more types if we need them. This may require extra color palettes. */ switch (type) { case 'success': { return
; } case 'error': { return
; } } return undefined; }} position="bottom-right" pauseOnFocusLoss transition={toastAnimation} /> ); } export function Status({ status }: { status: BoltProblemStatus | undefined }) { if (!status) { status = BoltProblemStatus.Pending; } const statusColors: Record = { [BoltProblemStatus.Pending]: 'bg-yellow-400 dark:text-yellow-400', [BoltProblemStatus.Unsolved]: 'bg-orange-500 dark:text-orange-500', [BoltProblemStatus.Solved]: 'bg-blue-500 dark:text-blue-500', }; return (
Status:
{status.charAt(0).toUpperCase() + status.slice(1)}
); } export function Keywords({ keywords }: { keywords: string[] | undefined }) { if (!keywords?.length) { return null; } return (
{keywords.map((keyword, index) => ( {keyword} ))}
); } function getProblemStatus(problem: BoltProblemDescription): BoltProblemStatus { return problem.status ?? BoltProblemStatus.Pending; } const Nothing = () => null; function ProblemsPage() { const [problems, setProblems] = useState(null); const [statusFilter, setStatusFilter] = useState(BoltProblemStatus.Solved); useEffect(() => { listAllProblems().then(setProblems); }, []); const filteredProblems = problems?.filter((problem) => { return statusFilter === 'all' || getProblemStatus(problem) === statusFilter; }); return ( }>
{() => }
{problems && (
)} {problems === null ? (
) : problems.length === 0 ? (
No problems found
) : ( )}
); } export default ProblemsPage;