import { PropsWithChildren } from "react"; import { Link, Redirect } from "react-router-dom"; import { useAuth } from "../useAuth"; import Nav from "../sections/Nav"; import { Calendar3, ChevronRight, Download } from "react-bootstrap-icons"; import { useAuthenticatedRequest } from "../util"; import HumanTime from "react-human-time"; import { OverlayTrigger, Tooltip } from "react-bootstrap"; interface RecentlyCreatedResponse { crates: RecentlyCreatedResponseVersion[]; } interface RecentlyCreatedResponseVersion { name: string; created_at: string; organisation: string; } interface RecentlyUpdatedResponse { versions: RecentlyUpdatedResponseVersion[]; } interface RecentlyUpdatedResponseVersion { name: string; version: string; organisation: string; } interface MostDownloadedResponse { crates: MostDownloadedResponseCrate[]; } interface MostDownloadedResponseCrate { name: string; downloads: number; organisation: string; } export default function Dashboard() { const auth = useAuth(); if (!auth) { return ; } const { response: recentlyCreated, error: recentlyCreatedError } = useAuthenticatedRequest({ auth, endpoint: "crates/recently-created", }); const { response: recentlyUpdated, error: recentlyUpdatedError } = useAuthenticatedRequest({ auth, endpoint: "crates/recently-updated", }); const { response: mostDownloaded, error: mostDownloadedError } = useAuthenticatedRequest({ auth, endpoint: "crates/most-downloaded", }); return (
); } function CrateCard({ name, organisation, children, }: PropsWithChildren<{ name: string; organisation: string }>) { return (
{organisation}/ {name}
{children}
); }