import { useMemo } from "react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "./ui/accordion"; import { Progress } from "./ui/progress"; import { usePinning } from "~/hooks/usePinning"; import { Tabs, TabsTrigger, TabsList, TabsContent } from "./ui/tabs"; import { Button } from "./ui/button"; import { Cross2Icon } from "@radix-ui/react-icons"; import type { PinningStatus } from "~/data/pinning"; export const PinningNetworkBanner = () => { const { progressData: data } = usePinning(); const itemsQueued = useMemo( () => data?.items.filter((item: PinningStatus) => item.status.includes("queued"), ) || [], [data], ); const itemsProcessing = useMemo( () => data?.items.filter((item: PinningStatus) => item.status.includes("processing"), ) || [], [data], ); const completedItems = useMemo( () => data?.items.filter((item: PinningStatus) => item.status.includes("completed"), ) || [], [data], ); return (
{`${completedItems.length}/${data?.items.length} items completed`} Queued In Progress Completed {itemsQueued.length ? ( itemsQueued.map((item: PinningStatus) => ( )) ) : (
Nothing yet.
)}
{itemsProcessing.length ? ( itemsProcessing.map((item: PinningStatus) => ( )) ) : (
Nothing yet.
)}
{completedItems.length ? ( completedItems.map((item: PinningStatus) => ( )) ) : (
Nothing yet.
)}
); }; const PinCidItem = ({ item }: { item: PinningStatus }) => { const { unpin } = usePinning(); return (
{item.id} {item.progress}% {item.status === "completed" ? ( ) : null}
); };